Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to R4 RP standard #6154

Merged
merged 2 commits into from
May 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,16 @@ public static IEnumerable<Tuple<string, string, string>> ApiInfo_NetAppManagemen
}.AsEnumerable();
}
}
// BEGIN: Code Generation Metadata Section
public static readonly String AutoRestVersion = "latest";
public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4283";
public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/netapp/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=C:\\Development\\Github\\azure-sdk-for-net\\src\\SDKs";
public static readonly String GithubForkName = "Azure";
public static readonly String GithubBranchName = "master";
public static readonly String GithubCommidId = "97a0c185b011986b2472105ab210832190557b6b";
public static readonly String CodeGenerationErrors = "";
public static readonly String GithubRepoName = "azure-rest-api-specs";
// END: Code Generation Metadata Section
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
<Description>Provides NetApp storage management capabilities for Microsoft Azure.</Description>
<AssemblyTitle>Microsoft Azure NetApp Management</AssemblyTitle>
<AssemblyName>Microsoft.Azure.Management.NetApp</AssemblyName>
<Version>0.9.1-preview</Version>
<Version>1.0.0</Version>
<PackageTags>MicrosoftAzure Management;NetApp</PackageTags>
<PackageReleaseNotes>
<![CDATA[
Version 0.9.1-preview relates to NetApp Files (ANF) RP R3
- Addition of export policy for volumes
- Addition of active directory for accounts
Version 0.9.0-preview relates to NetApp Files (ANF) RP R2
- Initial version. This is a public preview release of the NetApp storage management SDK.
Version 1.0.0 relates to NetApp Files (ANF) RP R4 (Gated) GA
- first non-preview version
- Correction to error mapping
- filesystem id no longer required for snapshot creation
General :
Azure NetApp Files provides the capability to create multiple file system volumes through Microsoft Azure.
Volumes reside within an account pool, a container representing the total data allocation available. A typical usage might be:
Expand Down
4 changes: 2 additions & 2 deletions src/SDKs/NetApp/Management.NetApp/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
[assembly: AssemblyTitle("Microsoft Azure NetApp Management Library")]
[assembly: AssemblyDescription("Provides management functionality for Azure NetApp Storage.")]

[assembly: AssemblyVersion("0.9.1.0")]
[assembly: AssemblyFileVersion("0.9.1.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
Expand Down
57 changes: 34 additions & 23 deletions src/SDKs/NetApp/NetApp.Tests/Helpers/ResourceUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ public class ResourceUtils
{
public const long gibibyte = 1024L * 1024L * 1024L;

protected const string subsId = "f557b96d-2308-4a18-aae1-b8f7e7e70cc7";
protected const string vnet = "sdk-net-tests-rg-vnet";
public const string location = "westeurope";
public const string resourceGroup = "sdk-net-tests-rg";
public const string accountName1 = "sdk-tests-acc1";
public const string accountName2 = "sdk-tests-acc2";
public const string poolName1 = "sdk-tests-pool1";
public const string poolName2 = "sdk-tests-pool2";
public const string volumeName1 = "sdk-tests-vol1";
public const string volumeName2 = "sdk-tests-vol2";
public const string snapshotName1 = "sdk-tests-snap1";
public const string snapshotName2 = "sdk-tests-snap2";
public const string vnet = "sdk-net-tests-rg-eus2-vnet";
public const string subsId = "0661b131-4a11-479b-96bf-2f95acca2f73";
public const string location = "eastus2";
public const string resourceGroup = "sdk-net-tests-rg-eus2";
public const string accountName1 = "sdk-net-tests-acc-1";
public const string accountName2 = "sdk-net-tests-acc-2";
public const string poolName1 = "sdk-net-tests-pool-1";
public const string poolName2 = "sdk-net-tests-pool-2";
public const string volumeName1 = "sdk-net-tests-vol-1";
public const string volumeName2 = "sdk-net-tests-vol-2";
public const string snapshotName1 = "sdk-net-tests-snap-1";
public const string snapshotName2 = "sdk-net-tests-snap-2";

public static ActiveDirectory activeDirectory = new ActiveDirectory()
{
Username = "sdkuser",
Password = "sdkpass",
Domain = "sdkdomain",
DNS = "127.0.0.1",
SMBServerName = "SDKSMBServerName",
Dns = "127.0.0.1",
SmbServerName = "SDKSMBServerName",
};

public static ExportPolicyRule defaultExportPolicyRule = new ExportPolicyRule()
Expand Down Expand Up @@ -58,6 +58,9 @@ public class ResourceUtils

public static NetAppAccount CreateAccount(AzureNetAppFilesManagementClient netAppMgmtClient, string accountName = accountName1, string resourceGroup = resourceGroup, string location = location, object tags = null, ActiveDirectory activeDirectory = null)
{
// request reference example
// az netappfiles account update -g --account-name cli-lf-acc2 --active-directories '[{"username": "aduser", "password": "aduser", "smbservername": "SMBSERVER", "dns": "1.2.3.4", "domain": "westcentralus"}]' -l westus2

var activeDirectories = new List<ActiveDirectory> { activeDirectory };

var netAppAccount = new NetAppAccount()
Expand Down Expand Up @@ -110,7 +113,7 @@ public static CapacityPool CreatePool(AzureNetAppFilesManagementClient netAppMgm
return resource;
}

public static Volume CreateVolume(AzureNetAppFilesManagementClient netAppMgmtClient, string volumeName = volumeName1, string poolName = poolName1, string accountName = accountName1, string resourceGroup = resourceGroup, string location = location, object tags = null, VolumePropertiesExportPolicy exportPolicy = null, bool volumeOnly = false)
public static Volume CreateVolume(AzureNetAppFilesManagementClient netAppMgmtClient, string volumeName = volumeName1, string poolName = poolName1, string accountName = accountName1, string resourceGroup = resourceGroup, string location = location, object tags = null, VolumePropertiesExportPolicy exportPolicy = null, bool volumeOnly = false, string snapshotId = null)
{
if (!volumeOnly)
{
Expand All @@ -125,7 +128,8 @@ public static Volume CreateVolume(AzureNetAppFilesManagementClient netAppMgmtCli
CreationToken = volumeName,
SubnetId = "/subscriptions/" + subsId + "/resourceGroups/" + resourceGroup + "/providers/Microsoft.Network/virtualNetworks/" + vnet + "/subnets/default",
Tags = tags,
ExportPolicy = exportPolicy
ExportPolicy = exportPolicy,
SnapshotId = snapshotId
};

var resource = netAppMgmtClient.Volumes.CreateOrUpdate(volume, resourceGroup, accountName, poolName, volumeName);
Expand All @@ -139,22 +143,29 @@ public static Volume CreateVolume(AzureNetAppFilesManagementClient netAppMgmtCli
public static void CreateSnapshot(AzureNetAppFilesManagementClient netAppMgmtClient, string snapshotName = snapshotName1, string volumeName = volumeName1, string poolName = poolName1, string accountName = accountName1, string resourceGroup = resourceGroup, string location = location, bool snapshotOnly = false)
{
Volume volume = null;
var snapshot = new Snapshot();

if (!snapshotOnly)
{
volume = CreateVolume(netAppMgmtClient, volumeName, poolName, accountName);

snapshot = new Snapshot
{
Location = location,
FileSystemId = volume?.FileSystemId
};
}
else
{
volume = netAppMgmtClient.Volumes.Get(resourceGroup, accountName, poolName, volumeName);
// for those tests where snapshotOnly is true, no filesystem id will be available
// use this opportunity to test snapshot creation with no filesystem id provided
// for these cases it should use the name in the resource id
snapshot = new Snapshot
{
Location = location,
};
}

var snapshot = new Snapshot
{
Location = location,
FileSystemId = volume?.FileSystemId
};

var resource = netAppMgmtClient.Snapshots.Create(snapshot, resourceGroup, accountName, poolName, volumeName, snapshotName);
Assert.Equal(resource.Name, accountName + '/' + poolName + '/' + volumeName + '/' + snapshotName);
}
Expand Down
4 changes: 2 additions & 2 deletions src/SDKs/NetApp/NetApp.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
5 changes: 3 additions & 2 deletions src/SDKs/NetApp/NetApp.Tests/ResourceTests/AccountTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ public void GetAccountByNameNotFound()
var account = netAppMgmtClient.Accounts.Get(ResourceUtils.resourceGroup, ResourceUtils.accountName1);
Assert.True(false); // expecting exception
}

catch (Exception ex)
{
Assert.Contains("NotFound", ex.Message);
Assert.Equal("The Resource 'Microsoft.NetApp/netAppAccounts/" + ResourceUtils.accountName1 + "' under resource group '" + ResourceUtils.resourceGroup + "' was not found.", ex.Message);
}
}
}
Expand Down Expand Up @@ -186,7 +187,7 @@ public void PatchAccount()
ResourceUtils.DeleteAccount(netAppMgmtClient);
}
}

private static string GetSessionsDirectoryPath()
{
string executingAssemblyPath = typeof(NetApp.Tests.ResourceTests.AccountTests).GetTypeInfo().Assembly.Location;
Expand Down
7 changes: 4 additions & 3 deletions src/SDKs/NetApp/NetApp.Tests/ResourceTests/PoolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void GetPoolByNameNotFound()
}
catch (Exception ex)
{
Assert.Contains("NotFound", ex.Message);
Assert.Contains("was not found", ex.Message);
}

// cleanup - remove the account
Expand All @@ -140,7 +140,7 @@ public void GetPoolByNameAccountNotFound()
}
catch (Exception ex)
{
Assert.Contains("NotFound", ex.Message);
Assert.Contains("was not found", ex.Message);
}

// cleanup - remove pool and account
Expand Down Expand Up @@ -171,7 +171,8 @@ public void DeleteAccountWithPoolPresent()
}
catch (Exception ex)
{
Assert.Contains("Conflict", ex.Message);
// Conflict
Assert.Equal("Can not delete resource before nested resources are deleted.", ex.Message);
}

// clean up
Expand Down
57 changes: 44 additions & 13 deletions src/SDKs/NetApp/NetApp.Tests/ResourceTests/SnapshotTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public void CreateDeleteSnapshot()
var snapshotsBefore = netAppMgmtClient.Snapshots.List(ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.poolName1, ResourceUtils.volumeName1);
Assert.Single(snapshotsBefore);

// delete the pool and check again
// delete the snapshot and check again
netAppMgmtClient.Snapshots.Delete(ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.poolName1, ResourceUtils.volumeName1, ResourceUtils.snapshotName1);
var snapshotsAfter = netAppMgmtClient.Snapshots.List(ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.poolName1, ResourceUtils.volumeName1);
Assert.Empty(snapshotsAfter);

// cleanup - remove the account
// cleanup - remove the resources
ResourceUtils.DeleteVolume(netAppMgmtClient);
ResourceUtils.DeletePool(netAppMgmtClient);
ResourceUtils.DeleteAccount(netAppMgmtClient);
Expand All @@ -55,7 +55,7 @@ public void ListSnapshots()
ResourceUtils.CreateSnapshot(netAppMgmtClient);
ResourceUtils.CreateSnapshot(netAppMgmtClient, ResourceUtils.snapshotName2, snapshotOnly: true);

// get the account list and check
// get the volume list and check
var snapshots = netAppMgmtClient.Snapshots.List(ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.poolName1, ResourceUtils.volumeName1);
Assert.Equal(snapshots.ElementAt(0).Name, ResourceUtils.accountName1 + '/' + ResourceUtils.poolName1 + '/' + ResourceUtils.volumeName1 + '/' + ResourceUtils.snapshotName1);
Assert.Equal(snapshots.ElementAt(1).Name, ResourceUtils.accountName1 + '/' + ResourceUtils.poolName1 + '/' + ResourceUtils.volumeName1 + '/' + ResourceUtils.snapshotName2);
Expand All @@ -78,10 +78,10 @@ public void GetSnapshotByName()
{
var netAppMgmtClient = NetAppTestUtilities.GetNetAppManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });

// create the account and pool
// create the snapshot
ResourceUtils.CreateSnapshot(netAppMgmtClient);

// get and check the pool
// get and check the snapshot
var snapshot = netAppMgmtClient.Snapshots.Get(ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.poolName1, ResourceUtils.volumeName1, ResourceUtils.snapshotName1);
Assert.Equal(snapshot.Name, ResourceUtils.accountName1 + '/' + ResourceUtils.poolName1 + '/' + ResourceUtils.volumeName1 + '/' + ResourceUtils.snapshotName1);

Expand All @@ -93,6 +93,34 @@ public void GetSnapshotByName()
}
}

