Inheritance: BatchClientParametersBase
        /// <summary>
        /// Creates a new pool.
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the pool.</param>
        public void CreatePool(NewPoolParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            PoolOperations poolOperations = parameters.Context.BatchOMClient.PoolOperations;
            CloudPool      pool           = poolOperations.CreatePool(poolId: parameters.PoolId, osFamily: parameters.OSFamily, virtualMachineSize: parameters.VirtualMachineSize);

            pool.DisplayName            = parameters.DisplayName;
            pool.ResizeTimeout          = parameters.ResizeTimeout;
            pool.MaxTasksPerComputeNode = parameters.MaxTasksPerComputeNode;
            pool.InterComputeNodeCommunicationEnabled = parameters.InterComputeNodeCommunicationEnabled;
            pool.TargetOSVersion = parameters.TargetOSVersion;

            if (!string.IsNullOrEmpty(parameters.AutoScaleFormula))
            {
                pool.AutoScaleEnabled            = true;
                pool.AutoScaleEvaluationInterval = parameters.AutoScaleEvaluationInterval;
                pool.AutoScaleFormula            = parameters.AutoScaleFormula;
            }
            else if (parameters.TargetDedicated.HasValue)
            {
                pool.TargetDedicated = parameters.TargetDedicated;
            }

            if (parameters.TaskSchedulingPolicy != null)
            {
                pool.TaskSchedulingPolicy = parameters.TaskSchedulingPolicy.omObject;
            }

            if (parameters.StartTask != null)
            {
                Utils.Utils.StartTaskSyncCollections(parameters.StartTask);
                pool.StartTask = parameters.StartTask.omObject;
            }

            if (parameters.Metadata != null)
            {
                pool.Metadata = new List <MetadataItem>();
                foreach (DictionaryEntry m in parameters.Metadata)
                {
                    pool.Metadata.Add(new MetadataItem(m.Key.ToString(), m.Value.ToString()));
                }
            }

            if (parameters.CertificateReferences != null)
            {
                pool.CertificateReferences = new List <CertificateReference>();
                foreach (PSCertificateReference c in parameters.CertificateReferences)
                {
                    pool.CertificateReferences.Add(c.omObject);
                }
            }

            WriteVerbose(string.Format(Resources.CreatingPool, parameters.PoolId));
            pool.Commit(parameters.AdditionalBehaviors);
        }
        /// <summary>
        /// Creates a new pool.
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the pool.</param>
        public void CreatePool(NewPoolParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            PoolOperations poolOperations = parameters.Context.BatchOMClient.PoolOperations;
            CloudPool pool = poolOperations.CreatePool(poolId: parameters.PoolId, osFamily: parameters.OSFamily, virtualMachineSize: parameters.VirtualMachineSize);
            pool.DisplayName = parameters.DisplayName;
            pool.ResizeTimeout = parameters.ResizeTimeout;
            pool.MaxTasksPerComputeNode = parameters.MaxTasksPerComputeNode;
            pool.InterComputeNodeCommunicationEnabled = parameters.InterComputeNodeCommunicationEnabled;
            pool.TargetOSVersion = parameters.TargetOSVersion;

            if (!string.IsNullOrEmpty(parameters.AutoScaleFormula))
            {
                pool.AutoScaleEnabled = true;
                pool.AutoScaleEvaluationInterval = parameters.AutoScaleEvaluationInterval;
                pool.AutoScaleFormula = parameters.AutoScaleFormula;
            }
            else if (parameters.TargetDedicated.HasValue)
            {
                pool.TargetDedicated = parameters.TargetDedicated;
            }

            if (parameters.TaskSchedulingPolicy != null)
            {
                pool.TaskSchedulingPolicy = parameters.TaskSchedulingPolicy.omObject;
            }

            if (parameters.StartTask != null)
            {
                Utils.Utils.StartTaskSyncCollections(parameters.StartTask);
                pool.StartTask = parameters.StartTask.omObject;
            }

            if (parameters.Metadata != null)
            {
                pool.Metadata = new List<MetadataItem>();
                foreach (DictionaryEntry m in parameters.Metadata)
                {
                    pool.Metadata.Add(new MetadataItem(m.Key.ToString(), m.Value.ToString()));
                }
            }

            if (parameters.CertificateReferences != null)
            {
                pool.CertificateReferences = new List<CertificateReference>();
                foreach (PSCertificateReference c in parameters.CertificateReferences)
                {
                    pool.CertificateReferences.Add(c.omObject);
                }
            }

            WriteVerbose(string.Format(Resources.CreatingPool, parameters.PoolId));
            pool.Commit(parameters.AdditionalBehaviors);
        }
        /// <summary>
        /// Creates a test pool for use in Scenario tests.
        /// </summary>
        public static void CreateTestPool(BatchController controller, BatchAccountContext context, string poolId, int targetDedicated)
        {
            RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            NewPoolParameters parameters = new NewPoolParameters(context, poolId, behaviors)
            {
                VirtualMachineSize = "small",
                OSFamily = "4",
                TargetOSVersion = "*",
                TargetDedicated = targetDedicated,
            };

            client.CreatePool(parameters);
        }
        protected override void ProcessRecord()
        {
            NewPoolParameters parameters = new NewPoolParameters(this.BatchContext, this.Id, this.AdditionalBehaviors)
            {
                VirtualMachineSize = this.VirtualMachineSize,
                OSFamily = this.OSFamily,
                DisplayName = this.DisplayName,
                TargetOSVersion = this.TargetOSVersion,
                ResizeTimeout = this.ResizeTimeout,
                TargetDedicated = this.TargetDedicated,
                AutoScaleFormula = this.AutoScaleFormula,
                MaxTasksPerComputeNode = this.MaxTasksPerComputeNode,
                TaskSchedulingPolicy = this.TaskSchedulingPolicy,
                Metadata = this.Metadata,
                InterComputeNodeCommunicationEnabled = this.InterComputeNodeCommunicationEnabled.IsPresent,
                StartTask = this.StartTask,
                CertificateReferences = this.CertificateReferences
            };

            BatchClient.CreatePool(parameters);
        }
        /// <summary>
        /// Creates a test pool for use in Scenario tests.
        /// </summary>
        public static void CreateTestPool(BatchController controller, BatchAccountContext context, string poolName)
        {
            YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            NewPoolParameters parameters = new NewPoolParameters(context, poolName, behaviors)
            {
                OSFamily = "4",
                TargetOSVersion = "*",
                TargetDedicated = 1
            };

            client.CreatePool(parameters);
        }
        /// <summary>
        /// Creates a test pool for use in Scenario tests.
        /// </summary>
        public static void CreateTestPool(BatchController controller, BatchAccountContext context, string poolId, int targetDedicated, CertificateReference certReference = null)
        {
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            PSCertificateReference[] certReferences = null;
            if (certReference != null)
            {
                certReferences = new PSCertificateReference[] { new PSCertificateReference(certReference) };
            }

            NewPoolParameters parameters = new NewPoolParameters(context, poolId)
            {
                VirtualMachineSize = "small",
                OSFamily = "4",
                TargetOSVersion = "*",
                TargetDedicated = targetDedicated,
                CertificateReferences = certReferences,
            };

            client.CreatePool(parameters);
        }
