public SetAzurePlatformExtensionEndpointCmdletInfo(
            ExtensionEndpointConfigSet endpointConfig,
            string inputEndpoint, string internalEndpoint, string instanceInputlEndpoint,
            string protocol, int?port, string localPort, int?maxPort, int?minPort)
        {
            this.cmdletName = Utilities.SetAzurePlatformExtensionEndpointCmdletName;

            this.cmdletParams.Add(new CmdletParam("EndpointConfig", endpointConfig));

            if (!string.IsNullOrEmpty(inputEndpoint))
            {
                this.cmdletParams.Add(new CmdletParam("InputEndpointName", inputEndpoint));
            }

            if (!string.IsNullOrEmpty(internalEndpoint))
            {
                this.cmdletParams.Add(new CmdletParam("InternalEndpointName", internalEndpoint));
            }

            if (!string.IsNullOrEmpty(instanceInputlEndpoint))
            {
                this.cmdletParams.Add(new CmdletParam("InstanceInputEndpointName", instanceInputlEndpoint));
            }

            this.cmdletParams.Add(new CmdletParam("Protocol", protocol));

            if (port != null)
            {
                this.cmdletParams.Add(new CmdletParam("Port", port));
            }

            if (!string.IsNullOrEmpty(localPort))
            {
                this.cmdletParams.Add(new CmdletParam("LocalPort", localPort));
            }

            if (maxPort != null)
            {
                this.cmdletParams.Add(new CmdletParam("FixedPortMax", maxPort));
            }

            if (minPort != null)
            {
                this.cmdletParams.Add(new CmdletParam("FixedPortMin", minPort));
            }
        }
        public RemoveAzurePlatformExtensionEndpointCmdletInfo(ExtensionEndpointConfigSet epConfig, string endpointName, string endpointKind)
        {
            this.cmdletName = Utilities.RemoveAzurePlatformExtensionEndpointCmdletName;

            this.cmdletParams.Add(new CmdletParam("EndpointConfig", epConfig));

            if (endpointKind.Equals("Input"))
            {
                this.cmdletParams.Add(new CmdletParam("InputEndpointName", endpointName));
            }
            else if (endpointKind.Equals("Internal"))
            {
                this.cmdletParams.Add(new CmdletParam("InternalEndpointName", endpointName));
            }
            else if (endpointKind.Equals("InstanceInput"))
            {
                this.cmdletParams.Add(new CmdletParam("InstanceInputEndpointName", endpointName));
            }
        }
        public void PublishAzurePlatformExtensionTest()
        {
            StartTest(MethodBase.GetCurrentMethod().Name, testStartTime);

            string extensionName = "RDP";
            string publisher     = "Microsoft.WindowsAzure.Extensions";

            const string version = "1.0.0.1";

            const string hr    = "WebRole|WorkerRole";
            Uri          media = new Uri("https://rdfeagntextacctsn1prod.blob.core.windows.net/AgentExtensionContainer/RemoteAccessPlugin.zip");
            const string label = "extension-label";

            const string description = "detailed extension-description";

            const string company = "Microsoft Azure";

            // Certificate Config
            const string storeLocation            = "LocalMachine";
            const string storeName                = "My";
            const string thumbprintAlgorithm      = "sha1";
            ExtensionCertificateConfig certConfig = vmPowershellCmdlets.NewAzurePlatformExtensionCertificateConfig(
                storeLocation, storeName, thumbprintAlgorithm, true);

            // Endpoint Config
            const string inputEP         = "Microsoft.WindowsAzure.Plugins.RemoteForwarder.RdpInput";
            const string internalEP      = "Microsoft.WindowsAzure.Plugins.RemoteAccess.Rdp";
            const string instanceInputEP = "Microsoft.WindowsAzure.Plugins.RemoteAccess.RdpInstanceInput";
            const string tcpProtocol     = "tcp";
            const int    port            = 3389;
            const string localPort1      = "*";
            const string localPort2      = "1111";
            const int    minPort         = 1;
            const int    maxPort         = 65535;

            ExtensionEndpointConfigSet epConfig = vmPowershellCmdlets.NewAzurePlatformExtensionEndpointConfigSet();

            epConfig = vmPowershellCmdlets.SetAzurePlatformExtensionEndpoint(epConfig,
                                                                             inputEP, tcpProtocol, port, localPort1);
            epConfig = vmPowershellCmdlets.SetAzurePlatformExtensionEndpoint(epConfig, internalEP, tcpProtocol, port);
            epConfig = vmPowershellCmdlets.SetAzurePlatformExtensionEndpoint(epConfig, instanceInputEP,
                                                                             tcpProtocol, localPort2, maxPort, minPort);

            // Local Resource Config
            const string lrName = "disk space for local caching";
            const int    size   = 50;
            ExtensionLocalResourceConfigSet lrConfig = vmPowershellCmdlets.NewAzurePlatformExtensionLocalResourceConfigSet();

            lrConfig = vmPowershellCmdlets.SetAzurePlatformExtensionLocalResource(lrConfig, lrName, size);

            DateTime     publishDate  = DateTime.Now;
            const string publicSchema = @"<?xml version=""1.0"" encoding=""utf-8""?>"
                                        + @"<xs:schema attributeFormDefault=""unqualified"""
                                        + @"  elementFormDefault=""qualified"""
                                        + @"  xmlns:xs=""http://www.w3.org/2001/XMLSchema"">"
                                        + @"  <xs:element name=""PublicConfig"">"
                                        + @"    <xs:complexType>"
                                        + @"      <xs:sequence>"
                                        + @"        <xs:element name=""UserName"" type=""xs:string"" />"
                                        + @"      </xs:sequence>"
                                        + @"    </xs:complexType>"
                                        + @"  </xs:element>"
                                        + @"</xs:schema>";

            const string privateSchema = @"<?xml version=""1.0"" encoding=""utf-8""?>"
                                         + @"<xs:schema attributeFormDefault=""unqualified"""
                                         + @"  elementFormDefault=""qualified"""
                                         + @"  xmlns:xs=""http://www.w3.org/2001/XMLSchema"">"
                                         + @"  <xs:element name=""PrivateConfig"">"
                                         + @"    <xs:complexType>"
                                         + @"      <xs:sequence>"
                                         + @"        <xs:element name=""Password"" type=""xs:string"" />"
                                         + @"      </xs:sequence>"
                                         + @"    </xs:complexType>"
                                         + @"  </xs:element>"
                                         + @"</xs:schema>";

            const string sample = "TestSampleConfig";

            const string eula       = "http://www.contoso.com/42588280809/eula";
            Uri          privacyUri = new Uri("http://www.contoso.com/42588280809/privacy");
            Uri          homepage   = new Uri("http://www.contoso.com/42588280809/homepage");

            const string os = "Windows";

            const bool   blockRole         = true;
            const bool   disallowUpgrade   = true;
            const bool   xmlExtension      = false;
            const bool   internalExtension = true;
            const bool   force             = true;
            const string regions           = "West US";

            // starting the test.
            try
            {
                vmPowershellCmdlets.PublishAzurePlatformExtension(
                    extensionName, publisher, version, hr,
                    media, label, description, company,
                    certConfig, epConfig, lrConfig,
                    publishDate, publicSchema, privateSchema, EncodeTo64(sample),
                    eula, privacyUri, homepage, os, regions,
                    blockRole, disallowUpgrade, xmlExtension, internalExtension, force);
            }
            catch (Exception e)
            {
                if (e.InnerException != null && e.InnerException.Message.Contains("ForbiddenError"))
                {
                    Console.WriteLine("Subscription is not a publisher.");
                }
                else
                {
                    throw;
                }
            }

            try
            {
                vmPowershellCmdlets.UnpublishAzurePlatformExtension(extensionName, publisher, version, true);
            }
            catch (Exception e)
            {
                if (e.InnerException != null && e.InnerException.Message.Contains("ForbiddenError"))
                {
                    Console.WriteLine("Subscription is not a publisher.");
                }
                else
                {
                    throw;
                }
            }

            extensionName = "VMAccessAgent";
            publisher     = "Microsoft.Compute";

            try
            {
                vmPowershellCmdlets.PublishAzurePlatformExtension(
                    extensionName, publisher, version, hr,
                    media, label, description, company,
                    certConfig, epConfig, lrConfig,
                    publishDate, publicSchema, privateSchema, EncodeTo64(sample),
                    eula, privacyUri, homepage, os, regions,
                    blockRole, disallowUpgrade, xmlExtension, internalExtension, force);
            }
            catch (Exception e)
            {
                if (e.InnerException != null && e.InnerException.Message.Contains("ForbiddenError"))
                {
                    Console.WriteLine("Subscription is not a publisher.");
                }
                else
                {
                    throw;
                }
            }

            pass = true;
        }
