Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private PersistentVM CreateIaaSVMWithCustomScriptExtesnion(SetAzureVMCustomScriptExtensionCmdletParmaterSetType scriptParameterSet, string vmName, InstanceSize size, string imageName, bool isWindows, string username, string password)
        {
            Utilities.PrintHeader("Creating a new IaaS VM config with custom script extension.");
            PersistentVM vm = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, imageName, isWindows, username, password);

            vm = SetCustomScripExtesnionToVM(scriptParameterSet, vm);
            Utilities.PrintFooter("Creating a new IaaS VM config with custom script extension");
            return(vm);
        }
Ejemplo n.º 3
0
        private void VerifyCustomScriptExtensionContext(SetAzureVMCustomScriptExtensionCmdletParmaterSetType type)
        {
            Utilities.PrintHeader("Verifiying Custom Script extesnion config.");
            var customScriptExtensionContext = vmPowershellCmdlets.GetAzureVMCustomScriptExtension(Utilities.GetAzureVM(vmName, serviceName));

            Utilities.PrintContext(customScriptExtensionContext);
            Utilities.LogAssert(() => Assert.AreEqual(customScriptExtensionContext.ExtensionName, customScriptExtension.ExtensionName), "Verifiying ExtensionName");
            Utilities.LogAssert(() => Assert.AreEqual(customScriptExtensionContext.RoleName, vmName), "Verifiying RoleName");;
            Utilities.LogAssert(() => Assert.IsTrue(customScriptExtensionContext.PrivateConfiguration == null ||
                                                    string.IsNullOrEmpty(customScriptExtensionContext.PrivateConfiguration.ConvertToUnsecureString())), "Verifiying PrivateConfiguration");;
            Utilities.LogAssert(() => Assert.IsFalse(string.IsNullOrEmpty(customScriptExtensionContext.PublicConfiguration)), "Verifiying ExtensionName");;
            Utilities.LogAssert(() => Assert.AreEqual(customScriptExtensionContext.Publisher, customScriptExtension.Publisher), "Verifiying PublisherName");;
            if (type != SetAzureVMCustomScriptExtensionCmdletParmaterSetType.DisableCustomScriptExtensionParamSetName &&
                type != SetAzureVMCustomScriptExtensionCmdletParmaterSetType.SetCustomScriptExtensionByContainerBlobsParamSetName &&
                type != SetAzureVMCustomScriptExtensionCmdletParmaterSetType.SetCustomScriptExtensionByUrisParamSetName)
            {
                Utilities.LogAssert(() => Assert.AreEqual(customScriptExtensionContext.ReferenceName, "CustomScriptExtension"), "Verifiying ReferenceName");
            }
            else
            {
                Utilities.LogAssert(() => Assert.AreEqual(customScriptExtensionContext.ReferenceName, referenceName), "Verifiying ReferenceName");
            }

            if (type == SetAzureVMCustomScriptExtensionCmdletParmaterSetType.DisableCustomScriptExtensionParamSetName ||
                type == SetAzureVMCustomScriptExtensionCmdletParmaterSetType.DisableCustomScriptExtensionParamSetNameWithOutDefaultParameters)
            {
                Utilities.LogAssert(() => Assert.AreEqual(customScriptExtensionContext.State, "Disable"), "Verifiying State");
            }
            else
            {
                Utilities.LogAssert(() => Assert.AreEqual(customScriptExtensionContext.State, "Enable"), "Verifiying State");
            }

            if (type != SetAzureVMCustomScriptExtensionCmdletParmaterSetType.DisableCustomScriptExtensionParamSetName &&
                type != SetAzureVMCustomScriptExtensionCmdletParmaterSetType.DisableCustomScriptExtensionParamSetNameWithOutDefaultParameters)
            {
                Utilities.LogAssert(() => Assert.IsTrue(customScriptExtensionContext.Uri != null), "Verifiying Uri");
                Utilities.LogAssert(() => Assert.IsTrue(customScriptExtensionContext.CommandToExecute.Contains(runFileName)), "Verifiying CommandToExecute");
            }
            else
            {
                Utilities.LogAssert(() => Assert.IsTrue(customScriptExtensionContext.Uri == null), "Verifiying Uri");
                //Utilities.LogAssert(() => Assert.IsTrue(string.IsNullOrEmpty(customScriptExtensionContext.CommandToExecute)), "Verifiying CommandToExecute");
            }
            Utilities.PrintFooter("Verifiying Custom Script extesnion config.");
        }
        private void VerifyCustomScriptExtensionContext(SetAzureVMCustomScriptExtensionCmdletParmaterSetType type)
        {
            Utilities.PrintHeader("Verifiying Custom Script extesnion config.");
            var customScriptExtensionContext = vmPowershellCmdlets.GetAzureVMCustomScriptExtension(Utilities.GetAzureVM(vmName, serviceName));
            Utilities.PrintContext(customScriptExtensionContext);
            Utilities.LogAssert(() => Assert.AreEqual(customScriptExtensionContext.ExtensionName, customScriptExtension.ExtensionName), "Verifiying ExtensionName");
            Utilities.LogAssert(() => Assert.AreEqual(customScriptExtensionContext.RoleName, vmName), "Verifiying RoleName"); ;
            Utilities.LogAssert(() => Assert.IsTrue(customScriptExtensionContext.PrivateConfiguration == null ||
                string.IsNullOrEmpty(customScriptExtensionContext.PrivateConfiguration.ConvertToUnsecureString())), "Verifiying PrivateConfiguration"); ;
            Utilities.LogAssert(() => Assert.IsFalse(string.IsNullOrEmpty(customScriptExtensionContext.PublicConfiguration)), "Verifiying ExtensionName"); ;
            Utilities.LogAssert(() => Assert.AreEqual(customScriptExtensionContext.Publisher, customScriptExtension.Publisher), "Verifiying PublisherName"); ;
            if(type != SetAzureVMCustomScriptExtensionCmdletParmaterSetType.DisableCustomScriptExtensionParamSetName 
                && type != SetAzureVMCustomScriptExtensionCmdletParmaterSetType.SetCustomScriptExtensionByContainerBlobsParamSetName
                 && type != SetAzureVMCustomScriptExtensionCmdletParmaterSetType.SetCustomScriptExtensionByUrisParamSetName)
            {
                Utilities.LogAssert(() => Assert.AreEqual(customScriptExtensionContext.ReferenceName, "CustomScriptExtension"), "Verifiying ReferenceName");
            }
            else
            {
                Utilities.LogAssert(() => Assert.AreEqual(customScriptExtensionContext.ReferenceName, referenceName), "Verifiying ReferenceName");
            }

            if (type == SetAzureVMCustomScriptExtensionCmdletParmaterSetType.DisableCustomScriptExtensionParamSetName
                || type == SetAzureVMCustomScriptExtensionCmdletParmaterSetType.DisableCustomScriptExtensionParamSetNameWithOutDefaultParameters)
            {
                Utilities.LogAssert(() => Assert.AreEqual(customScriptExtensionContext.State, "Disable"), "Verifiying State");
            }
            else
            {
                Utilities.LogAssert(() => Assert.AreEqual(customScriptExtensionContext.State, "Enable"), "Verifiying State");
            }

            if (type != SetAzureVMCustomScriptExtensionCmdletParmaterSetType.DisableCustomScriptExtensionParamSetName
                && type != SetAzureVMCustomScriptExtensionCmdletParmaterSetType.DisableCustomScriptExtensionParamSetNameWithOutDefaultParameters)
            {
                Utilities.LogAssert(() => Assert.IsTrue(customScriptExtensionContext.Uri != null), "Verifiying Uri");
                Utilities.LogAssert(() => Assert.IsTrue(customScriptExtensionContext.CommandToExecute.Contains(runFileName)), "Verifiying CommandToExecute");
                 
            }
            else
            {
                Utilities.LogAssert(() => Assert.IsTrue(customScriptExtensionContext.Uri == null), "Verifiying Uri");
                //Utilities.LogAssert(() => Assert.IsTrue(string.IsNullOrEmpty(customScriptExtensionContext.CommandToExecute)), "Verifiying CommandToExecute");
            }
            Utilities.PrintFooter("Verifiying Custom Script extesnion config.");
        }
        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;
        }
 private PersistentVM CreateIaaSVMWithCustomScriptExtesnion(SetAzureVMCustomScriptExtensionCmdletParmaterSetType scriptParameterSet, string vmName, InstanceSize size, string imageName, bool isWindows, string username, string password)
 {
     Utilities.PrintHeader("Creating a new IaaS VM config with custom script extension.");
     PersistentVM vm = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, imageName, isWindows, username, password);
     vm = SetCustomScripExtesnionToVM(scriptParameterSet, vm);
     Utilities.PrintFooter("Creating a new IaaS VM config with custom script extension");
     return vm;
 }