상속: IPersistentVM
예제 #1
0
 public SetAzureSubnetCmdletInfo(PersistentVM vm, string[] subnetNames)
 {
     this.cmdletName = Utilities.SetAzureSubnetCmdletName;
     
     this.cmdletParams.Add(new CmdletParam("VM", vm));
     this.cmdletParams.Add(new CmdletParam("SubnetNames", subnetNames));
 }
 //SetCustomScriptExtensionByContainerBlobsParamSetName
 public SetAzureVMCustomScriptExtensionCmdletInfo(PersistentVM vm, string[] fileName, string storageAccountName, string storageEndpointSuffix, string containerName,
       string storageAccountKey, string run, string argument, string referenceName, string version)
     : this(vm, run, argument, referenceName, version)
 {
     if (fileName.Length > 0)
     {
         cmdletParams.Add(new CmdletParam("FileName", fileName));
     }
     if (!string.IsNullOrEmpty(containerName))
     {
         cmdletParams.Add(new CmdletParam("ContainerName", containerName));
     }
     if (!string.IsNullOrEmpty(storageAccountName))
     {
         cmdletParams.Add(new CmdletParam("StorageAccountName", storageAccountName));
     }
     if (!string.IsNullOrEmpty(storageEndpointSuffix))
     {
         cmdletParams.Add(new CmdletParam("StorageEndpointSuffix", storageEndpointSuffix));
     }
     if (!string.IsNullOrEmpty(storageAccountKey))
     {
         cmdletParams.Add(new CmdletParam("StorageAccountKey", storageAccountKey));
     }
 }
        public SetAzureAvailabilitySetCmdletInfo(string availabilitySetName, PersistentVM vm)
        {
            cmdletName = Utilities.SetAzureAvailabilitySetCmdletName;

            cmdletParams.Add(new CmdletParam("AvailabilitySetName", availabilitySetName));
            this.cmdletParams.Add(new CmdletParam("VM", vm));
        }
 //DisableCustomScriptExtensionParamSetName
 public SetAzureVMCustomScriptExtensionCmdletInfo(PersistentVM vm, string referenceName, string version, bool disable)
     : this(vm, referenceName, version)
 {
     if (disable)
     {
         cmdletParams.Add(new CmdletParam("Disable"));
     }
 }
 //SetCustomScriptExtensionByUrisParamSetName
 public SetAzureVMCustomScriptExtensionCmdletInfo(PersistentVM vm, string referenceName, string version, string[] fileUri, string run, string argument)
     :this(vm,run,argument,referenceName,version)
 {
     if (fileUri != null)
     {
         cmdletParams.Add(new CmdletParam("FileUri", Utilities.ConvertToJsonArray(fileUri)));
     }
 }
        public UpdateAzureVMCmdletInfo(string vmName, string serviceName, PersistentVM persistentVM)
        {
            cmdletName = Utilities.UpdateAzureVMCmdletName;

            this.cmdletParams.Add(new CmdletParam("Name", vmName));
            this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
            this.cmdletParams.Add(new CmdletParam("VM", persistentVM));
        }
 public GetAzureAclConfigCmdletInfo(PersistentVM vm, string ep)
 {
     cmdletName = Utilities.GetAzureAclConfigCmdletName;
     cmdletParams.Add(new CmdletParam("VM", vm));
     if (!string.IsNullOrEmpty(ep))
     {
         cmdletParams.Add(new CmdletParam("EndpointName", ep));
     }
 }
        public NewAzureVMCmdletInfo(string serviceName, PersistentVM[] vMs, string vnetName, DnsServer[] dnsSettings,
            string serviceLabel, string serviceDescription, string deploymentLabel, string deploymentName, string location, string affinityGroup, string rsvIPName,InternalLoadBalancerConfig internalLoadBalancerConfig, bool waitForBoot)
        {
            this.cmdletName = Utilities.NewAzureVMCmdletName;

            this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
            this.cmdletParams.Add(new CmdletParam("VMs", vMs));

            if (!string.IsNullOrEmpty(vnetName))
            {
                this.cmdletParams.Add(new CmdletParam("VNetName", vnetName));
            }
            if (dnsSettings != null)
            {
                this.cmdletParams.Add(new CmdletParam("DnsSettings", dnsSettings));
            }
            if (!string.IsNullOrEmpty(affinityGroup))
            {
                this.cmdletParams.Add(new CmdletParam("AffinityGroup", affinityGroup));
            }
            if (!string.IsNullOrEmpty(serviceLabel))
            {
                this.cmdletParams.Add(new CmdletParam("ServiceLabel", serviceLabel));
            }
            if (!string.IsNullOrEmpty(serviceDescription))
            {
                this.cmdletParams.Add(new CmdletParam("ServiceDescription", serviceDescription));
            }
            if (!string.IsNullOrEmpty(deploymentLabel))
            {
                this.cmdletParams.Add(new CmdletParam("DeploymentLabel", deploymentLabel));
            }
            if (!string.IsNullOrEmpty(deploymentName))
            {
                this.cmdletParams.Add(new CmdletParam("DeploymentName", deploymentName));
            }
            if (!string.IsNullOrEmpty(location))
            {
                this.cmdletParams.Add(new CmdletParam("Location", location));
            }
            if (!string.IsNullOrEmpty(rsvIPName))
            {
                this.cmdletParams.Add(new CmdletParam("ReservedIPName", rsvIPName));
            }
            if (waitForBoot)
            {
                this.cmdletParams.Add(new CmdletParam("WaitForBoot", waitForBoot));
            }
            if (internalLoadBalancerConfig != null)
            {
                this.cmdletParams.Add(new CmdletParam("InternalLoadBalancerConfig", internalLoadBalancerConfig));
            }
        }
 private SetAzureVMCustomScriptExtensionCmdletInfo(PersistentVM vm, string run, string argument, string referenceName, string version)
     :this(vm, referenceName, version)
 {
     if (!string.IsNullOrEmpty(run))
     {
         cmdletParams.Add(new CmdletParam("Run", run));
     }
     if (!string.IsNullOrEmpty(argument))
     {
         cmdletParams.Add(new CmdletParam("Argument", argument));
     }
 }
 private SetAzureVMCustomScriptExtensionCmdletInfo(PersistentVM vm, string referenceName, string version)
 {
     cmdletName = Utilities.SetAzureVMCustomScriptExtensionCmdletName;
     cmdletParams.Add(new CmdletParam("VM", vm));
     if (!string.IsNullOrEmpty(version))
     {
         cmdletParams.Add(new CmdletParam("Version", version));
     }
     if (!string.IsNullOrEmpty(referenceName))
     {
         cmdletParams.Add(new CmdletParam("ReferenceName", referenceName));
     }
 }
