Skip to content

Commit b277725

Browse files
ankushbindlish2litchiyangMSFT
authored andcommitted
Az.storage sync.tiering policy (Azure#12383)
* Update Az.StorageSync.psd1 * Add Tiering properties * addd tiering proerties
1 parent c0bb414 commit b277725

File tree

9 files changed

+188
-12
lines changed

9 files changed

+188
-12
lines changed

src/StorageSync/StorageSync/Common/Converters/ServerEndpointConverter.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ protected override StorageSyncModels.ServerEndpoint Transform(PSServerEndpoint s
5858
source.OfflineDataTransfer,
5959
source.OfflineDataTransferStorageAccountResourceId,
6060
source.OfflineDataTransferStorageAccountTenantId,
61-
source.OfflineDataTransferShareName);
61+
source.OfflineDataTransferShareName,
62+
initialDownloadPolicy:source.InitialDownloadPolicy != null ? (StorageSyncModels.InitialDownloadPolicy)System.Enum.Parse(typeof(StorageSyncModels.InitialDownloadPolicy),source.InitialDownloadPolicy,ignoreCase:true): default(StorageSyncModels.InitialDownloadPolicy?),
63+
localCacheMode: source.LocalCacheMode != null ? (StorageSyncModels.LocalCacheMode)System.Enum.Parse(typeof(StorageSyncModels.LocalCacheMode), source.LocalCacheMode, ignoreCase: true) : default(StorageSyncModels.LocalCacheMode?));
6264
}
6365

6466
/// <summary>
@@ -90,7 +92,9 @@ protected override PSServerEndpoint Transform(StorageSyncModels.ServerEndpoint s
9092
OfflineDataTransfer = source.OfflineDataTransfer,
9193
OfflineDataTransferShareName = source.OfflineDataTransferShareName,
9294
OfflineDataTransferStorageAccountResourceId = source.OfflineDataTransferStorageAccountResourceId,
93-
OfflineDataTransferStorageAccountTenantId = source.OfflineDataTransferStorageAccountTenantId
95+
OfflineDataTransferStorageAccountTenantId = source.OfflineDataTransferStorageAccountTenantId,
96+
InitialDownloadPolicy= source.InitialDownloadPolicy.HasValue ? source.InitialDownloadPolicy.Value.ToString() : null,
97+
LocalCacheMode=source.LocalCacheMode.HasValue ? source.LocalCacheMode.Value.ToString() : null
9498
};
9599
}
96100
}

src/StorageSync/StorageSync/Common/HelpMessages.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ public class HelpMessages
175175
/// </summary>
176176
public const string OfflineDataTransferShareNameParameter = "Cloud Seeded Data File Share Uri Parameter.";
177177
/// <summary>
178+
/// The initial download policy parameter.
179+
/// </summary>
180+
public const string InitialDownloadPolicyParameter = "Initial Download Policy Parameter.";
181+
/// <summary>
182+
/// The Local cache mode parameter.
183+
/// </summary>
184+
public const string LocalCacheModeParameter = "Local Cache Mode Parameter.";
185+
/// <summary>
178186
/// The tier files older than days parameter
179187
/// </summary>
180188
public const string TierFilesOlderThanDaysParameter = "Tier Files Older Than Days Parameter.";

src/StorageSync/StorageSync/Models/PSServerEndpoint.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,17 @@ public class PSServerEndpoint : PSResourceBase
110110
/// </summary>
111111
/// <value>The offline data transfer storage account tenant identifier.</value>
112112
public string OfflineDataTransferStorageAccountTenantId { get; internal set; }
113+
114+
// <summary>
115+
/// Gets or sets a value indicating the policy to use for the initial download sync.
116+
/// </summary>
117+
/// <value>The initial download policy.</value>
118+
public string InitialDownloadPolicy { get; set; }
119+
120+
/// <summary>
121+
/// Gets or sets a value indicating the policy to use for regular download sync sessions.
122+
/// </summary>
123+
/// <value>The local cache mode.</value>
124+
public string LocalCacheMode { get; set; }
113125
}
114126
}

src/StorageSync/StorageSync/Properties/StorageSyncResources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/StorageSync/StorageSync/Properties/StorageSyncResources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,4 +282,10 @@
282282
<data name="SetStorageSyncServiceActionMessage" xml:space="preserve">
283283
<value>Updating a Storage Sync Service</value>
284284
</data>
285+
<data name="InvalidInitialDownloadPolicyErrorMessage" xml:space="preserve">
286+
<value>InitialDownloadPolicy parameter has invalid value.</value>
287+
</data>
288+
<data name="InvalidLocalCacheModeErrorMessage" xml:space="preserve">
289+
<value>LocalCacheMode parameter has invalid value.</value>
290+
</data>
285291
</root>

