/// <summary> /// Creates the child Highdensity. /// </summary> /// <param name="model"> /// The model. /// </param> /// <returns> /// MPObject. /// </returns> private MPObject CreateChildHighdensity(ChildHighdensity model) { var propertys = this.ChildHighdensityClass.PropertyCollection; // 获取到class的属性 var obj = new MPObject(MGroup.Instance, this.ChildHighdensityClass); // 实例化一个class obj[propertys["DN"]].Value = model.DN; obj[propertys["Status"]].Value = model.Status; obj[propertys["IPAddress"]].Value = model.IpAddress; obj[propertys["UUID"]].Value = model.UUID; obj[propertys["ProductSn"]].Value = model.ProductSn; obj[propertys["Type"]].Value = model.Type; obj[this.DisplayNameField].Value = model.Name; return(obj); }
/// <summary> /// 当Dn为高密子服务器的DN时,需要更新整个管理板 /// </summary> /// <param name="model">The model.</param> /// <param name="alarmSn">The alarm sn.</param> private void UpdateChildHighdensityServer(HWDeviceDetail model, int alarmSn) { try { logger.NotifyProcess.Info($"Start Update Child HighdensityServer:{model.DN} .[alarmSn:{alarmSn}]"); //更新子刀片 var server = new ChildHighdensity(this.ESightIp); server.MakeChildBladeDetail(model); HighdensityConnector.Instance.UpdateChildBoard(server, false); } catch (Exception ex) { logger.NotifyProcess.Error(ex, $"UpdateChildHighdensityServer Error.Dn:{model.DN} .[alarmSn:{alarmSn}] "); } }
/// <summary> /// 更新高密子服务器 /// </summary> /// <param name="model">The model.</param> public void UpdateChildHighdensityServer(HWDeviceDetail model) { try { var server = new ChildHighdensity(); server.DN = model.DN; server.Name = model.Name; server.IpAddress = model.IpAddress; server.MakeChildBladeDetail(model); HighdensityConnector.Instance.UpdateChildBoard(server); } catch (Exception ex) { this.OnNotifyError($"UpdateChildHighdensityServer Error.eSight:{this.ESightIp} Dn:{model.DN}. ", ex); } }
/// <summary> /// 查询高密列表 /// </summary> /// <param name="startPage">The start page.</param> /// <returns>高密列表</returns> public ApiServerList <HighdensityServer> QueryHighDesentyServer(int startPage) { var result = new ApiServerList <HighdensityServer>(); var queryDeviceParam = new DeviceParam() { PageSize = 100, StartPage = startPage, ServerType = "highdensity" }; var reqResult = this.GetServerList(queryDeviceParam); reqResult.Data.ForEach(x => { var highDesentyServer = new HighdensityServer(x); x.ChildBlades.ForEach(m => { var childHighdensity = new ChildHighdensity(m, this.ESight.HostIP); highDesentyServer.ChildHighdensitys.Add(childHighdensity); }); result.Data.Add(highDesentyServer); }); result.TotalSize = reqResult.TotalSize; result.TotalPage = reqResult.TotalPage; return(result); }
/// <summary> /// The reload. /// </summary> public void Reload() { var bladeMain = this.GetMain("bladeList.js"); var highdensityMain = this.GetMain("highdensityList.js"); var bladeChildDetial = this.GetDetails("bladeChildDetial.js"); var bladeDetial = this.GetDetails("bladeDetial.js"); var highdensityChildDetial = this.GetDetails("highdensityChildDetial.js"); var highdensityDetial = this.GetDetails("highdensityDetial.js"); // var rackMain = this.GetMain("rackList.js"); var rackDetail = this.GetDetails("rackDetail.js"); // var kunLunMain = this.GetMain("kunlunList.js"); var kunLunDetail = this.GetDetails("kunlunDetail.js"); this.BladeTest = new BladeServer(bladeMain); bladeMain.ChildBlades.ForEach( m => { var childBlade = new ChildBlade(m); childBlade.MakeChildBladeDetail(bladeChildDetial); this.BladeTest.ChildBlades.Add(childBlade); }); this.BladeTest.MakeDetail(bladeDetial); this.HighTest = new HighdensityServer(highdensityMain); highdensityMain.ChildBlades.ForEach( m => { var childHighdensity = new ChildHighdensity(m); childHighdensity.MakeChildBladeDetail(highdensityChildDetial); this.HighTest.ChildHighdensitys.Add(childHighdensity); }); this.HighTest.MakeDetail(highdensityDetial); this.RackTest = new RackServer(); this.RackTest.MakeDetail(rackDetail); this.KunLunTest = new KunLunServer(); this.KunLunTest.MakeDetail(kunLunDetail); #region MyRegion var path = Application.StartupPath + "//..//..//..//..//..//..//..//..//mockNew//alarmData//alarmData.js"; var data = File.ReadAllText(path).Replace("module.exports =", string.Empty); this.BladeEventData = new EventData(JsonUtil.DeserializeObject <AlarmData>(data.Replace("rack", "blade"))); this.ChildBladeEventData = new EventData(JsonUtil.DeserializeObject <AlarmData>(data.Replace("rack", "childeblade"))); this.HighEventData = new EventData(JsonUtil.DeserializeObject <AlarmData>(data.Replace("rack", "high"))); this.ChildHighEventData = new EventData(JsonUtil.DeserializeObject <AlarmData>(data.Replace("rack", "childhigh"))); this.KunLunEventData = new EventData(JsonUtil.DeserializeObject <AlarmData>(data.Replace("rack", "kunlun"))); this.RackEventData = new EventData(JsonUtil.DeserializeObject <AlarmData>(data.Replace("rack", "rack"))); path = Application.StartupPath + "//..//..//..//..//..//..//..//..//mockNew//alarmData//deviceChangeData.js"; data = File.ReadAllText(path).Replace("module.exports =", string.Empty); var daTemp = JsonUtil.DeserializeObject <NedeviceData>(data); this.DeviceChangeEventData = new DeviceChangeEventData(daTemp); #endregion }
/// <summary> /// The update child blade. /// </summary> /// <param name="model">The model.</param> /// <exception cref="Exception">Can not find the child blade server</exception> public void UpdateChildBoard(ChildHighdensity model) { HWLogger.NOTIFICATION_PROCESS.Debug("Start UpdateChildBoard"); var oldObject = this.GetObject($"DN = '{model.DN}'", this.ChildHighdensityClass); if (oldObject == null) { throw new Exception($"Can not find the child blade server:{model.DN}"); } var propertys = this.ChildHighdensityClass.PropertyCollection; // 获取到class的属性 var discoveryData = new IncrementalDiscoveryData(); var childHighdensityKey = this.ChildHighdensityClass.PropertyCollection["DN"]; oldObject[propertys["Status"]].Value = model.Status; oldObject[propertys["IPAddress"]].Value = model.IpAddress; oldObject[propertys["UUID"]].Value = model.UUID; oldObject[propertys["ProductSn"]].Value = model.ProductSn; oldObject[propertys["Type"]].Value = model.Type; oldObject[this.DisplayNameField].Value = model.Name; discoveryData.Add(oldObject); #region CPU var cpuGroup = oldObject.GetRelatedMonitoringObjects(this.CpuGroupClass).First(); discoveryData.Add(cpuGroup); var relatedCpuObjects = cpuGroup.GetRelatedMonitoringObjects(this.CpuClass); var deleteCpu = relatedCpuObjects.Where( x => model.CPUList.All(y => y.UUID != x[this.CpuClass.PropertyCollection["UUID"]].Value.ToString())) .ToList(); deleteCpu.ForEach(x => { discoveryData.Remove(x); }); model.CPUList.ForEach( y => { var cpu = this.UpdateCpu(y); if (cpu == null) { var newCpu = this.CreateCpu(y); newCpu[this.PartChildGroupKey].Value = cpuGroup[this.PartChildGroupKey].Value; newCpu[childHighdensityKey].Value = model.DN; newCpu[this.PartGroupKey].Value = oldObject[this.PartGroupKey].Value; newCpu[this.ComputerKey].Value = model.DN; newCpu[this.HuaweiServerKey].Value = model.DN; discoveryData.Add(newCpu); } else { discoveryData.Add(cpu); } }); #endregion #region Memory var memoryGroup = oldObject.GetRelatedMonitoringObjects(this.MemoryGroupClass).First(); discoveryData.Add(memoryGroup); var relatedMemoryObjects = memoryGroup.GetRelatedMonitoringObjects(this.MemoryClass); var deleteMemory = relatedMemoryObjects.Where( x => model.MemoryList.All( y => y.UUID != x[this.MemoryClass.PropertyCollection["UUID"]].Value.ToString())).ToList(); deleteMemory.ForEach(x => { discoveryData.Remove(x); }); model.MemoryList.ForEach( y => { var memory = this.UpdateMemory(y); if (memory == null) { var newMemory = this.CreateMemory(y); newMemory[this.PartChildGroupKey].Value = memoryGroup[this.PartChildGroupKey].Value; newMemory[childHighdensityKey].Value = model.DN; newMemory[this.PartGroupKey].Value = oldObject[this.PartGroupKey].Value; newMemory[this.ComputerKey].Value = model.DN; newMemory[this.HuaweiServerKey].Value = model.DN; discoveryData.Add(newMemory); } else { discoveryData.Add(memory); } }); #endregion #region Disk var diskGroup = oldObject.GetRelatedMonitoringObjects(this.DiskGroupClass).First(); discoveryData.Add(diskGroup); var relatedDiskObjects = diskGroup.GetRelatedMonitoringObjects(this.DiskClass); var deleteDisk = relatedDiskObjects.Where( x => model.DiskList.All( y => y.UUID != x[this.DiskClass.PropertyCollection["UUID"]].Value.ToString())) .ToList(); deleteDisk.ForEach(x => { discoveryData.Remove(x); }); model.DiskList.ForEach( y => { var disk = this.UpdateDisk(y); if (disk == null) { var newDisk = this.CreateDisk(y); newDisk[this.PartChildGroupKey].Value = diskGroup[this.PartChildGroupKey].Value; newDisk[childHighdensityKey].Value = model.DN; newDisk[this.PartGroupKey].Value = oldObject[this.PartGroupKey].Value; newDisk[this.ComputerKey].Value = model.DN; newDisk[this.HuaweiServerKey].Value = model.DN; discoveryData.Add(newDisk); } else { discoveryData.Add(disk); } }); #endregion #region Raid var raidGroup = oldObject.GetRelatedMonitoringObjects(this.RaidGroupClass).First(); discoveryData.Add(raidGroup); var relatedRaidObjects = raidGroup.GetRelatedMonitoringObjects(this.RaidClass); var deleteRaid = relatedRaidObjects.Where( x => model.RaidList.All( y => y.UUID != x[this.RaidClass.PropertyCollection["UUID"]].Value.ToString())) .ToList(); deleteRaid.ForEach(x => { discoveryData.Remove(x); }); model.RaidList.ForEach( y => { var raid = this.UpdateRaidControl(y); if (raid == null) { var newRaid = this.CreateRaidControl(y); newRaid[this.PartChildGroupKey].Value = raidGroup[this.PartChildGroupKey].Value; newRaid[childHighdensityKey].Value = model.DN; newRaid[this.PartGroupKey].Value = oldObject[this.PartGroupKey].Value; newRaid[this.ComputerKey].Value = model.DN; newRaid[this.HuaweiServerKey].Value = model.DN; discoveryData.Add(newRaid); } else { discoveryData.Add(raid); } }); #endregion discoveryData.Overwrite(this.MontioringConnector); HWLogger.NOTIFICATION_PROCESS.Debug("End UpdateChildBoard"); }