예제 #11
0
        public SetAzureOSDiskCmdletInfo(HostCaching? hs, PersistentVM vm, int? resizedSize)
        {
            cmdletName = Utilities.SetAzureOSDiskCmdletName;

            if (hs != null)
            {
                this.cmdletParams.Add(new CmdletParam("HostCaching", hs.ToString()));
            }
            this.cmdletParams.Add(new CmdletParam("VM", vm));
            if (resizedSize != null)
            {
                this.cmdletParams.Add(new CmdletParam("ResizedSizeInGB", resizedSize));
            }
        }
        public static void SaveStateToFile(PersistentVM role, string filePath)
        {
            if (role == null)
            {
                throw new ArgumentNullException("role", Resources.MissingPersistentVMRole);
            }
            
            XmlAttributeOverrides overrides = new XmlAttributeOverrides();
            XmlAttributes ignoreAttrib = new XmlAttributes();
            ignoreAttrib.XmlIgnore = true;
            overrides.Add(typeof(DataVirtualHardDisk), "MediaLink", ignoreAttrib);
            overrides.Add(typeof(DataVirtualHardDisk), "SourceMediaLink", ignoreAttrib);
            overrides.Add(typeof(OSVirtualHardDisk), "MediaLink", ignoreAttrib);

            var serializer = new System.Xml.Serialization.XmlSerializer(typeof(PersistentVM), overrides, new Type[] { typeof(NetworkConfigurationSet) }, null, null);
            using (TextWriter writer = new StreamWriter(filePath))
            {
                serializer.Serialize(writer, role);
            }
        }
예제 #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="vm"></param>
 /// <param name="availabilitySetName"></param>
 /// <returns></returns>
 internal static bool AzureAvailabilitySet(PersistentVM vm, string availabilitySetName)
 {
     try
     {
         Assert.IsTrue(vm.AvailabilitySetName.Equals(availabilitySetName, StringComparison.InvariantCultureIgnoreCase));
         return true;
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
         if (e is AssertFailedException)
         {
             return false;
         }
         else
         {
             throw;
         }
     }
 }