Beispiel #4
0
        public PublishAzurePlatformExtensionCmdletInfo(
            string extensionName, string publisher, string version, string hr,
            Uri media, string label, string description, string company,
            ExtensionCertificateConfig certConfig, ExtensionEndpointConfigSet epConfig, ExtensionLocalResourceConfigSet lrConfig,
            DateTime publishDate, string publicSchema, string privateSchema, string sample,
            string eula, Uri privacyUri, Uri homepage, string os, string regions,
            bool blockRole, bool disallowUpgrade, bool xmlExtension, bool internalExtension, bool force)
        {
            this.cmdletName = Utilities.PublishAzurePlatformExtensionCmdletName;

            this.cmdletParams.Add(new CmdletParam("ExtensionName", extensionName));
            this.cmdletParams.Add(new CmdletParam("Publisher", publisher));
            this.cmdletParams.Add(new CmdletParam("Version", version));

            this.cmdletParams.Add(new CmdletParam("HostingResources", hr));
            this.cmdletParams.Add(new CmdletParam("MediaLink", media));
            this.cmdletParams.Add(new CmdletParam("Label", label));
            this.cmdletParams.Add(new CmdletParam("Description", description));
            this.cmdletParams.Add(new CmdletParam("CompanyName", company));

            if (certConfig != null)
            {
                this.cmdletParams.Add(new CmdletParam("CertificateConfig", certConfig));
            }

            if (epConfig != null)
            {
                this.cmdletParams.Add(new CmdletParam("EndpointConfig", epConfig));
            }

            if (lrConfig != null)
            {
                this.cmdletParams.Add(new CmdletParam("LocalResourceConfig", lrConfig));
            }

            this.cmdletParams.Add(new CmdletParam("PublishedDate", publishDate));

            if (!string.IsNullOrEmpty(publicSchema))
            {
                this.cmdletParams.Add(new CmdletParam("PublicConfigurationSchema", publicSchema));
            }
            if (!string.IsNullOrEmpty(privateSchema))
            {
                this.cmdletParams.Add(new CmdletParam("PrivateConfigurationSchema", privateSchema));
            }
            if (!string.IsNullOrEmpty(sample))
            {
                this.cmdletParams.Add(new CmdletParam("SampleConfig", sample));
            }

            if (!string.IsNullOrEmpty(eula))
            {
                this.cmdletParams.Add(new CmdletParam("Eula", eula));
            }
            if (privacyUri != null)
            {
                this.cmdletParams.Add(new CmdletParam("PrivacyUri", privacyUri));
            }
            if (homepage != null)
            {
                this.cmdletParams.Add(new CmdletParam("HomepageUri", homepage));
            }
            if (!string.IsNullOrEmpty(os))
            {
                this.cmdletParams.Add(new CmdletParam("SupportedOS", os));
            }
            if (!string.IsNullOrEmpty(regions))
            {
                this.cmdletParams.Add(new CmdletParam("Regions", regions));
            }

            if (blockRole)
            {
                this.cmdletParams.Add(new CmdletParam("BlockRoleUponFailure"));
            }

            if (disallowUpgrade)
            {
                this.cmdletParams.Add(new CmdletParam("DisallowMajorVersionUpgrade"));
            }

            if (xmlExtension)
            {
                this.cmdletParams.Add(new CmdletParam("XmlExtension"));
            }

            if (force)
            {
                this.cmdletParams.Add(new CmdletParam("Force"));
            }

            this.cmdletParams.Add(new CmdletParam("ExtensionMode", (internalExtension)? "Internal" : "Public"));
        }