Exemple #1
0
 /// <summary>
 /// Initializes a new instance of the ContainerService class.
 /// </summary>
 /// <param name="location">Resource location</param>
 /// <param name="masterProfile">Properties of master agents.</param>
 /// <param name="agentPoolProfiles">Properties of the agent
 /// pool.</param>
 /// <param name="linuxProfile">Properties of Linux VMs.</param>
 /// <param name="id">Resource Id</param>
 /// <param name="name">Resource name</param>
 /// <param name="type">Resource type</param>
 /// <param name="tags">Resource tags</param>
 /// <param name="provisioningState">the current deployment or
 /// provisioning state, which only appears in the response.</param>
 /// <param name="orchestratorProfile">Properties of the
 /// orchestrator.</param>
 /// <param name="customProfile">Properties for custom clusters.</param>
 /// <param name="servicePrincipalProfile">Properties for cluster
 /// service principals.</param>
 /// <param name="windowsProfile">Properties of Windows VMs.</param>
 /// <param name="diagnosticsProfile">Properties of the diagnostic
 /// agent.</param>
 public ContainerService(string location, ContainerServiceMasterProfile masterProfile, IList <ContainerServiceAgentPoolProfile> agentPoolProfiles, ContainerServiceLinuxProfile linuxProfile, string id = default(string), string name = default(string), string type = default(string), IDictionary <string, string> tags = default(IDictionary <string, string>), string provisioningState = default(string), ContainerServiceOrchestratorProfile orchestratorProfile = default(ContainerServiceOrchestratorProfile), ContainerServiceCustomProfile customProfile = default(ContainerServiceCustomProfile), ContainerServiceServicePrincipalProfile servicePrincipalProfile = default(ContainerServiceServicePrincipalProfile), ContainerServiceWindowsProfile windowsProfile = default(ContainerServiceWindowsProfile), ContainerServiceDiagnosticsProfile diagnosticsProfile = default(ContainerServiceDiagnosticsProfile))
     : base(location, id, name, type, tags)
 {
     ProvisioningState       = provisioningState;
     OrchestratorProfile     = orchestratorProfile;
     CustomProfile           = customProfile;
     ServicePrincipalProfile = servicePrincipalProfile;
     MasterProfile           = masterProfile;
     AgentPoolProfiles       = agentPoolProfiles;
     WindowsProfile          = windowsProfile;
     LinuxProfile            = linuxProfile;
     DiagnosticsProfile      = diagnosticsProfile;
     CustomInit();
 }
