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

Storage/STG93 Add NFS Snapshot Support #5267

Merged
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
2 changes: 1 addition & 1 deletion sdk/storage/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "cpp",
"TagPrefix": "cpp/storage",
"Tag": "cpp/storage_9093786628"
"Tag": "cpp/storage_56979c9851"
}
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
* Root squash to set on the share. Only valid for NFS shares.
*/
Nullable<ShareRootSquash> RootSquash;
/**
* Version 2023-08-03 and newer. Specifies whether the snapshot virtual directory should be
* accessible at the root of share mount point when NFS is enabled. This header is only
* returned for shares, not for snapshots.
*/
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
};
/**
* @brief A listed Azure Storage share item.
Expand Down Expand Up @@ -570,6 +576,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
* Valid for NFS shares only.
*/
Nullable<ShareRootSquash> RootSquash;
/**
* Version 2023-08-03 and newer. Specifies whether the snapshot virtual directory should be
* accessible at the root of share mount point when NFS is enabled. This header is only
* returned for shares, not for snapshots.
*/
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
};
/**
* @brief Specifies the option include to delete the base share and all of its snapshots.
Expand Down Expand Up @@ -2085,6 +2097,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Nullable<Models::AccessTier> AccessTier;
Nullable<Models::ShareProtocols> EnabledProtocols;
Nullable<Models::ShareRootSquash> RootSquash;
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
};
static Response<Models::CreateShareResult> Create(
Core::Http::_internal::HttpPipeline& pipeline,
Expand Down Expand Up @@ -2200,6 +2213,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
Nullable<Models::AccessTier> AccessTier;
Nullable<std::string> LeaseId;
Nullable<Models::ShareRootSquash> RootSquash;
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
};
static Response<Models::SetSharePropertiesResult> SetProperties(
Core::Http::_internal::HttpPipeline& pipeline,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
* specified, the default is NoRootSquash.
*/
Azure::Nullable<Models::ShareRootSquash> RootSquash;

/**
* Version 2023-08-03 and newer. Specifies whether the snapshot virtual directory should be
* accessible at the root of share mount point when NFS is enabled. This header is only
* returned for shares, not for snapshots.
*/
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
};

/**
Expand Down Expand Up @@ -226,6 +233,13 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
* specified, the default is NoRootSquash.
*/
Azure::Nullable<Models::ShareRootSquash> RootSquash;

/**
* Version 2023-08-03 and newer. Specifies whether the snapshot virtual directory should be
* accessible at the root of share mount point when NFS is enabled. This header is only
* returned for shares, not for snapshots.
*/
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
};