src/StorageSync/StorageSync/ServerEndpoint/NewServerEndpointCommand.cs

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
using Microsoft.Azure.Commands.StorageSync.Properties;
2121
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
2222
using Microsoft.Azure.Management.StorageSync;
23-
using Microsoft.Azure.Management.StorageSync.Models;
23+
using StorageSyncModels = Microsoft.Azure.Management.StorageSync.Models;
2424
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
2525
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2626
using System.Management.Automation;
27+
using System;
2728

2829
namespace Microsoft.Azure.Commands.StorageSync.Cmdlets
2930
{
@@ -191,6 +192,41 @@ public class NewServerEndpointCommand : StorageSyncClientCmdletBase
191192
HelpMessage = HelpMessages.OfflineDataTransferShareNameParameter)]
192193
public string OfflineDataTransferShareName { get; set; }
193194

195+
// <summary>
196+
/// Gets or sets a value indicating the policy to use for the initial download sync.
197+
/// </summary>
198+
/// <value>The initial download policy.</value>
199+
[Parameter(
200+
Mandatory = false,
201+
ValueFromPipelineByPropertyName = false,
202+
HelpMessage = HelpMessages.InitialDownloadPolicyParameter)]
203+
// #TODO : Update swagger to make them string constants
204+
//[ValidateSet(StorageSyncModels.InitialDownloadPolicy.AvoidTieredFiles,
205+
// StorageSyncModels.InitialDownloadPolicy.NamespaceOnly,
206+
// StorageSyncModels.InitialDownloadPolicy.NamespaceThenModifiedFiles,
207+
// IgnoreCase = true)]
208+
[ValidateSet("AvoidTieredFiles",
209+
"NamespaceOnly",
210+
"NamespaceThenModifiedFiles",
211+
IgnoreCase = true)]
212+
public string InitialDownloadPolicy { get; set; }
213+
214+
/// <summary>
215+
/// Gets or sets a value indicating the policy to use for regular download sync sessions.
216+
/// </summary>
217+
/// <value>The local cache mode.</value>
218+
[Parameter(
219+
Mandatory = false,
220+
ValueFromPipelineByPropertyName = false,
221+
HelpMessage = HelpMessages.LocalCacheModeParameter)]
222+
//[ValidateSet(StorageSyncModels.LocalCacheMode.DownloadNewAndModifiedFiles,
223+
// StorageSyncModels.LocalCacheMode.UpdateLocallyCachedFiles,
224+
// IgnoreCase = true)]
225+
[ValidateSet("DownloadNewAndModifiedFiles",
226+
"UpdateLocallyCachedFiles",
227+
IgnoreCase = true)]
228+
public string LocalCacheMode { get; set; }
229+
194230
/// <summary>
195231
/// Gets or sets as job.
196232
/// </summary>
@@ -230,7 +266,7 @@ public override void ExecuteCmdlet()
230266
}
231267
}
232268

233-
var createParameters = new ServerEndpointCreateParameters()
269+
var createParameters = new StorageSyncModels.ServerEndpointCreateParameters()
234270
{
235271
CloudTiering = CloudTiering.ToBool() ? StorageSyncConstants.CloudTieringOn : StorageSyncConstants.CloudTieringOff,
236272
VolumeFreeSpacePercent = VolumeFreeSpacePercent,
@@ -241,14 +277,34 @@ public override void ExecuteCmdlet()
241277
OfflineDataTransferShareName = OfflineDataTransferShareName
242278
};
243279

280+
StorageSyncModels.InitialDownloadPolicy initialDownloadPolicy;
281+
if (this.IsParameterBound(c => c.InitialDownloadPolicy))
282+
{
283+
if (!Enum.TryParse(InitialDownloadPolicy, true, out initialDownloadPolicy))
284+
{
285+
throw new PSArgumentException(StorageSyncResources.InvalidInitialDownloadPolicyErrorMessage);
286+
}
287+
createParameters.InitialDownloadPolicy = initialDownloadPolicy;
288+
}
289+
290+
StorageSyncModels.LocalCacheMode localCacheMode;
291+
if (this.IsParameterBound(c => c.LocalCacheMode))
292+
{
293+
if (!Enum.TryParse(LocalCacheMode, true, out localCacheMode))
294+
{
295+
throw new PSArgumentException(StorageSyncResources.InvalidLocalCacheModeErrorMessage);
296+
}
297+
createParameters.LocalCacheMode = localCacheMode;
298+
}
299+
244300
string resourceGroupName = ResourceGroupName ?? ParentObject?.ResourceGroupName ?? parentResourceIdentifier.ResourceGroupName;
245301
string storageSyncServiceName = StorageSyncServiceName ?? ParentObject?.StorageSyncServiceName ?? parentResourceIdentifier.GetParentResourceName(StorageSyncConstants.StorageSyncServiceTypeName, 0);
246302
string syncGroupName = SyncGroupName ?? ParentObject?.SyncGroupName ?? parentResourceIdentifier.ResourceName;
247303

248304
Target = string.Join("/", resourceGroupName, storageSyncServiceName, syncGroupName, Name);
249305
if (ShouldProcess(Target, ActionMessage))
250306
{
251-
ServerEndpoint resource = StorageSyncClientWrapper.StorageSyncManagementClient.ServerEndpoints.Create(
307+
StorageSyncModels.ServerEndpoint resource = StorageSyncClientWrapper.StorageSyncManagementClient.ServerEndpoints.Create(
252308
resourceGroupName,
253309
storageSyncServiceName,
254310
syncGroupName,

src/StorageSync/StorageSync/ServerEndpoint/SetServerEndpointCommand.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using Microsoft.Azure.Management.StorageSync.Models;
2424
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
2525
using Microsoft.WindowsAzure.Commands.Utilities.Common;
26+
using System;
2627
using System.Management.Automation;
2728
using StorageSyncModels = Microsoft.Azure.Management.StorageSync.Models;
2829

@@ -160,7 +161,23 @@ public class SetServerEndpointCommand : StorageSyncClientCmdletBase
160161
HelpMessage = HelpMessages.TierFilesOlderThanDaysParameter)]
161162
public int? TierFilesOlderThanDays { get; set; }
162163

163-
/// <summary>
164+
/// <summary>
165+
/// Gets or sets a value indicating the policy to use for regular download sync sessions.
166+
/// </summary>
167+
/// <value>The local cache mode.</value>
168+
[Parameter(
169+
Mandatory = false,
170+
ValueFromPipelineByPropertyName = false,
171+
HelpMessage = HelpMessages.LocalCacheModeParameter)]
172+
//[ValidateSet(StorageSyncModels.LocalCacheMode.DownloadNewAndModifiedFiles,
173+
// StorageSyncModels.LocalCacheMode.UpdateLocallyCachedFiles,
174+
// IgnoreCase = true)]
175+
[ValidateSet("DownloadNewAndModifiedFiles",
176+
"UpdateLocallyCachedFiles",
177+
IgnoreCase = true)]
178+
public string LocalCacheMode { get; set; }
179+
180+
/// <summary>
164181
/// Gets or sets as job.
165182
/// </summary>
166183
/// <value>As job.</value>
@@ -243,6 +260,16 @@ public override void ExecuteCmdlet()
243260
updateParameters.OfflineDataTransfer = OfflineDataTransfer.ToBool() ? StorageSyncConstants.OfflineDataTransferOn : StorageSyncConstants.OfflineDataTransferOff;
244261
}
245262

