Inheritance: Microsoft.Azure.Commands.Batch.Models.JobOperationParameters
Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new task.
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the task.</param>
        public void CreateTask(NewTaskParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            CloudTask task = new CloudTask(parameters.TaskId, parameters.CommandLine);

            task.DisplayName = parameters.DisplayName;
            task.RunElevated = parameters.RunElevated;

            if (parameters.EnvironmentSettings != null)
            {
                task.EnvironmentSettings = new List <EnvironmentSetting>();
                foreach (DictionaryEntry d in parameters.EnvironmentSettings)
                {
                    EnvironmentSetting setting = new EnvironmentSetting(d.Key.ToString(), d.Value.ToString());
                    task.EnvironmentSettings.Add(setting);
                }
            }

            if (parameters.ResourceFiles != null)
            {
                task.ResourceFiles = new List <ResourceFile>();
                foreach (DictionaryEntry d in parameters.ResourceFiles)
                {
                    ResourceFile file = new ResourceFile(d.Value.ToString(), d.Key.ToString());
                    task.ResourceFiles.Add(file);
                }
            }

            if (parameters.AffinityInformation != null)
            {
                task.AffinityInformation = parameters.AffinityInformation.omObject;
            }

            if (parameters.Constraints != null)
            {
                task.Constraints = parameters.Constraints.omObject;
            }

            if (parameters.MultiInstanceSettings != null)
            {
                Utils.Utils.MultiInstanceSettingsSyncCollections(parameters.MultiInstanceSettings);
                task.MultiInstanceSettings = parameters.MultiInstanceSettings.omObject;
            }

            WriteVerbose(string.Format(Resources.CreatingTask, parameters.TaskId));
            if (parameters.Job != null)
            {
                parameters.Job.omObject.AddTask(task, parameters.AdditionalBehaviors);
            }
            else
            {
                JobOperations jobOperations = parameters.Context.BatchOMClient.JobOperations;
                jobOperations.AddTask(parameters.JobId, task, parameters.AdditionalBehaviors);
            }
        }
        /// <summary>
        /// Creates a new task.
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the task.</param>
        public void CreateTask(NewTaskParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            CloudTask task = new CloudTask(parameters.TaskId, parameters.CommandLine);
            task.DisplayName = parameters.DisplayName;
            task.RunElevated = parameters.RunElevated;

            if (parameters.EnvironmentSettings != null)
            {
                task.EnvironmentSettings = new List<EnvironmentSetting>();
                foreach (DictionaryEntry d in parameters.EnvironmentSettings)
                {
                    EnvironmentSetting setting = new EnvironmentSetting(d.Key.ToString(), d.Value.ToString());
                    task.EnvironmentSettings.Add(setting);
                }
            }

            if (parameters.ResourceFiles != null)
            {
                task.ResourceFiles = new List<ResourceFile>();
                foreach (DictionaryEntry d in parameters.ResourceFiles)
                {
                    ResourceFile file = new ResourceFile(d.Value.ToString(), d.Key.ToString());
                    task.ResourceFiles.Add(file);
                }
            }

            if (parameters.AffinityInformation != null)
            {
                task.AffinityInformation = parameters.AffinityInformation.omObject;
            }

            if (parameters.Constraints != null)
            {
                task.Constraints = parameters.Constraints.omObject;
            }

            if (parameters.MultiInstanceSettings != null)
            {
                Utils.Utils.MultiInstanceSettingsSyncCollections(parameters.MultiInstanceSettings);
                task.MultiInstanceSettings = parameters.MultiInstanceSettings.omObject;
            }

            WriteVerbose(string.Format(Resources.CreatingTask, parameters.TaskId));
            if (parameters.Job != null)
            {
                parameters.Job.omObject.AddTask(task, parameters.AdditionalBehaviors);
            }
            else
            {
                JobOperations jobOperations = parameters.Context.BatchOMClient.JobOperations;
                jobOperations.AddTask(parameters.JobId, task, parameters.AdditionalBehaviors);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new task
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the task</param>
        public void CreateTask(NewTaskParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            CloudTask task = new CloudTask(parameters.TaskName, parameters.CommandLine);

            task.RunElevated = parameters.RunElevated;

            if (parameters.EnvironmentSettings != null)
            {
                task.EnvironmentSettings = new List <IEnvironmentSetting>();
                foreach (DictionaryEntry d in parameters.EnvironmentSettings)
                {
                    EnvironmentSetting setting = new EnvironmentSetting(d.Key.ToString(), d.Value.ToString());
                    task.EnvironmentSettings.Add(setting);
                }
            }

            if (parameters.ResourceFiles != null)
            {
                task.ResourceFiles = new List <IResourceFile>();
                foreach (DictionaryEntry d in parameters.ResourceFiles)
                {
                    ResourceFile file = new ResourceFile(d.Value.ToString(), d.Key.ToString());
                    task.ResourceFiles.Add(file);
                }
            }

            if (parameters.AffinityInformation != null)
            {
                task.AffinityInformation = parameters.AffinityInformation.omObject;
            }

            if (parameters.TaskConstraints != null)
            {
                task.TaskConstraints = parameters.TaskConstraints.omObject;
            }

            WriteVerbose(string.Format(Resources.NBT_CreatingTask, parameters.TaskName));
            if (parameters.Job != null)
            {
                parameters.Job.omObject.AddTask(task, parameters.AdditionalBehaviors);
            }
            else
            {
                using (IWorkItemManager wiManager = parameters.Context.BatchOMClient.OpenWorkItemManager())
                {
                    wiManager.AddTask(parameters.WorkItemName, parameters.JobName, task, parameters.AdditionalBehaviors);
                }
            }
        }
        public override void ExecuteCmdlet()
        {
            NewTaskParameters parameters = new NewTaskParameters(this.BatchContext, this.WorkItemName, this.JobName, this.Job, 
                this.Name, this.AdditionalBehaviors)
            {
                CommandLine = this.CommandLine,
                ResourceFiles = this.ResourceFiles,
                EnvironmentSettings = this.EnvironmentSettings,
                RunElevated = this.RunElevated.IsPresent,
                AffinityInformation = this.AffinityInformation,
                TaskConstraints = this.TaskConstraints
            };

            BatchClient.CreateTask(parameters);
        }
        protected override void ProcessRecord()
        {
            NewTaskParameters parameters = new NewTaskParameters(this.BatchContext, this.JobId, this.Job, 
                this.Id, this.AdditionalBehaviors)
            {
                DisplayName = this.DisplayName,
                CommandLine = this.CommandLine,
                ResourceFiles = this.ResourceFiles,
                EnvironmentSettings = this.EnvironmentSettings,
                RunElevated = this.RunElevated.IsPresent,
                AffinityInformation = this.AffinityInformation,
                Constraints = this.Constraints
            };

            BatchClient.CreateTask(parameters);
        }
Ejemplo n.º 6
0
        public override void ExecuteCmdlet()
        {
            NewTaskParameters parameters = new NewTaskParameters(this.BatchContext, this.JobId, this.Job, 
                this.Id, this.AdditionalBehaviors)
            {
                DisplayName = this.DisplayName,
                CommandLine = this.CommandLine,
                ResourceFiles = this.ResourceFiles,
                EnvironmentSettings = this.EnvironmentSettings,
                RunElevated = this.RunElevated.IsPresent,
                AffinityInformation = this.AffinityInformation,
                Constraints = this.Constraints,
                MultiInstanceSettings = this.MultiInstanceSettings
            };

            BatchClient.CreateTask(parameters);
        }
        /// <summary>
        /// Creates a test task for use in Scenario tests.
        /// </summary>
        public static void CreateTestTask(BatchController controller, BatchAccountContext context, string jobId, string taskId, string cmdLine = "cmd /c dir /s")
        {
            RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            NewTaskParameters parameters = new NewTaskParameters(context, jobId, null, taskId, behaviors)
            {
                CommandLine = cmdLine,
                RunElevated = true
            };
            
            client.CreateTask(parameters);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a new task.
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the task.</param>
        public void CreateTask(NewTaskParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            CloudTask task = new CloudTask(parameters.TaskId, parameters.CommandLine);

            task.DisplayName = parameters.DisplayName;

            if (parameters.AuthenticationTokenSettings != null)
            {
                task.AuthenticationTokenSettings = parameters.AuthenticationTokenSettings.omObject;
            }

            if (parameters.UserIdentity != null)
            {
                task.UserIdentity = parameters.UserIdentity.omObject;
            }

            if (parameters.EnvironmentSettings != null)
            {
                task.EnvironmentSettings = new List <EnvironmentSetting>();
                foreach (DictionaryEntry d in parameters.EnvironmentSettings)
                {
                    EnvironmentSetting setting = new EnvironmentSetting(d.Key.ToString(), d.Value.ToString());
                    task.EnvironmentSettings.Add(setting);
                }
            }

            if (parameters.ResourceFiles != null)
            {
                task.ResourceFiles = parameters.ResourceFiles.Select(file => file.omObject).ToList();
            }

            if (parameters.AffinityInformation != null)
            {
                task.AffinityInformation = parameters.AffinityInformation.omObject;
            }

            if (parameters.Constraints != null)
            {
                task.Constraints = parameters.Constraints.omObject;
            }

            if (parameters.DependsOn != null)
            {
                task.DependsOn = parameters.DependsOn;
            }

            if (parameters.MultiInstanceSettings != null)
            {
                Utils.Utils.MultiInstanceSettingsSyncCollections(parameters.MultiInstanceSettings);
                task.MultiInstanceSettings = parameters.MultiInstanceSettings.omObject;
            }

            if (parameters.ApplicationPackageReferences != null)
            {
                task.ApplicationPackageReferences = parameters.ApplicationPackageReferences.ToList().ConvertAll(apr => apr.omObject);
            }

            if (parameters.ExitConditions != null)
            {
                Utils.Utils.ExitConditionsSyncCollections(parameters.ExitConditions);
                task.ExitConditions = parameters.ExitConditions.omObject;
            }

            if (parameters.OutputFiles != null)
            {
                task.OutputFiles = parameters.OutputFiles.ToList().ConvertAll(outputFile => outputFile.omObject);
            }

            task.ContainerSettings = parameters.ContainerSettings?.omObject;

            WriteVerbose(string.Format(Resources.CreatingTask, parameters.TaskId));
            if (parameters.Job != null)
            {
                parameters.Job.omObject.AddTask(task, parameters.AdditionalBehaviors);
            }
            else
            {
                JobOperations jobOperations = parameters.Context.BatchOMClient.JobOperations;
                jobOperations.AddTask(parameters.JobId, task, parameters.AdditionalBehaviors);
            }
        }
        /// <summary>
        /// Creates a test task for use in Scenario tests.
        /// </summary>
        public static void CreateTestTask(BatchController controller, BatchAccountContext context, string jobId, string taskId, string cmdLine = "cmd /c dir /s")
        {
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            NewTaskParameters parameters = new NewTaskParameters(context, jobId, null, taskId)
            {
                CommandLine = cmdLine,
                RunElevated = true
            };
            
            client.CreateTask(parameters);
        }
Ejemplo n.º 10
0
        public override void ExecuteCmdlet()
        {
            if (Tasks != null)
            {
                NewBulkTaskParameters parameters = new NewBulkTaskParameters(this.BatchContext, this.JobId, this.Job, this.Tasks, this.AdditionalBehaviors);
                BatchClient.AddTaskCollection(parameters);
            }
            else
            {
                NewTaskParameters parameters = new NewTaskParameters(this.BatchContext, this.JobId, this.Job,
                    this.Id, this.AdditionalBehaviors)
                {
                    DisplayName = this.DisplayName,
                    CommandLine = this.CommandLine,
                    ResourceFiles = this.ResourceFiles,
                    EnvironmentSettings = this.EnvironmentSettings,
                    RunElevated = this.RunElevated.IsPresent,
                    AffinityInformation = this.AffinityInformation,
                    Constraints = this.Constraints,
                    MultiInstanceSettings = this.MultiInstanceSettings,
                    DependsOn = this.DependsOn,
                    ApplicationPackageReferences = this.ApplicationPackageReferences,
                    ExitConditions = this.ExitConditions,
                };

                BatchClient.CreateTask(parameters);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates a new task
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the task</param>
        public void CreateTask(NewTaskParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            CloudTask task = new CloudTask(parameters.TaskName, parameters.CommandLine);
            task.RunElevated = parameters.RunElevated;

            if (parameters.EnvironmentSettings != null)
            {
                task.EnvironmentSettings = new List<IEnvironmentSetting>();
                foreach (DictionaryEntry d in parameters.EnvironmentSettings)
                {
                    EnvironmentSetting setting = new EnvironmentSetting(d.Key.ToString(), d.Value.ToString());
                    task.EnvironmentSettings.Add(setting);
                }
            }

            if (parameters.ResourceFiles != null)
            {
                task.ResourceFiles = new List<IResourceFile>();
                foreach (DictionaryEntry d in parameters.ResourceFiles)
                {
                    ResourceFile file = new ResourceFile(d.Value.ToString(), d.Key.ToString());
                    task.ResourceFiles.Add(file);
                }
            }

            if (parameters.AffinityInformation != null)
            {
                task.AffinityInformation = parameters.AffinityInformation.omObject;
            }

            if (parameters.TaskConstraints != null)
            {
                task.TaskConstraints = parameters.TaskConstraints.omObject;
            }

            WriteVerbose(string.Format(Resources.NBT_CreatingTask, parameters.TaskName));
            if (parameters.Job != null)
            {
                parameters.Job.omObject.AddTask(task, parameters.AdditionalBehaviors);
            }
            else
            {
                using (IWorkItemManager wiManager = parameters.Context.BatchOMClient.OpenWorkItemManager())
                {
                    wiManager.AddTask(parameters.WorkItemName, parameters.JobName, task, parameters.AdditionalBehaviors);
                }
            }
        }
        /// <summary>
        /// Creates a test task for use in Scenario tests.
        /// </summary>
        public static void CreateTestTask(BatchController controller, BatchAccountContext context, string jobId, string taskId, string cmdLine = "cmd /c dir /s", int numInstances = 0)
        {
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            PSMultiInstanceSettings multiInstanceSettings = null;
            if (numInstances > 1)
            {
                multiInstanceSettings = new PSMultiInstanceSettings(numInstances);
                multiInstanceSettings.CoordinationCommandLine = "cmd /c echo coordinating";
            }

            NewTaskParameters parameters = new NewTaskParameters(context, jobId, null, taskId)
            {
                CommandLine = cmdLine,
                MultiInstanceSettings = multiInstanceSettings,
                RunElevated = numInstances <= 1
            };
            
            client.CreateTask(parameters);
        }