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; dataProtection.Snapshot = snapshot; } if (psDataProtection.Backup != null) { var backup = new VolumeBackupProperties(); backup.BackupEnabled = psDataProtection.Backup.BackupEnabled; backup.BackupPolicyId = psDataProtection.Backup.BackupPolicyId; backup.PolicyEnforced = psDataProtection.Backup.PolicyEnforced; dataProtection.Backup = backup; } 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; psDataProtection.Snapshot = snapshot; } if (DataProtection.Backup != null) { var psBackupProps = new PSNetAppFilesVolumeBackupProperties() { BackupEnabled = DataProtection.Backup.BackupEnabled, BackupPolicyId = DataProtection.Backup.BackupPolicyId, PolicyEnforced = DataProtection.Backup.PolicyEnforced, VaultId = DataProtection.Backup.VaultId }; psDataProtection.Backup = psBackupProps; } return(psDataProtection); }
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 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 Volume CreateDpVolume(AzureNetAppFilesManagementClient netAppMgmtClient, Volume sourceVolume, string volumeName = volumeName1ReplDest, string poolName = remotePoolName1, string accountName = remoteAccountName1, string resourceGroup = remoteResourceGroup, string location = location, List <string> protocolTypes = null, IDictionary <string, string> tags = default(IDictionary <string, string>), VolumePropertiesExportPolicy exportPolicy = null, bool volumeOnly = false, string snapshotId = null) { if (!volumeOnly) { CreatePool(netAppMgmtClient, poolName, accountName, resourceGroup: resourceGroup, location: remoteLocation); } var defaultProtocolType = new List <string>() { "NFSv3" }; var volumeProtocolTypes = protocolTypes == null ? defaultProtocolType : protocolTypes; var replication = new ReplicationObject { EndpointType = "dst", RemoteVolumeResourceId = sourceVolume.Id, ReplicationSchedule = "_10minutely" }; var dataProtection = new VolumePropertiesDataProtection { Replication = replication }; var volume = new Volume { Location = remoteLocation, UsageThreshold = 100 * gibibyte, ProtocolTypes = volumeProtocolTypes, CreationToken = volumeName, //SubnetId = "/subscriptions/" + subsId + "/resourceGroups/" + resourceGroup + "/providers/Microsoft.Network/virtualNetworks/" + remoteVnet + "/subnets/default", SubnetId = "/subscriptions/" + netAppMgmtClient.SubscriptionId + "/resourceGroups/" + resourceGroup + "/providers/Microsoft.Network/virtualNetworks/" + remoteVnet + "/subnets/default", Tags = tags, ExportPolicy = exportPolicy, SnapshotId = snapshotId, VolumeType = "DataProtection", DataProtection = dataProtection }; var resource = netAppMgmtClient.Volumes.CreateOrUpdate(volume, resourceGroup, accountName, poolName, volumeName); Assert.Equal(resource.Name, accountName + '/' + poolName + '/' + volumeName); if (Environment.GetEnvironmentVariable("AZURE_TEST_MODE") == "Record") { Thread.Sleep(delay); // some robustness against ARM caching } return(resource); }
public static Volume CreateVolume(AzureNetAppFilesManagementClient netAppMgmtClient, string volumeName = volumeName1, string poolName = poolName1, string accountName = accountName1, string resourceGroup = resourceGroup, string location = location, List <string> protocolTypes = null, IDictionary <string, string> tags = default(IDictionary <string, string>), VolumePropertiesExportPolicy exportPolicy = null, string vnet = vnet, bool volumeOnly = false, string snapshotId = null, string snapshotPolicyId = null, string backupVnetLocation = "", long poolSize = 4398046511104, string enableSubvolumes = EnableSubvolumes.Disabled) { if (!volumeOnly) { CreatePool(netAppMgmtClient, poolName, accountName, resourceGroup: resourceGroup, location: location, poolSize: poolSize); } var defaultProtocolType = new List <string>() { "NFSv3" }; var volumeProtocolTypes = protocolTypes == null ? defaultProtocolType : protocolTypes; var volume = new Volume { Location = location, UsageThreshold = 100 * gibibyte, ProtocolTypes = volumeProtocolTypes, CreationToken = volumeName, SubnetId = "/subscriptions/" + netAppMgmtClient.SubscriptionId + "/resourceGroups/" + resourceGroup + "/providers/Microsoft.Network/virtualNetworks/" + vnet + "/subnets/default", Tags = tags, ExportPolicy = exportPolicy, SnapshotId = snapshotId, SecurityStyle = "unix", EnableSubvolumes = enableSubvolumes }; if (snapshotPolicyId != null) { var volumDataProtection = new VolumePropertiesDataProtection { Snapshot = new VolumeSnapshotProperties(snapshotPolicyId) }; volume.DataProtection = volumDataProtection; } var resource = netAppMgmtClient.Volumes.CreateOrUpdate(volume, resourceGroup, accountName, poolName, volumeName); Assert.Equal(resource.Name, accountName + '/' + poolName + '/' + volumeName); if (Environment.GetEnvironmentVariable("AZURE_TEST_MODE") == "Record") { Thread.Sleep(delay); // some robustness against ARM caching } return(resource); }
public static Volume CreateBackedupVolume(AzureNetAppFilesManagementClient netAppMgmtClient, string volumeName = volumeName1, string poolName = poolName1, string accountName = volumeBackupAccountName1, string resourceGroup = resourceGroup, string location = backupLocation, List <string> protocolTypes = null, IDictionary <string, string> tags = default(IDictionary <string, string>), VolumePropertiesExportPolicy exportPolicy = null, bool volumeOnly = false, string vnet = backupVnet, string backupPolicyId = null, string backupVaultId = null) { if (!volumeOnly) { CreatePool(netAppMgmtClient, poolName, accountName, resourceGroup: resourceGroup, location: location); } var defaultProtocolType = new List <string>() { "NFSv3" }; var volumeProtocolTypes = protocolTypes == null ? defaultProtocolType : protocolTypes; var dataProtection = new VolumePropertiesDataProtection { Backup = new VolumeBackupProperties { BackupEnabled = true, BackupPolicyId = backupPolicyId, VaultId = backupVaultId } }; var volume = new Volume { Location = location, UsageThreshold = 100 * gibibyte, ProtocolTypes = volumeProtocolTypes, CreationToken = volumeName, SubnetId = "/subscriptions/" + netAppMgmtClient.SubscriptionId + "/resourceGroups/" + resourceGroup + "/providers/Microsoft.Network/virtualNetworks/" + backupVnet + "/subnets/default", Tags = tags, ExportPolicy = exportPolicy, VolumeType = "DataProtection", DataProtection = dataProtection }; var resource = netAppMgmtClient.Volumes.CreateOrUpdate(volume, resourceGroup, accountName, poolName, volumeName); Assert.Equal(resource.Name, accountName + '/' + poolName + '/' + volumeName); if (Environment.GetEnvironmentVariable("AZURE_TEST_MODE") == "Record") { Thread.Sleep(delay); // some robustness against ARM caching } return(resource); }
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); }
/// <summary> /// Creates Or Updates Azure NetApp Files Volume /// </summary> /// <param name="anfClient">ANF client object</param> /// <param name="resourceGroupName">Resource group name</param> /// <param name="location">Azure location</param> /// <param name="accountName">Azure NetApp Files Account name</param> /// <param name="poolName">Azure NetApp Files Capacity Pool name</param> /// <param name="serviceLevel">Service Level</param> /// <param name="volumeName">Azure NetApp Files Volume name</param> /// <param name="subnetId">Subnet Id</param> /// <param name="volumeSize">Azure NetApp Files Volume size</param> /// <param name="snapshotPolicyId">Existing Snapshot Policy Id</param> /// <returns>Azure NetApp Files Volume</returns> public static async Task <Volume> CreateOrUpdateANFVolumeAsync(AzureNetAppFilesManagementClient anfClient, string resourceGroupName, string location, string accountName, string poolName, string serviceLevel, string volumeName, string subnetId, long volumeSize, string snapshotPolicyId) { VolumeSnapshotProperties snapshotProperties = new VolumeSnapshotProperties() { SnapshotPolicyId = snapshotPolicyId }; VolumePropertiesDataProtection dataProtectionProperties = new VolumePropertiesDataProtection() { Snapshot = snapshotProperties }; Volume volumeBody = new Volume() { Location = location.ToLower(), ServiceLevel = serviceLevel, //Service level can be one of three levels -> { Standard, Premium, Ultra } CreationToken = volumeName, SubnetId = subnetId, UsageThreshold = volumeSize, DataProtection = dataProtectionProperties, ProtocolTypes = new List <string>() { "NFSv3" } }; return(await anfClient.Volumes.CreateOrUpdateAsync(volumeBody, resourceGroupName, accountName, poolName, volumeName)); }