public override void ExecuteCmdlet() { try { var deviceInfos = StorSimpleClient.GetAllDevices(); switch (ParameterSetName) { case StorSimpleCmdletParameterSet.IdentifyByName: deviceInfos = deviceInfos.Where(x => x.FriendlyName.Equals(DeviceName, System.StringComparison.InvariantCultureIgnoreCase)); break; case StorSimpleCmdletParameterSet.IdentifyById: deviceInfos = deviceInfos.Where(x => x.DeviceId.Equals(DeviceId, System.StringComparison.InvariantCultureIgnoreCase)); break; default: break; } if (Type != null) { DeviceType deviceType; bool parseSuccess = Enum.TryParse(Type, true, out deviceType); if (parseSuccess) { deviceInfos = deviceInfos.Where(x => x.Type.Equals(deviceType)); } } if (ModelID != null) { deviceInfos = deviceInfos.Where(x => x.ModelDescription.Equals(ModelID, System.StringComparison.InvariantCultureIgnoreCase)); } if (Detailed.IsPresent) { List <DeviceDetails> deviceDetailsList = new List <DeviceDetails>(); foreach (var deviceInfo in deviceInfos) { deviceDetailsList.Add(StorSimpleClient.GetDeviceDetails(deviceInfo.DeviceId)); } WriteObject(deviceDetailsList, true); } else { WriteObject(deviceInfos, true); } WriteVerbose(string.Format(Resources.DeviceGet_StatusMessage, deviceInfos.Count(), deviceInfos.Count() > 1 ? "s" : string.Empty)); } catch (Exception exception) { this.HandleException(exception); } }
public override void ExecuteCmdlet() { try { // Make sure params were supplied appropriately. ProcessParameters(); // Get the current device details. var deviceDetails = StorSimpleClient.GetDeviceDetails(DeviceId); if (deviceDetails == null) { throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenIdInResourceMessage, StorSimpleContext.ResourceName, DeviceId)); } // If the device is being configured for the first time, validate that mandatory params // for first setup have been provided if (!deviceDetails.DeviceProperties.IsConfigUpdated && !ValidParamsForFirstDeviceConfiguration(StorSimpleNetworkConfig, TimeZone, SecondaryDnsServer)) { throw new ArgumentException(Resources.MandatoryParamsMissingForInitialDeviceConfiguration); } // Validate Network configs - this method throws an exception if any validation fails ValidateNetworkConfigs(deviceDetails, StorSimpleNetworkConfig); WriteVerbose(string.Format(Resources.BeginningDeviceConfiguration, deviceDetails.DeviceProperties.FriendlyName)); // Update device details objects with the details provided to the cmdlet // and make request with updated data var taskStatusInfo = StorSimpleClient.UpdateDeviceDetails(deviceDetails, this.NewName, this.TimeZone, this.secondaryDnsServer, this.StorSimpleNetworkConfig); HandleSyncTaskResponse(taskStatusInfo, "Setup"); if (taskStatusInfo.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded) { var updatedDetails = StorSimpleClient.GetDeviceDetails(DeviceId.ToString()); WriteObject(updatedDetails); WriteVerbose(string.Format(Resources.StorSimpleDeviceUpdatedSuccessfully, updatedDetails.DeviceProperties.FriendlyName, updatedDetails.DeviceProperties.DeviceId)); } } catch (Exception exception) { this.HandleException(exception); } }
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); } }