Skip to content

Commit fc043e1

Browse files
authored
add nfs support (Azure#5267)
1 parent e62da2f commit fc043e1

File tree

8 files changed

+202
-38
lines changed

8 files changed

+202
-38
lines changed

sdk/storage/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "cpp",
44
"TagPrefix": "cpp/storage",
5-
"Tag": "cpp/storage_9093786628"
5+
"Tag": "cpp/storage_56979c9851"
66
}

sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/rest_client.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
393393
* Root squash to set on the share. Only valid for NFS shares.
394394
*/
395395
Nullable<ShareRootSquash> RootSquash;
396+
/**
397+
* Version 2023-08-03 and newer. Specifies whether the snapshot virtual directory should be
398+
* accessible at the root of share mount point when NFS is enabled. This header is only
399+
* returned for shares, not for snapshots.
400+
*/
401+
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
396402
};
397403
/**
398404
* @brief A listed Azure Storage share item.
@@ -570,6 +576,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
570576
* Valid for NFS shares only.
571577
*/
572578
Nullable<ShareRootSquash> RootSquash;
579+
/**
580+
* Version 2023-08-03 and newer. Specifies whether the snapshot virtual directory should be
581+
* accessible at the root of share mount point when NFS is enabled. This header is only
582+
* returned for shares, not for snapshots.
583+
*/
584+
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
573585
};
574586
/**
575587
* @brief Specifies the option include to delete the base share and all of its snapshots.
@@ -2085,6 +2097,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
20852097
Nullable<Models::AccessTier> AccessTier;
20862098
Nullable<Models::ShareProtocols> EnabledProtocols;
20872099
Nullable<Models::ShareRootSquash> RootSquash;
2100+
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
20882101
};
20892102
static Response<Models::CreateShareResult> Create(
20902103
Core::Http::_internal::HttpPipeline& pipeline,
@@ -2200,6 +2213,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
22002213
Nullable<Models::AccessTier> AccessTier;
22012214
Nullable<std::string> LeaseId;
22022215
Nullable<Models::ShareRootSquash> RootSquash;
2216+
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
22032217
};
22042218
static Response<Models::SetSharePropertiesResult> SetProperties(
22052219
Core::Http::_internal::HttpPipeline& pipeline,

sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_options.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
174174
* specified, the default is NoRootSquash.
175175
*/
176176
Azure::Nullable<Models::ShareRootSquash> RootSquash;
177+
178+
/**
179+
* Version 2023-08-03 and newer. Specifies whether the snapshot virtual directory should be
180+
* accessible at the root of share mount point when NFS is enabled. This header is only
181+
* returned for shares, not for snapshots.
182+
*/
183+
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
177184
};
178185

179186
/**
@@ -226,6 +233,13 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
226233
* specified, the default is NoRootSquash.
227234
*/
228235
Azure::Nullable<Models::ShareRootSquash> RootSquash;
236+
237+
/**
238+
* Version 2023-08-03 and newer. Specifies whether the snapshot virtual directory should be
239+
* accessible at the root of share mount point when NFS is enabled. This header is only
240+
* returned for shares, not for snapshots.
241+
*/
242+
Nullable<bool> EnableSnapshotVirtualDirectoryAccess;
229243
};
230244

