Skip to content
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 @@ -82,13 +82,22 @@ function Test-NodeTypeOperations
Assert-AreEqual "StandardSSD_LRS" $snt.DataDiskType
Assert-True { $snt.IsStateless }

$restart = Restart-AzServiceFabricManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_0, snt_1 -PassThru
$redeploy = Invoke-AzServiceFabricRedeployManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_4 -PassThru
Assert-True { $redeploy }

$restart = Restart-AzServiceFabricManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_0 -UpdateType Default -PassThru
Assert-True { $restart }

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

$reimage = Set-AzServiceFabricManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_3 -Reimage -PassThru
$deallocate = Invoke-AzServiceFabricDeallocateManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_2 -PassThru
Assert-True { $deallocate }

$start = Start-AzServiceFabricManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_2 -PassThru
Assert-True { $start }

$reimage = Invoke-AzServiceFabricReimageManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt -NodeName snt_3 -UpdateType ByUpgradeDomain -PassThru
Assert-True { $reimage }

$snt = Get-AzServiceFabricManagedNodeType -ResourceGroupName $resourceGroupName -ClusterName $clusterName -Name snt
Expand Down

Large diffs are not rendered by default.

28 changes: 20 additions & 8 deletions src/ServiceFabric/ServiceFabric/Az.ServiceFabric.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,33 @@ CmdletsToExport = 'Add-AzServiceFabricClientCertificate',
'Add-AzServiceFabricManagedClusterNetworkSecurityRule',
'Add-AzServiceFabricManagedNodeTypeVMExtension',
'Add-AzServiceFabricManagedNodeTypeVMSecret',
'Add-AzServiceFabricNode', 'Add-AzServiceFabricNodeType',
'Add-AzServiceFabricNode',
'Add-AzServiceFabricNodeType',
'Get-AzServiceFabricApplication',
'Get-AzServiceFabricApplicationType',
'Get-AzServiceFabricApplicationTypeVersion',
'Get-AzServiceFabricCluster', 'Get-AzServiceFabricManagedCluster',
'Get-AzServiceFabricCluster',
'Get-AzServiceFabricManagedCluster',
'Get-AzServiceFabricManagedClusterApplication',
'Get-AzServiceFabricManagedClusterApplicationType',
'Get-AzServiceFabricManagedClusterApplicationTypeVersion',
'Get-AzServiceFabricManagedClusterService',
'Get-AzServiceFabricManagedNodeType', 'Get-AzServiceFabricService',
'Get-AzServiceFabricManagedNodeType',
'Get-AzServiceFabricService',
'Invoke-AzServiceFabricDeallocateManagedNodeType',
'Invoke-AzServiceFabricRedeployManagedNodeType',
'Invoke-AzServiceFabricReimageManagedNodeType',
'New-AzServiceFabricApplication',
'New-AzServiceFabricApplicationType',
'New-AzServiceFabricApplicationTypeVersion',
'New-AzServiceFabricCluster', 'New-AzServiceFabricManagedCluster',
'New-AzServiceFabricCluster',
'New-AzServiceFabricManagedCluster',
'New-AzServiceFabricManagedClusterApplication',
'New-AzServiceFabricManagedClusterApplicationType',
'New-AzServiceFabricManagedClusterApplicationTypeVersion',
'New-AzServiceFabricManagedClusterService',
'New-AzServiceFabricManagedNodeType', 'New-AzServiceFabricService',
'New-AzServiceFabricManagedNodeType',
'New-AzServiceFabricService',
'Remove-AzServiceFabricApplication',
'Remove-AzServiceFabricApplicationType',
'Remove-AzServiceFabricApplicationTypeVersion',
Expand All @@ -113,16 +121,20 @@ CmdletsToExport = 'Add-AzServiceFabricClientCertificate',
'Remove-AzServiceFabricManagedClusterService',
'Remove-AzServiceFabricManagedNodeType',
'Remove-AzServiceFabricManagedNodeTypeVMExtension',
'Remove-AzServiceFabricNode', 'Remove-AzServiceFabricNodeType',
'Remove-AzServiceFabricService', 'Remove-AzServiceFabricSetting',
'Remove-AzServiceFabricNode',
'Remove-AzServiceFabricNodeType',
'Remove-AzServiceFabricService',
'Remove-AzServiceFabricSetting',
'Restart-AzServiceFabricManagedNodeType',
'Set-AzServiceFabricManagedCluster',
'Set-AzServiceFabricManagedClusterApplication',
'Set-AzServiceFabricManagedClusterApplicationType',
'Set-AzServiceFabricManagedClusterApplicationTypeVersion',
'Set-AzServiceFabricManagedClusterService',
'Set-AzServiceFabricManagedNodeType', 'Set-AzServiceFabricSetting',
'Set-AzServiceFabricManagedNodeType',
'Set-AzServiceFabricSetting',
'Set-AzServiceFabricUpgradeType',
'Start-AzServiceFabricManagedNodeType',
'Update-AzServiceFabricApplication',
'Update-AzServiceFabricDurability',
'Update-AzServiceFabricNodeType',
Expand Down
6 changes: 6 additions & 0 deletions src/ServiceFabric/ServiceFabric/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
- Additional information about change #1
-->
## Upcoming Release
* Added new cmdlets for managed node types:
- `Invoke-AzServiceFabricDeallocateManagedNodeType`
- `Invoke-AzServiceFabricRedeployManagedNodeType`
- `Invoke-AzServiceFabricReimageManagedNodeType`
- `Start-AzServiceFabricManagedNodeType`
* Marked `NodeName` as non-required and added parameter `-UpdateType` in `Restart-AzServiceFabricManagedNodeType` to allow UD by UD restarts of all nodes in node type.
* Renamed Remove-AzServiceFabricManagedNodeType parameter sets to use "Remove" instead of "Delete" for consistency with cmdlet name.

