public override void ExecuteCmdlet()
        {
            try
            {
                var startMigrationPlanRequest = new MigrationPlanStartRequest();
                startMigrationPlanRequest.ConfigId = LegacyConfigId;
                startMigrationPlanRequest.DataContainerNameList = (null != LegacyContainerNames)
                    ? new List<string>(LegacyContainerNames.ToList().Distinct(StringComparer.InvariantCultureIgnoreCase))
                    : new List<string>();

                var status = StorSimpleClient.StartLegacyVolumeContainerMigrationPlan(startMigrationPlanRequest);
                MigrationCommonModelFormatter opFormatter = new MigrationCommonModelFormatter();
                WriteObject(opFormatter.GetResultMessage(Resources.StartMigrationPlanSuccessMessage, status));
            }
            catch (Exception except)
            {
                this.HandleException(except);
            }
        }
 public override void ExecuteCmdlet()
 {
     try
     {
         var confirmMigrationRequest = new MigrationConfirmStatusRequest();
         confirmMigrationRequest.Operation =
             (MigrationOperation) Enum.Parse(typeof (MigrationOperation), MigrationOperation, true);
         confirmMigrationRequest.DataContainerNameList = (null != LegacyContainerNames)
             ? new List<string>(LegacyContainerNames.ToList().Distinct(StringComparer.InvariantCultureIgnoreCase))
             : new List<string>();
         var status = StorSimpleClient.ConfirmLegacyVolumeContainerStatus(LegacyConfigId, confirmMigrationRequest);
         MigrationCommonModelFormatter opFormatter = new MigrationCommonModelFormatter();
         WriteObject(opFormatter.GetResultMessage(Resources.ConfirmMigrationSuccessMessage, status));
     }
     catch (Exception except)
     {
         this.HandleException(except);
     }
 }
        /// <summary>
        /// Converts the configs in the desired formated string
        /// </summary>
        /// <returns>format content to be displayed</returns>
        public override string ToString()
        {
            try
            {
                StringBuilder consoleOutput = new StringBuilder();
                MigrationCommonModelFormatter modelBase = new MigrationCommonModelFormatter();
                int maxLength = this.GetType().GetProperties().ToList().Max(t => t.Name.Length);
                if (null != this.VolumeGroups)
                {
                    consoleOutput.Append(Resources.MigrationVolumeContainerRelatedGroupHeader).AppendLine();
                    int groupCount = 0;
                    List<List<MigrationDataContainer>> dataContainerGroupList = ComputedRelatedVolumeContainers();
                    if (null != dataContainerGroupList)
                    {
                        foreach (var dataContainerGroup in dataContainerGroupList)
                        {
                            if (null != dataContainerGroup && 0 < dataContainerGroup.Count)
                            {
                                consoleOutput.Append("\t");
                                string relatedDCNames =
                                    modelBase.ConcatStringList(dataContainerGroup.Select(dc => dc.Name).ToList());
                                string relatedDCVar =
                                    string.Format(Resources.MigrationVolumeContainerRelatedGroupSubHeader, ++groupCount);
                                consoleOutput.Append(modelBase.IntendAndConCat(relatedDCVar, relatedDCNames,
                                    Resources.MigrationVolumeContainerRelatedGroupSubHeader.Length + 1));
                                consoleOutput.AppendLine();
                            }
                        }
                    }
                    else
                    {
                        consoleOutput.AppendLine(Resources.MigrationVolumeContainerRelatedGroupingNotFound);
                    }
                }

                return consoleOutput.ToString();
            }
            catch (Exception except)
            {
                // powershell will consume the exception, and no details will be displayed if the exception is thrown, hence handling and returning error string.
                return string.Format(Resources.MigrationErrorInDisplayingDetails, except.ToString());
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Converts the configs in the desired formated string
        /// </summary>
        /// <returns>format content to be displayed</returns>
        public override string ToString()
        {
            try
            {
                StringBuilder consoleOutput             = new StringBuilder();
                MigrationCommonModelFormatter modelBase = new MigrationCommonModelFormatter();
                int maxLength = this.GetType().GetProperties().ToList().Max(t => t.Name.Length);
                if (null != this.VolumeGroups)
                {
                    consoleOutput.Append(Resources.MigrationVolumeContainerRelatedGroupHeader).AppendLine();
                    int groupCount = 0;
                    List <List <MigrationDataContainer> > dataContainerGroupList = ComputedRelatedVolumeContainers();
                    if (null != dataContainerGroupList)
                    {
                        foreach (var dataContainerGroup in dataContainerGroupList)
                        {
                            if (null != dataContainerGroup && 0 < dataContainerGroup.Count)
                            {
                                consoleOutput.Append("\t");
                                string relatedDCNames =
                                    modelBase.ConcatStringList(dataContainerGroup.Select(dc => dc.Name).ToList());
                                string relatedDCVar =
                                    string.Format(Resources.MigrationVolumeContainerRelatedGroupSubHeader, ++groupCount);
                                consoleOutput.Append(modelBase.IntendAndConCat(relatedDCVar, relatedDCNames,
                                                                               Resources.MigrationVolumeContainerRelatedGroupSubHeader.Length + 1));
                                consoleOutput.AppendLine();
                            }
                        }
                    }
                    else
                    {
                        consoleOutput.AppendLine(Resources.MigrationVolumeContainerRelatedGroupingNotFound);
                    }
                }

                return(consoleOutput.ToString());
            }
            catch (Exception except)
            {
                // powershell will consume the exception, and no details will be displayed if the exception is thrown, hence handling and returning error string.
                return(string.Format(Resources.MigrationErrorInDisplayingDetails, except.ToString()));
            }
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                var importDataContainerRequest = new MigrationImportDataContainerRequest();
                switch (ParameterSetName)
                {
                    case StorSimpleCmdletParameterSet.MigrateAllContainer:
                        {
                            importDataContainerRequest.DataContainerNames = new List<string>();
                            break;
                        }
                    case StorSimpleCmdletParameterSet.MigrateSpecificContainer:
                        {
                            importDataContainerRequest.DataContainerNames =
                                    new List<string>(LegacyContainerNames.ToList().Distinct(
                                        StringComparer.InvariantCultureIgnoreCase));
                            break;
                        }
                    default:
                        {
                            // unexpected code path.
                            throw new ParameterBindingException(
                                string.Format(Resources.MigrationParameterSetNotFound, ParameterSetName));
                        }
                }

                importDataContainerRequest.ForceOnOtherDevice = Force.IsPresent;
                importDataContainerRequest.SkipACRs = SkipACRs.IsPresent;

                var migrationJobStatus = StorSimpleClient.MigrationImportDataContainer(LegacyConfigId,
                    importDataContainerRequest);
                MigrationCommonModelFormatter opFormatter = new MigrationCommonModelFormatter();
                WriteObject(opFormatter.GetResultMessage(Resources.MigrationImportDataContainerSuccessMessage,
                    migrationJobStatus));
            }
            catch (Exception except)
            {
                this.HandleException(except);
            }
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                var confirmMigrationRequest = new MigrationConfirmStatusRequest();
                confirmMigrationRequest.Operation =
                    (MigrationOperation)Enum.Parse(typeof(MigrationOperation), MigrationOperation, true);
                switch (ParameterSetName)
                {
                    case StorSimpleCmdletParameterSet.MigrateAllContainer:
                        {
                            confirmMigrationRequest.DataContainerNameList = new List<string>();
                            break;
                        }
                    case StorSimpleCmdletParameterSet.MigrateSpecificContainer:
                        {
                            confirmMigrationRequest.DataContainerNameList =
                            new List<string>(LegacyContainerNames.ToList().Distinct(
                                StringComparer.InvariantCultureIgnoreCase));
                            break;
                        }
                    default:
                        {
                            // unexpected code path hit.
                            throw new ParameterBindingException(
                                string.Format(Resources.MigrationParameterSetNotFound, ParameterSetName));
                        }
                }

                var status = StorSimpleClient.ConfirmLegacyVolumeContainerStatus(LegacyConfigId, confirmMigrationRequest);
                MigrationCommonModelFormatter opFormatter = new MigrationCommonModelFormatter();
                WriteObject(opFormatter.GetResultMessage(Resources.ConfirmMigrationSuccessMessage, status));
            }
            catch (Exception except)
            {
                this.HandleException(except);
            }
        }