Added Set-VMCSDDC function to rename SDDC
This commit is contained in:
@@ -918,23 +918,23 @@ Function Get-VMCPublicIP {
|
|||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Get-VMCPublicIP -OrgName $OrgName -SDDCName $SDDCName
|
Get-VMCPublicIP -OrgName $OrgName -SDDCName $SDDCName
|
||||||
#>
|
#>
|
||||||
Param (
|
Param (
|
||||||
[Parameter(Mandatory=$True)]$OrgName,
|
[Parameter(Mandatory=$True)]$OrgName,
|
||||||
[Parameter(Mandatory=$True)]$SDDCName
|
[Parameter(Mandatory=$True)]$SDDCName
|
||||||
)
|
)
|
||||||
|
|
||||||
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
||||||
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
||||||
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
||||||
|
|
||||||
$publicIPService = Get-VmcService "com.vmware.vmc.orgs.sddcs.publicips"
|
$publicIPService = Get-VmcService "com.vmware.vmc.orgs.sddcs.publicips"
|
||||||
$publicIPs = $publicIPService.list($orgId,$sddcId)
|
$publicIPs = $publicIPService.list($orgId,$sddcId)
|
||||||
|
|
||||||
$publicIPs | select public_ip, name, allocation_id
|
$publicIPs | select public_ip, name, allocation_id
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Function New-VMCPublicIP {
|
Function New-VMCPublicIP {
|
||||||
<#
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
===========================================================================
|
===========================================================================
|
||||||
@@ -952,28 +952,28 @@ Function Get-VMCPublicIP {
|
|||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
New-VMCPublicIP -OrgName $OrgName -SDDCName $SDDCName -Description "Test for Randy"
|
New-VMCPublicIP -OrgName $OrgName -SDDCName $SDDCName -Description "Test for Randy"
|
||||||
#>
|
#>
|
||||||
Param (
|
Param (
|
||||||
[Parameter(Mandatory=$True)]$OrgName,
|
[Parameter(Mandatory=$True)]$OrgName,
|
||||||
[Parameter(Mandatory=$True)]$SDDCName,
|
[Parameter(Mandatory=$True)]$SDDCName,
|
||||||
[Parameter(Mandatory=$False)]$Description
|
[Parameter(Mandatory=$False)]$Description
|
||||||
)
|
)
|
||||||
|
|
||||||
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
||||||
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
||||||
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
||||||
|
|
||||||
$publicIPService = Get-VmcService "com.vmware.vmc.orgs.sddcs.publicips"
|
$publicIPService = Get-VmcService "com.vmware.vmc.orgs.sddcs.publicips"
|
||||||
|
|
||||||
$publicIPSpec = $publicIPService.Help.create.spec.Create()
|
$publicIPSpec = $publicIPService.Help.create.spec.Create()
|
||||||
$publicIPSpec.count = 1
|
$publicIPSpec.count = 1
|
||||||
$publicIPSpec.names = @($Description)
|
$publicIPSpec.names = @($Description)
|
||||||
|
|
||||||
Write-Host "Requesting a new public IP Address for your SDDC ..."
|
Write-Host "Requesting a new public IP Address for your SDDC ..."
|
||||||
$results = $publicIPService.create($orgId,$sddcId,$publicIPSpec)
|
$results = $publicIPService.create($orgId,$sddcId,$publicIPSpec)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Function Remove-VMCPublicIP {
|
Function Remove-VMCPublicIP {
|
||||||
<#
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
===========================================================================
|
===========================================================================
|
||||||
@@ -991,21 +991,58 @@ Function Get-VMCPublicIP {
|
|||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Remove-VMCPublicIP -OrgName $OrgName -SDDCName $SDDCName -AllocationId "eipalloc-0567acf34e436c01f"
|
Remove-VMCPublicIP -OrgName $OrgName -SDDCName $SDDCName -AllocationId "eipalloc-0567acf34e436c01f"
|
||||||
#>
|
#>
|
||||||
Param (
|
Param (
|
||||||
[Parameter(Mandatory=$True)]$OrgName,
|
[Parameter(Mandatory=$True)]$OrgName,
|
||||||
[Parameter(Mandatory=$True)]$SDDCName,
|
[Parameter(Mandatory=$True)]$SDDCName,
|
||||||
[Parameter(Mandatory=$True)]$AllocationId
|
[Parameter(Mandatory=$True)]$AllocationId
|
||||||
)
|
)
|
||||||
|
|
||||||
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
||||||
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
||||||
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
||||||
|
|
||||||
$publicIPService = Get-VmcService "com.vmware.vmc.orgs.sddcs.publicips"
|
$publicIPService = Get-VmcService "com.vmware.vmc.orgs.sddcs.publicips"
|
||||||
|
|
||||||
Write-Host "Deleting public IP Address with ID $AllocationId ..."
|
Write-Host "Deleting public IP Address with ID $AllocationId ..."
|
||||||
$results = $publicIPService.delete($orgId,$sddcId,$AllocationId)
|
$results = $publicIPService.delete($orgId,$sddcId,$AllocationId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Set-VMCSDDC {
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created by: William Lam
|
||||||
|
Date: 01/12/2019
|
||||||
|
Organization: VMware
|
||||||
|
Blog: http://www.virtuallyghetto.com
|
||||||
|
Twitter: @lamw
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
.SYNOPSIS
|
||||||
|
Rename an SDDC
|
||||||
|
.DESCRIPTION
|
||||||
|
This cmdlet renames an SDDC
|
||||||
|
.EXAMPLE
|
||||||
|
Set-VMCSDDC -SDDC $SDDCName -OrgName $OrgName -Name $NewSDDCName
|
||||||
|
#>
|
||||||
|
Param (
|
||||||
|
[Parameter(Mandatory=$True)]$SDDCName,
|
||||||
|
[Parameter(Mandatory=$True)]$OrgName,
|
||||||
|
[Parameter(Mandatory=$True)]$Name
|
||||||
|
)
|
||||||
|
|
||||||
|
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
||||||
|
$sddc = Get-VMCSDDC -Org $OrgName -Name $SDDCName
|
||||||
|
if($sddc) {
|
||||||
|
$sddcService = Get-VmcService com.vmware.vmc.orgs.sddcs
|
||||||
|
$renameSpec = $sddcService.help.patch.sddc_patch_request.Create()
|
||||||
|
$renameSpec.name = $Name
|
||||||
|
|
||||||
|
Write-Host "`nRenaming SDDC `'$SDDCName`' to `'$Name`' ...`n"
|
||||||
|
$results = $sddcService.patch($sddc.org_id,$sddc.id,$renameSpec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Export-ModuleMember -Function 'Get-VMCCommand', 'Connect-VMCVIServer', 'Get-VMCOrg', 'Get-VMCSDDC', 'Get-VMCTask', 'Get-VMCSDDCDefaultCredential', 'Get-VMCSDDCPublicIP', 'Get-VMCVMHost', 'Get-VMCSDDCVersion', 'Get-VMCFirewallRule', 'Export-VMCFirewallRule', 'Import-VMCFirewallRule', 'Remove-VMCFirewallRule', 'Get-VMCLogicalNetwork', 'Remove-VMCLogicalNetwork', 'New-VMCLogicalNetwork', 'Get-VMCSDDCSummary', 'Get-VMCPublicIP', 'New-VMCPublicIP', 'Remove-VMCPublicIP'
|
Export-ModuleMember -Function 'Get-VMCCommand', 'Connect-VMCVIServer', 'Get-VMCOrg', 'Get-VMCSDDC', 'Get-VMCTask', 'Get-VMCSDDCDefaultCredential', 'Get-VMCSDDCPublicIP', 'Get-VMCVMHost', 'Get-VMCSDDCVersion', 'Get-VMCFirewallRule', 'Export-VMCFirewallRule', 'Import-VMCFirewallRule', 'Remove-VMCFirewallRule', 'Get-VMCLogicalNetwork', 'Remove-VMCLogicalNetwork', 'New-VMCLogicalNetwork', 'Get-VMCSDDCSummary', 'Get-VMCPublicIP', 'New-VMCPublicIP', 'Remove-VMCPublicIP', 'Set-VMCSDDC'
|
||||||
|
|||||||
Reference in New Issue
Block a user