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