예제 #14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="vm"></param>
 /// <param name="expLabel"></param>
 /// <param name="expSize"></param>
 /// <param name="expLun"></param>
 /// <param name="hc"></param>
 /// <returns></returns>
 internal static bool AzureDataDisk(PersistentVM vm, string expLabel, int expSize, int expLun, HostCaching hc)
 {
     bool found = false;
     foreach (DataVirtualHardDisk disk in vmPowershellCmdlets.GetAzureDataDisk(vm))
     {
         if (CheckDataDisk(disk, expLabel, expSize, expLun, hc))
         {
             found = true;
             break;
         }
     }
     return found;
 }
예제 #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="vm"></param>
 /// <param name="expOS"></param>
 /// <param name="expHC"></param>
 /// <returns></returns>
 internal static bool AzureOsDisk(PersistentVM vm, string expOS, HostCaching expHC)
 {
     try
     {
         OSVirtualHardDisk osdisk = vmPowershellCmdlets.GetAzureOSDisk(vm);
         Console.WriteLine("OS Disk: Name - {0}, Label - {1}, HostCaching - {2}, OS - {3}", osdisk.DiskName, osdisk.DiskLabel, osdisk.HostCaching, osdisk.OS);
         Assert.IsTrue(osdisk.Equals(vm.OSVirtualHardDisk), "OS disk returned is not the same!");
         Assert.AreEqual(expOS, osdisk.OS);
         Assert.AreEqual(expHC.ToString(), osdisk.HostCaching);
         return true;
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
         if (e is AssertFailedException)
         {
             return false;
         }
         else
         {
             throw;
         }
     }
 }
예제 #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="vm"></param>
        /// <param name="epInfos"></param>
        /// <returns></returns>
        internal static bool AzureEndpoint(PersistentVM vm, AzureEndPointConfigInfo[] epInfos)
        {
            try
            {
                var serverEndpoints = vmPowershellCmdlets.GetAzureEndPoint(vm);

                // List the endpoints found for debugging.
                Console.WriteLine("***** Checking for Endpoints **************************************************");
                Console.WriteLine("***** Listing Returned Endpoints");
                foreach (InputEndpointContext ep in serverEndpoints)
                {
                    Console.WriteLine("Endpoint - Name:{0} Protocol:{1} Port:{2} LocalPort:{3} Vip:{4}", ep.Name, ep.Protocol, ep.Port, ep.LocalPort, ep.Vip);

                    if (!string.IsNullOrEmpty(ep.LBSetName))
                    {
                        Console.WriteLine("\t- LBSetName:{0}", ep.LBSetName);
                        Console.WriteLine("\t- Probe - Port:{0} Protocol:{1} Interval:{2} Timeout:{3}", ep.ProbePort, ep.ProbeProtocol, ep.ProbeIntervalInSeconds, ep.ProbeTimeoutInSeconds);
                    }
                }

                Console.WriteLine("*******************************************************************************");

                // Check if the specified endpoints were found.
                foreach (AzureEndPointConfigInfo epInfo in epInfos)
                {
                    bool found = false;

                    foreach (InputEndpointContext ep in serverEndpoints)
                    {
                        if (epInfo.CheckInputEndpointContext(ep))
                        {
                            found = true;
                            Console.WriteLine("Endpoint found: {0}", epInfo.EndpointName);
                            break;
                        }
                    }
                    Assert.IsTrue(found, string.Format("Error: Endpoint '{0}' was not found!", epInfo.EndpointName));
                }
                return true;
            }

            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return false;
            }
        }
예제 #17
0
 public void VerifyVM(PersistentVM vm, OS ImageFamily, HostCaching hostCaching, int LogicalDiskSizeInGB, int noOfDataDisks)
 {
     //Verify OS Disk
     Console.WriteLine("VM OS Virtual Hard Disk properties:");
     Utilities.PrintContext(vm.OSVirtualHardDisk);
     Assert.AreEqual(HostCaching.ReadWrite.ToString(), vm.OSVirtualHardDisk.HostCaching, "Os disk Property HostCaching is not matching.");
     Assert.AreEqual(ImageFamily.ToString(), vm.OSVirtualHardDisk.OS,"ImageFamily property is not matching.");
     //Verify Data Disk
     Console.WriteLine("VM Data Hard Disk properties:");
     Utilities.PrintContext(vm.DataVirtualHardDisks[0]);
     Assert.AreEqual(hostCaching.ToString(), vm.DataVirtualHardDisks[0].HostCaching, "Data disk Property HostCaching is not matching.");
     Assert.AreEqual(LogicalDiskSizeInGB, vm.DataVirtualHardDisks[0].LogicalDiskSizeInGB,"Data disk size is not matching.");
     Assert.AreEqual(noOfDataDisks, vm.DataVirtualHardDisks.Count, "Data disks count is not matching.");
 }