Exemple #2
0
        private void Run()
        {
            // OrchestratorProfile
            Microsoft.Azure.Management.Compute.Models.ContainerServiceOrchestratorProfile vOrchestratorProfile = null;

            // CustomProfile
            Microsoft.Azure.Management.Compute.Models.ContainerServiceCustomProfile vCustomProfile = null;

            // ServicePrincipalProfile
            Microsoft.Azure.Management.Compute.Models.ContainerServiceServicePrincipalProfile vServicePrincipalProfile = null;

            // MasterProfile
            Microsoft.Azure.Management.Compute.Models.ContainerServiceMasterProfile vMasterProfile = null;

            // WindowsProfile
            Microsoft.Azure.Management.Compute.Models.ContainerServiceWindowsProfile vWindowsProfile = null;

            // LinuxProfile
            Microsoft.Azure.Management.Compute.Models.ContainerServiceLinuxProfile vLinuxProfile = null;

            // DiagnosticsProfile
            Microsoft.Azure.Management.Compute.Models.ContainerServiceDiagnosticsProfile vDiagnosticsProfile = null;

            if (this.OrchestratorType.HasValue)
            {
                if (vOrchestratorProfile == null)
                {
                    vOrchestratorProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceOrchestratorProfile();
                }
                vOrchestratorProfile.OrchestratorType = this.OrchestratorType.Value;
            }

            if (this.CustomProfileOrchestrator != null)
            {
                if (vCustomProfile == null)
                {
                    vCustomProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceCustomProfile();
                }
                vCustomProfile.Orchestrator = this.CustomProfileOrchestrator;
            }

            if (this.ServicePrincipalProfileClientId != null)
            {
                if (vServicePrincipalProfile == null)
                {
                    vServicePrincipalProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceServicePrincipalProfile();
                }
                vServicePrincipalProfile.ClientId = this.ServicePrincipalProfileClientId;
            }

            if (this.ServicePrincipalProfileSecret != null)
            {
                if (vServicePrincipalProfile == null)
                {
                    vServicePrincipalProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceServicePrincipalProfile();
                }
                vServicePrincipalProfile.Secret = this.ServicePrincipalProfileSecret;
            }

            if (this.MasterCount != null)
            {
                if (vMasterProfile == null)
                {
                    vMasterProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceMasterProfile();
                }
                vMasterProfile.Count = this.MasterCount;
            }

            if (this.MasterDnsPrefix != null)
            {
                if (vMasterProfile == null)
                {
                    vMasterProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceMasterProfile();
                }
                vMasterProfile.DnsPrefix = this.MasterDnsPrefix;
            }

            if (this.WindowsProfileAdminUsername != null)
            {
                if (vWindowsProfile == null)
                {
                    vWindowsProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceWindowsProfile();
                }
                vWindowsProfile.AdminUsername = this.WindowsProfileAdminUsername;
            }

            if (this.WindowsProfileAdminPassword != null)
            {
                if (vWindowsProfile == null)
                {
                    vWindowsProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceWindowsProfile();
                }
                vWindowsProfile.AdminPassword = this.WindowsProfileAdminPassword;
            }

            if (this.AdminUsername != null)
            {
                if (vLinuxProfile == null)
                {
                    vLinuxProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceLinuxProfile();
                }
                vLinuxProfile.AdminUsername = this.AdminUsername;
            }


            if (this.SshPublicKey != null)
            {
                if (vLinuxProfile == null)
                {
                    vLinuxProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceLinuxProfile();
                }
                if (vLinuxProfile.Ssh == null)
                {
                    vLinuxProfile.Ssh = new Microsoft.Azure.Management.Compute.Models.ContainerServiceSshConfiguration();
                }
                if (vLinuxProfile.Ssh.PublicKeys == null)
                {
                    vLinuxProfile.Ssh.PublicKeys = new List <Microsoft.Azure.Management.Compute.Models.ContainerServiceSshPublicKey>();
                }
                foreach (var element in this.SshPublicKey)
                {
                    var vPublicKeys = new Microsoft.Azure.Management.Compute.Models.ContainerServiceSshPublicKey();
                    vPublicKeys.KeyData = element;
                    vLinuxProfile.Ssh.PublicKeys.Add(vPublicKeys);
                }
            }

            if (vDiagnosticsProfile == null)
            {
                vDiagnosticsProfile = new Microsoft.Azure.Management.Compute.Models.ContainerServiceDiagnosticsProfile();
            }
            if (vDiagnosticsProfile.VmDiagnostics == null)
            {
                vDiagnosticsProfile.VmDiagnostics = new Microsoft.Azure.Management.Compute.Models.ContainerServiceVMDiagnostics();
            }

            vDiagnosticsProfile.VmDiagnostics.Enabled = this.VmDiagnosticsEnabled;

            var vContainerService = new PSContainerService
            {
                Location                = this.Location,
                Tags                    = (this.Tag == null) ? null : this.Tag.Cast <DictionaryEntry>().ToDictionary(ht => (string)ht.Key, ht => (string)ht.Value),
                AgentPoolProfiles       = this.AgentPoolProfile,
                OrchestratorProfile     = vOrchestratorProfile,
                CustomProfile           = vCustomProfile,
                ServicePrincipalProfile = vServicePrincipalProfile,
                MasterProfile           = vMasterProfile,
                WindowsProfile          = vWindowsProfile,
                LinuxProfile            = vLinuxProfile,
                DiagnosticsProfile      = vDiagnosticsProfile,
            };

            WriteObject(vContainerService);
        }