## Version 3.7.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// ----------------------------------------------------------------------------------
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Management.Automation;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Commands.ServiceFabric.Common;
using Microsoft.Azure.Management.ServiceFabricManagedClusters.Models;

namespace Microsoft.Azure.Commands.ServiceFabric.Commands
{
[Cmdlet(VerbsLifecycle.Invoke, ResourceManager.Common.AzureRMConstants.AzurePrefix + Constants.ServiceFabricPrefix + "DeallocateManagedNodeType", SupportsShouldProcess = true), OutputType(typeof(bool))]
public class InvokeAzServiceFabricDeallocateManagedNodeType : ServiceFabricManagedCmdletBase
{
#region Params

#region Common params

[Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true,
HelpMessage = "Specify the name of the resource group.")]
[ResourceGroupCompleter]
[ValidateNotNullOrEmpty()]
public string ResourceGroupName { get; set; }

[Parameter(Mandatory = true, Position = 1, ValueFromPipelineByPropertyName = true,
HelpMessage = "Specify the name of the cluster.")]
[ResourceNameCompleter(Constants.ManagedClustersFullType, nameof(ResourceGroupName))]
[ValidateNotNullOrEmpty()]
public string ClusterName { get; set; }

[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true,
HelpMessage = "Specify the name of the node type.")]
[ValidateNotNullOrEmpty()]
[Alias("NodeTypeName")]
public string Name { get; set; }

#endregion

[Parameter(Mandatory = true, HelpMessage = "List of node names for the operation.")]
[ValidateNotNullOrEmpty()]
public string[] NodeName { get; set; }