예제 #18
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            ValidateParameters();

            var role = new PersistentVM
            {
                AvailabilitySetName = AvailabilitySetName,
                ConfigurationSets = new Collection<ConfigurationSet>(),
                DataVirtualHardDisks = new Collection<DataVirtualHardDisk>(),
                RoleName = Name,
                RoleSize = InstanceSize,
                RoleType = RoleType,
                Label = Label,
                ProvisionGuestAgent = true
            };

            role.OSVirtualHardDisk = new OSVirtualHardDisk()
            {
                DiskName = DiskName,
                SourceImageName = ImageName,
                MediaLink = string.IsNullOrEmpty(MediaLocation) ? null : new Uri(MediaLocation),
                HostCaching = HostCaching,
                DiskLabel = string.IsNullOrEmpty(DiskLabel) ? null : DiskLabel
            };

            WriteObject(role, true);
        }
        private void ValidateLinuxParameterSetParameters(PersistentVM vm)
        {
            if (LinuxParameterSetName.Equals(ParameterSetName, StringComparison.OrdinalIgnoreCase))
            {
                if (!this.NoSSHPassword && ValidationHelpers.IsLinuxPasswordValid(Password) == false)
                {
                    throw new ArgumentException(Resources.PasswordNotComplexEnough);
                }

                if (ValidationHelpers.IsLinuxHostNameValid(vm.RoleName) == false)
                {
                    throw new ArgumentException(Resources.InvalidHostName);
                }
            }
        }
        private void ValidateWindowsParameterSetParameters(PersistentVM vm)
        {
            if (WindowsParameterSetName.Equals(ParameterSetName, StringComparison.OrdinalIgnoreCase) || 
                WindowsDomainParameterSetName.Equals(ParameterSetName, StringComparison.OrdinalIgnoreCase))
            {
                if (ValidationHelpers.IsWindowsPasswordValid(Password) == false)
                {
                    throw new ArgumentException(Resources.PasswordNotComplexEnough);
                }

                if (ValidationHelpers.IsWindowsComputerNameValid(vm.RoleName) == false)
                {
                    throw new ArgumentException(Resources.InvalidComputerName);
                }
            }
        }
 public GetAzureDataDiskCmdletInfo(PersistentVM vM)
 {
     this.cmdletName = Utilities.GetAzureDataDiskCmdletName;
     this.cmdletParams.Add(new CmdletParam("VM", vM));
 }
 public SetAzureDataDiskResizeConfig(string diskName, int resize, PersistentVM vm)
 {
     this.DiskName = diskName;
     this.ResizedSizeInGB = resize;
     this.Vm = vm;
 }
        private PersistentVM SetCustomScripExtesnionToVM(SetAzureVMCustomScriptExtensionCmdletParmaterSetType type, PersistentVM vm)
        {
            switch (type)
            {
                case SetAzureVMCustomScriptExtensionCmdletParmaterSetType.SetCustomScriptExtensionByUrisParamSetName:
                    Console.WriteLine("Calling Set-AzureVMCustomScriptExtension cmdlet using SetCustomScriptExtensionByUrisParamSetName parameter set including all parameters.");
                    return vmPowershellCmdlets.SetAzureVMCustomScriptExtension(vm, fileURI, true, runFileName, referenceName, customScriptExtension.Version);
                case SetAzureVMCustomScriptExtensionCmdletParmaterSetType.SetCustomScriptExtensionByUrisParamSetNameWithOutDefaultParameters:
                    Console.WriteLine("Calling Set-AzureVMCustomScriptExtension cmdlet using SetCustomScriptExtensionByUrisParamSetName parameter set without optional parameters");
                    return vmPowershellCmdlets.SetAzureVMCustomScriptExtension(vm, fileURI,true,runFileName);
                case SetAzureVMCustomScriptExtensionCmdletParmaterSetType.DisableCustomScriptExtensionParamSetName:
                    Console.WriteLine("Calling Set-AzureVMCustomScriptExtension cmdlet using DisableCustomScriptExtensionParamSetName parameter set including all parameters.");
                    return vmPowershellCmdlets.SetAzureVMCustomScriptExtension(vm, true, referenceName, customScriptExtension.Version);
                case SetAzureVMCustomScriptExtensionCmdletParmaterSetType.DisableCustomScriptExtensionParamSetNameWithOutDefaultParameters:
                    Console.WriteLine("Calling Set-AzureVMCustomScriptExtension cmdlet using DisableCustomScriptExtensionParamSetName parameter set without optional parameters");
                    return vmPowershellCmdlets.SetAzureVMCustomScriptExtension(vm,true);
                case SetAzureVMCustomScriptExtensionCmdletParmaterSetType.SetCustomScriptExtensionByContainerBlobsParamSetName:
                    Console.WriteLine("Calling Set-AzureVMCustomScriptExtension cmdlet using SetCustomScriptExtensionByContainerBlobsParamSetName parameter set including all parameters.");
                    return vmPowershellCmdlets.SetAzureVMCustomScriptExtension(vm,fileNames, runFileName, storageAccountKey.StorageAccountName, endpointSuffix, containerName, storageAccountKey.Primary, referenceName, customScriptExtension.Version);
                case SetAzureVMCustomScriptExtensionCmdletParmaterSetType.SetCustomScriptExtensionByContainerBlobsParamSetNameWithOutDefaultParameters:
                    Console.WriteLine("Calling Set-AzureVMCustomScriptExtension cmdlet using SetCustomScriptExtensionByContainerBlobsParamSetName parameter set without optional parameters");
                    return vmPowershellCmdlets.SetAzureVMCustomScriptExtension(vm,fileNames, runFileName,containerName: containerName);
                default:
                    break;
            }

            return vm;
        }
 public GetAzureEndpointCmdletInfo(PersistentVM vm)
 {
     this.cmdletName = Utilities.GetAzureEndpointCmdletName;
     this.cmdletParams.Add(new CmdletParam("VM", vm));
 }
 public RemoveAzureDataDiskConfig(int lun, PersistentVM vm)
 {
     this.Vm = vm;
     this.lun = lun;
 }
        private IPersistentVM GetAzureVM(String roleName, String serviceName)
        {
            var vm = new PersistentVM {RoleName = roleName};
            var vmContext = new PersistentVMRoleContext
            {
                DeploymentName = roleName,
                Name = roleName,
                ServiceName = serviceName,
                VM = vm
            };

            return vmContext;
        }
 private static void VerifyPublicIP(string publicIpName, PersistentVM vm1)
 {
     Utilities.ExecuteAndLog(() =>
     {
         var publicIpContext = vmPowershellCmdlets.GetAzurePublicIpName(publicIpName, vm1);
         Console.WriteLine("Public IP Context Properties:");
         Utilities.PrintContext(publicIpContext);
         Console.WriteLine("\n Verifing recquired properties");
         Utilities.LogAssert(() => Assert.AreEqual(publicIpName, publicIpContext.Name), "Public IP Name");
     }, "Verify Public ip of the VM");
 }
