Exemple #1
0
 public static PSNetAppFilesVolume ToPsNetAppFilesVolume(this Management.NetApp.Models.Volume volume)
 {
     return(new PSNetAppFilesVolume
     {
         ResourceGroupName = new ResourceIdentifier(volume.Id).ResourceGroupName,
         Location = volume.Location,
         Id = volume.Id,
         Name = volume.Name,
         Type = volume.Type,
         Tags = volume.Tags,
         ProvisioningState = volume.ProvisioningState,
         FileSystemId = volume.FileSystemId,
         ServiceLevel = volume.ServiceLevel,
         UsageThreshold = volume.UsageThreshold,
         ExportPolicy = (volume.ExportPolicy != null) ? ConvertExportPolicyToPs(volume.ExportPolicy) : null,
         ProtocolTypes = volume.ProtocolTypes,
         MountTargets = volume.MountTargets,
         SnapshotId = volume.SnapshotId,
         BaremetalTenantId = volume.BaremetalTenantId,
         SubnetId = volume.SubnetId,
         CreationToken = volume.CreationToken,
         VolumeType = volume.VolumeType,
         DataProtection = (volume.DataProtection != null) ? ConvertDataProtectionToPs(volume.DataProtection) : null,
         IsRestoring = volume.IsRestoring,
         SnapshotDirectoryVisible = volume.SnapshotDirectoryVisible,
         BackupId = volume.BackupId,
         SecurityStyle = volume.SecurityStyle,
         ThroughputMibps = volume.ThroughputMibps,
         KerberosEnabled = volume.KerberosEnabled,
         SmbEncryption = volume.SmbEncryption,
         SmbContinuouslyAvailable = volume.SmbContinuouslyAvailable,
         LdapEnabled = volume.LdapEnabled,
         CoolAccess = volume.CoolAccess,
         CoolnessPeriod = volume.CoolnessPeriod,
         UnixPermission = volume.UnixPermissions
     });
 }
        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
            };

            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());
            }
        }