public override void ExecuteCmdlet() { IDictionary <string, string> tagPairs = null; if (Tag != null) { tagPairs = new Dictionary <string, string>(); foreach (string key in Tag.Keys) { tagPairs.Add(key, Tag[key].ToString()); } } if (ParameterSetName == ParentObjectParameterSet) { ResourceGroupName = PoolObject.ResourceGroupName; Location = PoolObject.Location; var NameParts = PoolObject.Name.Split('/'); AccountName = NameParts[0]; PoolName = NameParts[1]; } var dataProtection = new PSNetAppFilesVolumeDataProtection { Replication = ReplicationObject, Snapshot = Snapshot, Backup = Backup }; var volumeBody = new Management.NetApp.Models.Volume() { ServiceLevel = ServiceLevel, UsageThreshold = UsageThreshold, CreationToken = CreationToken, SubnetId = SubnetId, Location = Location, ExportPolicy = (ExportPolicy != null) ? ModelExtensions.ConvertExportPolicyFromPs(ExportPolicy) : null, DataProtection = (dataProtection.Replication != null) ? ModelExtensions.ConvertDataProtectionFromPs(dataProtection) : null, VolumeType = VolumeType, ProtocolTypes = ProtocolType, Tags = tagPairs, SnapshotId = SnapshotId, SnapshotDirectoryVisible = SnapshotDirectoryVisible, SecurityStyle = SecurityStyle, BackupId = BackupId, ThroughputMibps = ThroughputMibps, KerberosEnabled = KerberosEnabled }; if (ShouldProcess(Name, string.Format(PowerShell.Cmdlets.NetAppFiles.Properties.Resources.CreateResourceMessage, ResourceGroupName))) { var anfVolume = AzureNetAppFilesManagementClient.Volumes.CreateOrUpdate(volumeBody, ResourceGroupName, AccountName, PoolName, Name); WriteObject(anfVolume.ToPsNetAppFilesVolume()); } }
public static PSNetAppFilesVolumeDataProtection ConvertDataProtectionToPs(VolumePropertiesDataProtection DataProtection) { var psDataProtection = new PSNetAppFilesVolumeDataProtection(); var replication = new PSNetAppFilesReplicationObject(); // replication.ReplicationId = DataProtection.Replication.ReplicationId; replication.EndpointType = DataProtection.Replication.EndpointType; replication.ReplicationSchedule = DataProtection.Replication.ReplicationSchedule; replication.RemoteVolumeResourceId = DataProtection.Replication.RemoteVolumeResourceId; // replication.RemoteVolumeRegion = DataProtection.Replication.RemoteVolumeRegion; psDataProtection.Replication = replication; return(psDataProtection); }
public static VolumePatchPropertiesDataProtection ConvertToPatchFromPs(this PSNetAppFilesVolumeDataProtection psDataProtection) { var dataProtection = new VolumePatchPropertiesDataProtection(); if (psDataProtection.Backup != null) { var backup = new VolumeBackupProperties(); backup.BackupEnabled = psDataProtection.Backup.BackupEnabled; backup.BackupPolicyId = psDataProtection.Backup.BackupPolicyId; backup.PolicyEnforced = psDataProtection.Backup.PolicyEnforced; backup.VaultId = psDataProtection.Backup.VaultId; dataProtection.Backup = backup; } return(dataProtection); }
public static VolumePropertiesDataProtection ConvertDataProtectionFromPs(PSNetAppFilesVolumeDataProtection psDataProtection) { var dataProtection = new VolumePropertiesDataProtection(); var replication = new ReplicationObject(); // replication.ReplicationId = psDataProtection.Replication.ReplicationId; replication.EndpointType = psDataProtection.Replication.EndpointType; replication.ReplicationSchedule = psDataProtection.Replication.ReplicationSchedule; replication.RemoteVolumeResourceId = psDataProtection.Replication.RemoteVolumeResourceId; // replication.RemoteVolumeRegion = psDataProtection.Replication.RemoteVolumeRegion; dataProtection.Replication = replication; return(dataProtection); }
public static PSNetAppFilesVolumeDataProtection ConvertDataProtectionToPs(VolumePropertiesDataProtection DataProtection) { var psDataProtection = new PSNetAppFilesVolumeDataProtection(); if (DataProtection.Replication != null) { var replication = new PSNetAppFilesReplicationObject(); // replication.ReplicationId = DataProtection.Replication.ReplicationId; replication.EndpointType = DataProtection.Replication.EndpointType; replication.ReplicationSchedule = DataProtection.Replication.ReplicationSchedule; replication.RemoteVolumeResourceId = DataProtection.Replication.RemoteVolumeResourceId; // replication.RemoteVolumeRegion = DataProtection.Replication.RemoteVolumeRegion; psDataProtection.Replication = replication; } if (DataProtection.Snapshot != null) { var snapshot = new PSNetAppFilesVolumeSnapshot(); snapshot.SnapshotPolicyId = DataProtection.Snapshot.SnapshotPolicyId; } return(psDataProtection); }
public static VolumePropertiesDataProtection ConvertDataProtectionFromPs(PSNetAppFilesVolumeDataProtection psDataProtection) { var dataProtection = new VolumePropertiesDataProtection(); if (psDataProtection.Replication != null) { var replication = new ReplicationObject(); // replication.ReplicationId = psDataProtection.Replication.ReplicationId; replication.EndpointType = psDataProtection.Replication.EndpointType; replication.ReplicationSchedule = psDataProtection.Replication.ReplicationSchedule; replication.RemoteVolumeResourceId = psDataProtection.Replication.RemoteVolumeResourceId; // replication.RemoteVolumeRegion = psDataProtection.Replication.RemoteVolumeRegion; dataProtection.Replication = replication; } if (psDataProtection.Snapshot != null) { var snapshot = new VolumeSnapshotProperties(); snapshot.SnapshotPolicyId = psDataProtection.Snapshot.SnapshotPolicyId; } return(dataProtection); }
public override void ExecuteCmdlet() { IDictionary <string, string> tagPairs = null; if (Tag != null) { tagPairs = new Dictionary <string, string>(); foreach (string key in Tag.Keys) { tagPairs.Add(key, Tag[key].ToString()); } } if (ParameterSetName == ResourceIdParameterSet) { var resourceIdentifier = new ResourceIdentifier(this.ResourceId); ResourceGroupName = resourceIdentifier.ResourceGroupName; var parentResources = resourceIdentifier.ParentResource.Split('/'); AccountName = parentResources[1]; PoolName = parentResources[3]; Name = resourceIdentifier.ResourceName; } else if (ParameterSetName == ObjectParameterSet) { ResourceGroupName = InputObject.ResourceGroupName; Location = InputObject.Location; var NameParts = InputObject.Name.Split('/'); AccountName = NameParts[0]; PoolName = NameParts[1]; Name = NameParts[2]; } else if (ParameterSetName == ParentObjectParameterSet) { ResourceGroupName = PoolObject.ResourceGroupName; Location = PoolObject.Location; var NameParts = InputObject.Name.Split('/'); AccountName = NameParts[0]; PoolName = NameParts[1]; } PSNetAppFilesVolumeDataProtection dataProtection = null; if (!string.IsNullOrWhiteSpace(SnapshotPolicyId) || Backup != null) { dataProtection = new PSNetAppFilesVolumeDataProtection { Snapshot = new PSNetAppFilesVolumeSnapshot() { SnapshotPolicyId = SnapshotPolicyId }, Backup = Backup }; } var volumePatchBody = new VolumePatch() { ServiceLevel = ServiceLevel, UsageThreshold = UsageThreshold, ExportPolicy = (ExportPolicy != null) ? ModelExtensions.ConvertExportPolicyPatchFromPs(ExportPolicy) : null, Tags = tagPairs, ThroughputMibps = ThroughputMibps, DataProtection = (dataProtection != null) ? dataProtection.ConvertToPatchFromPs() : null, IsDefaultQuotaEnabled = IsDefaultQuotaEnabled, DefaultUserQuotaInKiBs = DefaultUserQuotaInKiB, DefaultGroupQuotaInKiBs = DefaultGroupQuotaInKiB }; if (ShouldProcess(Name, string.Format(PowerShell.Cmdlets.NetAppFiles.Properties.Resources.UpdateResourceMessage, ResourceGroupName))) { var anfVolume = AzureNetAppFilesManagementClient.Volumes.Update(volumePatchBody, ResourceGroupName, AccountName, PoolName, Name); WriteObject(anfVolume.ToPsNetAppFilesVolume()); } }
public override void ExecuteCmdlet() { IDictionary <string, string> tagPairs = null; if (Tag != null) { tagPairs = new Dictionary <string, string>(); foreach (string key in Tag.Keys) { tagPairs.Add(key, Tag[key].ToString()); } } if (ParameterSetName == ParentObjectParameterSet) { ResourceGroupName = PoolObject.ResourceGroupName; Location = PoolObject.Location; var NameParts = PoolObject.Name.Split('/'); AccountName = NameParts[0]; PoolName = NameParts[1]; } PSNetAppFilesVolumeDataProtection dataProtection = null; if (ReplicationObject != null || !string.IsNullOrWhiteSpace(SnapshotPolicyId) || Backup != null) { dataProtection = new PSNetAppFilesVolumeDataProtection { Replication = ReplicationObject, Snapshot = new PSNetAppFilesVolumeSnapshot() { SnapshotPolicyId = SnapshotPolicyId }, Backup = Backup }; } var volumeBody = new Management.NetApp.Models.Volume() { ServiceLevel = ServiceLevel, UsageThreshold = UsageThreshold, CreationToken = CreationToken, SubnetId = SubnetId, Location = Location, ExportPolicy = (ExportPolicy != null) ? ModelExtensions.ConvertExportPolicyFromPs(ExportPolicy) : null, DataProtection = (dataProtection != null) ? ModelExtensions.ConvertDataProtectionFromPs(dataProtection) : null, VolumeType = VolumeType, ProtocolTypes = ProtocolType, Tags = tagPairs, SnapshotId = SnapshotId, SnapshotDirectoryVisible = SnapshotDirectoryVisible, SecurityStyle = SecurityStyle, BackupId = BackupId, ThroughputMibps = ThroughputMibps, KerberosEnabled = KerberosEnabled.IsPresent, SmbEncryption = SmbEncryption, SmbContinuouslyAvailable = SmbContinuouslyAvailable, LdapEnabled = LdapEnabled, CoolAccess = CoolAccess, CoolnessPeriod = CoolnessPeriod, UnixPermissions = UnixPermissions, AvsDataStore = AvsDataStore, IsDefaultQuotaEnabled = IsDefaultQuotaEnabled, DefaultUserQuotaInKiBs = DefaultUserQuotaInKiB, DefaultGroupQuotaInKiBs = DefaultGroupQuotaInKiB, NetworkFeatures = NetworkFeature }; if (ShouldProcess(Name, string.Format(PowerShell.Cmdlets.NetAppFiles.Properties.Resources.CreateResourceMessage, ResourceGroupName))) { var anfVolume = AzureNetAppFilesManagementClient.Volumes.CreateOrUpdate(volumeBody, ResourceGroupName, AccountName, PoolName, Name); WriteObject(anfVolume.ToPsNetAppFilesVolume()); } }