private bool ProcessParameters()
        {
            deviceId = StorSimpleClient.GetDeviceId(DeviceName);

            if (deviceId == null)
            {
                throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
            }
            switch (ParameterSetName)
            {
            case StorSimpleCmdletParameterSet.IdentifyById:
                if (string.IsNullOrEmpty(BackupId))
                {
                    throw new ArgumentException(Resources.InvalidBackupIdParameter);
                }
                else
                {
                    finalBackupId = BackupId;
                }
                break;

            case StorSimpleCmdletParameterSet.IdentifyByObject:
                if (Backup == null || string.IsNullOrEmpty(Backup.InstanceId))
                {
                    throw new ArgumentException(Resources.InvalidBackupObjectParameter);
                }
                else
                {
                    finalBackupId = Backup.InstanceId;
                }
                break;
            }
            return(true);
        }
        private bool ProcessParameters()
        {
            switch (ParameterSetName)
            {
            case StorSimpleCmdletParameterSet.IdentifyById:
                this.sourceDeviceId = SourceDeviceId;
                this.targetDeviceId = TargetDeviceId;
                break;

            case StorSimpleCmdletParameterSet.IdentifyByName:
                this.sourceDeviceId = StorSimpleClient.GetDeviceId(SourceDeviceName);

                if (this.sourceDeviceId == null)
                {
                    throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, SourceDeviceName));
                }

                this.targetDeviceId = StorSimpleClient.GetDeviceId(TargetDeviceName);

                if (this.targetDeviceId == null)
                {
                    throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, TargetDeviceName));
                }
                break;
            }

            return(true);
        }
        private void ProcessParameters()
        {
            deviceId = StorSimpleClient.GetDeviceId(DeviceName);

            if (deviceId == null)
            {
                throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
            }
        }
예제 #4
0
        private void ProcessParameters()
        {
            deviceId = StorSimpleClient.GetDeviceId(DeviceName);

            if (deviceId == null)
            {
                WriteVerbose(Resources.NotFoundMessageDevice);
            }
        }
        public override void ExecuteCmdlet()
        {
            ConfirmAction(Force.IsPresent,
                          Resources.RemoveWarningVolume,
                          Resources.RemoveConfirmationVolume,
                          string.Empty,
                          () =>
            {
                try
                {
                    var deviceid = StorSimpleClient.GetDeviceId(DeviceName);

                    if (deviceid == null)
                    {
                        WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                        WriteObject(null);
                        return;
                    }

                    string volumeId = string.Empty;
                    switch (ParameterSetName)
                    {
                    case StorSimpleCmdletParameterSet.IdentifyByObject:
                        volumeId = Volume.InstanceId;
                        break;

                    case StorSimpleCmdletParameterSet.IdentifyByName:
                        var volumeInfo = StorSimpleClient.GetVolumeByName(deviceid, VolumeName);
                        if (volumeInfo == null)
                        {
                            WriteVerbose(Resources.NotFoundMessageVirtualDisk);
                            return;
                        }
                        volumeId = volumeInfo.VirtualDiskInfo.InstanceId;
                        break;
                    }

                    if (WaitForComplete.IsPresent)
                    {
                        WriteVerbose("About to run a task to remove your volume!");
                        var taskstatus = StorSimpleClient.RemoveVolume(deviceid, volumeId);
                        HandleSyncTaskResponse(taskstatus, "delete");
                    }
                    else
                    {
                        WriteVerbose("About to run a task to remove your volume!");
                        var taskresponse = StorSimpleClient.RemoveVolumeAsync(deviceid, volumeId);
                        HandleAsyncTaskResponse(taskresponse, "delete");
                    }
                }
                catch (Exception exception)
                {
                    this.HandleException(exception);
                }
            });
        }