예제 #28
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            ValidateParameters();

            var role = new PersistentVM
            {
                AvailabilitySetName = this.AvailabilitySetName,
                ConfigurationSets = new Collection<ConfigurationSet>(),
                DataVirtualHardDisks = new Collection<DataVirtualHardDisk>(),
                RoleName = this.Name,
                RoleSize = this.InstanceSize,
                RoleType = RoleType,
                Label = this.Label,
                ProvisionGuestAgent = true,
                DebugSettings = new DebugSettings(),
                LicenseType = this.LicenseType
            };

            role.OSVirtualHardDisk = new OSVirtualHardDisk()
            {
                DiskName = this.DiskName,
                SourceImageName = this.ImageName,
                MediaLink = string.IsNullOrEmpty(MediaLocation) ? null : new Uri(this.MediaLocation),
                HostCaching = this.HostCaching,
                DiskLabel = string.IsNullOrEmpty(DiskLabel) ? null : this.DiskLabel
            };

            role.DebugSettings.BootDiagnosticsEnabled = !(this.DisableBootDiagnostics.IsPresent);
            WriteObject(role, true);
        }
 public SetAzureOSDiskCmdletInfo(HostCaching hs, PersistentVM vm)
 {
     cmdletName = Utilities.SetAzureOSDiskCmdletName;
     this.cmdletParams.Add(new CmdletParam("HostCaching", hs.ToString()));
     this.cmdletParams.Add(new CmdletParam("VM", vm));
 }
 public StopAzureVMCmdletInfo(PersistentVM vm, string serviceName, bool stay, bool force)
     : this(serviceName, stay, force)
 {
     this.cmdletParams.Add(new CmdletParam("VM", vm));
 }