コード例 #1
0
        public void CreateReservedIPThenLinuxVM()
        {
            try
            {
                string reservedIpName  = Utilities.GetUniqueShortName("ResrvdIP");
                string reservedIpLabel = Utilities.GetUniqueShortName(" ResrvdIPLbl", 5);
                string dnsName         = Utilities.GetUniqueShortName("Dns");
                string vmName          = Utilities.GetUniqueShortName(vmNamePrefix);
                string deploymentName  = Utilities.GetUniqueShortName("Depl");
                string affinityGroup   = Utilities.GetUniqueShortName("AffGrp");
                var    input           = new ReservedIPContext()
                {
                    DeploymentName = string.Empty,
                    Label          = reservedIpLabel,
                    InUse          = false,
                    Location       = locationName,
                    ReservedIPName = reservedIpName,
                    State          = "Created"
                };

                // Reserve a new IP
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, reservedIpLabel), "Reserve a new IP");

                //Get the reserved ip and verify the reserved Ip properties.
                VerifyReservedIpNotInUse(input);
                // Create a new VM with the reserved ip.
                DnsServer dns = null;
                Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureAffinityGroup(affinityGroup, locationName, affinityGroup, affinityGroup), "Create a new affinity group");

                Utilities.ExecuteAndLog(() =>
                {
                    PersistentVM vm = Utilities.CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Linux, username, password, subnet);
                    vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, affinityGroup: affinityGroup, reservedIPName: reservedIpName);
                }, "");
                VerifyReservedIpInUse(serviceName, input);
                vmPowershellCmdlets.RemoveAzureDeployment(serviceName, DeploymentSlotType.Production, true);
                VerifyReservedIpNotInUse(input);
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureReservedIP(reservedIpName, true), "Release the reserved ip");
                VerifyReservedIpRemoved(reservedIpName);
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureService(serviceName, true), "Delete the hosted service");
                cleanupIfPassed = false;
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureAffinityGroup(affinityGroup), "Delete the affintiy group");
                pass = true;
            }
            catch (Exception ex)
            {
                pass = false;
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
コード例 #2
0
        public void CreateWindowsVMThenReservedExistingIP()
        {
            try
            {
                string reservedIpName  = Utilities.GetUniqueShortName("ResrvdIP");
                string reservedIpLabel = Utilities.GetUniqueShortName(" ResrvdIPLbl", 5);
                string dnsName         = Utilities.GetUniqueShortName("Dns");
                string vmName          = Utilities.GetUniqueShortName(vmNamePrefix);
                string deploymentName  = Utilities.GetUniqueShortName("Depl");
                var    input           = new ReservedIPContext()
                {
                    DeploymentName = string.Empty,
                    Label          = reservedIpLabel,
                    InUse          = false,
                    Location       = locationName,
                    ReservedIPName = reservedIpName,
                    State          = "Created"
                };

                // Create a new VM with the reserved ip.
                DnsServer dns = null;
                Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
                Utilities.ExecuteAndLog(() =>
                {
                    PersistentVM vm = Utilities.CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows, username, password, subnet);
                    vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName);
                }, "Create a new windows azure vm without reserved ip.");

                // Reserve an existing IP
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, serviceName, reservedIpLabel), "Reserve existing deployment IP");

                VerifyReservedIpInUse(serviceName, input);

                Utilities.ExecuteAndLog(() => { vmPowershellCmdlets.RemoveAzureReservedIPAssociation(reservedIpName, serviceName, true); }, "Remove an Azure Reserved IP Association");

                VerifyReservedIpNotInUse(input);
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureVM(vmName, serviceName, true), "Remove Azure VM and verify that a warning is given.");
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureReservedIP(reservedIpName, true), "Release the reserved ip");
                VerifyReservedIpRemoved(reservedIpName);
                pass = true;
            }
            catch (Exception ex)
            {
                pass = false;
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
コード例 #3
0
        public void TestAssociateReservedIPToStageSlotIaaSFails()
        {
            try
            {
                string reservedIpName  = Utilities.GetUniqueShortName("ResrvdIP");
                string reservedIpLabel = Utilities.GetUniqueShortName(" ResrvdIPLbl", 5);
                string dnsName         = Utilities.GetUniqueShortName("Dns");
                string vmName          = Utilities.GetUniqueShortName(vmNamePrefix);
                var    input           = new ReservedIPContext()
                {
                    DeploymentName = string.Empty,
                    Label          = reservedIpLabel,
                    InUse          = false,
                    Location       = locationName,
                    ReservedIPName = reservedIpName,
                    State          = "Created"
                };

                // Reserve a new IP
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, reservedIpLabel), "Reserve a new IP");
                //Get the reserved ip and verify the reserved Ip properties.
                VerifyReservedIpNotInUse(input);
                // Create a new VM with the reserved ip.
                DnsServer dns = null;
                Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
                Utilities.ExecuteAndLog(() =>
                {
                    PersistentVM vm = Utilities.CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows, username, password, subnet);
                    vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName);
                }, "Create a new windows azure vm without reserved ip.");

                Utilities.ExecuteAndLog(() => { vmPowershellCmdlets.SetAzureReservedIPAssociation(reservedIpName,
                                                                                                  serviceName, DeploymentSlotType.Staging); }, "Create a new Azure Reserved IP Association");
            }
            catch (Exception ex)
            {
                pass = true;
                Console.WriteLine(ex.ToString());
                return;
            }
            throw new Exception("Test Did not fail as expected when association was tried on stage slot in IaaS");
        }
