protected ContainerService CreateDefaultContainerServiceInput(string rgName, string masterDnsPrefix, string agentPoolDnsPrefix)
        {
            var publicKeys = new ContainerServiceSshPublicKey(DefaultSshPublicKey);

            var agentPoolProfiles = new ContainerServiceAgentPoolProfile(DefaultAgentPoolProfileName, 1, DefaultVmSize, agentPoolDnsPrefix)
            {
            };

            return(new ContainerService(m_location)
            {
                Tags = new Dictionary <string, string>()
                {
                    { "RG", "rg" }, { "testTag", "1" }
                },
                AgentPoolProfiles = new[] { agentPoolProfiles },
                // Todo: DiagnosticsProfile will be available in GA
                //DiagnosticsProfile = new ContainerServiceDiagnosticsProfile
                //{
                //    VmDiagnostics = new ContainerServiceVMDiagnostics
                //    {
                //        Enabled = true
                //    }
                //},

                LinuxProfile = new ContainerServiceLinuxProfile(DefaultLinuxAdminUsername, new ContainerServiceSshConfiguration(new[] { publicKeys })
                {
                }),
                MasterProfile = new ContainerServiceMasterProfile(masterDnsPrefix)
                {
                },
                OrchestratorProfile = new ContainerServiceOrchestratorProfile(ContainerServiceOrchestratorTypes.Dcos)
                {
                }
            });
        }
        public ContainerServiceImpl WithSshKey(string sshKeyData)
        {
            ContainerServiceSshConfiguration ssh = new ContainerServiceSshConfiguration();

            ssh.PublicKeys = new List <ContainerServiceSshPublicKey>();
            ContainerServiceSshPublicKey sshPublicKey = new ContainerServiceSshPublicKey();

            sshPublicKey.KeyData = sshKeyData;
            ssh.PublicKeys.Add(sshPublicKey);
            this.Inner.LinuxProfile.Ssh = ssh;
            return(this);
        }