示例#7
0
        /// <summary>
        /// Creates a new Pool
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the Pool</param>
        public void CreatePool(NewPoolParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            if (string.IsNullOrWhiteSpace(parameters.PoolName))
            {
                throw new ArgumentNullException("PoolName");
            }

            using (IPoolManager poolManager = parameters.Context.BatchOMClient.OpenPoolManager())
            {
                ICloudPool pool = poolManager.CreatePool(poolName: parameters.PoolName, osFamily: parameters.OSFamily);
                pool.ResizeTimeout = parameters.ResizeTimeout;
                pool.MaxTasksPerVM = parameters.MaxTasksPerVM;
                pool.Communication = parameters.Communication;

                if (!string.IsNullOrEmpty(parameters.VMSize))
                {
                    // Don't override OM default if unspecified
                    pool.VMSize = parameters.VMSize;
                }

                if (!string.IsNullOrEmpty(parameters.AutoScaleFormula))
                {
                    pool.AutoScaleEnabled = true;
                    pool.AutoScaleFormula = parameters.AutoScaleFormula;
                    // Clear OM default to avoid server errors
                    pool.TargetDedicated = null;
                }
                else if (parameters.TargetDedicated.HasValue)
                {
                    // Don't override OM default if unspecified
                    pool.TargetDedicated = parameters.TargetDedicated;
                }

                if (parameters.SchedulingPolicy != null)
                {
                    pool.SchedulingPolicy = parameters.SchedulingPolicy.omObject;
                }

                if (parameters.StartTask != null)
                {
                    Utils.Utils.StartTaskSyncCollections(parameters.StartTask);
                    pool.StartTask = parameters.StartTask.omObject;
                }

                if (parameters.Metadata != null)
                {
                    pool.Metadata = new List <IMetadataItem>();
                    foreach (DictionaryEntry m in parameters.Metadata)
                    {
                        pool.Metadata.Add(new MetadataItem(m.Key.ToString(), m.Value.ToString()));
                    }
                }

                if (parameters.CertificateReferences != null)
                {
                    pool.CertificateReferences = new List <ICertificateReference>();
                    foreach (PSCertificateReference c in parameters.CertificateReferences)
                    {
                        pool.CertificateReferences.Add(c.omObject);
                    }
                }

                WriteVerbose(string.Format(Resources.NBP_CreatingPool, parameters.PoolName));
                pool.Commit(parameters.AdditionalBehaviors);
            }
        }
