/// <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();
        }
Esempio n. 3
0
 void SaveLicenseKey(string key)
 {
     _emoSettings[null, "Key"].Value = key;
     _emoSettings.Overwrite();
 }
Esempio n. 4
0
        protected override void ProcessRecord()
        {
            try
            {
                if (_announcement != null)
                {
                    WriteVerbose("Setting by instance");

                    bool change = false;
                    if (_DisplayName != null)
                    {
                        WriteDebug("Setting instance Name");
                        _announcement[null, "DisplayName"].Value = _DisplayName;
                        _announcement[null, "Title"].Value       = _DisplayName;
                        change = true;
                    }
                    if (_Body != null)
                    {
                        WriteDebug("Setting instance Body");
                        _announcement[null, "Body"].Value = _Body;
                        change = true;
                    }
                    if (_Priority != null)
                    {
                        WriteDebug("Setting instance Priority");
                        _announcement[null, "Priority"].Value = enumPriority.Id;
                        change = true;
                    }
                    if (_ExpirationDate != null)
                    {
                        WriteDebug("Setting instance ExpirationDate");
                        _announcement[null, "ExpirationDate"].Value = _ExpirationDate;
                        change = true;
                    }
                    if (change)
                    {
                        WriteDebug("Overwriting instance");
                        _announcement.Overwrite();
                        if (_passThru)
                        {
                            WriteObject(ServiceManagerObjectHelper.AdaptManagementObject(this, _announcement));
                        }
                    }
                }
                else if (_InternalID != null)
                {
                    bool change = false;
                    WriteVerbose("Setting by ID");
                    EnterpriseManagementObject emo = _mg.EntityObjects.GetObject <EnterpriseManagementObject>(new Guid(_InternalID), ObjectQueryOptions.Default);
                    if (_DisplayName != null)
                    {
                        emo[clsAnnouncement, "DisplayName"].Value = _DisplayName;
                        emo[clsAnnouncement, "Title"].Value       = _DisplayName;
                        change = true;
                    }
                    if (_Body != null)
                    {
                        emo[clsAnnouncement, "Body"].Value = _Body;
                        change = true;
                    }
                    if (_Priority != null)
                    {
                        emo[clsAnnouncement, "Priority"].Value = enumPriority.Id;
                        change = true;
                    }
                    if (_ExpirationDate != null)
                    {
                        emo[clsAnnouncement, "ExpirationDate"].Value = _ExpirationDate;
                        change = true;
                    }
                    if (change)
                    {
                        emo.Overwrite();
                        if (_passThru)
                        {
                            WriteObject(ServiceManagerObjectHelper.AdaptManagementObject(this, emo));
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                WriteError(new ErrorRecord(exception, "Object", ErrorCategory.NotSpecified, "Announcement"));
            }
        }
        public async Task ProcessActivity(EnterpriseManagementObject activityObj)
        {
            try
            {
                if (activityObj[ActivityClass, "JobId"].Value != null)
                {
                    var jobId = (Guid)activityObj[ActivityClass, "JobId"].Value;

                    var jt = _aaClient.GetJobAsync(jobId);
                    var ot = _aaClient.GetJobOutput(jobId);

                    var j = await jt;
                    activityObj[ActivityClass, "JobStatus"].Value = j.Properties.Status;
                    activityObj[ActivityClass, "JobException"].Value = j.Properties.Exception;

                    var s = j.Properties.Status.ToLower();
                    if (s == "completed")
                        activityObj[ActivityClass, "Status"].Value = ActivityCompletedEnum;
                    else if (s == "stopped" || s == "failed")
                        activityObj[ActivityClass, "Status"].Value = ActivityFailedEnum;

                    activityObj[ActivityClass, "JobOutput"].Value = await ot;
                    activityObj.Overwrite();
                }
            }
            catch (Exception error)
            {
                activityObj[ActivityClass, "JobException"].Value = error.Message;
                activityObj.Overwrite();
            }
        }