Пример #1
0
        /// <summary>
        /// Runs when update feSight.
        /// </summary>
        /// <param name="fusionDirector">The fusion director.</param>
        private void RunUpdateESight(HWESightHost eSight)
        {
            HWLogger.GetESightNotifyLogger(eSight.HostIP).Info($"Recieve: update eSight");
            var instance = this.FindInstance(eSight);

            instance.Sync();
        }
Пример #2
0
        /// <summary>
        /// 解析设备变更消息
        /// </summary>
        /// <param name="eSight">The e sight.</param>
        /// <param name="json">The json.</param>
        /// <exception cref="System.Exception">
        /// </exception>
        private void AnalysisNeDevice(HWESightHost eSight, string json)
        {
            try
            {
                var messge       = JsonUtil.DeserializeObject <TcpMessage <NotifyModel <NedeviceData> > >(json);
                var nedeviceData = messge.Data;
                if (nedeviceData == null)
                {
                    return;
                }
                var dn = nedeviceData.Data.DeviceId;
                HWLogger.GetESightNotifyLogger(eSight.HostIP).Info($"AnalysisNeDevice [MsgType:{nedeviceData.MsgType}] [DN:{dn}][deviceName:{nedeviceData.Data.DeviceName}][desc:{nedeviceData.Data.Description}] ");
                var instance = this.FindInstance(eSight);
                instance.UpdateAliveTime(DateTime.Now);//更新保活時間(esight在发生告警后不会发送保活信息)
                switch (nedeviceData.MsgType)
                {
                case 1:     // 新增
                    //instance.Sync();
                    break;

                case 2:     // 删除
                            // 高密的设备变更消息需要单独处理
                    var deleteServerType = instance.GetServerTypeByDn(dn);
                    if (deleteServerType == ServerTypeEnum.ChildHighdensity || deleteServerType == ServerTypeEnum.Highdensity)
                    {
                        instance.SyncHighdensityList();
                    }
                    else
                    {
                        instance.DeleteServer(dn, deleteServerType);
                    }
                    break;

                case 3:     // 修改
                    var modifyServerType = instance.GetServerTypeByDn(dn);
                    instance.StartUpdateTask(dn, modifyServerType, 0);
                    break;

                default:
                    break;
                }
            }
            catch (Exception e)
            {
                HWLogger.GetESightNotifyLogger(eSight.HostIP).Error(e, $"AnalysisNeDevice Error.");
            }
        }
Пример #3
0
        /// <summary>
        /// 解析告警变更消息
        /// </summary>
        /// <param name="eSight">The eSight.</param>
        /// <param name="json">The json.</param>
        /// <exception cref="System.Exception"></exception>
        private void AnalysisAlarm(HWESightHost eSight, string json)
        {
            try
            {
                var messge    = JsonUtil.DeserializeObject <TcpMessage <NotifyModel <AlarmData> > >(json);
                var alarmData = messge.Data;
                if (alarmData != null)
                {
                    var dn      = alarmData.Data.NeDN;
                    var alarmSn = alarmData.Data.AlarmSN;
                    HWLogger.GetESightNotifyLogger(eSight.HostIP).Info($"[alarmSn:{alarmSn}] AnalysisAlarm.[DN:{dn}][optType:{alarmData.Data.OptType}][alarmName:{alarmData.Data.AlarmName}] ");

                    var instance = this.FindInstance(eSight);
                    instance.UpdateAliveTime(DateTime.Now);//更新保活時間(esight在发生告警后不会发送保活信息)
                    var serverType = instance.GetServerTypeByDn(dn);
                    if (serverType == ServerTypeEnum.ChildBlade)
                    {
                        //更新子刀片的管理板
                        var childDeviceId = $"{eSight.HostIP}-{dn}";
                        var parentDn      = BladeConnector.Instance.GetParentDn(childDeviceId);
                        instance.StartUpdateTask(parentDn, ServerTypeEnum.Blade, alarmSn);
                    }
                    if (serverType == ServerTypeEnum.ChildHighdensity)
                    {
                        //更新子刀片的管理板
                        var childDeviceId = $"{eSight.HostIP}-{dn}";
                        var parentDn      = HighdensityConnector.Instance.GetParentDn(childDeviceId);
                        instance.StartUpdateTask(parentDn, ServerTypeEnum.Highdensity, alarmSn);
                    }
                    if (serverType == ServerTypeEnum.Switch)
                    {
                        //交换板告警 只用更新管理板
                        var childDeviceId = $"{eSight.HostIP}-{dn}";
                        var parentDn      = BladeConnector.Instance.GetSwitchParentDn(childDeviceId);
                        instance.StartUpdateTask(parentDn, ServerTypeEnum.Blade, alarmSn);
                        instance.SubmitNewAlarm(alarmData.Data);
                        return;
                    }
                    instance.StartUpdateTask(alarmData.Data.NeDN, serverType, alarmSn);
                    instance.SubmitNewAlarm(alarmData.Data);
                }
            }
            catch (Exception e)
            {
                HWLogger.GetESightNotifyLogger(eSight.HostIP).Error(e, $"AnalysisAlarm Error.");
            }
        }