示例#8
0
        /// <summary>
        /// Creates a new pool.
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the pool.</param>
        public void CreatePool(NewPoolParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            PoolOperations poolOperations = parameters.Context.BatchOMClient.PoolOperations;

            CloudPool pool = poolOperations.CreatePool();

            pool.Id = parameters.PoolId;
            pool.VirtualMachineSize     = parameters.VirtualMachineSize;
            pool.DisplayName            = parameters.DisplayName;
            pool.ResizeTimeout          = parameters.ResizeTimeout;
            pool.MaxTasksPerComputeNode = parameters.MaxTasksPerComputeNode;
            pool.InterComputeNodeCommunicationEnabled = parameters.InterComputeNodeCommunicationEnabled;

            if (!string.IsNullOrEmpty(parameters.AutoScaleFormula))
            {
                pool.AutoScaleEnabled            = true;
                pool.AutoScaleEvaluationInterval = parameters.AutoScaleEvaluationInterval;
                pool.AutoScaleFormula            = parameters.AutoScaleFormula;
            }
            else if (parameters.TargetDedicatedComputeNodes.HasValue || parameters.TargetLowPriorityComputeNodes.HasValue)
            {
                pool.TargetDedicatedComputeNodes   = parameters.TargetDedicatedComputeNodes;
                pool.TargetLowPriorityComputeNodes = parameters.TargetLowPriorityComputeNodes;
            }

            if (parameters.TaskSchedulingPolicy != null)
            {
                pool.TaskSchedulingPolicy = parameters.TaskSchedulingPolicy.omObject;
            }

            if (parameters.StartTask != null)
            {
                Utils.Utils.StartTaskSyncCollections(parameters.StartTask);
                pool.StartTask = parameters.StartTask.omObject;
            }

            if (parameters.Metadata != null)
            {
                pool.Metadata = new List <MetadataItem>();
                foreach (DictionaryEntry m in parameters.Metadata)
                {
                    pool.Metadata.Add(new MetadataItem(m.Key.ToString(), m.Value.ToString()));
                }
            }

            if (parameters.CertificateReferences != null)
            {
                pool.CertificateReferences = new List <CertificateReference>();
                foreach (PSCertificateReference c in parameters.CertificateReferences)
                {
                    pool.CertificateReferences.Add(c.omObject);
                }
            }

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

            if (parameters.CloudServiceConfiguration != null)
            {
                pool.CloudServiceConfiguration = parameters.CloudServiceConfiguration.omObject;
            }

            if (parameters.VirtualMachineConfiguration != null)
            {
                Utils.Utils.VirtualMachineConfigurationSyncCollections(parameters.VirtualMachineConfiguration);
                pool.VirtualMachineConfiguration = parameters.VirtualMachineConfiguration.omObject;
            }

            if (parameters.NetworkConfiguration != null)
            {
                pool.NetworkConfiguration = parameters.NetworkConfiguration.omObject;
            }

            if (parameters.MountConfiguration != null)
            {
                pool.MountConfiguration = new List <MountConfiguration>();
                foreach (PSMountConfiguration m in parameters.MountConfiguration)
                {
                    pool.MountConfiguration.Add(m.omObject);
                }
            }

            if (parameters.UserAccounts != null)
            {
                pool.UserAccounts = parameters.UserAccounts.ToList().ConvertAll(user => user.omObject);
            }

            if (parameters.ApplicationLicenses != null)
            {
                pool.ApplicationLicenses = parameters.ApplicationLicenses;
            }

            WriteVerbose(string.Format(Resources.CreatingPool, parameters.PoolId));
            pool.Commit(parameters.AdditionalBehaviors);
        }
        public override void ExecuteCmdlet()
        {
            NewPoolParameters parameters = new NewPoolParameters(this.BatchContext, this.Id, this.AdditionalBehaviors)
            {
                VirtualMachineSize = this.VirtualMachineSize,
                DisplayName = this.DisplayName,
                ResizeTimeout = this.ResizeTimeout,
                TargetDedicated = this.TargetDedicated,
                AutoScaleEvaluationInterval = this.AutoScaleEvaluationInterval,
                AutoScaleFormula = this.AutoScaleFormula,
                MaxTasksPerComputeNode = this.MaxTasksPerComputeNode,
                TaskSchedulingPolicy = this.TaskSchedulingPolicy,
                Metadata = this.Metadata,
                InterComputeNodeCommunicationEnabled = this.InterComputeNodeCommunicationEnabled.IsPresent,
                StartTask = this.StartTask,
                CertificateReferences = this.CertificateReferences,
                ApplicationPackageReferences = this.ApplicationPackageReferences,
                VirtualMachineConfiguration =  this.VirtualMachineConfiguration,
                CloudServiceConfiguration = this.CloudServiceConfiguration,
                NetworkConfiguration = this.NetworkConfiguration
            };

            if (ShouldProcess("AzureBatchPool"))
            {
                BatchClient.CreatePool(parameters);
            }
        }
        /// <summary>
        /// Creates a new pool
        /// </summary>
        /// <param name="parameters">The parameters to use when creating the pool</param>
        public void CreatePool(NewPoolParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            using (IPoolManager poolManager = parameters.Context.BatchOMClient.OpenPoolManager())
            {
                ICloudPool pool = poolManager.CreatePool(poolName: parameters.PoolName, osFamily: parameters.OSFamily);
                pool.ResizeTimeout = parameters.ResizeTimeout;
                pool.MaxTasksPerVM = parameters.MaxTasksPerVM;
                pool.Communication = parameters.Communication;

                if (!string.IsNullOrEmpty(parameters.VMSize))
                {
                    // Don't override OM default if unspecified
                    pool.VMSize = parameters.VMSize;
                }

                if (!string.IsNullOrEmpty(parameters.AutoScaleFormula))
                {
                    pool.AutoScaleEnabled = true;
                    pool.AutoScaleFormula = parameters.AutoScaleFormula;
                    // Clear OM default to avoid server errors
                    pool.TargetDedicated = null;
                }
                else if (parameters.TargetDedicated.HasValue)
                {
                    // Don't override OM default if unspecified
                    pool.TargetDedicated = parameters.TargetDedicated;
                }

                if (parameters.SchedulingPolicy != null)
                {
                    pool.SchedulingPolicy = parameters.SchedulingPolicy.omObject;
                }

                if (parameters.StartTask != null)
                {
                    Utils.Utils.StartTaskSyncCollections(parameters.StartTask);
                    pool.StartTask = parameters.StartTask.omObject;
                }

                if (parameters.Metadata != null)
                {
                    pool.Metadata = new List<IMetadataItem>();
                    foreach (DictionaryEntry m in parameters.Metadata)
                    {
                        pool.Metadata.Add(new MetadataItem(m.Key.ToString(), m.Value.ToString()));
                    }
                }

                if (parameters.CertificateReferences != null)
                {
                    pool.CertificateReferences = new List<ICertificateReference>();
                    foreach (PSCertificateReference c in parameters.CertificateReferences)
                    {
                        pool.CertificateReferences.Add(c.omObject);
                    }
                }

                WriteVerbose(string.Format(Resources.NBP_CreatingPool, parameters.PoolName));
                pool.Commit(parameters.AdditionalBehaviors);
            }
        }
        public override void ExecuteCmdlet()
        {
            NewPoolParameters parameters = new NewPoolParameters(this.BatchContext, this.Name, this.AdditionalBehaviors)
            {
                VMSize = this.VMSize,
                OSFamily = this.OSFamily,
                TargetOSVersion = this.TargetOSVersion,
                ResizeTimeout = this.ResizeTimeout,
                TargetDedicated = this.TargetDedicated,
                AutoScaleFormula = this.AutoScaleFormula,
                MaxTasksPerVM = this.MaxTasksPerVM,
                SchedulingPolicy = this.SchedulingPolicy,
                Metadata = this.Metadata,
                Communication = this.CommunicationEnabled.IsPresent,
                StartTask = this.StartTask,
                CertificateReferences = this.CertificateReferences
            };

            BatchClient.CreatePool(parameters);
        }
        /// <summary>
        /// Creates a test pool for use in Scenario tests.
        /// </summary>
        public static void CreateTestPool(BatchController controller, BatchAccountContext context, string poolId, int targetDedicated,
            CertificateReference certReference = null, StartTask startTask = null)
        {
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            PSCertificateReference[] certReferences = null;
            if (certReference != null)
            {
                certReferences = new PSCertificateReference[] { new PSCertificateReference(certReference) };
            }
            PSStartTask psStartTask = null;
            if (startTask != null)
            {
                psStartTask = new PSStartTask(startTask);
            }

            PSCloudServiceConfiguration paasConfiguration = new PSCloudServiceConfiguration("4", "*");

            NewPoolParameters parameters = new NewPoolParameters(context, poolId)
            {
                VirtualMachineSize = "small",
                CloudServiceConfiguration = paasConfiguration,
                TargetDedicated = targetDedicated,
                CertificateReferences = certReferences,
                StartTask = psStartTask,
                InterComputeNodeCommunicationEnabled = true
            };

            client.CreatePool(parameters);
        }