Exemple #1
0
        private static List <RunbookParameter> GetRunbookParametersById(string serviceURL,
                                                                        Guid runbookID)
        {
            List <RunbookParameter> parameters = null;

            SCOService.OrchestratorContext context =
                new SCOService.OrchestratorContext(new Uri(serviceURL));

            // Set credentials to default or a specific user.
            context.Credentials = System.Net.CredentialCache.DefaultCredentials;

            // Get the parameters based on the runbook ID
            parameters = context.RunbookParameters.Where(rp => rp.RunbookId == runbookID &&
                                                         rp.Direction == "In").ToList();
            return(parameters);
        }
Exemple #2
0
        private static Runbook GetRunbookByPath(string serviceURL, string path)
        {
            Runbook runbook = null;

            SCOService.OrchestratorContext context =
                new SCOService.OrchestratorContext(new Uri(serviceURL));

            // Set credentials to default or a specific user.
            context.Credentials = System.Net.CredentialCache.DefaultCredentials;

            // Get the runbook based on the entered path
            runbook = context.Runbooks.Where(rb =>
            {
                return(rb.Path == path);
            }).First();
            return(runbook);
        }
Exemple #3
0
        //public static OrchestratorContext GetOrchestratorContext(string serviceURL, string userName, string password, string domain)
        //{
        //    // Path to Orchestrator web service
        //    string serviceRoot = serviceURL;

        //    // Create Orchestrator context
        //    SCOService.OrchestratorContext context = new SCOService.OrchestratorContext(new Uri(serviceRoot));

        //    // Set credentials to default or a specific user.
        //    //context.Credentials = System.Net.CredentialCache.DefaultCredentials;
        //    context.Credentials = new System.Net.NetworkCredential(userName, password, domain);

        //    return context;
        //}

        private static OrchestratorContext GetOrchestratorContext()
        {
            SCOIntegrationSettings settings = new SCOIntegrationSettings();

            settings = SCOIntegrationSettings.GetSettings();

            // Path to Orchestrator web service
            string serviceRoot = settings.SCOServiceUrl;

            // Create Orchestrator context
            SCOService.OrchestratorContext context = new SCOService.OrchestratorContext(new Uri(serviceRoot));

            // Set credentials to a specific user.
            //context.Credentials = System.Net.CredentialCache.DefaultCredentials;
            context.Credentials = new System.Net.NetworkCredential(settings.SCOServerUsername, settings.SCOServerUserPassword, settings.SCODomain);

            return(context);
        }
Exemple #4
0
        private static Job StartRunbookJob(string serviceURL, Guid runbookID,
                                           List <RunbookParameter> runbookParameters, Hashtable runbookParameterValues)
        {
            Job job = new Job();
            // Configure the XML for the parameters
            StringBuilder parametersXml = new StringBuilder();

            if (runbookParameters != null && runbookParameters.Count() > 0)
            {
                parametersXml.Append("<Data>");
                foreach (var param in runbookParameters)
                {
                    parametersXml.AppendFormat(
                        "<Parameter><ID>{0}</ID><Value>{1}</Value></Parameter>",
                        param.Id.ToString("B"), runbookParameterValues[param.Name]);
                }
                parametersXml.Append("</Data>");
            }

            try
            {
                // Create new job and assign runbook Id and parameters.
                job.RunbookId  = runbookID;
                job.Parameters = parametersXml.ToString();

                SCOService.OrchestratorContext context =
                    new SCOService.OrchestratorContext(new Uri(serviceURL));

                // Set credentials to default or a specific user.
                context.Credentials = System.Net.CredentialCache.DefaultCredentials;

                // Add newly created job.
                context.AddToJobs(job);
                context.SaveChanges();

                return(job);
            }
            catch (DataServiceQueryException ex)
            {
                throw new ApplicationException("Error starting runbook.", ex);
            }
        }