[Parameter(Mandatory = false)]
public SwitchParameter PassThru { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background and return a Job to track progress.")]
public SwitchParameter AsJob { get; set; }

#endregion

public override void ExecuteCmdlet()
{
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)))
{
try
{
var actionParams = new NodeTypeActionParameters(nodes: this.NodeName);
var beginRequestResponse = this.SfrpMcClient.NodeTypes.BeginDeallocateWithHttpMessagesAsync(
this.ResourceGroupName,
this.ClusterName,
this.Name,
actionParams).GetAwaiter().GetResult();

this.PollLongRunningOperation(beginRequestResponse);

if (this.PassThru)
{
WriteObject(true);
}
}
catch (Exception ex)
{
PrintSdkExceptionDetail(ex);
throw;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// ----------------------------------------------------------------------------------
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Management.Automation;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Commands.ServiceFabric.Common;
using Microsoft.Azure.Management.ServiceFabricManagedClusters.Models;

namespace Microsoft.Azure.Commands.ServiceFabric.Commands
{
[Cmdlet(VerbsLifecycle.Invoke, ResourceManager.Common.AzureRMConstants.AzurePrefix + Constants.ServiceFabricPrefix + "RedeployManagedNodeType", SupportsShouldProcess = true), OutputType(typeof(bool))]
public class InvokeAzServiceFabricRedeployManagedNodeType : ServiceFabricManagedCmdletBase
{
#region Params

#region Common params

[Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true,
HelpMessage = "Specify the name of the resource group.")]
[ResourceGroupCompleter]
[ValidateNotNullOrEmpty()]
public string ResourceGroupName { get; set; }

[Parameter(Mandatory = true, Position = 1, ValueFromPipelineByPropertyName = true,
HelpMessage = "Specify the name of the cluster.")]
[ResourceNameCompleter(Constants.ManagedClustersFullType, nameof(ResourceGroupName))]
[ValidateNotNullOrEmpty()]
public string ClusterName { get; set; }

[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true,
HelpMessage = "Specify the name of the node type.")]
[ValidateNotNullOrEmpty()]
[Alias("NodeTypeName")]
public string Name { get; set; }

#endregion

[Parameter(Mandatory = false, HelpMessage = "List of node names for the operation.")]
public string[] NodeName { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Specify the update type. Valid values are 'Default' and 'ByUpgradeDomain'.")]
public string UpdateType { get; set; }

[Parameter(Mandatory = false,
HelpMessage = "Using this flag will force the nodes to redeploy even if service fabric is unable to disable the nodes.")]
public SwitchParameter ForceRedeploy { get; set; }

[Parameter(Mandatory = false)]
public SwitchParameter PassThru { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background and return a Job to track progress.")]
public SwitchParameter AsJob { get; set; }

#endregion

public override void ExecuteCmdlet()
{
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")))
{
try
{
var actionParams = new NodeTypeActionParameters(nodes: this.NodeName, updateType: this.UpdateType, force: this.ForceRedeploy.IsPresent);
var beginRequestResponse = this.SfrpMcClient.NodeTypes.BeginRedeployWithHttpMessagesAsync(
this.ResourceGroupName,
this.ClusterName,
this.Name,
actionParams).GetAwaiter().GetResult();

this.PollLongRunningOperation(beginRequestResponse);

if (this.PassThru)
{
WriteObject(true);
}
}
catch (Exception ex)
{
PrintSdkExceptionDetail(ex);
throw;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// ----------------------------------------------------------------------------------
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Commands.ServiceFabric.Common;
using Microsoft.Azure.Commands.ServiceFabric.Models;
using Microsoft.Azure.Management.ServiceFabricManagedClusters.Models;
using System;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.ServiceFabric.Commands
{
[Cmdlet(VerbsLifecycle.Invoke, ResourceManager.Common.AzureRMConstants.AzurePrefix + Constants.ServiceFabricPrefix + "ReimageManagedNodeType", SupportsShouldProcess = true), OutputType(typeof(bool))]
public class InvokeAzServiceFabricReimageManagedNodeType : ServiceFabricManagedCmdletBase
{
#region Params

#region Common params

[Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true,
HelpMessage = "Specify the name of the resource group.")]
[ResourceGroupCompleter]
[ValidateNotNullOrEmpty()]
public string ResourceGroupName { get; set; }

[Parameter(Mandatory = true, Position = 1, ValueFromPipelineByPropertyName = true,
HelpMessage = "Specify the name of the cluster.")]
[ResourceNameCompleter(Constants.ManagedClustersFullType, nameof(ResourceGroupName))]
[ValidateNotNullOrEmpty()]
public string ClusterName { get; set; }

[Parameter(Mandatory = true, Position = 2, ValueFromPipelineByPropertyName = true,
HelpMessage = "Specify the name of the node type.")]
[ValidateNotNullOrEmpty()]
[Alias("NodeTypeName")]
public string Name { get; set; }

#endregion

[Parameter(Mandatory = false, HelpMessage = "List of node names for the operation.")]
public string[] NodeName { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Specify the update type. Valid values are 'Default' and 'ByUpgradeDomain'.")]
public string UpdateType { get; set; }

[Parameter(Mandatory = false,
HelpMessage = "Using this flag will force the nodes to reimage even if service fabric is unable to disable the nodes.")]
public SwitchParameter ForceReimage { get; set; }

[Parameter(Mandatory = false)]
public SwitchParameter PassThru { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background and return a Job to track progress.")]
public SwitchParameter AsJob { get; set; }

#endregion

public override void ExecuteCmdlet()
{
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")))
{
try
{
var actionParams = new NodeTypeActionParameters(nodes: this.NodeName, updateType: this.UpdateType, force: this.ForceReimage.IsPresent);
var beginRequestResponse = this.SfrpMcClient.NodeTypes.BeginReimageWithHttpMessagesAsync(
this.ResourceGroupName,
this.ClusterName,
this.Name,
actionParams).GetAwaiter().GetResult();

this.PollLongRunningOperation(beginRequestResponse);

if (this.PassThru)
{
WriteObject(true);
}
}
catch (Exception ex)
{
PrintSdkExceptionDetail(ex);
throw;
}
}
}
}
}
Loading