231245
/**

sdk/storage/azure-storage-files-shares/src/rest_client.cpp

Lines changed: 99 additions & 37 deletions
Large diffs are not rendered by default.

sdk/storage/azure-storage-files-shares/src/share_client.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
149149
protocolLayerOptions.AccessTier = options.AccessTier;
150150
protocolLayerOptions.EnabledProtocols = options.EnabledProtocols;
151151
protocolLayerOptions.RootSquash = options.RootSquash;
152+
protocolLayerOptions.EnableSnapshotVirtualDirectoryAccess
153+
= options.EnableSnapshotVirtualDirectoryAccess;
152154
auto result
153155
= _detail::ShareClient::Create(*m_pipeline, m_shareUrl, protocolLayerOptions, context);
154156
Models::CreateShareResult ret;
@@ -245,6 +247,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares {
245247
protocolLayerOptions.Quota = options.ShareQuotaInGiB;
246248
protocolLayerOptions.AccessTier = options.AccessTier;
247249
protocolLayerOptions.RootSquash = options.RootSquash;
250+
protocolLayerOptions.EnableSnapshotVirtualDirectoryAccess
251+
= options.EnableSnapshotVirtualDirectoryAccess;
248252
return _detail::ShareClient::SetProperties(
249253
*m_pipeline, m_shareUrl, protocolLayerOptions, context);
250254
}

sdk/storage/azure-storage-files-shares/swagger/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ directive:
469469
$["x-ms-enabled-protocols"]["enum"] = ["Smb", "Nfs"];
470470
$["x-ms-enabled-protocols"]["x-ms-enum"] = {"name": "ShareProtocols", "modelAsString": false};
471471
$["x-ms-enabled-protocols"]["x-ms-enum"]["values"] = [{"value": "SMB", "name": "Smb"},{"value": "NFS", "name": "Nfs"}];
472+
$["x-ms-enable-snapshot-virtual-directory-access"]["x-nullable"] = true;
472473
- from: swagger-document
473474
where: $["x-ms-paths"]["/{shareName}?restype=share"].get.responses["200"]
474475
transform: >
@@ -1067,6 +1068,7 @@ directive:
10671068
$.ShareItemDetails.properties["EnabledProtocols"].description = "The protocols which have been enabled on the share.";
10681069
$.ShareItemDetails.properties["RootSquash"].description = "Root squash to set on the share. Only valid for NFS shares.";
10691070
$.ShareItemDetails.properties["Last-Modified"].description = "The date and time the share was last modified.";
1071+
$.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.";
10701072
$.ShareItemInternal.properties["Name"].description = "The name of the share.";
10711073
$.ShareItemInternal.properties["Snapshot"].description = "The snapshot of the share.";
10721074
$.ShareItemInternal.properties["Deleted"].description = "True if the share is deleted.";

sdk/storage/azure-storage-files-shares/test/ut/share_client_test.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,4 +729,30 @@ namespace Azure { namespace Storage { namespace Test {
729729
shareClient = Files::Shares::ShareClient(m_shareClient->GetUrl(), credential, clientOptions);
730730
EXPECT_THROW(shareClient.GetPermission(created.FilePermissionKey), StorageException);
731731
}
732+
733+
TEST_F(FileShareClientTest, EnableSnapshotVirtualDirectoryAccess_PLAYBACKONLY_)
734+
{
735+
std::string shareName = LowercaseRandomString();
736+
auto shareClient = m_shareServiceClient->GetShareClient(shareName);
737+
Files::Shares::CreateShareOptions createOptions;
738+
createOptions.EnabledProtocols = Files::Shares::Models::ShareProtocols::Nfs;
739+
shareClient.Create(createOptions);
740+
741+
Files::Shares::SetSharePropertiesOptions setPropertiesOptions;
742+
// EnableSnapshotVirtualDirectoryAccess = true
743+
setPropertiesOptions.EnableSnapshotVirtualDirectoryAccess = true;
744+
shareClient.SetProperties(setPropertiesOptions);
745+
auto properties = shareClient.GetProperties().Value;
746+
EXPECT_TRUE(
747+
properties.EnableSnapshotVirtualDirectoryAccess.HasValue()
748+
&& properties.EnableSnapshotVirtualDirectoryAccess.Value());
749+
750+
// EnableSnapshotVirtualDirectoryAccess = false
751+
setPropertiesOptions.EnableSnapshotVirtualDirectoryAccess = false;
752+
shareClient.SetProperties(setPropertiesOptions);
753+
properties = shareClient.GetProperties().Value;
754+
EXPECT_TRUE(
755+
properties.EnableSnapshotVirtualDirectoryAccess.HasValue()
756+
&& !properties.EnableSnapshotVirtualDirectoryAccess.Value());
757+
}
732758
}}} // namespace Azure::Storage::Test

sdk/storage/azure-storage-files-shares/test/ut/share_service_client_test.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,48 @@ namespace Azure { namespace Storage { namespace Test {
132132
}
133133
}
134134

135+
TEST_F(FileShareServiceClientTest, ListSharesEnableSnapshotVirtualDirectoryAccess_PLAYBACKONLY_)
136+
{
137+
std::string shareName1 = LowercaseRandomString();
138+
std::string shareName2 = LowercaseRandomString();
139+
auto shareClient1 = m_shareServiceClient->GetShareClient(shareName1);
140+
auto shareClient2 = m_shareServiceClient->GetShareClient(shareName2);
141+
Files::Shares::CreateShareOptions createOptions;
142+
createOptions.EnabledProtocols = Files::Shares::Models::ShareProtocols::Nfs;
143+
shareClient1.Create(createOptions);
144+
shareClient2.Create(createOptions);
145+
146+
Files::Shares::SetSharePropertiesOptions setPropertiesOptions;
147+
setPropertiesOptions.EnableSnapshotVirtualDirectoryAccess = true;
148+
shareClient1.SetProperties(setPropertiesOptions);
149+
setPropertiesOptions.EnableSnapshotVirtualDirectoryAccess = false;
150+
shareClient2.SetProperties(setPropertiesOptions);
151+
152+
Azure::Nullable<Files::Shares::Models::ShareItem> share1;
153+
Azure::Nullable<Files::Shares::Models::ShareItem> share2;
154+
for (auto page = m_shareServiceClient->ListShares(); page.HasPage(); page.MoveToNextPage())
155+
{
156+
for (const auto& share : page.Shares)
157+
{
158+
if (share.Name == shareName1)
159+
{
160+
share1 = share;
161+
}
162+
else if (share.Name == shareName2)
163+
{
164+
share2 = share;
165+
}
166+
}
167+
}
168+
ASSERT_TRUE(share1.HasValue() && share2.HasValue());
169+
EXPECT_TRUE(
170+
share1.Value().Details.EnableSnapshotVirtualDirectoryAccess.HasValue()
171+
&& share1.Value().Details.EnableSnapshotVirtualDirectoryAccess.Value());
172+
EXPECT_TRUE(
173+
share2.Value().Details.EnableSnapshotVirtualDirectoryAccess.HasValue()
174+
&& !share2.Value().Details.EnableSnapshotVirtualDirectoryAccess.Value());
175+
}
176+
135177
TEST_F(FileShareServiceClientTest, GetProperties)
136178
{
137179
auto ret = m_shareServiceClient->GetProperties();

0 commit comments

Comments
 (0)