-
Notifications
You must be signed in to change notification settings - Fork 89
Add Remove-NsxServiceGroupMember cmdlet #448
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26657,6 +26657,77 @@ function Add-NsxServiceGroupMember { | |
end {} | ||
} | ||
|
||
function Remove-NsxServiceGroupMember { | ||
|
||
<# | ||
.SYNOPSIS | ||
Removes a single Service, numerous Services, or a Service Group to a Service | ||
Group | ||
|
||
.DESCRIPTION | ||
Removes the defined Service or Service Group to an NSX Service Groups. Service | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from an NSX Service Group_ |
||
groups contain a mixture of selected ports to represent a potential | ||
grouping of like ports. | ||
|
||
This cmdlet removes the defined Services or Service Groups within a Service | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems unclear (all service groups? If you are implying that user can pass all servicegroups on the pipeline, thats a given...) - reword? |
||
Group for specific or all Service Groups | ||
|
||
.EXAMPLE | ||
Get-NsxServiceGroup Heartbeat | Remove-NsxServiceGroupMember -Member $Service1 | ||
|
||
Remove all saved Service Group Members named Heartbeat in Service Group in $Service1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. description is not clear. and you probably should show how you get $service1. Reword to something like 'Gets the service fred and removes it from the service group Heartbeat. |
||
|
||
Get-NsxServiceGroup Service-Group-4 | Remove-NsxServiceGroupMember $Service1,$Service2 -Confirm:$false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs a new .EXAMPLE header. |
||
|
||
Remove all saved Service Group Members named Heartbeat in Service Group in $Service1 and $Service2 without prompting for confirmation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again the comment is not so clear. There is no mention of heartbeat in the cli example? |
||
|
||
#> | ||
|
||
param ( | ||
#Mastergroup removed from Get-NsxServiceGroup | ||
[Parameter (Mandatory=$true,ValueFromPipeline=$true)] | ||
[ValidateScript({ ValidateServiceGroup $_ })] | ||
[System.Xml.XmlElement]$ServiceGroup, | ||
[Parameter (Mandatory=$False)] | ||
#Prompt for confirmation. Specify as -confirm:$false to disable confirmation prompt | ||
[switch]$Confirm=$true, | ||
[Parameter (Mandatory=$true,Position=1)] | ||
[ValidateScript({ ValidateServiceOrServiceGroup $_ })] | ||
#The [] in XmlElement means it can expect more than one object! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid programmer comments in the param block - these are visible to the user in get-help and should be used to explain what the param is. you can tell the user that you accept a collection if you want but do it in a user centric way. |
||
[System.Xml.XmlElement[]]$Member, | ||
[Parameter (Mandatory=$False)] | ||
#PowerNSX Connection object | ||
[ValidateNotNullOrEmpty()] | ||
[PSCustomObject]$Connection=$defaultNSXConnection | ||
) | ||
|
||
begin {} | ||
|
||
process{ | ||
foreach ($Mem in $Member){ | ||
if ( $confirm ) { | ||
$message = "Removal of a Service Group Member is permanent." | ||
$question = "Proceed with removal of Service Group Member $($Mem.name)?" | ||
|
||
$choices = New-Object Collections.ObjectModel.Collection[Management.Automation.Host.ChoiceDescription] | ||
$choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&Yes')) | ||
$choices.Add((New-Object Management.Automation.Host.ChoiceDescription -ArgumentList '&No')) | ||
|
||
$decision = $Host.UI.PromptForChoice($message, $question, $choices, 1) | ||
} | ||
else { $decision = 0 } | ||
|
||
if ($decision -eq 0) { | ||
$URI = "/api/2.0/services/applicationgroup/$($ServiceGroup.objectId)/members/$($Mem.objectId)" | ||
$null = invoke-nsxwebrequest -method "DELETE" -uri $URI -connection $connection | ||
Write-Progress -activity "Removing Service or Service Group $($Mem) to Service Group $($ServiceGroup)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. write-progress needs to have a 'before' and 'after' write-progress (with the latter specifying -completed) otherwise you get 'hanging' progress dialog. |
||
} | ||
} | ||
} | ||
|
||
end {} | ||
} | ||
|
||
function Get-NsxApplicableMember { | ||
|
||
<# | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reword : Removes one or more services or service groups from a service group.