public override void ExecuteCmdlet()
        {
            if (ShouldProcess(Name, @"Creating operationalization cluster..."))
            {
                var cluster = new OperationalizationCluster();

                if (string.Equals(this.ParameterSetName, CreateFromObjectParameterSet, StringComparison.OrdinalIgnoreCase))
                {
                    cluster = InputObject.ConvertToOperationalizationCluster();
                }
                else if (string.Equals(this.ParameterSetName, CreateFromCmdletParametersParameterSet, StringComparison.OrdinalIgnoreCase))
                {
                    cluster.Location    = Location;
                    cluster.ClusterType = ClusterType;
                    cluster.Description = Description;

                    if (StorageAccount != null)
                    {
                        cluster.StorageAccount = new StorageAccountProperties(StorageAccount);
                    }

                    if (AzureContainerRegistry != null)
                    {
                        cluster.ContainerRegistry = new ContainerRegistryProperties(AzureContainerRegistry);
                    }

                    if (GlobalServiceConfigurationETag != null)
                    {
                        cluster.GlobalServiceConfiguration      = cluster.GlobalServiceConfiguration ?? new GlobalServiceConfiguration();
                        cluster.GlobalServiceConfiguration.Etag = GlobalServiceConfigurationETag;
                    }

                    if (GlobalServiceConfigurationAdditionalProperties != null)
                    {
                        cluster.GlobalServiceConfiguration = cluster.GlobalServiceConfiguration ?? new GlobalServiceConfiguration();
                        cluster.GlobalServiceConfiguration.AdditionalProperties = GlobalServiceConfigurationAdditionalProperties.Cast <DictionaryEntry>().ToDictionary(kvp => (string)kvp.Key, kvp => kvp.Value);
                    }

                    if (SslStatus != null)
                    {
                        cluster.GlobalServiceConfiguration.Ssl        = cluster.GlobalServiceConfiguration.Ssl ?? new SslConfiguration();
                        cluster.GlobalServiceConfiguration.Ssl.Status = SslStatus;
                    }

                    if (SslCertificate != null)
                    {
                        cluster.GlobalServiceConfiguration.Ssl      = cluster.GlobalServiceConfiguration.Ssl ?? new SslConfiguration();
                        cluster.GlobalServiceConfiguration.Ssl.Cert = SslCertificate;
                    }

                    if (SslKey != null)
                    {
                        cluster.GlobalServiceConfiguration.Ssl     = cluster.GlobalServiceConfiguration.Ssl ?? new SslConfiguration();
                        cluster.GlobalServiceConfiguration.Ssl.Key = SslKey;
                    }

                    if (SslCName != null)
                    {
                        cluster.GlobalServiceConfiguration.Ssl       = cluster.GlobalServiceConfiguration.Ssl ?? new SslConfiguration();
                        cluster.GlobalServiceConfiguration.Ssl.Cname = SslCName;
                    }

                    switch (ClusterType)
                    {
                    case Management.MachineLearningCompute.Models.ClusterType.ACS:
                        cluster.ContainerService = new AcsClusterProperties
                        {
                            OrchestratorType       = OrchestratorType,
                            OrchestratorProperties = new KubernetesClusterProperties
                            {
                                ServicePrincipal = new ServicePrincipalProperties
                                {
                                    ClientId = ClientId,
                                    Secret   = Secret
                                }
                            },
                            MasterCount = MasterCount,
                            AgentCount  = AgentCount,
                            AgentVmSize = AgentVmSize
                        };

                        break;

                    case Management.MachineLearningCompute.Models.ClusterType.Local:
                        break;

                    default:
                        break;
                    }
                }

                try
                {
                    WriteObject(new PSOperationalizationCluster(MachineLearningComputeManagementClient.OperationalizationClusters.CreateOrUpdate(ResourceGroupName, Name, cluster)));
                }
                catch (Exception e)
                {
                    HandleNestedExceptionMessages(e);
                }
            }
        }
Exemple #2
0
        public override void ExecuteCmdlet()
        {
            if (string.Equals(this.ParameterSetName, ObjectParameterSet, StringComparison.OrdinalIgnoreCase))
            {
                var resourceInfo = new ResourceIdentifier(InputObject.Id);
                ResourceGroupName = resourceInfo.ResourceGroupName;
                Name = resourceInfo.ResourceName;
            }
            else if (string.Equals(this.ParameterSetName, ResourceIdParameterSet, StringComparison.OrdinalIgnoreCase))
            {
                var resourceInfo = new ResourceIdentifier(ResourceId);
                ResourceGroupName = resourceInfo.ResourceGroupName;
                Name = resourceInfo.ResourceName;
            }

            if (ShouldProcess(Name, @"Updating operationalization cluster..."))
            {
                OperationalizationCluster clusterToUpdate;

                if (string.Equals(this.ParameterSetName, ObjectParameterSet, StringComparison.OrdinalIgnoreCase))
                {
                    clusterToUpdate = InputObject.ConvertToOperationalizationCluster();
                }
                else
                {
                    clusterToUpdate = MachineLearningComputeManagementClient.OperationalizationClusters.Get(ResourceGroupName, Name);
                }

                switch (clusterToUpdate.ClusterType)
                {
                case ClusterType.ACS:
                    if (AgentCount != null)
                    {
                        clusterToUpdate.ContainerService.AgentCount = AgentCount;
                    }
                    break;

                case ClusterType.Local:
                    break;

                default:
                    break;
                }

                if (SslStatus != null || SslCertificate != null || SslKey != null || SslCName != null)
                {
                    if (clusterToUpdate.GlobalServiceConfiguration == null)
                    {
                        clusterToUpdate.GlobalServiceConfiguration = new GlobalServiceConfiguration();
                    }

                    if (clusterToUpdate.GlobalServiceConfiguration.Ssl == null)
                    {
                        clusterToUpdate.GlobalServiceConfiguration.Ssl = new SslConfiguration();
                    }

                    if (SslStatus != null)
                    {
                        clusterToUpdate.GlobalServiceConfiguration.Ssl.Status = SslStatus;
                    }

                    if (SslCertificate != null)
                    {
                        clusterToUpdate.GlobalServiceConfiguration.Ssl.Cert = SslCertificate;
                    }

                    if (SslKey != null)
                    {
                        clusterToUpdate.GlobalServiceConfiguration.Ssl.Key = SslKey;
                    }

                    if (SslCName != null)
                    {
                        clusterToUpdate.GlobalServiceConfiguration.Ssl.Cname = SslCName;
                    }
                }

                try
                {
                    WriteObject(new PSOperationalizationCluster(MachineLearningComputeManagementClient.OperationalizationClusters.CreateOrUpdate(ResourceGroupName, Name, clusterToUpdate)));
                }
                catch (Exception e)
                {
                    HandleNestedExceptionMessages(e);
                }
            }
        }