static private void VerifyVmWithStaticCAIsReserved(string vmName, string svcName, string inputDip) { //Get the DIP of the VM (Get-AzureVM) VirtualNetworkStaticIPContext ipContext PersistentVMRoleContext vm = vmPowershellCmdlets.GetAzureVM(vmName, svcName); string confirguredVip = vm.IpAddress; if (!string.IsNullOrEmpty(confirguredVip)) { //Verify that the DIP of the VM is matched with an input DIP. Console.WriteLine("Verifying that the DIP of the VM {0} is matched with input DIP {1}.", inputDip, confirguredVip); Assert.AreEqual(inputDip, confirguredVip, string.Format("Static CA IpAddress {0} is not the same as the Input DIP {1}", confirguredVip, inputDip)); Console.WriteLine("Verifyied that the DIP of the VM {0} is matched with input DIP {1}.", inputDip, confirguredVip); //Verify that the DIP is actually reserved. Console.WriteLine("Verifying that the DIP of the VM is actually reserved"); var ipContext = vmPowershellCmdlets.GetAzureStaticVNetIP(vm.VM); Utilities.PrintContext(ipContext); Assert.AreEqual(inputDip, ipContext.IPAddress, string.Format("Reserved IPAddress {0} is not equal to the input DIP {1}", ipContext.IPAddress, inputDip)); Console.WriteLine("Verifyied that the DIP of the VM is actually reserved"); //Verify that the IP is not available (Test-AzureStaticVNetIP –VnetName $vnet –IPAddress “10.0.0.5”) Console.WriteLine("Verifing that the IP {0} is not available", inputDip); VirtualNetworkStaticIPAvailabilityContext availibiltyContext = vmPowershellCmdlets.TestAzureStaticVNetIP(VNetName, inputDip); Console.WriteLine("IsAvailable:{0}", availibiltyContext.IsAvailable); Console.WriteLine("AvailableAddresses:{0}{1}", Environment.NewLine, availibiltyContext.AvailableAddresses.Aggregate((current, next) => current + Environment.NewLine + next)); Assert.IsFalse(availibiltyContext.IsAvailable, string.Format("Test-AzureStaticVNetIP should return true as {0} is reserved", inputDip, vm.Name)); Assert.IsFalse(availibiltyContext.AvailableAddresses.Contains(inputDip), string.Format("{0} is reserved for vm {1} and should not be in available addresses.", inputDip, vmName)); Console.WriteLine("Verified that the IP {0} is not available", inputDip); } else { throw new Exception("Configured IPAddres value is null or empty"); } }
private void CheckAvailabilityofIpAddress(string vnetName, string ipaddress) { Console.WriteLine("Checking if VIP {0} is available and unreserved", ipaddress); VirtualNetworkStaticIPAvailabilityContext availibiltyContext = vmPowershellCmdlets.TestAzureStaticVNetIP(vnetName, ipaddress); Utilities.PrintContext(availibiltyContext); //Assert that it is available. Assert.IsTrue(availibiltyContext.IsAvailable, "ipaddress {0} is expected to be available", ipaddress); Console.WriteLine("Ip address {0} is available", ipaddress); }