protected override void ProcessRecord() { switch (ParameterSetName) { case "folder": foreach (Runbook rb in SCOrch.getMonitorRunbook(sco, folder, loadParameterData.IsPresent)) { WriteObject(rb); } break; case "guid": foreach (Runbook rb in SCOrch.getMonitorRunbook(sco, folderGUID, loadParameterData.IsPresent)) { WriteObject(rb); } break; case "path": foreach (Runbook rb in SCOrch.getMonitorRunbook(sco, folderPath, loadParameterData.IsPresent)) { WriteObject(rb); } break; case "all": foreach (Runbook rb in SCOrch.getMonitorRunbook(sco, loadParameterData.IsPresent)) { WriteObject(rb); } break; } }
protected override void ProcessRecord() { foreach (Folder fol in SCOrch.getSubFolders(sco, FolderPath, loadRunbooks.IsPresent)) { WriteObject(fol); } }
private void pollForJobCompletion(OrchestratorContext sco, Guid jobID) { while (!SCOrch.getJobDetails(sco, jobID).job.Status.Equals("Completed")) { System.Threading.Thread.Sleep(new TimeSpan(0, 0, 3)); } }
private static bool runRunbook() { bool status = true; OrchestratorContext sco = setupOrchestratorConnection(); string jobID; try { if (!String.IsNullOrEmpty(RUNBOOK_PATH)) { jobID = Convert.ToString(((Job)SCOrch.startRunbookJob(sco, RUNBOOK_PATH, INPUT_RUNBOOK_PARAMETERS)).Id); } else if (!String.IsNullOrEmpty(RUNBOOK_PATH)) { jobID = Convert.ToString(((Job)SCOrch.startRunbookJob(sco, new Guid(RUNBOOK_GUID), INPUT_RUNBOOK_PARAMETERS)).Id); } else { Console.WriteLine("Must pass either -RunbookPath or -RunbookGUID"); return(false); } if (waitForExit) { pollForJobCompletion(sco, new Guid(jobID)); } } // If webservice isn't available attempt 1 try again catch { throw; } return(status); }
private static void pollForJobCompletion(OrchestratorContext sco, Guid jobID) { try { while (!SCOrch.getJobDetails(sco, jobID).job.Status.Equals("Completed")) { System.Threading.Thread.Sleep(new TimeSpan(0, 0, 3)); } JobInstance j = SCOrch.getJobDetails(sco, jobID); Console.WriteLine("<OutputParameters>"); foreach (string key in j.OutputParameters.Keys) { Console.WriteLine(string.Format("\t<{0}>{1}</{0}>", key, j.OutputParameters[key])); } Console.WriteLine("</OutputParameters>"); } // Allow for 1 webservice Error catch { sco = setupOrchestratorConnection(); while (!SCOrch.getJobDetails(sco, jobID).job.Status.Equals("Completed")) { System.Threading.Thread.Sleep(new TimeSpan(0, 0, 3)); } JobInstance j = SCOrch.getJobDetails(sco, jobID); Console.WriteLine("<OutputParameters>"); foreach (string key in j.OutputParameters.Keys) { Console.WriteLine(string.Format("\t<{0}>{1}</{0}>", key, j.OutputParameters[key])); } Console.WriteLine("</OutputParameters>"); } }
protected override void ProcessRecord() { Event[] events = SCOrch.getOrchestartorEvents(sco, minDate, maxDate); foreach (Event e in events) { WriteObject(e); } }
private static bool runRunbook() { bool status = true; OrchestratorContext sco = setupOrchestratorConnection(); OrchestratorInterop.SCOrchestrator.Job job; try { if (string.IsNullOrEmpty(TargetRunbookServer)) { if (!String.IsNullOrEmpty(RunbookPath)) { job = SCOrch.startRunbookJob(sco, RunbookPath, _InputParameters); } else if (!String.IsNullOrEmpty(RunbookGUID)) { job = SCOrch.startRunbookJob(sco, new Guid(RunbookGUID), _InputParameters); } else { throw new Exception("Must pass either -RunbookPath or -RunbookGUID"); } } else { if (!String.IsNullOrEmpty(RunbookPath)) { job = SCOrch.startRunbookJob(sco, RunbookPath, TargetRunbookServer, _InputParameters); } else if (!String.IsNullOrEmpty(RunbookGUID)) { job = SCOrch.startRunbookJob(sco, new Guid(RunbookGUID), TargetRunbookServer, _InputParameters); } else { throw new Exception("Must pass either -RunbookPath or -RunbookGUID"); } } if (WaitForExit) { pollForJobCompletion(sco, job.Id); } else { JobInstance ji = new JobInstance(); ji.job = job; // WriteObject(ji); } } catch { throw; } return(status); }
public void Execute(IActivityRequest request, IActivityResponse response) { OrchestratorContext sco = new OrchestratorContext(new Uri(Credentials.OrchestratorServiceURL)); sco.Credentials = new NetworkCredential(Credentials.UserName, Credentials.Password, Credentials.Domain); sco.MergeOption = MergeOption.OverwriteChanges; Runbook[] runbookArray = SCOrch.getAllRunningRunbooks(sco); response.WithFiltering().PublishRange(parseResults(runbookArray)); }
public void Execute(IActivityRequest request, IActivityResponse response) { OrchestratorContext sco = new OrchestratorContext(new Uri(Credentials.OrchestratorServiceURL)); sco.Credentials = new NetworkCredential(Credentials.UserName, Credentials.Password, Credentials.Domain); sco.MergeOption = MergeOption.OverwriteChanges; RunbookServerInst[] RunbookServerArray = SCOrch.getAllRunbookServer(sco, true); response.WithFiltering().PublishRange(parseResults(RunbookServerArray)); response.Publish("Number Of Runbook Servers", numberOfRunbookServer); }
public void Execute(IActivityRequest request, IActivityResponse response) { String JobId = request.Inputs["Job Id"].AsString(); OrchestratorContext sco = new OrchestratorContext(new Uri(Credentials.OrchestratorServiceURL)); sco.Credentials = new NetworkCredential(Credentials.UserName, Credentials.Password, Credentials.Domain); sco.MergeOption = MergeOption.OverwriteChanges; JobInstance jobInstance = SCOrch.getJobDetails(sco, new Guid(JobId)); response.WithFiltering().PublishRange(parseResults(jobInstance)); }
public void Execute(IActivityRequest request, IActivityResponse response) { String JobStatus = request.Inputs["Job Status"].AsString(); OrchestratorContext sco = new OrchestratorContext(new Uri(Credentials.OrchestratorServiceURL)); sco.Credentials = new NetworkCredential(Credentials.UserName, Credentials.Password, Credentials.Domain); sco.MergeOption = MergeOption.OverwriteChanges; Runbook[] RunbookArray = SCOrch.getMonitorRunbook(sco, false); response.WithFiltering().PublishRange(parseResults(RunbookArray)); }
public void Execute(IActivityRequest request, IActivityResponse response) { String RunbookIdentifier = request.Inputs["Runbook Identifier"].AsString(); String IdentifierType = request.Inputs["Identifier Type"].AsString(); String jobStatus = String.Empty; if (request.Inputs.Contains("Job Status")) { jobStatus = request.Inputs["Job Status"].AsString(); } OrchestratorContext sco = new OrchestratorContext(new Uri(Credentials.OrchestratorServiceURL)); sco.Credentials = new NetworkCredential(Credentials.UserName, Credentials.Password, Credentials.Domain); sco.MergeOption = MergeOption.OverwriteChanges; JobInstance[] jobInstance = new JobInstance[0]; switch (IdentifierType) { case "Runbook Path": if (jobStatus.Equals(String.Empty)) { jobInstance = SCOrch.getRunbookJobInstances(sco, RunbookIdentifier); } else { jobInstance = SCOrch.getRunbookJobInstances(sco, RunbookIdentifier, jobStatus); } break; case "Runbook GUID": Guid runbookGUID = new Guid(RunbookIdentifier); if (jobStatus.Equals(String.Empty)) { jobInstance = SCOrch.getRunbookJobInstances(sco, runbookGUID); } else { jobInstance = SCOrch.getRunbookJobInstances(sco, runbookGUID, jobStatus); } break; default: response.LogErrorMessage("Must choose Runbook Path or Runbook GUID as an Identifier Type"); break; } response.WithFiltering().PublishRange(parseResults(jobInstance)); response.Publish("Number of Jobs", numberOfJobs); }
protected override void ProcessRecord() { if (string.IsNullOrEmpty(runbookServerName) && runbookServerGUID.Equals(Guid.Empty)) { RunbookServerInst[] RunbookServers = SCOrch.getAllRunbookServer(sco, loadJobs.IsPresent); foreach (RunbookServerInst rs in RunbookServers) { WriteObject(rs); } } else if (!string.IsNullOrEmpty(runbookServerName)) { WriteObject(SCOrch.getRunbookServer(sco, runbookServerName, loadJobs)); } else { WriteObject(SCOrch.getRunbookServer(sco, runbookServerGUID, loadJobs.IsPresent)); } }
protected override void ProcessRecord() { switch (ParameterSetName) { case "RunbookPath": WriteObject(SCOrch.getRunbook(sco, RunbookPath, loadParameterData.IsPresent)); break; case "RunbookGUID": WriteObject(SCOrch.getRunbook(sco, RunbookGUID, loadParameterData.IsPresent)); break; case "Folder": foreach (Runbook rb in SCOrch.getAllRunbooksInFolder(sco, FolderPath, loadParameterData.IsPresent)) { WriteObject(rb); } break; } }
public void Design(IActivityDesigner designer) { OrchestratorContext sco = new OrchestratorContext(new Uri(Credentials.OrchestratorServiceURL)); sco.Credentials = new NetworkCredential(Credentials.UserName, Credentials.Password, Credentials.Domain); sco.MergeOption = MergeOption.OverwriteChanges; string[] SummaryString = SCOrch.getOrchestartorEventSummaries(sco); if (SummaryString.Length > 0) { designer.AddFilter("Summary").WithRelations(Relation.Contains | Relation.EqualTo).WithListBrowser(SummaryString); } else { designer.AddFilter("Summary").WithRelations(Relation.Contains | Relation.EqualTo); } designer.AddFilter("CreationTime").WithRelations(Relation.After | Relation.Before); designer.AddCorellatedData(typeof(EventInst)); designer.AddOutput("Number of Events"); }
public void Execute(IActivityRequest request, IActivityResponse response) { String Summary = String.Empty; String SummaryCriteria = String.Empty; DateTime MinCreationDate = DateTime.MinValue; DateTime MaxCreationDate = DateTime.MaxValue; foreach (IFilterCriteria filter in request.Filters) { switch (filter.Name) { case "CreationTime": switch (filter.Relation) { case Relation.After: MinCreationDate = Convert.ToDateTime(filter.Value.AsString()); break; case Relation.Before: MaxCreationDate = Convert.ToDateTime(filter.Value.AsString()); break; } break; case "Summary": Summary = filter.Value.AsString(); switch (filter.Relation) { case Relation.Contains: SummaryCriteria = "Contains"; break; case Relation.EqualTo: SummaryCriteria = "Equals"; break; } break; default: break; } } OrchestratorContext sco = new OrchestratorContext(new Uri(Credentials.OrchestratorServiceURL)); sco.Credentials = new NetworkCredential(Credentials.UserName, Credentials.Password, Credentials.Domain); sco.MergeOption = MergeOption.OverwriteChanges; Event[] eventArray = null; if (Summary.Equals(String.Empty)) { eventArray = SCOrch.getOrchestartorEvents(sco, MinCreationDate, MaxCreationDate); } else { eventArray = SCOrch.getOrchestartorEvents(sco, MinCreationDate, MaxCreationDate, Summary, SummaryCriteria); } response.WithFiltering().PublishRange(parseResults(eventArray)); response.Publish("Number of Events", numberOfEvents); }
public void Design(IActivityDesigner designer) { string[] RunbookServerNames = new string[0]; try { OrchestratorContext sco = new OrchestratorContext(new Uri(Credentials.OrchestratorServiceURL)); sco.Credentials = new NetworkCredential(Credentials.UserName, Credentials.Password, Credentials.Domain); sco.MergeOption = MergeOption.OverwriteChanges; RunbookServerInst[] allRunbookServers = SCOrch.getAllRunbookServer(sco, false); RunbookServerNames = new string[allRunbookServers.Count()]; int b = 0; foreach (RunbookServerInst r in allRunbookServers) { try { RunbookServerNames[b] = r.server.Name; b++; } catch { } } } catch { } designer.AddInput("Runbook Identifier").WithDefaultValue(@"\ParentFolder\ContainingFolder\Runbook Name"); designer.AddInput("Identifier Type").WithDefaultValue(@"Runbook Path").WithListBrowser(new string[] { "Runbook Path", "Runbook GUID" }); designer.AddInput("Wait for Exit").WithDefaultValue("True").WithListBrowser(new string[] { "True", "False" }); if (RunbookServerNames.Length > 0) { designer.AddInput("Runbook Server Name").WithDefaultValue(RunbookServerNames[0]).WithListBrowser(RunbookServerNames).NotRequired(); } else { designer.AddInput("Runbook Server Name").NotRequired(); } designer.AddInput("Alternate User Name").NotRequired(); designer.AddInput("Alternate User Domain").NotRequired(); designer.AddInput("Password").NotRequired(); for (int i = 0; i < Credentials.MaxInputParameters; i++) { if (i < 10) { designer.AddInput("0" + i.ToString() + "_ParameterName").NotRequired(); designer.AddInput("0" + i.ToString() + "_ParameterValue").NotRequired(); } else { designer.AddInput(i.ToString() + "_ParameterName").NotRequired(); designer.AddInput(i.ToString() + "_ParameterValue").NotRequired(); } } designer.AddCorellatedData(typeof(JobDetails)); }
public void Execute(IActivityRequest request, IActivityResponse response) { String RunbookIdentifier = request.Inputs["Runbook Identifier"].AsString(); String IdentifierType = request.Inputs["Identifier Type"].AsString(); String WaitForExit = request.Inputs["Wait For Exit"].AsString(); String RunbookServerName = String.Empty; String altUserName = String.Empty; String altUserDomain = String.Empty; String altPassword = String.Empty; if (request.Inputs.Contains("Alternate User Name") && request.Inputs.Contains("Alternate User Domain") && request.Inputs.Contains("Password")) { altPassword = request.Inputs["Password"].AsString(); altUserDomain = request.Inputs["Alternate User Domain"].AsString(); altUserName = request.Inputs["Alternate User Name"].AsString(); } if (request.Inputs.Contains("Runbook Server Name")) { RunbookServerName = request.Inputs["Runbook Server Name"].AsString(); } Dictionary <string, string> ParameterList = new Dictionary <string, string>(); for (int i = 0; i < Credentials.MaxInputParameters; i++) { if (i < 10) { if (request.Inputs.Contains("0" + i.ToString() + "_ParameterName") && request.Inputs.Contains("0" + i.ToString() + "_ParameterValue")) { string paramName = request.Inputs["0" + i.ToString() + "_ParameterName"].AsString(); string paramValue = request.Inputs["0" + i.ToString() + "_ParameterValue"].AsString(); ParameterList.Add(paramName, paramValue); } } else { if (request.Inputs.Contains(i.ToString() + "_ParameterName") && request.Inputs.Contains(i.ToString() + "_ParameterValue")) { string paramName = request.Inputs["0" + i.ToString() + "_ParameterName"].AsString(); string paramValue = request.Inputs["0" + i.ToString() + "_ParameterValue"].AsString(); ParameterList.Add(paramName, paramValue); } } } OrchestratorContext sco = new OrchestratorContext(new Uri(Credentials.OrchestratorServiceURL)); if (altUserName.Equals(String.Empty)) { sco.Credentials = new NetworkCredential(Credentials.UserName, Credentials.Password, Credentials.Domain); } else { sco.Credentials = new NetworkCredential(altUserName, altPassword, altUserDomain); } sco.MergeOption = MergeOption.OverwriteChanges; Guid jobInstanceGUID = Guid.NewGuid(); if (RunbookServerName.Equals(String.Empty)) { switch (IdentifierType.ToUpper()) { case "RUNBOOK PATH": jobInstanceGUID = ((Job)SCOrch.startRunbookJob(sco, RunbookIdentifier, ParameterList)).Id; break; case "RUNBOOK GUID": Guid runbookGUID = new Guid(RunbookIdentifier); jobInstanceGUID = ((Job)SCOrch.startRunbookJob(sco, runbookGUID, ParameterList)).Id; break; default: jobInstanceGUID = ((Job)SCOrch.startRunbookJob(sco, RunbookIdentifier, ParameterList)).Id; break; } } else { switch (IdentifierType.ToUpper()) { case "RUNBOOK PATH": jobInstanceGUID = ((Job)SCOrch.startRunbookJob(sco, RunbookIdentifier, RunbookServerName, ParameterList)).Id; break; case "RUNBOOK GUID": Guid runbookGUID = new Guid(RunbookIdentifier); jobInstanceGUID = ((Job)SCOrch.startRunbookJob(sco, runbookGUID, RunbookServerName, ParameterList)).Id; break; default: jobInstanceGUID = ((Job)SCOrch.startRunbookJob(sco, RunbookIdentifier, RunbookServerName, ParameterList)).Id; break; } } if (WaitForExit.Equals("True")) { JobInstance ji = SCOrch.getJobDetails(sco, jobInstanceGUID); while (!(ji.job.Status.Equals("Completed") || ji.job.Status.Equals("Canceled") || ji.job.Status.Equals("Failed"))) { System.Threading.Thread.Sleep(new TimeSpan(0, 0, 3)); ji = SCOrch.getJobDetails(sco, jobInstanceGUID); } } JobInstance jobInstance = SCOrch.getJobDetails(sco, jobInstanceGUID); response.WithFiltering().PublishRange(parseResults(jobInstance)); }
protected override void ProcessRecord() { switch (ParameterSetName) { case "SingleJob": WriteObject(SCOrch.getJobDetails(sco, job.job.Id)); break; case "Runbook": if (string.IsNullOrEmpty(jobStatus)) { foreach (JobInstance ji in SCOrch.getRunbookJobInstances(sco, runbook.Id, LoadJobDetails.IsPresent)) { WriteObject(ji); } } else { foreach (JobInstance ji in SCOrch.getRunbookJobInstances(sco, runbook.Id, jobStatus, LoadJobDetails.IsPresent)) { WriteObject(ji); } } break; case "AllJobs": if (string.IsNullOrEmpty(jobStatus)) { foreach (JobInstance ji in SCOrch.getAllJobs(sco, LoadJobDetails.IsPresent)) { WriteObject(ji); } } else { foreach (JobInstance ji in SCOrch.getAllJobs(sco, jobStatus, LoadJobDetails.IsPresent)) { WriteObject(ji); } } break; case "RunbookServer": if (string.IsNullOrEmpty(jobStatus)) { foreach (JobInstance ji in SCOrch.getAllJobInstancesOnRunbookServer(sco, runbookServer, LoadJobDetails.IsPresent)) { WriteObject(ji); } } else { foreach (JobInstance ji in SCOrch.getAllJobInstancesOnRunbookServer(sco, runbookServer, jobStatus, LoadJobDetails.IsPresent)) { WriteObject(ji); } } break; default: break; } }
protected override void ProcessRecord() { String exceptionMessage = String.Empty; bool finished = false; int internalCounter = 0; while (internalCounter < RetryCount && !finished) { sco = setupOrchestratorConnection(); OrchestratorInterop.SCOrchestrator.Job job; try { switch (ParameterSetName) { case "Runbook": if (RunbookServer.Equals(String.Empty)) { job = SCOrch.startRunbookJob(sco, Runbook.Id, HashtableToDictionary(_InputParameters)); } else { job = SCOrch.startRunbookJob(sco, Runbook.Id, RunbookServer, HashtableToDictionary(_InputParameters)); } break; case "RunbookGuid": if (RunbookServer.Equals(String.Empty)) { job = SCOrch.startRunbookJob(sco, RunbookGuid, HashtableToDictionary(_InputParameters)); } else { job = SCOrch.startRunbookJob(sco, RunbookGuid, RunbookServer, HashtableToDictionary(_InputParameters)); } break; default: case "RunbookPath": if (RunbookServer.Equals(String.Empty)) { job = SCOrch.startRunbookJob(sco, RunbookPath, HashtableToDictionary(_InputParameters)); } else { job = SCOrch.startRunbookJob(sco, RunbookPath, RunbookServer, HashtableToDictionary(_InputParameters)); } break; } if (WaitForExit.IsPresent) { pollForJobCompletion(sco, job.Id); WriteObject(SCOrch.getJobDetails(sco, job.Id)); } else { WriteObject(new JobInstance() { job = job }); } finished = true; } catch (Exception e) { exceptionMessage = String.Format("Summary: {0}\nDetails: {1}", e.Message, e.InnerException); if (exceptionMessage.Contains("Summary: No Input Parameter on Runbook Found for Key:")) { throw new Exception(exceptionMessage); } else if (exceptionMessage.Equals("Must pass either -RunbookPath or -RunbookGUID")) { throw new Exception(exceptionMessage); } else if (exceptionMessage.Contains("Runbook Not Found: ")) { throw new Exception(exceptionMessage); } else if (exceptionMessage.Contains("The requested operation requires Publish permissions on the Runbook")) { throw new Exception(exceptionMessage); } internalCounter++; Thread.Sleep(new TimeSpan(0, 0, RetryDelay)); } } if (internalCounter >= RetryCount) { throw new Exception(exceptionMessage); } }
protected override void ProcessRecord() { WriteObject(SCOrch.stopRunbookJob(sco, job.job.Id)); }