예제 #6
0
        public override void ExecuteCmdlet()
        {
            try
            {
                var deviceId = StorSimpleClient.GetDeviceId(DeviceName);
                if (deviceId == null)
                {
                    WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                    WriteObject(null);
                    return;
                }

                VirtualDisk diskDetails = StorSimpleClient.GetVolumeByName(deviceId, VolumeName).VirtualDiskInfo;
                if (diskDetails == null)
                {
                    WriteVerbose(Resources.NotFoundMessageVirtualDisk);
                    WriteObject(null);
                    return;
                }

                if (Online != null)
                {
                    diskDetails.Online = Online.GetValueOrDefault();
                }
                if (VolumeSizeInBytes != null)
                {
                    diskDetails.SizeInBytes = VolumeSizeInBytes.GetValueOrDefault();
                }
                if (VolumeAppType != null)
                {
                    diskDetails.AppType = VolumeAppType.GetValueOrDefault();
                }
                if (AccessControlRecords != null)
                {
                    diskDetails.AcrList = AccessControlRecords;
                }

                if (WaitForComplete.IsPresent)
                {
                    var taskstatus = StorSimpleClient.UpdateVolume(deviceId, diskDetails.InstanceId, diskDetails);
                    HandleSyncTaskResponse(taskstatus, "update");
                    var updatedVolume = StorSimpleClient.GetVolumeByName(deviceId, VolumeName);
                    WriteObject(updatedVolume.VirtualDiskInfo);
                }
                else
                {
                    var taskresult = StorSimpleClient.UpdateVolumeAsync(deviceId, diskDetails.InstanceId, diskDetails);

                    HandleAsyncTaskResponse(taskresult, "update");
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
        private bool ProcessParameters()
        {
            deviceId = StorSimpleClient.GetDeviceId(DeviceName);

            if (deviceId == null)
            {
                WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                WriteObject(null);
                return(false);
            }
            return(true);
        }
예제 #8
0
        private bool ProcessParameters()
        {
            deviceId = StorSimpleClient.GetDeviceId(DeviceName);

            if (deviceId == null)
            {
                throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
            }

            ProcessAddSchedules();
            ProcessAddVolumeIds();
            return(true);
        }
예제 #9
0
        public override void ExecuteCmdlet()
        {
            try
            {
                WriteVerbose(string.Format(Resources.MigrationMsgQueringDeviceId, TargetDeviceName));
                string deviceid = StorSimpleClient.GetDeviceId(TargetDeviceName);
                if (!File.Exists(ConfigFilePath))
                {
                    throw new FileNotFoundException(String.Format(Resources.MigrationConfigFileNotFound,
                                                                  StorSimpleContext.ResourceName, ConfigFilePath));
                }
                else if (string.IsNullOrEmpty(deviceid))
                {
                    throw new ArgumentException(String.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage,
                                                              StorSimpleContext.ResourceName, TargetDeviceName));
                }
                else
                {
                    // creating the config file parser instance - parser decrypt the xml and parses the config xml
                    WriteVerbose(string.Format(Resources.MigrationMsgDeviceFound, deviceid));
                    var secretsEncryptor        = new ServiceSecretEncryptor(this.StorSimpleClient);
                    var parser                  = new LegacyApplianceConfigParser(secretsEncryptor);
                    var legacyApplianceMetaData = new LegacyApplianceConfiguration();

                    legacyApplianceMetaData.Details = parser.ParseLegacyApplianceConfig(ConfigFilePath,
                                                                                        ConfigDecryptionKey);
                    LegacyApplianceConfig config = legacyApplianceMetaData.Details;
                    legacyApplianceMetaData.LegacyConfigId = Guid.NewGuid().ToString();
                    config.InstanceId = config.Name = legacyApplianceMetaData.LegacyConfigId;
                    legacyApplianceMetaData.ConfigFile          = ConfigFilePath;
                    legacyApplianceMetaData.ImportedOn          = DateTime.Now;
                    legacyApplianceMetaData.TargetApplianceName = TargetDeviceName;
                    config.DeviceId = deviceid;

                    legacyApplianceMetaData.Result = Resources.ImportLegacyApplianceConfigSuccessMessage;
                    WriteVerbose(Resources.MigrationMsgUploadingConfig);
                    var configList = ConfigSplitHelper.Split(legacyApplianceMetaData.Details);
                    foreach (var singleConfig in configList)
                    {
                        StorSimpleClient.ImportLegacyApplianceConfig(legacyApplianceMetaData.LegacyConfigId,
                                                                     singleConfig);
                    }

                    WriteObject(legacyApplianceMetaData);
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                string deviceid = null;
                deviceid = StorSimpleClient.GetDeviceId(DeviceName);

                if (deviceid == null)
                {
                    WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                    WriteObject(null);
                    return;
                }

                //Virtual disk create request object
                var virtualDiskToCreate = new VirtualDiskRequest()
                {
                    Name                   = VolumeName,
                    AccessType             = AccessType.ReadWrite,
                    AcrList                = AccessControlRecords,
                    AppType                = VolumeAppType,
                    IsDefaultBackupEnabled = EnableDefaultBackup,
                    SizeInBytes            = VolumeSizeInBytes,
                    DataContainer          = VolumeContainer,
                    Online                 = Online,
                    IsMonitoringEnabled    = EnableMonitoring
                };

                if (WaitForComplete.IsPresent)
                {
                    var taskStatus = StorSimpleClient.CreateVolume(deviceid, virtualDiskToCreate);;
                    HandleSyncTaskResponse(taskStatus, "create");
                    if (taskStatus.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded)
                    {
                        var createdVolume = StorSimpleClient.GetVolumeByName(deviceid, VolumeName);
                        WriteObject(createdVolume.VirtualDiskInfo);
                    }
                }

                else
                {
                    var taskstatus = StorSimpleClient.CreateVolumeAsync(deviceid, virtualDiskToCreate);;
                    HandleAsyncTaskResponse(taskstatus, "create");
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                string deviceid = null;

                switch (ParameterSetName)
                {
                case StorSimpleCmdletParameterSet.IdentifyById:
                    if (StorSimpleClient.IsValidDeviceId(DeviceId))
                    {
                        deviceid = DeviceId;
                    }
                    else
                    {
                        throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenIdInResourceMessage, StorSimpleContext.ResourceName, DeviceId));
                    }
                    break;

                case StorSimpleCmdletParameterSet.IdentifyByName:
                    deviceid = StorSimpleClient.GetDeviceId(DeviceName);
                    if (deviceid == null)
                    {
                        throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                    }
                    break;

                default:
                    break;
                }

                if (string.IsNullOrEmpty(deviceid))
                {
                    WriteObject(null);
                    return;
                }

                var dcgroupList = StorSimpleClient.GetFaileoverDataContainerGroups(deviceid).DataContainerGroupResponse.DCGroups;
                WriteObject(dcgroupList);
                WriteVerbose(string.Format(Resources.ReturnedCountDataContainerGroupMessage,
                                           dcgroupList.Count,
                                           dcgroupList.Count > 1 ? "s" : string.Empty));
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
예제 #12
0
        public override void ExecuteCmdlet()
        {
            try
            {
                var deviceId = StorSimpleClient.GetDeviceId(DeviceName);
                if (deviceId == null)
                {
                    WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                    WriteObject(null);
                    return;
                }

                switch (ParameterSetName)
                {
                case StorSimpleCmdletParameterSet.IdentifyByParentObject:
                    var volumeInfoList = StorSimpleClient.GetAllVolumesFordataContainer(deviceId, VolumeContainer.InstanceId);
                    WriteObject(volumeInfoList.ListofVirtualDisks);
                    WriteVerbose(string.Format(Resources.ReturnedCountVolumeMessage, volumeInfoList.ListofVirtualDisks.Count, volumeInfoList.ListofVirtualDisks.Count > 1 ? "s" : string.Empty));
                    break;

                case StorSimpleCmdletParameterSet.IdentifyByName:
                    var volumeInfo = StorSimpleClient.GetVolumeByName(deviceId, VolumeName);
                    if (volumeInfo != null &&
                        volumeInfo.VirtualDiskInfo != null &&
                        volumeInfo.VirtualDiskInfo.InstanceId != null)
                    {
                        WriteObject(volumeInfo.VirtualDiskInfo);
                        WriteVerbose(string.Format(Resources.FoundVolumeMessage, VolumeName));
                    }
                    else
                    {
                        WriteVerbose(string.Format(Resources.NotFoundVolumeMessage, VolumeName));
                    }
                    break;
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                var deviceid = StorSimpleClient.GetDeviceId(DeviceName);

                if (deviceid == null)
                {
                    WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                    WriteObject(null);
                    return;
                }

                if (VolumeContainerName == null)
                {
                    var dataContainerList = StorSimpleClient.GetAllDataContainers(deviceid);
                    WriteObject(dataContainerList.DataContainers);
                    WriteVerbose(string.Format(Resources.ReturnedCountDataContainerMessage, dataContainerList.DataContainers.Count, dataContainerList.DataContainers.Count > 1 ? "s" : string.Empty));
                }
                else
                {
                    var dataContainer = StorSimpleClient.GetDataContainer(deviceid, VolumeContainerName);
                    if (dataContainer != null &&
                        dataContainer.DataContainerInfo != null &&
                        dataContainer.DataContainerInfo.InstanceId != null)
                    {
                        WriteObject(dataContainer.DataContainerInfo);
                        WriteVerbose(string.Format(Resources.FoundDataContainerMessage, VolumeContainerName));
                    }
                    else
                    {
                        WriteVerbose(string.Format(Resources.NotFoundDataContainerMessage, VolumeContainerName));
                    }
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
예제 #14
0
        private bool ProcessParameters()
        {
            deviceId = StorSimpleClient.GetDeviceId(DeviceName);

            if (deviceId == null)
            {
                WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                WriteObject(null);
                return(false);
            }
            switch (ParameterSetName)
            {
            case StorSimpleCmdletParameterSet.IdentifyById:
                Guid backuppolicyIdGuid;
                bool isIdValidGuid = Guid.TryParse(BackupPolicyId, out backuppolicyIdGuid);
                if (string.IsNullOrEmpty(BackupPolicyId) ||
                    !isIdValidGuid)
                {
                    throw new ArgumentException(Resources.InvalidBackupPolicyIdParameter);
                }
                else
                {
                    backupPolicyIdFinal = BackupPolicyId;
                }
                break;

            case StorSimpleCmdletParameterSet.IdentifyByObject:
                if (BackupPolicy == null || string.IsNullOrEmpty(BackupPolicy.InstanceId))
                {
                    throw new ArgumentException(Resources.InvalidBackupPolicyObjectParameter);
                }
                else
                {
                    backupPolicyIdFinal = BackupPolicy.InstanceId;
                }
                break;
            }
            return(true);
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                ValidateParams();

                // Make sure we have a device for supplied name and get its device id.
                var deviceId = StorSimpleClient.GetDeviceId(DeviceName);
                if (deviceId == null)
                {
                    throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                }

                // Get the current device details. ( If we found id from the name, this call is bound to succeed)
                var deviceDetails = StorSimpleClient.GetDeviceDetails(deviceId);

                // The cik also needs to be sent to the service.
                string cik = EncryptionCmdLetHelper.RetrieveCIK(this, StorSimpleContext.ResourceId);

                // Update device details.
                var cryptoManager = new StorSimpleCryptoManager(StorSimpleClient);
                StorSimpleClient.UpdateVirtualDeviceDetails(deviceDetails, TimeZone, SecretKey, AdministratorPassword, SnapshotManagerPassword, cik, cryptoManager);

                // Make request with updated data
                WriteVerbose(string.Format(Resources.BeginningDeviceConfiguration, deviceDetails.DeviceProperties.FriendlyName));
                var taskStatusInfo = StorSimpleClient.UpdateDeviceDetails(deviceDetails);
                HandleSyncTaskResponse(taskStatusInfo, "Setup");
                if (taskStatusInfo.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded)
                {
                    var updatedDetails = StorSimpleClient.GetDeviceDetails(deviceId);
                    WriteObject(updatedDetails);
                    WriteVerbose(string.Format(Resources.StorSimpleDeviceUpdatedSuccessfully, updatedDetails.DeviceProperties.FriendlyName, updatedDetails.DeviceProperties.DeviceId));
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
예제 #16
0
        public override void ExecuteCmdlet()
        {
            ConfirmAction(Force.IsPresent,
                          Resources.RemoveWarningVolume,
                          Resources.RemoveConfirmationVolume,
                          string.Empty,
                          () =>
            {
                try
                {
                    var deviceid = StorSimpleClient.GetDeviceId(DeviceName);

                    if (deviceid == null)
                    {
                        WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                        WriteObject(null);
                        return;
                    }

                    if (WaitForComplete.IsPresent)
                    {
                        WriteVerbose("About to run a task to remove your Volume container!");
                        var taskstatusInfo = StorSimpleClient.DeleteDataContainer(deviceid, VolumeContainer.InstanceId);
                        HandleSyncTaskResponse(taskstatusInfo, "delete");
                    }
                    else
                    {
                        WriteVerbose("About to create a task to remove your Volume container!");
                        var taskresult = StorSimpleClient.DeleteDataContainerAsync(deviceid, VolumeContainer.InstanceId);
                        HandleAsyncTaskResponse(taskresult, "delete");
                    }
                }
                catch (Exception exception)
                {
                    this.HandleException(exception);
                }
            });
        }
        private void ProcessParameters()
        {
            // Default values for first and skip are 0
            First = First ?? 0;

            Skip = Skip ?? 0;

            // Need to use xml convert because we want ISO 8601 formatting - which is a mandatory requirement from the backend.
            fromDateTimeIsoString = From.HasValue ? XmlConvert.ToString(From.Value) : null;

            toDateTimeIsoString = To.HasValue ? XmlConvert.ToString(To.Value) : null;

            deviceId = null;

            if (DeviceName != null)
            {
                deviceId = StorSimpleClient.GetDeviceId(DeviceName);
                if (deviceId == null)
                {
                    throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                }
            }
        }
        private void ProcessParameters()
        {
            // Make sure that atleast one of the settings has been provided.
            // Its no use making a request when the user didnt specify any of
            // the settings.
            if (string.IsNullOrEmpty(NewName) && TimeZone == null &&
                string.IsNullOrEmpty(SecondaryDnsServer) &&
                (StorSimpleNetworkConfig == null || StorSimpleNetworkConfig.Count() < 1))
            {
                throw new ArgumentException(Resources.SetAzureStorSimpleDeviceNoSettingsProvided);
            }

            // Make sure that the DeviceId property has the appropriate value irrespective of the parameter set
            if (ParameterSetName == StorSimpleCmdletParameterSet.IdentifyByName)
            {
                var deviceId = StorSimpleClient.GetDeviceId(DeviceName);
                if (deviceId == null)
                {
                    throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                }
                DeviceId = deviceId;
            }
            TrySetIPAddress(SecondaryDnsServer, out secondaryDnsServer, "SecondaryDnsServer");
        }
예제 #19
0
        private void ProcessParameters()
        {
            deviceId = StorSimpleClient.GetDeviceId(DeviceName);

            if (deviceId == null)
            {
                throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
            }

            BackupType backupTypeSelected = Management.StorSimple.Models.BackupType.Invalid;

            switch (ParameterSetName)
            {
            case StorSimpleCmdletParameterSet.Empty:
                backupTypeSelected = Microsoft.WindowsAzure.Management.StorSimple.Models.BackupType.LocalSnapshot;
                break;

            case PARAMETERSET_BACKUPTYPE:
                backupTypeSelected = (BackupType)Enum.Parse(typeof(BackupType), BackupType);
                break;
            }
            backupNowRequest      = new BackupNowRequest();
            backupNowRequest.Type = backupTypeSelected;
        }
예제 #20
0
        private void ProcessParameters()
        {
            deviceId = StorSimpleClient.GetDeviceId(DeviceName);

            if (deviceId == null)
            {
                WriteVerbose(Resources.NotFoundMessageDevice);
            }

            BackupType backupTypeSelected = Management.StorSimple.Models.BackupType.Invalid;

            switch (ParameterSetName)
            {
            case StorSimpleCmdletParameterSet.Empty:
                backupTypeSelected = Microsoft.WindowsAzure.Management.StorSimple.Models.BackupType.LocalSnapshot;
                break;

            case PARAMETERSET_BACKUPTYPE:
                backupTypeSelected = (BackupType)Enum.Parse(typeof(BackupType), BackupType);
                break;
            }
            backupNowRequest      = new BackupNowRequest();
            backupNowRequest.Type = backupTypeSelected;
        }
예제 #21
0
        public override void ExecuteCmdlet()
        {
            try
            {
                string deviceid = StorSimpleClient.GetDeviceId(DeviceName);
                if (deviceid == null)
                {
                    WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                    WriteObject(null);
                    return;
                }

                if (EncryptionEnabled == true && string.IsNullOrEmpty(EncryptionKey))
                {
                    throw new ArgumentNullException("EncryptionKey");
                }

                string encryptedKey = null;
                StorSimpleCryptoManager storSimpleCryptoManager = new StorSimpleCryptoManager(StorSimpleClient);
                if (EncryptionEnabled == true)
                {
                    WriteVerbose(Resources.EncryptionInProgressMessage);
                    storSimpleCryptoManager.EncryptSecretWithRakPub(EncryptionKey, out encryptedKey);
                }

                if (string.IsNullOrEmpty(PrimaryStorageAccountCredential.InstanceId))
                {
                    //The SAC needs to be created inline
                    WriteVerbose(Resources.InlineSacCreationMessage);

                    var sac = PrimaryStorageAccountCredential;

                    //validate storage account credentials
                    bool   storageAccountPresent;
                    string encryptedPassword;
                    string thumbprint;
                    string endpoint = GetEndpointFromHostname(sac.Hostname);
                    string location = GetStorageAccountLocation(sac.Name, out storageAccountPresent);
                    if (!storageAccountPresent ||
                        !ValidateAndEncryptStorageCred(sac.Name, sac.Password, endpoint, out encryptedPassword, out thumbprint))
                    {
                        return;
                    }

                    sac.Password = encryptedPassword;
                    sac.PasswordEncryptionCertThumbprint = thumbprint;
                    sac.Location = location;
                }

                var dc = new DataContainerRequest
                {
                    IsDefault                       = false,
                    Name                            = VolumeContainerName,
                    BandwidthRate                   = BandWidthRateInMbps,
                    IsEncryptionEnabled             = EncryptionEnabled ?? false,
                    EncryptionKey                   = encryptedKey,
                    VolumeCount                     = 0,
                    PrimaryStorageAccountCredential = PrimaryStorageAccountCredential,
                    SecretsEncryptionThumbprint     = storSimpleCryptoManager.GetSecretsEncryptionThumbprint()
                };

                if (WaitForComplete.IsPresent)
                {
                    var taskStatus = StorSimpleClient.CreateDataContainer(deviceid, dc);
                    HandleSyncTaskResponse(taskStatus, "create");
                    if (taskStatus.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded)
                    {
                        var createdDataContainer = StorSimpleClient.GetDataContainer(deviceid, VolumeContainerName);
                        WriteObject(createdDataContainer.DataContainerInfo);
                    }
                }

                else
                {
                    var taskstatus = StorSimpleClient.CreateDataContainerAsync(deviceid, dc);
                    HandleAsyncTaskResponse(taskstatus, "create");
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
예제 #22
0
        private bool ProcessParameters()
        {
            deviceId = StorSimpleClient.GetDeviceId(DeviceName);

            if (deviceId == null)
            {
                WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                WriteObject(null);
                return(false);
            }

            if (string.IsNullOrEmpty(From))
            {
                FromDateTime = DateTime.MinValue;
            }
            else
            {
                bool result = DateTime.TryParse(From, out FromDateTime);
                if (!result)
                {
                    throw new ArgumentException(Resources.InvalidFromMessage);
                }
            }
            if (string.IsNullOrEmpty(To))
            {
                ToDateTime = DateTime.MaxValue;
            }
            else
            {
                bool result = DateTime.TryParse(To, out ToDateTime);
                if (!result)
                {
                    throw new ArgumentException(Resources.InvalidFromMessage);
                }
            }

            switch (ParameterSetName)
            {
            case StorSimpleCmdletParameterSet.IdentifyById:
                filterType    = "BackupPolicy";
                isAllSelected = Boolean.FalseString;
                IdToPass      = BackupPolicyId;
                break;

            case StorSimpleCmdletParameterSet.IdentifyById2:
                filterType    = "Volume";
                isAllSelected = Boolean.FalseString;
                IdToPass      = VolumeId;
                break;

            case StorSimpleCmdletParameterSet.IdentifyByObject:
                filterType    = "BackupPolicy";
                isAllSelected = Boolean.FalseString;
                IdToPass      = BackupPolicy.InstanceId;
                break;

            case StorSimpleCmdletParameterSet.IdentifyByObject2:
                filterType    = "Volume";
                isAllSelected = Boolean.FalseString;
                IdToPass      = Volume.InstanceId;
                break;

            default:
                //case where only deviceName is passed
                filterType    = "BackupPolicy";
                isAllSelected = Boolean.TrueString;
                IdToPass      = null;
                break;
            }
            return(true);
        }
예제 #23
0
        public override void ExecuteCmdlet()
        {
            try
            {
                string sourceDeviceIdentifierInMessage = string.IsNullOrEmpty(DeviceName) ? DeviceId : DeviceName;
                string targetDeviceIdentifierInMessage = string.IsNullOrEmpty(TargetDeviceName) ? TargetDeviceId : TargetDeviceName;
                ConfirmAction(
                    Force.IsPresent,
                    string.Format(Resources.StartDeviceFailoverJobWarningMessage, sourceDeviceIdentifierInMessage, targetDeviceIdentifierInMessage),
                    string.Format(Resources.StartDeviceFailoverJobMessage, sourceDeviceIdentifierInMessage, targetDeviceIdentifierInMessage),
                    string.Empty,
                    () =>
                {
                    string deviceId       = null;
                    string targetDeviceId = null;

                    switch (ParameterSetName)
                    {
                    case StorSimpleCmdletParameterSet.IdentifyById:
                        deviceId       = DeviceId;
                        targetDeviceId = TargetDeviceId;
                        break;

                    case StorSimpleCmdletParameterSet.IdentifyByName:
                        deviceId       = StorSimpleClient.GetDeviceId(DeviceName);
                        targetDeviceId = StorSimpleClient.GetDeviceId(TargetDeviceName);
                        if (deviceId == null)
                        {
                            throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                        }
                        if (targetDeviceId == null)
                        {
                            throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, TargetDeviceName));
                        }
                        break;

                    default:
                        break;
                    }

                    if (string.IsNullOrEmpty(deviceId) || string.IsNullOrEmpty(targetDeviceId))
                    {
                        WriteObject(null);
                        return;
                    }

                    if (!ValidTargetDeviceForFailover(deviceId, targetDeviceId))
                    {
                        WriteObject(null);
                        return;
                    }

                    var vcIdList = StorSimpleClient.GetVcIdListFromVcGroups(VolumecontainerGroups);

                    var drRequest = new DeviceFailoverRequest()
                    {
                        DataContainerIds = vcIdList,
                        TargetDeviceId   = targetDeviceId,
                        CleanupPrimary   = true,
                        ReturnWorkflowId = true
                    };

                    var jobResponse = StorSimpleClient.TriggerFailover(deviceId, drRequest);
                    HandleDeviceJobResponse(jobResponse, "start");
                });
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
예제 #24
0
        public override void ExecuteCmdlet()
        {
            try
            {
                var deviceId = StorSimpleClient.GetDeviceId(DeviceName);
                if (deviceId == null)
                {
                    throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                }

                VirtualDisk diskDetails = null;

                switch (ParameterSetName)
                {
                case StorSimpleCmdletParameterSet.IdentifyByObject:
                    diskDetails = Volume;
                    break;

                case StorSimpleCmdletParameterSet.IdentifyByName:
                    diskDetails = StorSimpleClient.GetVolumeByName(deviceId, VolumeName).VirtualDiskInfo;
                    break;

                default:
                    break;
                }

                if (diskDetails == null)
                {
                    throw new ArgumentException(Resources.NotFoundMessageVirtualDisk);
                }

                if (Online != null)
                {
                    diskDetails.Online = Online.GetValueOrDefault();
                }
                if (VolumeSizeInBytes != null)
                {
                    diskDetails.SizeInBytes = VolumeSizeInBytes.GetValueOrDefault();
                }
                if (VolumeAppType != null)
                {
                    diskDetails.AppType = VolumeAppType.GetValueOrDefault();
                }
                if (AccessControlRecords != null)
                {
                    diskDetails.AcrList = AccessControlRecords;
                }

                if (!string.IsNullOrWhiteSpace(NewName))
                {
                    diskDetails.Name = NewName;
                }

                if (WaitForComplete.IsPresent)
                {
                    var taskstatus = StorSimpleClient.UpdateVolume(deviceId, diskDetails.InstanceId, diskDetails);
                    HandleSyncTaskResponse(taskstatus, "update");
                    var updatedVolume = StorSimpleClient.GetVolumeByName(deviceId, diskDetails.Name);
                    WriteObject(updatedVolume.VirtualDiskInfo);
                }
                else
                {
                    var taskresult = StorSimpleClient.UpdateVolumeAsync(deviceId, diskDetails.InstanceId, diskDetails);

                    HandleAsyncTaskResponse(taskresult, "update");
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }