Skip to content

Commit efdb836

Browse files
authored
[Az.ServiceFabric] Add cmdlets Invoke-AzServiceFabricDeallocateManagedNodeType, Invoke-AzServiceFabricRedeployManagedNodeType, Start-AzServiceFabricManagedNodeType (#28499)
1 parent 768c851 commit efdb836

16 files changed

+5518
-2521
lines changed

src/ServiceFabric/ServiceFabric.Test/ScenarioTests/ServiceFabricManagedClustersTests.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,22 @@ function Test-NodeTypeOperations
8282
Assert-AreEqual "StandardSSD_LRS" $snt.DataDiskType
8383
Assert-True { $snt.IsStateless }
8484

85-
$restart = Restart-AzServiceFabricManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_0, snt_1 -PassThru
85+
$redeploy = Invoke-AzServiceFabricRedeployManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_4 -PassThru
86+
Assert-True { $redeploy }
87+
88+
$restart = Restart-AzServiceFabricManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_0 -UpdateType Default -PassThru
8689
Assert-True { $restart }
8790

8891
$delete = Remove-AzServiceFabricManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_1 -PassThru
8992
Assert-True { $delete }
9093

91-
$reimage = Set-AzServiceFabricManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_3 -Reimage -PassThru
94+
$deallocate = Invoke-AzServiceFabricDeallocateManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_2 -PassThru
95+
Assert-True { $deallocate }
96+
97+
$start = Start-AzServiceFabricManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_2 -PassThru
98+
Assert-True { $start }
99+
100+
$reimage = Invoke-AzServiceFabricReimageManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_3 -UpdateType ByUpgradeDomain -PassThru
92101
Assert-True { $reimage }
93102

94103
$snt = Get-AzServiceFabricManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt

src/ServiceFabric/ServiceFabric.Test/SessionRecords/Microsoft.Azure.Commands.ServiceFabric.Test.ScenarioTests.ServiceFabricManagedClustersTests/TestNodeTypeOperations.json

Lines changed: 4169 additions & 2501 deletions
Large diffs are not rendered by default.

src/ServiceFabric/ServiceFabric/Az.ServiceFabric.psd1

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,33 @@ CmdletsToExport = 'Add-AzServiceFabricClientCertificate',
8282
'Add-AzServiceFabricManagedClusterNetworkSecurityRule',
8383
'Add-AzServiceFabricManagedNodeTypeVMExtension',
8484
'Add-AzServiceFabricManagedNodeTypeVMSecret',
85-
'Add-AzServiceFabricNode', 'Add-AzServiceFabricNodeType',
85+
'Add-AzServiceFabricNode',
86+
'Add-AzServiceFabricNodeType',
8687
'Get-AzServiceFabricApplication',
8788
'Get-AzServiceFabricApplicationType',
8889
'Get-AzServiceFabricApplicationTypeVersion',
89-
'Get-AzServiceFabricCluster', 'Get-AzServiceFabricManagedCluster',
90+
'Get-AzServiceFabricCluster',
91+
'Get-AzServiceFabricManagedCluster',
9092
'Get-AzServiceFabricManagedClusterApplication',
9193
'Get-AzServiceFabricManagedClusterApplicationType',
9294
'Get-AzServiceFabricManagedClusterApplicationTypeVersion',
9395
'Get-AzServiceFabricManagedClusterService',
94-
'Get-AzServiceFabricManagedNodeType', 'Get-AzServiceFabricService',
96+
'Get-AzServiceFabricManagedNodeType',
97+
'Get-AzServiceFabricService',
98+
'Invoke-AzServiceFabricDeallocateManagedNodeType',
99+
'Invoke-AzServiceFabricRedeployManagedNodeType',
100+
'Invoke-AzServiceFabricReimageManagedNodeType',
95101
'New-AzServiceFabricApplication',
96102
'New-AzServiceFabricApplicationType',
97103
'New-AzServiceFabricApplicationTypeVersion',
98-
'New-AzServiceFabricCluster', 'New-AzServiceFabricManagedCluster',
104+
'New-AzServiceFabricCluster',
105+
'New-AzServiceFabricManagedCluster',
99106
'New-AzServiceFabricManagedClusterApplication',
100107
'New-AzServiceFabricManagedClusterApplicationType',
101108
'New-AzServiceFabricManagedClusterApplicationTypeVersion',
102109
'New-AzServiceFabricManagedClusterService',
103-
'New-AzServiceFabricManagedNodeType', 'New-AzServiceFabricService',
110+
'New-AzServiceFabricManagedNodeType',
111+
'New-AzServiceFabricService',
104112
'Remove-AzServiceFabricApplication',
105113
'Remove-AzServiceFabricApplicationType',
106114
'Remove-AzServiceFabricApplicationTypeVersion',
@@ -113,16 +121,20 @@ CmdletsToExport = 'Add-AzServiceFabricClientCertificate',
113121
'Remove-AzServiceFabricManagedClusterService',
114122
'Remove-AzServiceFabricManagedNodeType',
115123
'Remove-AzServiceFabricManagedNodeTypeVMExtension',
116-
'Remove-AzServiceFabricNode', 'Remove-AzServiceFabricNodeType',
117-
'Remove-AzServiceFabricService', 'Remove-AzServiceFabricSetting',
124+
'Remove-AzServiceFabricNode',
125+
'Remove-AzServiceFabricNodeType',
126+
'Remove-AzServiceFabricService',
127+
'Remove-AzServiceFabricSetting',
118128
'Restart-AzServiceFabricManagedNodeType',
119129
'Set-AzServiceFabricManagedCluster',
120130
'Set-AzServiceFabricManagedClusterApplication',
121131
'Set-AzServiceFabricManagedClusterApplicationType',
122132
'Set-AzServiceFabricManagedClusterApplicationTypeVersion',
123133
'Set-AzServiceFabricManagedClusterService',
124-
'Set-AzServiceFabricManagedNodeType', 'Set-AzServiceFabricSetting',
134+
'Set-AzServiceFabricManagedNodeType',
135+
'Set-AzServiceFabricSetting',
125136
'Set-AzServiceFabricUpgradeType',
137+
'Start-AzServiceFabricManagedNodeType',
126138
'Update-AzServiceFabricApplication',
127139
'Update-AzServiceFabricDurability',
128140
'Update-AzServiceFabricNodeType',

src/ServiceFabric/ServiceFabric/ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Added new cmdlets for managed node types:
22+
- `Invoke-AzServiceFabricDeallocateManagedNodeType`
23+
- `Invoke-AzServiceFabricRedeployManagedNodeType`
24+
- `Invoke-AzServiceFabricReimageManagedNodeType`
25+
- `Start-AzServiceFabricManagedNodeType`
26+
* Marked `NodeName` as non-required and added parameter `-UpdateType` in `Restart-AzServiceFabricManagedNodeType` to allow UD by UD restarts of all nodes in node type.
2127
* Renamed Remove-AzServiceFabricManagedNodeType parameter sets to use "Remove" instead of "Delete" for consistency with cmdlet name.
2228

2329
## Version 3.7.0
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// ----------------------------------------------------------------------------------
2+
// Copyright Microsoft Corporation
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
// ----------------------------------------------------------------------------------
13+
14+
using System;
15+
using System.Management.Automation;
16+
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
17+
using Microsoft.Azure.Commands.ServiceFabric.Common;
18+
using Microsoft.Azure.Management.ServiceFabricManagedClusters.Models;
19+
20+
namespace Microsoft.Azure.Commands.ServiceFabric.Commands
21+
{
22+
[Cmdlet(VerbsLifecycle.Invoke, ResourceManager.Common.AzureRMConstants.AzurePrefix + Constants.ServiceFabricPrefix + "DeallocateManagedNodeType", SupportsShouldProcess = true), OutputType(typeof(bool))]
23+
public class InvokeAzServiceFabricDeallocateManagedNodeType : ServiceFabricManagedCmdletBase
24+
{
25+
#region Params
26+
27+
#region Common params
28+
29+
[Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true,
30+
HelpMessage = "Specify the name of the resource group.")]
31+
[ResourceGroupCompleter]
32+
[ValidateNotNullOrEmpty()]
33+
public string ResourceGroupName { get; set; }
34+
35+
[Parameter(Mandatory = true, Position = 1, ValueFromPipelineByPropertyName = true,
36+
HelpMessage = "Specify the name of the cluster.")]
37+
[ResourceNameCompleter(Constants.ManagedClustersFullType, nameof(ResourceGroupName))]
38+
[ValidateNotNullOrEmpty()]
39+
public string ClusterName { get; set; }
40+
41+
[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true,
42+
HelpMessage = "Specify the name of the node type.")]
43+
[ValidateNotNullOrEmpty()]
44+
[Alias("NodeTypeName")]
45+
public string Name { get; set; }
46+
47+
#endregion
48+
49+
[Parameter(Mandatory = true, HelpMessage = "List of node names for the operation.")]
50+
[ValidateNotNullOrEmpty()]
51+
public string[] NodeName { get; set; }
52+
53+
[Parameter(Mandatory = false)]
54+
public SwitchParameter PassThru { get; set; }
55+
56+
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background and return a Job to track progress.")]
57+
public SwitchParameter AsJob { get; set; }
58+
59+
#endregion
60+
61+
public override void ExecuteCmdlet()
62+
{
63+
if (ShouldProcess(target: this.Name, action: string.Format("Deallocate node(s) {0}, from node type {1} on cluster {2}", string.Join(", ", this.NodeName), this.Name, this.ClusterName)))
64+
{
65+
try
66+
{
67+
var actionParams = new NodeTypeActionParameters(nodes: this.NodeName);
68+
var beginRequestResponse = this.SfrpMcClient.NodeTypes.BeginDeallocateWithHttpMessagesAsync(
69+
this.ResourceGroupName,
70+
this.ClusterName,
71+
this.Name,
72+
actionParams).GetAwaiter().GetResult();
73+
74+
this.PollLongRunningOperation(beginRequestResponse);
75+
76+
if (this.PassThru)
77+
{
78+
WriteObject(true);
79+
}
80+
}
81+
catch (Exception ex)
82+
{
83+
PrintSdkExceptionDetail(ex);
84+
throw;
85+
}
86+
}
87+
}
88+
}
89+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// ----------------------------------------------------------------------------------
2+
// Copyright Microsoft Corporation
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
// ----------------------------------------------------------------------------------
13+
14+
using System;
15+
using System.Management.Automation;
16+
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
17+
using Microsoft.Azure.Commands.ServiceFabric.Common;
18+
using Microsoft.Azure.Management.ServiceFabricManagedClusters.Models;
19+
20+
namespace Microsoft.Azure.Commands.ServiceFabric.Commands
21+
{
22+
[Cmdlet(VerbsLifecycle.Invoke, ResourceManager.Common.AzureRMConstants.AzurePrefix + Constants.ServiceFabricPrefix + "RedeployManagedNodeType", SupportsShouldProcess = true), OutputType(typeof(bool))]
23+
public class InvokeAzServiceFabricRedeployManagedNodeType : ServiceFabricManagedCmdletBase
24+
{
25+
#region Params
26+
27+
#region Common params
28+
29+
[Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true,
30+
HelpMessage = "Specify the name of the resource group.")]
31+
[ResourceGroupCompleter]
32+
[ValidateNotNullOrEmpty()]
33+
public string ResourceGroupName { get; set; }
34+
35+
[Parameter(Mandatory = true, Position = 1, ValueFromPipelineByPropertyName = true,
36+
HelpMessage = "Specify the name of the cluster.")]
37+
[ResourceNameCompleter(Constants.ManagedClustersFullType, nameof(ResourceGroupName))]
38+
[ValidateNotNullOrEmpty()]
39+
public string ClusterName { get; set; }
40+
41+
[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true,
42+
HelpMessage = "Specify the name of the node type.")]
43+
[ValidateNotNullOrEmpty()]
44+
[Alias("NodeTypeName")]
45+
public string Name { get; set; }
46+
47+
#endregion
48+
49+
[Parameter(Mandatory = false, HelpMessage = "List of node names for the operation.")]
50+
public string[] NodeName { get; set; }
51+
52+
[Parameter(Mandatory = false, HelpMessage = "Specify the update type. Valid values are 'Default' and 'ByUpgradeDomain'.")]
53+
public string UpdateType { get; set; }
54+
55+
[Parameter(Mandatory = false,
56+
HelpMessage = "Using this flag will force the nodes to redeploy even if service fabric is unable to disable the nodes.")]
57+
public SwitchParameter ForceRedeploy { get; set; }
58+
59+
[Parameter(Mandatory = false)]
60+
public SwitchParameter PassThru { get; set; }
61+
62+
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background and return a Job to track progress.")]
63+
public SwitchParameter AsJob { get; set; }
64+
65+
#endregion
66+
67+
public override void ExecuteCmdlet()
68+
{
69+
if (ShouldProcess(target: this.Name, action: string.Format("Redeploy node(s) {0}, from node type {1} on cluster {2} with update type {3}", (this.NodeName == null)? String.Empty : string.Join(", ", this.NodeName), this.Name, this.ClusterName, this.UpdateType ?? "Default")))
70+
{
71+
try
72+
{
73+
var actionParams = new NodeTypeActionParameters(nodes: this.NodeName, updateType: this.UpdateType, force: this.ForceRedeploy.IsPresent);
74+
var beginRequestResponse = this.SfrpMcClient.NodeTypes.BeginRedeployWithHttpMessagesAsync(
75+
this.ResourceGroupName,
76+
this.ClusterName,
77+
this.Name,
78+
actionParams).GetAwaiter().GetResult();
79+
80+
this.PollLongRunningOperation(beginRequestResponse);
81+
82+
if (this.PassThru)
83+
{
84+
WriteObject(true);
85+
}
86+
}
87+
catch (Exception ex)
88+
{
89+
PrintSdkExceptionDetail(ex);
90+
throw;
91+
}
92+
}
93+
}
94+
}
95+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// ----------------------------------------------------------------------------------
2+
// Copyright Microsoft Corporation
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
// ----------------------------------------------------------------------------------
13+
14+
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
15+
using Microsoft.Azure.Commands.ServiceFabric.Common;
16+
using Microsoft.Azure.Commands.ServiceFabric.Models;
17+
using Microsoft.Azure.Management.ServiceFabricManagedClusters.Models;
18+
using System;
19+
using System.Management.Automation;
20+
21+
namespace Microsoft.Azure.Commands.ServiceFabric.Commands
22+
{
23+
[Cmdlet(VerbsLifecycle.Invoke, ResourceManager.Common.AzureRMConstants.AzurePrefix + Constants.ServiceFabricPrefix + "ReimageManagedNodeType", SupportsShouldProcess = true), OutputType(typeof(bool))]
24+
public class InvokeAzServiceFabricReimageManagedNodeType : ServiceFabricManagedCmdletBase
25+
{
26+
#region Params
27+
28+
#region Common params
29+
30+
[Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true,
31+
HelpMessage = "Specify the name of the resource group.")]
32+
[ResourceGroupCompleter]
33+
[ValidateNotNullOrEmpty()]
34+
public string ResourceGroupName { get; set; }
35+
36+
[Parameter(Mandatory = true, Position = 1, ValueFromPipelineByPropertyName = true,
37+
HelpMessage = "Specify the name of the cluster.")]
38+
[ResourceNameCompleter(Constants.ManagedClustersFullType, nameof(ResourceGroupName))]
39+
[ValidateNotNullOrEmpty()]
40+
public string ClusterName { get; set; }
41+
42+
[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true,
43+
HelpMessage = "Specify the name of the node type.")]
44+
[ValidateNotNullOrEmpty()]
45+
[Alias("NodeTypeName")]
46+
public string Name { get; set; }
47+
48+
#endregion
49+
50+
[Parameter(Mandatory = false, HelpMessage = "List of node names for the operation.")]
51+
public string[] NodeName { get; set; }
52+
53+
[Parameter(Mandatory = false, HelpMessage = "Specify the update type. Valid values are 'Default' and 'ByUpgradeDomain'.")]
54+
public string UpdateType { get; set; }
55+
56+
[Parameter(Mandatory = false,
57+
HelpMessage = "Using this flag will force the nodes to reimage even if service fabric is unable to disable the nodes.")]
58+
public SwitchParameter ForceReimage { get; set; }
59+
60+
[Parameter(Mandatory = false)]
61+
public SwitchParameter PassThru { get; set; }
62+
63+
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background and return a Job to track progress.")]
64+
public SwitchParameter AsJob { get; set; }
65+
66+
#endregion
67+
68+
public override void ExecuteCmdlet()
69+
{
70+
if (ShouldProcess(target: this.Name, action: string.Format("Reimage node(s) {0}, from node type {1} on cluster {2} with update type {3}", (this.NodeName == null) ? String.Empty : string.Join(", ", this.NodeName), this.Name, this.ClusterName, this.UpdateType ?? "Default")))
71+
{
72+
try
73+
{
74+
var actionParams = new NodeTypeActionParameters(nodes: this.NodeName, updateType: this.UpdateType, force: this.ForceReimage.IsPresent);
75+
var beginRequestResponse = this.SfrpMcClient.NodeTypes.BeginReimageWithHttpMessagesAsync(
76+
this.ResourceGroupName,
77+
this.ClusterName,
78+
this.Name,
79+
actionParams).GetAwaiter().GetResult();
80+
81+
this.PollLongRunningOperation(beginRequestResponse);
82+
83+
if (this.PassThru)
84+
{
85+
WriteObject(true);
86+
}
87+
}
88+
catch (Exception ex)
89+
{
90+
PrintSdkExceptionDetail(ex);
91+
throw;
92+
}
93+
}
94+
}
95+
}
96+
}

0 commit comments

Comments
 (0)