Closed s2patrick closed 7 years ago
Hi Partick, thank you for your feedback.
Just to be clear, you want to maintenance a monitoring object regardless of class, right? If that is the case I think I can manage that, i just have to find the time to implement it.
Hi, yes... that is correct. /patrick
Patrick. I will find some time to review this, but if you add this to the maintenance controller i believe it should work.
` ///
List<SCOMMonitoringObjectModel> MonitoringObjects = new List<SCOMMonitoringObjectModel>();
List<SCOMObjectMaintenanceModel> MaintenanceObjects = new List<SCOMObjectMaintenanceModel>();
if (!monObject.InMaintenanceMode)
{
{
//set maintenance properties
DateTime startTime = DateTime.UtcNow;
DateTime schedEndTime = DateTime.UtcNow.AddMinutes(Data.Minutes);
MaintenanceModeReason reason = MaintenanceModeReason.PlannedOther;
string comment = Data.comment;
monObject.ScheduleMaintenanceMode(startTime, schedEndTime, reason, comment);
//Add properties to list
SCOMObjectMaintenanceModel maintenanceObject = new SCOMObjectMaintenanceModel();
maintenanceObject.displayName = monObject.DisplayName;
maintenanceObject.id = monObject.Id.ToString();
maintenanceObject.EndTime = schedEndTime;
maintenanceObject.Minutes = Data.Minutes;
maintenanceObject.comment = comment;
//add computers to list
MaintenanceObjects.Add(maintenanceObject);
}
}
//If computer already in maintenance. Do nothing and list info
else
{
MaintenanceWindow MaintenanceWindow = monObject.GetMaintenanceWindow();
HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.Conflict);
message.Content = new StringContent("Object already in maintenance until" + MaintenanceWindow.ScheduledEndTime);
throw new HttpResponseException(message);
}
//Return list of computers as Json
return Json(MaintenanceObjects);
}`
Patrick. Try the api from the dev branch. A lot of updates including the one you requested
Ehrnst, hi. Awesome, thank you for your time. Will try next week once I am back at my lab. I owe you a beer! :-)
Hi, great API, thanks for that.
It would be great to see the method to set a Maint. Mode not just for Windows Computers, but for any class. For instance, we need to set MM for a class to which service monitors are targeted, not the whole machine.
Thanks again and best, Patrick