2 * Copyright 2016-2017 ZTE Corporation.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 * Created by 10184303 on 15-11-17.
\r
21 var registerCometdMessage = function (url, callback) {
\r
22 var cometd = new $.Cometd();
\r
23 var cometdURL = location.protocol + "//" + location.host + "/api/nsocnotification/v1";
\r
29 cometd.addListener("/meta/handshake", function (handshake) {
\r
30 if (handshake.successful === true) {
\r
31 cometd.batch(function () {
\r
32 cometd.subscribe(url, function (message) {
\r
33 callback.call(this, message.data);
\r
40 registerCometdMessage("/VIMstatus", function (data) {
\r
41 var alarmArray = JSON.parse(data.greeting);
\r
42 console.log(data.greeting);
\r
43 for (var i = 0; i < alarmArray.length; i++) {
\r
44 vm.vimStatusTime = alarmArray[i].checkTime;
\r
45 for (var n = 0; n < vm.vimInfo.length; n++) {
\r
46 if (alarmArray[i].id == vm.vimInfo[n].oid && alarmArray[i].hostStorageInfo == "") {
\r
47 vm.vimInfo[n].status = alarmArray[i].status;
\r
48 vm.vimInfo[n].errorInfo = alarmArray[i].alarmContent;
\r
51 if (alarmArray[i].id == vm.vimInfo[n].oid && alarmArray[i].hostStorageInfo.length != "") {
\r
52 vm.vimInfo[n].status = "inactive";
\r
53 vm.vimInfo[n].errorInfo = alarmArray[i].hostStorageInfo;
\r
60 setTimeout('resUtil.tooltipVimStatus()', 5000);
\r