コード例 #4
0
        public void TestVirtualIPLifecycle()
        {
            try
            {
                string dnsName      = Utilities.GetUniqueShortName("Dns");
                string vmName       = Utilities.GetUniqueShortName(vmNamePrefix);
                string vipName      = Utilities.GetUniqueShortName("Vip");
                string endpointName = Utilities.GetUniqueShortName("Endpoint");
                // Create a new VM with the reserved ip.
                DnsServer dns = null;
                Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); },
                                        "Create a new Azure DNS");
                PersistentVM vm = null;
                Utilities.ExecuteAndLog(() =>
                {
                    vm = Utilities.CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows,
                                                                                      username, password, subnet);
                    vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName);
                }, "Create a new windows azure vm without reserved ip.");

                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.AddAzureVirtualIP(vipName, serviceName), "Adding Azure VirtualIP");

                var deployment   = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Production);
                var retrievedVip = deployment.VirtualIPs.FirstOrDefault(vip => string.Equals(vip.Name, vipName));
                Assert.IsNotNull(retrievedVip);
                Assert.IsTrue(string.IsNullOrEmpty(retrievedVip.Address));

                AzureEndPointConfigInfo endpointInfo = new AzureEndPointConfigInfo
                {
                    EndpointName       = endpointName,
                    EndpointProtocol   = ProtocolInfo.tcp,
                    EndpointLocalPort  = 1000,
                    EndpointPublicPort = 444,
                    VirtualIPName      = vipName,
                    Vm = vm
                };

                var updatedVM = vmPowershellCmdlets.AddAzureEndPoint(endpointInfo);
                vmPowershellCmdlets.UpdateAzureVM(vmName, serviceName, updatedVM);
                deployment   = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Production);
                retrievedVip = deployment.VirtualIPs.FirstOrDefault(vip => string.Equals(vip.Name, vipName));
                Assert.IsNotNull(retrievedVip);
                Assert.IsTrue(!string.IsNullOrEmpty(retrievedVip.Address));

                AzureEndPointConfigInfo removeEndpointInfo = new AzureEndPointConfigInfo
                {
                    EndpointName       = endpointName,
                    EndpointProtocol   = ProtocolInfo.tcp,
                    EndpointLocalPort  = 1000,
                    EndpointPublicPort = 444,
                    VirtualIPName      = vipName,
                    Vm = updatedVM
                };

                updatedVM = vmPowershellCmdlets.RemoveAzureEndPoint(endpointName, updatedVM);
                vmPowershellCmdlets.UpdateAzureVM(vmName, serviceName, updatedVM);

                deployment   = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Production);
                retrievedVip = deployment.VirtualIPs.FirstOrDefault(vip => string.Equals(vip.Name, vipName));
                Assert.IsNotNull(retrievedVip);
                Assert.IsTrue(string.IsNullOrEmpty(retrievedVip.Address));

                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureVirtualIP(vipName, serviceName), "Adding Azure VirtualIP");

                deployment   = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Production);
                retrievedVip = deployment.VirtualIPs.FirstOrDefault(vip => string.Equals(vip.Name, vipName));
                Assert.IsNull(retrievedVip);
                cleanupIfPassed = false;

                vmPowershellCmdlets.RemoveAzureDeployment(serviceName, "Production", true);
                pass = true;
            }
            catch (Exception ex)
            {
                pass = false;
                Console.WriteLine(ex.ToString());
                throw;
            }
        }