/// <summary> /// Convert OM MonitoringObject to HWESightHost Entity Function /// </summary> /// <returns></returns> private static Func <EnterpriseManagementObject, HWESightHost> ConvertMonitoringObjectToESightHost() { return(obj => { var props = OM12Connection.GetManagementPackProperties(obj); HWESightHost appliance = new HWESightHost { HostIP = obj[props["Host"]].Value as String, HostPort = Convert.ToInt32(obj[props["Port"]].Value), AliasName = obj[props["AliasName"]].Value as String, SystemID = obj[props["SystemId"]].Value as String, LoginAccount = obj[props["LoginAccount"]].Value as String, LoginPd = obj[props["LoginPassword"]].Value as String, CreateTime = ((DateTime)obj[props["CreatedOn"]].Value).ToLocalTime(), LastModifyTime = ((DateTime)obj[props["LastModifiedOn"]].Value).ToLocalTime(), OpenID = obj[props["OpenID"]].Value as String, SubscribeID = obj[props["SubscribeID"]].Value as String, SubKeepAliveStatus = Convert.ToInt32(obj[props["SubKeepAliveStatus"]].Value), SubscriptionAlarmStatus = Convert.ToInt32(obj[props["SubscriptionAlarmStatus"]].Value), SubscriptionNeDeviceStatus = Convert.ToInt32(obj[props["SubscriptionNeDeviceStatus"]].Value), SubKeepAliveError = obj[props["SubKeepAliveError"]].Value as String, SubscripeAlarmError = obj[props["SubscripeAlarmError"]].Value as String, SubscripeNeDeviceError = obj[props["SubscripeNeDeviceError"]].Value as String, //LatestConnectInfo = obj[props["LatestConnectInfo"]].Value as String, //LatestStatus = obj[props["LatestStatus"]].Value as string, }; return appliance; }); }
public void TestGetAllESightApplicanceAsync() { string clazzName = EntityTypeConst.BladeServer.Fan; ManagementPackClass clazz = OM12Connection.GetManagementPackClass(clazzName); var clazzProps = clazz.GetProperties(); var list = OM12Connection.All <PartialMonitoringObject>(clazzName); var first = list.FirstOrDefault(); var props = OM12Connection.GetManagementPackProperties(first); var baseProps = OM12Connection.GetManagementPackProperties(EntityTypeConst.ESight.HuaweiServer); var Status = first[props["Status"]].Value; var DN = first[baseProps["DN"]].Value; Console.WriteLine(clazz); }
/// <summary> /// Updates esight connect status. /// </summary> /// <param name="hostIp">The host ip.</param> /// <param name="latestStatus">The latest status.</param> /// <param name="latestConnectInfo">The latest connect information.</param> public void UpdateESightConnectStatus(string hostIp, string latestStatus, string latestConnectInfo) { IObjectReader <EnterpriseManagementObject> items = OM12Connection.Query <EnterpriseManagementObject>(ESightAppliance.EntityClassName, $"Host='{hostIp}'"); EnterpriseManagementObject managementObject = items.FirstOrDefault(); if (managementObject == null) { throw new Exception($"Can not find the eSight:{hostIp}"); } var props = OM12Connection.GetManagementPackProperties(managementObject); managementObject[props["LastModifiedOn"]].Value = DateTime.UtcNow; managementObject[props["LatestStatus"]].Value = latestStatus; managementObject[props["LatestConnectInfo"]].Value = latestConnectInfo; managementObject.Overwrite(); }
/// <summary> /// Updates the esight alarm. /// </summary> /// <param name="hostIp">The host ip.</param> /// <param name="alarmStatus">The alarm status.</param> /// <param name="error">The error.</param> public void UpdateESightNeDevice(string hostIp, int alarmStatus, string error) { IObjectReader <EnterpriseManagementObject> items = OM12Connection.Query <EnterpriseManagementObject>(ESightAppliance.EntityClassName, $"Host='{hostIp}'"); EnterpriseManagementObject managementObject = items.FirstOrDefault(); if (managementObject == null) { throw new Exception($"Can not find the eSight:{hostIp}"); } var props = OM12Connection.GetManagementPackProperties(managementObject); managementObject[props["LastModifiedOn"]].Value = DateTime.UtcNow; managementObject[props["SubscripeNeDeviceError"]].Value = error; managementObject[props["SubscriptionNeDeviceStatus"]].Value = alarmStatus; managementObject.Overwrite(); }
private ESightAppliance GetModelFromMpObject(EnterpriseManagementObject obj) { var props = OM12Connection.GetManagementPackProperties(obj); var model = new ESightAppliance() { Host = obj[props["Host"]].Value as String, Port = obj[props["Port"]].Value.ToString(), AliasName = obj[props["AliasName"]].Value as String, SystemId = obj[props["SystemId"]].Value as String, LoginAccount = obj[props["LoginAccount"]].Value as String, LoginPassword = obj[props["LoginPassword"]].Value as String, CreatedOn = ((DateTime)obj[props["CreatedOn"]].Value).ToLocalTime(), LastModifiedOn = ((DateTime)obj[props["LastModifiedOn"]].Value).ToLocalTime(), SubscriptionAlarmStatus = Convert.ToInt32(obj[props["SubscriptionAlarmStatus"]].Value), SubscriptionNeDeviceStatus = Convert.ToInt32(obj[props["SubscriptionNeDeviceStatus"]].Value), //LatestStatus = obj[props["LatestStatus"]].Value as string, SubscribeID = obj[props["SubscribeID"]].Value as string, }; LogHelper.Info($"Host[{model.Host}] Port[{model.Port}] LoginAccount[{model.LoginAccount}] SubscribeID[{model.SubscribeID}] "); return(model); }