Esempio n. 3
0
        protected ContainerService CreateDefaultContainerServiceInput(string rgName, string masterDnsPrefix, string agentPoolDnsPrefix)
        {
            var publicKeys = new ContainerServiceSshPublicKey
            {
                KeyData = DefaultSshPublicKey
            };

            var agentPoolProfiles = new ContainerServiceAgentPoolProfile
            {
                DnsPrefix = agentPoolDnsPrefix,
                Name      = DefaultAgentPoolProfileName,
                VmSize    = DefaultVmSize,
                Count     = 1 // This should be added because of AutoRest bug.
            };

            return(new ContainerService
            {
                Location = m_location,
                Tags = new Dictionary <string, string>()
                {
                    { "RG", "rg" }, { "testTag", "1" }
                },
                AgentPoolProfiles = new [] { agentPoolProfiles },

                // Todo: DiagnosticsProfile will be available in GA
                //DiagnosticsProfile = new ContainerServiceDiagnosticsProfile
                //{
                //    VmDiagnostics = new ContainerServiceVMDiagnostics
                //    {
                //        Enabled = true
                //    }
                //},

                LinuxProfile = new ContainerServiceLinuxProfile
                {
                    AdminUsername = DefaultLinuxAdminUsername,
                    Ssh = new ContainerServiceSshConfiguration
                    {
                        PublicKeys = new [] { publicKeys }
                    }
                },
                MasterProfile = new ContainerServiceMasterProfile
                {
                    DnsPrefix = masterDnsPrefix
                },
                OrchestratorProfile = new ContainerServiceOrchestratorProfile
                {
                    OrchestratorType = ContainerServiceOrchestratorTypes.DCOS
                }
            });
        }
        private void Run()
        {
            // OrchestratorProfile
            ContainerServiceOrchestratorProfile vOrchestratorProfile = null;

            // CustomProfile
            ContainerServiceCustomProfile vCustomProfile = null;

            // ServicePrincipalProfile
            ContainerServiceServicePrincipalProfile vServicePrincipalProfile = null;

            // MasterProfile
            ContainerServiceMasterProfile vMasterProfile = null;

            // WindowsProfile
            ContainerServiceWindowsProfile vWindowsProfile = null;

            // LinuxProfile
            ContainerServiceLinuxProfile vLinuxProfile = null;

            // DiagnosticsProfile
            ContainerServiceDiagnosticsProfile vDiagnosticsProfile = null;

            if (this.IsParameterBound(c => c.OrchestratorType))
            {
                if (vOrchestratorProfile == null)
                {
                    vOrchestratorProfile = new ContainerServiceOrchestratorProfile();
                }
                vOrchestratorProfile.OrchestratorType = this.OrchestratorType.Value;
            }

            if (this.IsParameterBound(c => c.CustomProfileOrchestrator))
            {
                if (vCustomProfile == null)
                {
                    vCustomProfile = new ContainerServiceCustomProfile();
                }
                vCustomProfile.Orchestrator = this.CustomProfileOrchestrator;
            }

            if (this.IsParameterBound(c => c.ServicePrincipalProfileClientId))
            {
                if (vServicePrincipalProfile == null)
                {
                    vServicePrincipalProfile = new ContainerServiceServicePrincipalProfile();
                }
                vServicePrincipalProfile.ClientId = this.ServicePrincipalProfileClientId;
            }

            if (this.IsParameterBound(c => c.ServicePrincipalProfileSecret))
            {
                if (vServicePrincipalProfile == null)
                {
                    vServicePrincipalProfile = new ContainerServiceServicePrincipalProfile();
                }
                vServicePrincipalProfile.Secret = this.ServicePrincipalProfileSecret;
            }

            if (this.IsParameterBound(c => c.MasterCount))
            {
                if (vMasterProfile == null)
                {
                    vMasterProfile = new ContainerServiceMasterProfile();
                }
                vMasterProfile.Count = this.MasterCount;
            }

            if (this.IsParameterBound(c => c.MasterDnsPrefix))
            {
                if (vMasterProfile == null)
                {
                    vMasterProfile = new ContainerServiceMasterProfile();
                }
                vMasterProfile.DnsPrefix = this.MasterDnsPrefix;
            }

            if (this.IsParameterBound(c => c.WindowsProfileAdminUsername))
            {
                if (vWindowsProfile == null)
                {
                    vWindowsProfile = new ContainerServiceWindowsProfile();
                }
                vWindowsProfile.AdminUsername = this.WindowsProfileAdminUsername;
            }

            if (this.IsParameterBound(c => c.WindowsProfileAdminPassword))
            {
                if (vWindowsProfile == null)
                {
                    vWindowsProfile = new ContainerServiceWindowsProfile();
                }
                vWindowsProfile.AdminPassword = this.WindowsProfileAdminPassword;
            }

            if (this.IsParameterBound(c => c.AdminUsername))
            {
                if (vLinuxProfile == null)
                {
                    vLinuxProfile = new ContainerServiceLinuxProfile();
                }
                vLinuxProfile.AdminUsername = this.AdminUsername;
            }


            if (this.IsParameterBound(c => c.SshPublicKey))
            {
                if (vLinuxProfile == null)
                {
                    vLinuxProfile = new ContainerServiceLinuxProfile();
                }
                if (vLinuxProfile.Ssh == null)
                {
                    vLinuxProfile.Ssh = new ContainerServiceSshConfiguration();
                }
                if (vLinuxProfile.Ssh.PublicKeys == null)
                {
                    vLinuxProfile.Ssh.PublicKeys = new List <ContainerServiceSshPublicKey>();
                }
                foreach (var element in this.SshPublicKey)
                {
                    var vPublicKeys = new ContainerServiceSshPublicKey();
                    vPublicKeys.KeyData = element;
                    vLinuxProfile.Ssh.PublicKeys.Add(vPublicKeys);
                }
            }

            if (vDiagnosticsProfile == null)
            {
                vDiagnosticsProfile = new ContainerServiceDiagnosticsProfile();
            }
            if (vDiagnosticsProfile.VmDiagnostics == null)
            {
                vDiagnosticsProfile.VmDiagnostics = new ContainerServiceVMDiagnostics();
            }

            vDiagnosticsProfile.VmDiagnostics.Enabled = this.VmDiagnosticsEnabled;

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

            WriteObject(vContainerService);
        }