protected override void ExecuteCommand()
        {
            ServiceManagementProfile.Initialize();

            base.ExecuteCommand();

            if (this.CurrentDeploymentNewSM == null)
            {
                return;
            }

            string[] inputRoleNames = (this.ParameterSetName == "ByName") ? this.Name : this.VM.Select(vm => vm.GetInstance().RoleName).ToArray();

            // Generate a list of role names matching wildcard patterns or
            // the exact name specified in the -Name parameter.
            var roleNames = PersistentVMHelper.GetRoleNames(this.CurrentDeploymentNewSM.RoleInstances, inputRoleNames);

            // Insure at least one of the role name instances can be found.
            if ((roleNames == null) || (!roleNames.Any()))
            {
                throw new ArgumentOutOfRangeException(String.Format(Resources.RoleInstanceCanNotBeFoundWithName, Name));
            }

            var parameters = new VirtualMachineStartRolesParameters();

            foreach (var r in roleNames)
            {
                parameters.Roles.Add(r);
            }

            this.ExecuteClientActionNewSM(
                null,
                this.CommandRuntime.ToString(),
                () => this.ComputeClient.VirtualMachines.StartRoles(this.ServiceName, this.CurrentDeploymentNewSM.Name, parameters));
        }
Exemple #2
0
        protected PSArgument[] CreateVirtualMachineStartRolesParameters()
        {
            string serviceName    = string.Empty;
            string deploymentName = string.Empty;
            VirtualMachineStartRolesParameters parameters = new VirtualMachineStartRolesParameters();

            return(ConvertFromObjectsToArguments(new string[] { "ServiceName", "DeploymentName", "Parameters" }, new object[] { serviceName, deploymentName, parameters }));
        }
Exemple #3
0
        protected void ExecuteVirtualMachineStartRolesMethod(object[] invokeMethodInputParameters)
        {
            string serviceName    = (string)ParseParameter(invokeMethodInputParameters[0]);
            string deploymentName = (string)ParseParameter(invokeMethodInputParameters[1]);
            VirtualMachineStartRolesParameters parameters = (VirtualMachineStartRolesParameters)ParseParameter(invokeMethodInputParameters[2]);

            var result = VirtualMachineClient.StartRoles(serviceName, deploymentName, parameters);

            WriteObject(result);
        }