Пример #1
0
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            if (this.Validate.IsPresent)
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.StorageClient.StorageAccounts.ValidateMigration(this.StorageAccountName),
                    (operation, service) =>
                {
                    var context = MigrationValidateContextHelper.ConvertToContext(operation, service);
                    return(context);
                });
            }
            else if (this.Abort.IsPresent)
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.StorageClient.StorageAccounts.AbortMigration(this.StorageAccountName));
            }
            else if (this.Commit.IsPresent)
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.StorageClient.StorageAccounts.CommitMigration(this.StorageAccountName));
            }
            else
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.StorageClient.StorageAccounts.PrepareMigration(this.StorageAccountName));
            }
        }
        protected override void OnProcessRecord()
        {
            ServiceManagementProfile.Initialize();

            if (this.Abort.IsPresent)
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.ComputeClient.Deployments.AbortMigration(this.ServiceName, DeploymentName));
            }
            else if (this.Commit.IsPresent)
            {
                ExecuteClientActionNewSM(
                    null,
                    CommandRuntime.ToString(),
                    () => this.ComputeClient.Deployments.CommitMigration(this.ServiceName, DeploymentName));
            }
            else
            {
                if (this.CreateNewVirtualNetwork.IsPresent)
                {
                    DestinationVNetType = DestinationVirtualNetwork.New;
                }
                else
                {
                    DestinationVNetType = DestinationVirtualNetwork.Existing;
                }

                var parameter = (this.ParameterSetName.Equals(PrepareExistingParameterSetName) ||
                                 this.ParameterSetName.Equals(ValidateExistingParameterSetName))
                    ? new PrepareDeploymentMigrationParameters
                {
                    DestinationVirtualNetwork = this.DestinationVNetType,
                    ResourceGroupName         = this.VirtualNetworkResourceGroupName,
                    SubNetName         = this.SubnetName,
                    VirtualNetworkName = this.VirtualNetworkName
                }
                    : new PrepareDeploymentMigrationParameters
                {
                    DestinationVirtualNetwork = this.DestinationVNetType,
                    ResourceGroupName         = string.Empty,
                    SubNetName         = string.Empty,
                    VirtualNetworkName = string.Empty
                };

                if (this.Validate.IsPresent)
                {
                    ExecuteClientActionNewSM(
                        null,
                        CommandRuntime.ToString(),
                        () => this.ComputeClient.Deployments.ValidateMigration(this.ServiceName, DeploymentName, parameter),
                        (operation, service) =>
                    {
                        var context = MigrationValidateContextHelper.ConvertToContext(operation, service);
                        return(context);
                    });
                }
                else
                {
                    ExecuteClientActionNewSM(
                        null,
                        CommandRuntime.ToString(),
                        () => this.ComputeClient.Deployments.PrepareMigration(this.ServiceName, DeploymentName, parameter));
                }
            }
        }