[Fact]
public void CreateVolumeFromSnapshot()
{
HttpMockServer.RecordsDirectory = GetSessionsDirectoryPath();
using (MockContext context = MockContext.Start(this.GetType().FullName))
{
var netAppMgmtClient = NetAppTestUtilities.GetNetAppManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });

// create the snapshot
ResourceUtils.CreateSnapshot(netAppMgmtClient);

// get and check the snapshot
var snapshot = netAppMgmtClient.Snapshots.Get(ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.poolName1, ResourceUtils.volumeName1, ResourceUtils.snapshotName1);
ResourceUtils.CreateVolume(netAppMgmtClient, ResourceUtils.volumeName2, volumeOnly: true, snapshotId: snapshot.SnapshotId);
// name assertion is performed in the volume create

// clean up
ResourceUtils.DeleteSnapshot(netAppMgmtClient);
ResourceUtils.DeleteVolume(netAppMgmtClient, ResourceUtils.volumeName2);
ResourceUtils.DeleteVolume(netAppMgmtClient);
ResourceUtils.DeletePool(netAppMgmtClient);
ResourceUtils.DeleteAccount(netAppMgmtClient);
}
}

/*
* the RP functionality is not stable enough for this test as it stands
* commenting out for now
[Fact]
public void DeleteVolumeWithSnapshotPresent()
{
Expand All @@ -101,18 +129,20 @@ public void DeleteVolumeWithSnapshotPresent()
{
var netAppMgmtClient = NetAppTestUtilities.GetNetAppManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
// create the account and pool
// create the snapshot
ResourceUtils.CreateSnapshot(netAppMgmtClient);
// try and delete the account
// try and delete the volume
try
{
netAppMgmtClient.Volumes.Delete(ResourceUtils.resourceGroup, ResourceUtils.accountName1, ResourceUtils.poolName1, ResourceUtils.volumeName1);
Assert.True(false); // expecting exception
Assert.True(true);
}
catch (Exception ex)
catch (Exception)
{
Assert.Contains("Conflict", ex.Message);
// not expecting exception with the Delete
// it should work even though there were nested snapshots
Assert.True(false);
}
// clean up
Expand All @@ -122,6 +152,7 @@ public void DeleteVolumeWithSnapshotPresent()
ResourceUtils.DeleteAccount(netAppMgmtClient);
}
}
*/

[Fact]
public void PatchSnapshot()
Expand All @@ -131,7 +162,7 @@ public void PatchSnapshot()
{
var netAppMgmtClient = NetAppTestUtilities.GetNetAppManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });

// create the account
// create the snapshot
ResourceUtils.CreateSnapshot(netAppMgmtClient);

var dict = new Dictionary<string, string>();
Expand All @@ -150,10 +181,10 @@ public void PatchSnapshot()
}
catch (Exception ex)
{
Assert.Contains("MethodNotAllowed", ex.Message);
Assert.Contains("Patch operation is not supported", ex.Message);
}

// cleanup - remove the account
// cleanup
ResourceUtils.DeleteSnapshot(netAppMgmtClient);
ResourceUtils.DeleteVolume(netAppMgmtClient);
ResourceUtils.DeletePool(netAppMgmtClient);
Expand Down
Loading