Пример #4
0
        /// <summary>
        /// Runs to delete eSight.
        /// </summary>
        /// <param name="eSightIp">The e sight ip.</param>
        private void RunDeleteESight(string eSightIp)
        {
            HWLogger.GetESightNotifyLogger(eSightIp).Info($"Recieve: delete this eSight");
            Task.Run(() =>
            {
                BladeConnector.Instance.RemoveServerFromMGroup(eSightIp);
                HighdensityConnector.Instance.RemoveServerFromMGroup(eSightIp);
                RackConnector.Instance.RemoveServerFromMGroup(eSightIp);
                KunLunConnector.Instance.RemoveServerFromMGroup(eSightIp);
            });
            var syncInstance = this.SyncInstances.FirstOrDefault(y => y.ESightIp == eSightIp);

            if (syncInstance != null)
            {
                syncInstance.Unsubscribe();
                syncInstance.Close();
                this.SyncInstances.Remove(syncInstance);
            }
        }
Пример #5
0
        /// <summary>
        /// Analysises the TCP MSG.
        /// </summary>
        /// <param name="json">The json.</param>
        /// <exception cref="System.Exception">can not find eSight:" + tcpMessage.ESightIp</exception>
        /// <exception cref="System.ArgumentOutOfRangeException"></exception>
        public void AnalysisTcpMsg(string json)
        {
            try
            {
                var tcpMessage = JsonUtil.DeserializeObject <TcpMessage <object> >(json);
                var eSightList = ESightDal.Instance.GetList();
                var eSight     = eSightList.FirstOrDefault(x => x.SubscribeID == tcpMessage.SubscribeId);
                if (eSight == null)
                {
                    throw new Exception("can not find eSight:" + tcpMessage.SubscribeId);
                }
                if (tcpMessage.MsgType != TcpMessageType.KeepAlive)
                {
                    HWLogger.GetESightNotifyLogger(eSight.HostIP).Info($"RecieveTcpMsg. data:{json}");
                }
                else
                {
                    HWLogger.GetESightSubscribeLogger(eSight.HostIP).Info($"RecieveTcpMsg. data:{json}");
                }

                switch (tcpMessage.MsgType)
                {
                case TcpMessageType.Alarm:
                    this.AnalysisAlarm(eSight, json);
                    break;

                case TcpMessageType.NeDevice:
                    this.AnalysisNeDevice(eSight, json);
                    break;

                case TcpMessageType.KeepAlive:
                    this.AnalysisAlive(eSight, json);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception ex)
            {
                this.OnError("AnalysisTcpMsg Error: ", ex);
            }
        }