/**
Expand Down
136 changes: 99 additions & 37 deletions sdk/storage/azure-storage-files-shares/src/rest_client.cpp

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions sdk/storage/azure-storage-files-shares/src/share_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
protocolLayerOptions.AccessTier = options.AccessTier;
protocolLayerOptions.EnabledProtocols = options.EnabledProtocols;
protocolLayerOptions.RootSquash = options.RootSquash;
protocolLayerOptions.EnableSnapshotVirtualDirectoryAccess
= options.EnableSnapshotVirtualDirectoryAccess;
auto result
= _detail::ShareClient::Create(*m_pipeline, m_shareUrl, protocolLayerOptions, context);
Models::CreateShareResult ret;
Expand Down Expand Up @@ -245,6 +247,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
protocolLayerOptions.Quota = options.ShareQuotaInGiB;
protocolLayerOptions.AccessTier = options.AccessTier;
protocolLayerOptions.RootSquash = options.RootSquash;
protocolLayerOptions.EnableSnapshotVirtualDirectoryAccess
= options.EnableSnapshotVirtualDirectoryAccess;
return _detail::ShareClient::SetProperties(
*m_pipeline, m_shareUrl, protocolLayerOptions, context);
}
Expand Down
2 changes: 2 additions & 0 deletions sdk/storage/azure-storage-files-shares/swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ directive:
$["x-ms-enabled-protocols"]["enum"] = ["Smb", "Nfs"];
$["x-ms-enabled-protocols"]["x-ms-enum"] = {"name": "ShareProtocols", "modelAsString": false};
$["x-ms-enabled-protocols"]["x-ms-enum"]["values"] = [{"value": "SMB", "name": "Smb"},{"value": "NFS", "name": "Nfs"}];
$["x-ms-enable-snapshot-virtual-directory-access"]["x-nullable"] = true;
- from: swagger-document
where: $["x-ms-paths"]["/{shareName}?restype=share"].get.responses["200"]
transform: >
Expand Down Expand Up @@ -1067,6 +1068,7 @@ directive:
$.ShareItemDetails.properties["EnabledProtocols"].description = "The protocols which have been enabled on the share.";
$.ShareItemDetails.properties["RootSquash"].description = "Root squash to set on the share. Only valid for NFS shares.";
$.ShareItemDetails.properties["Last-Modified"].description = "The date and time the share was last modified.";
$.ShareItemDetails.properties["EnableSnapshotVirtualDirectoryAccess"].description = "Version 2023-08-03 and newer. Specifies whether the snapshot virtual directory should be accessible at the root of share mount point when NFS is enabled. This header is only returned for shares, not for snapshots.";
$.ShareItemInternal.properties["Name"].description = "The name of the share.";
$.ShareItemInternal.properties["Snapshot"].description = "The snapshot of the share.";
$.ShareItemInternal.properties["Deleted"].description = "True if the share is deleted.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,4 +729,30 @@ namespace Azure { namespace Storage { namespace Test {
shareClient = Files::Shares::ShareClient(m_shareClient->GetUrl(), credential, clientOptions);
EXPECT_THROW(shareClient.GetPermission(created.FilePermissionKey), StorageException);
}

TEST_F(FileShareClientTest, EnableSnapshotVirtualDirectoryAccess_PLAYBACKONLY_)
{
std::string shareName = LowercaseRandomString();
auto shareClient = m_shareServiceClient->GetShareClient(shareName);
Files::Shares::CreateShareOptions createOptions;
createOptions.EnabledProtocols = Files::Shares::Models::ShareProtocols::Nfs;
shareClient.Create(createOptions);

Files::Shares::SetSharePropertiesOptions setPropertiesOptions;
// EnableSnapshotVirtualDirectoryAccess = true
setPropertiesOptions.EnableSnapshotVirtualDirectoryAccess = true;
shareClient.SetProperties(setPropertiesOptions);
auto properties = shareClient.GetProperties().Value;
EXPECT_TRUE(
properties.EnableSnapshotVirtualDirectoryAccess.HasValue()
&& properties.EnableSnapshotVirtualDirectoryAccess.Value());

// EnableSnapshotVirtualDirectoryAccess = false
setPropertiesOptions.EnableSnapshotVirtualDirectoryAccess = false;
shareClient.SetProperties(setPropertiesOptions);
properties = shareClient.GetProperties().Value;
EXPECT_TRUE(
properties.EnableSnapshotVirtualDirectoryAccess.HasValue()
&& !properties.EnableSnapshotVirtualDirectoryAccess.Value());
}
}}} // namespace Azure::Storage::Test
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,48 @@ namespace Azure { namespace Storage { namespace Test {
}
}

TEST_F(FileShareServiceClientTest, ListSharesEnableSnapshotVirtualDirectoryAccess_PLAYBACKONLY_)
{
std::string shareName1 = LowercaseRandomString();
std::string shareName2 = LowercaseRandomString();
auto shareClient1 = m_shareServiceClient->GetShareClient(shareName1);
auto shareClient2 = m_shareServiceClient->GetShareClient(shareName2);
Files::Shares::CreateShareOptions createOptions;
createOptions.EnabledProtocols = Files::Shares::Models::ShareProtocols::Nfs;
shareClient1.Create(createOptions);
shareClient2.Create(createOptions);

Files::Shares::SetSharePropertiesOptions setPropertiesOptions;
setPropertiesOptions.EnableSnapshotVirtualDirectoryAccess = true;
shareClient1.SetProperties(setPropertiesOptions);
setPropertiesOptions.EnableSnapshotVirtualDirectoryAccess = false;
shareClient2.SetProperties(setPropertiesOptions);

Azure::Nullable<Files::Shares::Models::ShareItem> share1;
Azure::Nullable<Files::Shares::Models::ShareItem> share2;
for (auto page = m_shareServiceClient->ListShares(); page.HasPage(); page.MoveToNextPage())
{
for (const auto& share : page.Shares)
{
if (share.Name == shareName1)
{
share1 = share;
}
else if (share.Name == shareName2)
{
share2 = share;
}
}
}
ASSERT_TRUE(share1.HasValue() && share2.HasValue());
EXPECT_TRUE(
share1.Value().Details.EnableSnapshotVirtualDirectoryAccess.HasValue()
&& share1.Value().Details.EnableSnapshotVirtualDirectoryAccess.Value());
EXPECT_TRUE(
share2.Value().Details.EnableSnapshotVirtualDirectoryAccess.HasValue()
&& !share2.Value().Details.EnableSnapshotVirtualDirectoryAccess.Value());
}

TEST_F(FileShareServiceClientTest, GetProperties)
{
auto ret = m_shareServiceClient->GetProperties();
Expand Down