263+
StorageSyncModels.LocalCacheMode localCacheMode;
264+
if (this.IsParameterBound(c => c.LocalCacheMode))
265+
{
266+
if (!Enum.TryParse(LocalCacheMode, true, out localCacheMode))
267+
{
268+
throw new PSArgumentException(StorageSyncResources.InvalidLocalCacheModeErrorMessage);
269+
}
270+
updateParameters.LocalCacheMode = localCacheMode;
271+
}
272+
246273
Target = string.Join("/", resourceGroupName, storageSyncServiceName, parentResourceName, resourceName);
247274
if (ShouldProcess(Target, ActionMessage))
248275
{

src/StorageSync/StorageSync/help/New-AzStorageSyncServerEndpoint.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ This command creates a new server endpoint on a registered server. This enables
1717
New-AzStorageSyncServerEndpoint [-ResourceGroupName] <String> [-StorageSyncServiceName] <String>
1818
[-SyncGroupName] <String> -Name <String> -ServerResourceId <String> -ServerLocalPath <String> [-CloudTiering]
1919
[-VolumeFreeSpacePercent <Int32>] [-OfflineDataTransfer] [-TierFilesOlderThanDays <Int32>]
20-
[-OfflineDataTransferShareName <String>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
20+
[-OfflineDataTransferShareName <String>] [InitialDownloadPolicy] [LocalCacheMode] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
2121
[-Confirm] [<CommonParameters>]
2222
```
2323

2424
### ObjectParameterSet
2525
```
2626
New-AzStorageSyncServerEndpoint [-ParentObject] <PSSyncGroup> -Name <String> -ServerResourceId <String>
2727
-ServerLocalPath <String> [-CloudTiering] [-VolumeFreeSpacePercent <Int32>] [-OfflineDataTransfer]
28-
[-TierFilesOlderThanDays <Int32>] [-OfflineDataTransferShareName <String>] [-AsJob]
28+
[-TierFilesOlderThanDays <Int32>] [-OfflineDataTransferShareName <String>] [InitialDownloadPolicy] [LocalCacheMode] [-AsJob]
2929
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
3030
```
3131

3232
### ParentStringParameterSet
3333
```
3434
New-AzStorageSyncServerEndpoint [-ParentResourceId] <String> -Name <String> -ServerResourceId <String>
3535
-ServerLocalPath <String> [-CloudTiering] [-VolumeFreeSpacePercent <Int32>] [-OfflineDataTransfer]
36-
[-TierFilesOlderThanDays <Int32>] [-OfflineDataTransferShareName <String>] [-AsJob]
36+
[-TierFilesOlderThanDays <Int32>] [-OfflineDataTransferShareName <String>] [InitialDownloadPolicy] [LocalCacheMode] [-AsJob]
3737
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
3838
```
3939

@@ -142,6 +142,36 @@ Accept pipeline input: False
142142
Accept wildcard characters: False
143143
```
144144
145+
### -initialDownloadPolicy
146+
Local cache mode Parameter
147+
148+
```yaml
149+
Type: System.String
150+
Parameter Sets: (All)
151+
Aliases:
152+
153+
Required: False
154+
Position: Named
155+
Default value: None
156+
Accept pipeline input: False
157+
Accept wildcard characters: False
158+
```
159+
160+
### -localCacheMode
161+
Local cache mode Parameter
162+
163+
```yaml
164+
Type: System.String
165+
Parameter Sets: (All)
166+
Aliases:
167+
168+
Required: False
169+
Position: Named
170+
Default value: None
171+
Accept pipeline input: False
172+
Accept wildcard characters: False
173+
```
174+
145175
### -ParentObject
146176
SyncGroup Object, normally passed through the parameter.
147177

src/StorageSync/StorageSync/help/Set-AzStorageSyncServerEndpoint.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ This command allows for changes on the adjustable parameters of a server endpoin
1616
```
1717
Set-AzStorageSyncServerEndpoint [-ResourceGroupName] <String> [-StorageSyncServiceName] <String>
1818
[-SyncGroupName] <String> [-Name] <String> [-CloudTiering] [-VolumeFreeSpacePercent <Int32>]
19-
[-OfflineDataTransfer] [-TierFilesOlderThanDays <Int32>] [-AsJob] [-DefaultProfile <IAzureContextContainer>]
19+
[-OfflineDataTransfer] [-TierFilesOlderThanDays <Int32>] [LocalCacheMode] [-AsJob] [-DefaultProfile <IAzureContextContainer>]
2020
[-WhatIf] [-Confirm] [<CommonParameters>]
2121
```
2222

2323
### ResourceIdParameterSet
2424
```
2525
Set-AzStorageSyncServerEndpoint [-ResourceId] <String> [-CloudTiering] [-VolumeFreeSpacePercent <Int32>]
26-
[-OfflineDataTransfer] [-TierFilesOlderThanDays <Int32>] [-AsJob] [-DefaultProfile <IAzureContextContainer>]
26+
[-OfflineDataTransfer] [-TierFilesOlderThanDays <Int32>] [LocalCacheMode] [-AsJob] [-DefaultProfile <IAzureContextContainer>]
2727
[-WhatIf] [-Confirm] [<CommonParameters>]
2828
```
2929

3030
### ObjectParameterSet
3131
```
3232
Set-AzStorageSyncServerEndpoint [-InputObject] <PSServerEndpoint> [-CloudTiering]
33-
[-VolumeFreeSpacePercent <Int32>] [-OfflineDataTransfer] [-TierFilesOlderThanDays <Int32>] [-AsJob]
33+
[-VolumeFreeSpacePercent <Int32>] [-OfflineDataTransfer] [-TierFilesOlderThanDays <Int32>] [LocalCacheMode] [-AsJob]
3434
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
3535
```
3636

@@ -138,6 +138,21 @@ Accept pipeline input: False
138138
Accept wildcard characters: False
139139
```
140140
141+
### -localCacheMode
142+
Local cache mode Parameter
143+
144+
```yaml
145+
Type: System.String
146+
Parameter Sets: (All)
147+
Aliases:
148+
149+
Required: False
150+
Position: Named
151+
Default value: None
152+
Accept pipeline input: False
153+
Accept wildcard characters: False
154+
```
155+
141156
### -ResourceGroupName
142157
Resource Group Name.
143158

0 commit comments

Comments
 (0)