Update VMware.VMC.psm1
Add switch to Connect-VMCVIServer to allow the use of the management IP Address instead of the Public IP address. This would be used when the DNS resolution for the VMC vCenter is set to the private IP.
This commit is contained in:
@@ -47,15 +47,22 @@ Function Connect-VMCVIServer {
|
|||||||
Param (
|
Param (
|
||||||
[Parameter(Mandatory=$true)]$Org,
|
[Parameter(Mandatory=$true)]$Org,
|
||||||
[Parameter(Mandatory=$true)]$Sddc,
|
[Parameter(Mandatory=$true)]$Sddc,
|
||||||
[switch]$Autologin
|
[switch]$Autologin,
|
||||||
|
[switch]$UseManagementIP
|
||||||
)
|
)
|
||||||
|
|
||||||
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 {
|
||||||
$creds = Get-VMCSDDCDefaultCredential -Org $Org -Sddc $Sddc
|
$creds = Get-VMCSDDCDefaultCredential -Org $Org -Sddc $Sddc
|
||||||
Write-Host "Connecting to VMC vCenter Server" $creds.vc_public_ip
|
If($UseManagementIP){
|
||||||
Connect-VIServer -Server $creds.vc_public_ip -User $creds.cloud_username -Password $creds.cloud_password | Add-Member -MemberType Noteproperty -Name Location -Value "VMC"
|
$Server = $creds.vc_management_ip
|
||||||
Write-Host "Connecting to VMC CIS Endpoint" $creds.vc_public_ip
|
}Else{
|
||||||
Connect-CisServer -Server $creds.vc_public_ip -User $creds.cloud_username -Password $creds.cloud_password | Add-Member -MemberType Noteproperty -Name Location -Value "VMC"
|
$Server = $creds.vc_public_ip
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Connecting to VMC vCenter Server" $Server
|
||||||
|
Connect-VIServer -Server $Server -User $creds.cloud_username -Password $creds.cloud_password | Add-Member -MemberType Noteproperty -Name Location -Value "VMC"
|
||||||
|
Write-Host "Connecting to VMC CIS Endpoint" $Server
|
||||||
|
Connect-CisServer -Server $Server -User $creds.cloud_username -Password $creds.cloud_password | Add-Member -MemberType Noteproperty -Name Location -Value "VMC"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Function Get-VMCOrg {
|
Function Get-VMCOrg {
|
||||||
@@ -87,7 +94,7 @@ Function Get-VMCOrg {
|
|||||||
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use Connect-VMC to connect" } Else {
|
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use Connect-VMC to connect" } Else {
|
||||||
$orgService = Get-VMCService com.vmware.vmc.orgs
|
$orgService = Get-VMCService com.vmware.vmc.orgs
|
||||||
if ($PSBoundParameters.ContainsKey("Name")){
|
if ($PSBoundParameters.ContainsKey("Name")){
|
||||||
$orgs = $orgService.list() | Where {$_.display_name -eq $Name}
|
$orgs = $orgService.list() | Where {$_.display_name -match $Name}
|
||||||
} Else {
|
} Else {
|
||||||
$orgs = $orgService.list()
|
$orgs = $orgService.list()
|
||||||
}
|
}
|
||||||
@@ -130,7 +137,7 @@ Function Get-VMCSDDC {
|
|||||||
$orgID = $org.ID
|
$orgID = $org.ID
|
||||||
$sddcService = Get-VMCService com.vmware.vmc.orgs.sddcs
|
$sddcService = Get-VMCService com.vmware.vmc.orgs.sddcs
|
||||||
if ($PSBoundParameters.ContainsKey("Name")){
|
if ($PSBoundParameters.ContainsKey("Name")){
|
||||||
$sddcService.list($OrgID) | Where {$_.name -eq $Name}
|
$sddcService.list($OrgID) | Where {$_.name -match $Name}
|
||||||
} Else {
|
} Else {
|
||||||
$sddcService.list($OrgID)
|
$sddcService.list($OrgID)
|
||||||
}
|
}
|
||||||
@@ -320,6 +327,7 @@ Function Get-VMCSDDCVersion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Get-VMCFirewallRule {
|
Function Get-VMCFirewallRule {
|
||||||
<#
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
@@ -393,8 +401,9 @@ Function Get-VMCFirewallRule {
|
|||||||
}
|
}
|
||||||
$results
|
$results
|
||||||
}
|
}
|
||||||
Function Export-VMCFirewallRule {
|
|
||||||
<#
|
Function Export-VMCFirewallRule {
|
||||||
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Created by: William Lam
|
Created by: William Lam
|
||||||
@@ -477,9 +486,10 @@ Function Export-VMCFirewallRule {
|
|||||||
} else {
|
} else {
|
||||||
$results | ConvertTo-Json
|
$results | ConvertTo-Json
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Function Import-VMCFirewallRule {
|
|
||||||
<#
|
Function Import-VMCFirewallRule {
|
||||||
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Created by: William Lam
|
Created by: William Lam
|
||||||
@@ -633,9 +643,10 @@ Function Import-VMCFirewallRule {
|
|||||||
|
|
||||||
Write-host "Adding VMC Firewall Rules ..."
|
Write-host "Adding VMC Firewall Rules ..."
|
||||||
$firewallRuleAdd = $firewallService.add($orgId,$sddcId,$EdgeId,$firewallRules)
|
$firewallRuleAdd = $firewallService.add($orgId,$sddcId,$EdgeId,$firewallRules)
|
||||||
}
|
}
|
||||||
Function Remove-VMCFirewallRule {
|
|
||||||
<#
|
Function Remove-VMCFirewallRule {
|
||||||
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Created by: William Lam
|
Created by: William Lam
|
||||||
@@ -682,7 +693,8 @@ Function Remove-VMCFirewallRule {
|
|||||||
$firewallService = Get-VmcService com.vmware.vmc.orgs.sddcs.networks.edges.firewall.config.rules
|
$firewallService = Get-VmcService com.vmware.vmc.orgs.sddcs.networks.edges.firewall.config.rules
|
||||||
Write-Host "Removing VMC Firewall Rule Id $RuleId ..."
|
Write-Host "Removing VMC Firewall Rule Id $RuleId ..."
|
||||||
$firewallService.delete($orgId,$sddcId,$EdgeId,$RuleId)
|
$firewallService.delete($orgId,$sddcId,$EdgeId,$RuleId)
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Get-VMCLogicalNetwork {
|
Function Get-VMCLogicalNetwork {
|
||||||
<#
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
@@ -690,7 +702,7 @@ Function Get-VMCLogicalNetwork {
|
|||||||
Created by: Kyle Ruddy
|
Created by: Kyle Ruddy
|
||||||
Date: 03/06/2018
|
Date: 03/06/2018
|
||||||
Organization: VMware
|
Organization: VMware
|
||||||
Blog: https://www.kmruddy.com
|
Blog: https://thatcouldbeaproblem.com
|
||||||
Twitter: @kmruddy
|
Twitter: @kmruddy
|
||||||
===========================================================================
|
===========================================================================
|
||||||
|
|
||||||
@@ -722,17 +734,9 @@ Function Get-VMCLogicalNetwork {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
# @LucD22 - 21/10/18 - Fix for issue #176 VMware.VMC module only lists firts 20 Logical networks
|
$logicalNetworkService = Get-VmcService com.vmware.vmc.orgs.sddcs.networks.logical
|
||||||
# Loop until entries (total_count) are returned
|
|
||||||
|
|
||||||
$index = [long]0
|
$logicalNetworks = ($logicalNetworkService.get_0($orgId, $sddcId)).data | Sort-Object -Property id
|
||||||
|
|
||||||
$logicalNetworks = do{
|
|
||||||
$netData = $logicalNetworkService.get_0($orgId,$sddcId,$pagesize,$index)
|
|
||||||
$netData.data | Sort-Object -Property id
|
|
||||||
$index = $index + $netdata.paging_info.page_size
|
|
||||||
}
|
|
||||||
until($index -ge $netData.paging_info.total_count)
|
|
||||||
|
|
||||||
if($LogicalNetworkName) {
|
if($LogicalNetworkName) {
|
||||||
$logicalNetworks = $logicalNetworks | Where-Object {$_.Name -eq $LogicalNetworkName}
|
$logicalNetworks = $logicalNetworks | Where-Object {$_.Name -eq $LogicalNetworkName}
|
||||||
@@ -754,6 +758,7 @@ Function Get-VMCLogicalNetwork {
|
|||||||
}
|
}
|
||||||
$results
|
$results
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Remove-VMCLogicalNetwork {
|
Function Remove-VMCLogicalNetwork {
|
||||||
<#
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
@@ -761,7 +766,7 @@ Function Remove-VMCLogicalNetwork {
|
|||||||
Created by: Kyle Ruddy
|
Created by: Kyle Ruddy
|
||||||
Date: 03/06/2018
|
Date: 03/06/2018
|
||||||
Organization: VMware
|
Organization: VMware
|
||||||
Blog: https://www.kmruddy.com
|
Blog: https://thatcouldbeaproblem.com
|
||||||
Twitter: @kmruddy
|
Twitter: @kmruddy
|
||||||
===========================================================================
|
===========================================================================
|
||||||
|
|
||||||
@@ -801,14 +806,15 @@ Function Remove-VMCLogicalNetwork {
|
|||||||
$logicalNetworkService = Get-VmcService com.vmware.vmc.orgs.sddcs.networks.logical
|
$logicalNetworkService = Get-VmcService com.vmware.vmc.orgs.sddcs.networks.logical
|
||||||
$logicalNetworkService.delete($orgId,$sddcId,$lsId)
|
$logicalNetworkService.delete($orgId,$sddcId,$lsId)
|
||||||
}
|
}
|
||||||
|
|
||||||
Function New-VMCLogicalNetwork {
|
Function New-VMCLogicalNetwork {
|
||||||
<#
|
<#
|
||||||
.NOTES
|
.NOTES
|
||||||
===========================================================================
|
===========================================================================
|
||||||
Created by: Kyle Ruddy
|
Created by: Kyle Ruddy
|
||||||
Date: 03/06/2018
|
Date: 03/06/2018
|
||||||
Organization: VMware
|
Organization: VMware
|
||||||
Blog: https://www.kmruddy.com
|
Blog: https://thatcouldbeaproblem.com
|
||||||
Twitter: @kmruddy
|
Twitter: @kmruddy
|
||||||
===========================================================================
|
===========================================================================
|
||||||
|
|
||||||
@@ -818,7 +824,7 @@ Function New-VMCLogicalNetwork {
|
|||||||
Creates a new Logical Network
|
Creates a new Logical Network
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
New-VMCLogicalNetwork -OrgName <Org Name> -SDDCName <SDDC Name> -LogicalNetworkName <LogicalNetwork Name> -SubnetMask <Subnet Mask Prefix> -Gateway <Gateway IP Address>
|
New-VMCLogicalNetwork -OrgName <Org Name> -SDDCName <SDDC Name> -LogicalNetworkName <LogicalNetwork Name> -SubnetMask <Subnet Mask Prefix> -Gateway <Gateway IP Address>
|
||||||
#>
|
#>
|
||||||
[cmdletbinding(SupportsShouldProcess = $true,ConfirmImpact='High')]
|
[cmdletbinding(SupportsShouldProcess = $true,ConfirmImpact='High')]
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$true)][String]$SDDCName,
|
[Parameter(Mandatory=$true)][String]$SDDCName,
|
||||||
@@ -855,768 +861,5 @@ Function New-VMCLogicalNetwork {
|
|||||||
$logicalNetworkService.create($orgId, $sddcId, $logicalNetworkSpec)
|
$logicalNetworkService.create($orgId, $sddcId, $logicalNetworkSpec)
|
||||||
Get-VMCLogicalNetwork -OrgName $OrgName -SDDCName $SDDCName -LogicalNetworkName $LogicalNetworkName
|
Get-VMCLogicalNetwork -OrgName $OrgName -SDDCName $SDDCName -LogicalNetworkName $LogicalNetworkName
|
||||||
}
|
}
|
||||||
Function Get-VMCSDDCSummary {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: VMware
|
|
||||||
Date: 09/04/18
|
|
||||||
Organization: VMware
|
|
||||||
Blog: https://www.virtuallyghetto.com
|
|
||||||
Twitter: @lamw
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
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'
|
||||||
Returns a number of useful informational data about a given SDDC within VMC Org
|
|
||||||
.DESCRIPTION
|
|
||||||
Returns Version, Create/Expiration Date, Deployment Type, Region, AZ, Instance Type, VPC CIDR & NSX-T
|
|
||||||
.EXAMPLE
|
|
||||||
Get-VMCSDDCSummary -Name <SDDC Name> -Org <Org Name>
|
|
||||||
#>
|
|
||||||
Param (
|
|
||||||
[Parameter(Mandatory=$True)]$Org,
|
|
||||||
[Parameter(Mandatory=$True)]$Name
|
|
||||||
)
|
|
||||||
|
|
||||||
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
|
||||||
$orgId = (Get-VMCOrg -Name $Org).Id
|
|
||||||
$sddcId = (Get-VMCSDDC -Name $Name -Org $Org).Id
|
|
||||||
|
|
||||||
$sddcService = Get-VmcService "com.vmware.vmc.orgs.sddcs"
|
|
||||||
$sddc = $sddcService.get($orgId,$sddcId)
|
|
||||||
|
|
||||||
$results = [pscustomobject] @{
|
|
||||||
Version = $sddc.resource_config.sddc_manifest.vmc_version;
|
|
||||||
CreateDate = $sddc.created;
|
|
||||||
ExpirationDate = $sddc.expiration_date;
|
|
||||||
DeploymentType = $sddc.resource_config.deployment_type;
|
|
||||||
Region = $sddc.resource_config.region;
|
|
||||||
AvailabilityZone = $sddc.resource_config.availability_zones;
|
|
||||||
InstanceType = $sddc.resource_config.sddc_manifest.esx_ami.instance_type;
|
|
||||||
VpcCIDR = $sddc.resource_config.vpc_info.vpc_cidr;
|
|
||||||
NSXT = $sddc.resource_config.nsxt;
|
|
||||||
VPC_VGW = $sddc.resource_config.vpc_info.vgw_id;
|
|
||||||
}
|
|
||||||
$results
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Function Get-VMCPublicIP {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: William LamVPC_VGW
|
|
||||||
Date: 09/12/2018
|
|
||||||
Organization: VMware
|
|
||||||
Blog: http://www.virtuallyghetto.com
|
|
||||||
Twitter: @lamw
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Retrieves all public IP Addresses for a given SDDC
|
|
||||||
.DESCRIPTION
|
|
||||||
This cmdlet retrieves all public IP Address for a given SDDC
|
|
||||||
.EXAMPLE
|
|
||||||
Get-VMCPublicIP -OrgName $OrgName -SDDCName $SDDCName
|
|
||||||
#>
|
|
||||||
Param (
|
|
||||||
[Parameter(Mandatory=$True)]$OrgName,
|
|
||||||
[Parameter(Mandatory=$True)]$SDDCName
|
|
||||||
)
|
|
||||||
|
|
||||||
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
|
||||||
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
|
||||||
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
|
||||||
|
|
||||||
$publicIPService = Get-VmcService "com.vmware.vmc.orgs.sddcs.publicips"
|
|
||||||
$publicIPs = $publicIPService.list($orgId,$sddcId)
|
|
||||||
|
|
||||||
$publicIPs | select public_ip, name, allocation_id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Function New-VMCPublicIP {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: William Lam
|
|
||||||
Date: 09/12/2018
|
|
||||||
Organization: VMware
|
|
||||||
Blog: http://www.virtuallyghetto.com
|
|
||||||
Twitter: @lamw
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Request a new public IP Address for a given SDDC
|
|
||||||
.DESCRIPTION
|
|
||||||
This cmdlet requests a new public IP Address for a given SDDC
|
|
||||||
.EXAMPLE
|
|
||||||
New-VMCPublicIP -OrgName $OrgName -SDDCName $SDDCName -Description "Test for Randy"
|
|
||||||
#>
|
|
||||||
Param (
|
|
||||||
[Parameter(Mandatory=$True)]$OrgName,
|
|
||||||
[Parameter(Mandatory=$True)]$SDDCName,
|
|
||||||
[Parameter(Mandatory=$False)]$Description
|
|
||||||
)
|
|
||||||
|
|
||||||
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
|
||||||
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
|
||||||
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
|
||||||
|
|
||||||
$publicIPService = Get-VmcService "com.vmware.vmc.orgs.sddcs.publicips"
|
|
||||||
|
|
||||||
$publicIPSpec = $publicIPService.Help.create.spec.Create()
|
|
||||||
$publicIPSpec.count = 1
|
|
||||||
$publicIPSpec.names = @($Description)
|
|
||||||
|
|
||||||
Write-Host "Requesting a new public IP Address for your SDDC ..."
|
|
||||||
$results = $publicIPService.create($orgId,$sddcId,$publicIPSpec)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Function Remove-VMCPublicIP {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: William Lam
|
|
||||||
Date: 09/12/2018
|
|
||||||
Organization: VMware
|
|
||||||
Blog: http://www.virtuallyghetto.com
|
|
||||||
Twitter: @lamw
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Removes a specific public IP Addresses for a given SDDC
|
|
||||||
.DESCRIPTION
|
|
||||||
This cmdlet removes a specific public IP Address for a given SDDC
|
|
||||||
.EXAMPLE
|
|
||||||
Remove-VMCPublicIP -OrgName $OrgName -SDDCName $SDDCName -AllocationId "eipalloc-0567acf34e436c01f"
|
|
||||||
#>
|
|
||||||
Param (
|
|
||||||
[Parameter(Mandatory=$True)]$OrgName,
|
|
||||||
[Parameter(Mandatory=$True)]$SDDCName,
|
|
||||||
[Parameter(Mandatory=$True)]$AllocationId
|
|
||||||
)
|
|
||||||
|
|
||||||
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
|
||||||
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
|
||||||
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
|
||||||
|
|
||||||
$publicIPService = Get-VmcService "com.vmware.vmc.orgs.sddcs.publicips"
|
|
||||||
|
|
||||||
Write-Host "Deleting public IP Address with ID $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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Function New-VMCPublicIP {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: William Lam
|
|
||||||
Date: 09/12/2018
|
|
||||||
Organization: VMware
|
|
||||||
Blog: http://www.virtuallyghetto.com
|
|
||||||
Twitter: @lamw
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Request a new public IP Address for a given SDDC
|
|
||||||
.DESCRIPTION
|
|
||||||
This cmdlet requests a new public IP Address for a given SDDC
|
|
||||||
.EXAMPLE
|
|
||||||
New-VMCPublicIP -OrgName $OrgName -SDDCName $SDDCName -Description "Test for Randy"
|
|
||||||
#>
|
|
||||||
Param (
|
|
||||||
[Parameter(Mandatory=$True)]$OrgName,
|
|
||||||
[Parameter(Mandatory=$True)]$SDDCName,
|
|
||||||
[Parameter(Mandatory=$False)]$Description
|
|
||||||
)
|
|
||||||
|
|
||||||
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
|
||||||
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
|
||||||
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
|
||||||
|
|
||||||
$publicIPService = Get-VmcService "com.vmware.vmc.orgs.sddcs.publicips"
|
|
||||||
|
|
||||||
$publicIPSpec = $publicIPService.Help.create.spec.Create()
|
|
||||||
$publicIPSpec.count = 1
|
|
||||||
$publicIPSpec.names = @($Description)
|
|
||||||
|
|
||||||
Write-Host "Requesting a new public IP Address for your SDDC ..."
|
|
||||||
$results = $publicIPService.create($orgId,$sddcId,$publicIPSpec)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Function Remove-VMCPublicIP {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: William Lam
|
|
||||||
Date: 09/12/2018
|
|
||||||
Organization: VMware
|
|
||||||
Blog: http://www.virtuallyghetto.com
|
|
||||||
Twitter: @lamw
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Removes a specific public IP Addresses for a given SDDC
|
|
||||||
.DESCRIPTION
|
|
||||||
This cmdlet removes a specific public IP Address for a given SDDC
|
|
||||||
.EXAMPLE
|
|
||||||
Remove-VMCPublicIP -OrgName $OrgName -SDDCName $SDDCName -AllocationId "eipalloc-0567acf34e436c01f"
|
|
||||||
#>
|
|
||||||
Param (
|
|
||||||
[Parameter(Mandatory=$True)]$OrgName,
|
|
||||||
[Parameter(Mandatory=$True)]$SDDCName,
|
|
||||||
[Parameter(Mandatory=$True)]$AllocationId
|
|
||||||
)
|
|
||||||
|
|
||||||
If (-Not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect" } Else {
|
|
||||||
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
|
||||||
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
|
||||||
|
|
||||||
$publicIPService = Get-VmcService "com.vmware.vmc.orgs.sddcs.publicips"
|
|
||||||
|
|
||||||
Write-Host "Deleting public IP Address with ID $AllocationId ..."
|
|
||||||
$results = $publicIPService.delete($orgId,$sddcId,$AllocationId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Function Get-VMCEdge {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: Luc Dekens
|
|
||||||
Date: 23/10/2018
|
|
||||||
Organization: Community
|
|
||||||
Blog: http://lucd.info
|
|
||||||
Twitter: @LucD22
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Returns all the VMC Edges
|
|
||||||
.DESCRIPTION
|
|
||||||
Returns all the VMC Edges
|
|
||||||
.EXAMPLE
|
|
||||||
Get-VMCEdge -OrgName $orgName -SddcName $SDDCName -EdgeType gatewayServices
|
|
||||||
#>
|
|
||||||
Param (
|
|
||||||
[Parameter(Mandatory=$True)]
|
|
||||||
[string]$OrgName,
|
|
||||||
[Parameter(Mandatory=$True)]
|
|
||||||
[string]$SDDCName,
|
|
||||||
[ValidateSet('gatewayServices','distributedRouter')]
|
|
||||||
[string]$EdgeType = ''
|
|
||||||
)
|
|
||||||
|
|
||||||
If (-Not $global:DefaultVMCServers) {
|
|
||||||
Write-error "No VMC Connection found, please use the Connect-VMC to connect"
|
|
||||||
}
|
|
||||||
Else {
|
|
||||||
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
|
||||||
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
|
||||||
|
|
||||||
$edgeService = Get-VmcService -Name 'com.vmware.vmc.orgs.sddcs.networks.edges'
|
|
||||||
$index = [long]0
|
|
||||||
$edges = do{
|
|
||||||
$edgeData = $edgeService.get($orgId,$sddcId,$EdgeType,'',$index)
|
|
||||||
$edgeData.edge_page.data | Sort-Object -Property id
|
|
||||||
$index = $index + $edgeData.edge_page.paging_info.page_size
|
|
||||||
}
|
|
||||||
until($index -ge $edgeData.paging_info.total_count)
|
|
||||||
$edges | %{
|
|
||||||
[pscustomobject]@{
|
|
||||||
Name = $_.Name
|
|
||||||
Id = $_.id
|
|
||||||
Type = $_.edge_type
|
|
||||||
State = $_.state
|
|
||||||
Status = $_.edge_status
|
|
||||||
VNics = $_.number_of_connected_vnics
|
|
||||||
TenantId = $_.tenant_id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Function Get-VMCEdgeStatus {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: Luc Dekens
|
|
||||||
Date: 23/10/2018
|
|
||||||
Organization: Community
|
|
||||||
Blog: http://lucd.info
|
|
||||||
Twitter: @LucD22
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Returns the status of the gateway
|
|
||||||
.DESCRIPTION
|
|
||||||
Retrieve the status of the specified management or compute gateway (NSX Edge).
|
|
||||||
.EXAMPLE
|
|
||||||
Get-VMCEdgeStatus -OrgName $orgName -SddcName $SDDCName -Edge $EdgeName
|
|
||||||
#>
|
|
||||||
Param (
|
|
||||||
[Parameter(Mandatory=$True)]
|
|
||||||
[string]$OrgName,
|
|
||||||
[Parameter(Mandatory=$True)]
|
|
||||||
[string]$SDDCName,
|
|
||||||
[Parameter(Mandatory=$True)]
|
|
||||||
[string]$EdgeName
|
|
||||||
)
|
|
||||||
|
|
||||||
If (-Not $global:DefaultVMCServers) {
|
|
||||||
Write-error "No VMC Connection found, please use the Connect-VMC to connect"
|
|
||||||
}
|
|
||||||
Else {
|
|
||||||
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
|
||||||
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
|
||||||
$edgeId = Get-VMCEdge -SDDCName $SDDCName -Org $OrgName | where{$_.Name -eq $EdgeName} | select -ExpandProperty Id
|
|
||||||
|
|
||||||
$statusService = Get-VmcService -Name 'com.vmware.vmc.orgs.sddcs.networks.edges.status'
|
|
||||||
$status = $statusService.get($orgId,$sddcId,$edgeId)
|
|
||||||
|
|
||||||
$vmStatus = $status.edge_vm_status | %{
|
|
||||||
[pscustomobject]@{
|
|
||||||
Name = $_.name
|
|
||||||
State = $_.edge_VM_status
|
|
||||||
HAState = $_.ha_state
|
|
||||||
Index = $_.index
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$featureStatus = $status.feature_statuses | %{
|
|
||||||
[pscustomobject]@{
|
|
||||||
Service = $_.service
|
|
||||||
Status = $_.status
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[pscustomobject]@{
|
|
||||||
Time = [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($status.timestamp/1000))
|
|
||||||
Status = $status.edge_status
|
|
||||||
PublishStatus = $status.publish_status
|
|
||||||
SystemStatus = $_.system_status
|
|
||||||
NicInUse = $status.ha_vnic_in_use
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Function Get-VMCEdgeNic {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: Luc Dekens
|
|
||||||
Date: 23/10/2018
|
|
||||||
Organization: Community
|
|
||||||
Blog: http://lucd.info
|
|
||||||
Twitter: @LucD22
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Returns all interfaces for the gateway
|
|
||||||
.DESCRIPTION
|
|
||||||
Retrieve all interfaces for the specified management or compute gateway (NSX Edge).
|
|
||||||
.EXAMPLE
|
|
||||||
Get-VMCEdgeNic -OrgName $orgName -SddcName $SDDCName -Edge $EdgeName
|
|
||||||
#>
|
|
||||||
Param (
|
|
||||||
[Parameter(Mandatory=$True)]
|
|
||||||
[string]$OrgName,
|
|
||||||
[Parameter(Mandatory=$True)]
|
|
||||||
[string]$SDDCName,
|
|
||||||
[Parameter(Mandatory=$True)]
|
|
||||||
[string]$EdgeName
|
|
||||||
)
|
|
||||||
|
|
||||||
If (-Not $global:DefaultVMCServers) {
|
|
||||||
Write-error "No VMC Connection found, please use the Connect-VMC to connect"
|
|
||||||
}
|
|
||||||
Else {
|
|
||||||
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
|
||||||
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
|
||||||
$edgeId = Get-VMCEdge -SDDCName $SDDCName -Org $OrgName | where{$_.Name -eq $EdgeName} | select -ExpandProperty Id
|
|
||||||
|
|
||||||
$vnicService = Get-VmcService -Name 'com.vmware.vmc.orgs.sddcs.networks.edges.vnics'
|
|
||||||
$vnicService.get($orgId,$sddcId,$edgeId) | select -ExpandProperty vnics | %{
|
|
||||||
[pscustomobject]@{
|
|
||||||
Label = $_.label
|
|
||||||
Name = $_.Name
|
|
||||||
Type = $_.type
|
|
||||||
Index = $_.index
|
|
||||||
IsConnected = $_.is_connected
|
|
||||||
Portgroup = $_.portgroup_name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Function Get-VMCEdgeNicStat {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: Luc Dekens
|
|
||||||
Date: 23/10/2018
|
|
||||||
Organization: Community
|
|
||||||
Blog: http://lucd.info
|
|
||||||
Twitter: @LucD22
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Returns statistics for the gateway interfaces
|
|
||||||
.DESCRIPTION
|
|
||||||
Retrieve interface statistics for a management or compute gateway (NSX Edge).
|
|
||||||
.EXAMPLE
|
|
||||||
Get-VMCEdgeNicStat -OrgName $orgName -SddcName $SDDCName -Edge $EdgeName
|
|
||||||
#>
|
|
||||||
[CmdletBinding(DefaultParameterSetName='Default')]
|
|
||||||
Param (
|
|
||||||
[Parameter(Mandatory=$True)]
|
|
||||||
[string]$OrgName,
|
|
||||||
[Parameter(Mandatory=$True)]
|
|
||||||
[string]$SDDCName,
|
|
||||||
[Parameter(Mandatory=$True)]
|
|
||||||
[string]$EdgeName
|
|
||||||
# [DateTime]$Start,
|
|
||||||
# [DateTime]$Finish
|
|
||||||
)
|
|
||||||
|
|
||||||
If (-Not $global:DefaultVMCServers) {
|
|
||||||
Write-error "No VMC Connection found, please use the Connect-VMC to connect"
|
|
||||||
}
|
|
||||||
Else {
|
|
||||||
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
|
||||||
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
|
||||||
$edgeId = Get-VMCEdge -SDDCName $SDDCName -Org $OrgName | where{$_.Name -eq $EdgeName} | select -ExpandProperty Id
|
|
||||||
|
|
||||||
# $epoch = Get-Date 01/01/1970
|
|
||||||
#
|
|
||||||
# if($start){
|
|
||||||
# $startEpoch = (New-TimeSpan -Start $epoch -End $Start.ToUniversalTime()).TotalMilliseconds
|
|
||||||
# }
|
|
||||||
# if($Finish){
|
|
||||||
# $finishEpoch = (New-TimeSpan -Start $epoch -End $Finish.ToUniversalTime()).TotalMilliseconds
|
|
||||||
# }
|
|
||||||
|
|
||||||
$vnicStatService = Get-VmcService -Name 'com.vmware.vmc.orgs.sddcs.networks.edges.statistics.interfaces'
|
|
||||||
# $stats = $vnicStatService.get($orgId,$sddcId,$edgeId,[long]$startEpoch,[long]$finishEpoch)
|
|
||||||
$stats = $vnicStatService.get($orgId,$sddcId,$edgeId)
|
|
||||||
|
|
||||||
$stats.data_dto | Get-Member -MemberType NoteProperty | where{$_.Name -ne 'Help'} | %{$_.Name} | %{
|
|
||||||
$stats.data_dto."$_" | %{
|
|
||||||
[pscustomobject]@{
|
|
||||||
vNIC = $_.vnic
|
|
||||||
Timestamp = [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($_.timestamp))
|
|
||||||
In = $_.in
|
|
||||||
Out = $_.out
|
|
||||||
Unit = 'Kbps'
|
|
||||||
Interval = $stats.meta_dto.interval
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Function Get-VMCEdgeUplinkStat {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: Luc Dekens
|
|
||||||
Date: 23/10/2018
|
|
||||||
Organization: Community
|
|
||||||
Blog: http://lucd.info
|
|
||||||
Twitter: @LucD22
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Returns statistics for the uplink interfaces
|
|
||||||
.DESCRIPTION
|
|
||||||
Retrieve uplink interface statistics for a management or compute gateway (NSX Edge).
|
|
||||||
.EXAMPLE
|
|
||||||
Get-VMCEdgeUplinkStat -OrgName $orgName -SddcName $SDDCName -Edge $EdgeName
|
|
||||||
#>
|
|
||||||
Param (
|
|
||||||
[Parameter(Mandatory=$True)]
|
|
||||||
[string]$OrgName,
|
|
||||||
[Parameter(Mandatory=$True)]
|
|
||||||
[string]$SDDCName,
|
|
||||||
[Parameter(Mandatory=$True)]
|
|
||||||
[string]$EdgeName
|
|
||||||
# [DateTime]$Start,
|
|
||||||
# [DateTime]$Finish
|
|
||||||
)
|
|
||||||
|
|
||||||
If (-Not $global:DefaultVMCServers) {
|
|
||||||
Write-error "No VMC Connection found, please use the Connect-VMC to connect"
|
|
||||||
}
|
|
||||||
Else {
|
|
||||||
$orgId = (Get-VMCOrg -Name $OrgName).Id
|
|
||||||
$sddcId = (Get-VMCSDDC -Name $SDDCName -Org $OrgName).Id
|
|
||||||
$edgeId = Get-VMCEdge -SDDCName $SDDCName -Org $OrgName | where{$_.Name -eq $EdgeName} | select -ExpandProperty Id
|
|
||||||
|
|
||||||
# $epoch = Get-Date 01/01/1970
|
|
||||||
#
|
|
||||||
# if($start){
|
|
||||||
# $startEpoch = (New-TimeSpan -Start $epoch -End $Start.ToUniversalTime()).TotalMilliseconds
|
|
||||||
# }
|
|
||||||
# if($Finish){
|
|
||||||
# $finishEpoch = (New-TimeSpan -Start $epoch -End $Finish.ToUniversalTime()).TotalMilliseconds
|
|
||||||
# }
|
|
||||||
|
|
||||||
$uplinkStatService = Get-VmcService -Name 'com.vmware.vmc.orgs.sddcs.networks.edges.statistics.interfaces.uplink'
|
|
||||||
# $stats = $uplinkStatService.get($orgId,$sddcId,$edgeId,[long]$startEpoch,[long]$finishEpoch)
|
|
||||||
$stats = $uplinkStatService.get($orgId,$sddcId,$edgeId)
|
|
||||||
|
|
||||||
$stats.data_dto | Get-Member -MemberType NoteProperty | where{$_.Name -ne 'Help'} | %{$_.Name} | %{
|
|
||||||
if($stats.data_dto."$_".Count -ne 0){
|
|
||||||
$stats.data_dto."$_" | %{
|
|
||||||
[pscustomobject]@{
|
|
||||||
vNIC = $_.vnic
|
|
||||||
Timestamp = [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($_.timestamp))
|
|
||||||
In = $_.in
|
|
||||||
Out = $_.out
|
|
||||||
Unit = 'Kbps'
|
|
||||||
Interval = $stats.meta_dto.interval
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Function New-VMCSDDCCluster {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: Kyle Ruddy
|
|
||||||
Date: 03/16/2019
|
|
||||||
Organization: VMware
|
|
||||||
Blog: https://www.kmruddy.com
|
|
||||||
Twitter: @kmruddy
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Creates a new cluster for the designated SDDC
|
|
||||||
.DESCRIPTION
|
|
||||||
Creates a new cluster
|
|
||||||
.EXAMPLE
|
|
||||||
New-VMCSDDCCluster -OrgName <Org Name> -SDDCName <SDDC Name> -HostCount 1 -CPUCoreCount 8
|
|
||||||
#>
|
|
||||||
[cmdletbinding(SupportsShouldProcess = $true,ConfirmImpact='High')]
|
|
||||||
param(
|
|
||||||
[Parameter(Mandatory=$true)][String]$OrgName,
|
|
||||||
[Parameter(Mandatory=$true)][String]$SDDCName,
|
|
||||||
[Parameter(Mandatory=$true)][Int]$HostCount,
|
|
||||||
[Parameter(Mandatory=$true)][ValidateSet("8","16","32")]$CPUCoreCount
|
|
||||||
)
|
|
||||||
|
|
||||||
if (-not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect"; break }
|
|
||||||
|
|
||||||
$orgId = Get-VMCOrg -Name $OrgName | Select-Object -ExpandProperty Id
|
|
||||||
$sddcId = Get-VMCSDDC -Name $SDDCName -Org $OrgName | Select-Object -ExpandProperty Id
|
|
||||||
|
|
||||||
if(-not $orgId) {
|
|
||||||
Write-Host -ForegroundColor red "Unable to find Org $OrgName, please verify input"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if(-not $sddcId) {
|
|
||||||
Write-Host -ForegroundColor red "Unable to find SDDC $SDDCName, please verify input"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
$sddcClusterSvc = Get-VmcService -Name com.vmware.vmc.orgs.sddcs.clusters
|
|
||||||
|
|
||||||
$sddcClusterCreateSpec = $sddcClusterSvc.Help.create.cluster_config.Create()
|
|
||||||
$sddcClusterCreateSpec.host_cpu_cores_count = $CPUCoreCount
|
|
||||||
$sddcClusterCreateSpec.num_hosts = $HostCount
|
|
||||||
|
|
||||||
$sddcClusterTask = $sddcClusterSvc.Create($org.Id, $sddc.Id, $sddcClusterCreateSpec)
|
|
||||||
$sddcClusterTask | Select-Object Id,Task_Type,Status,Created | Format-Table
|
|
||||||
}
|
|
||||||
Function Get-VMCSDDCCluster {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: Kyle Ruddy
|
|
||||||
Date: 03/16/2019
|
|
||||||
Organization: VMware
|
|
||||||
Blog: https://www.kmruddy.com
|
|
||||||
Twitter: @kmruddy
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Retreives cluster information for the designated SDDC
|
|
||||||
.DESCRIPTION
|
|
||||||
Lists cluster information for an SDDC
|
|
||||||
.EXAMPLE
|
|
||||||
Get-VMCSDDCCluster -OrgName <Org Name> -SDDCName <SDDC Name> -HostCount 1 -CPUCoreCount 8
|
|
||||||
#>
|
|
||||||
[cmdletbinding(SupportsShouldProcess = $true,ConfirmImpact='Low')]
|
|
||||||
param(
|
|
||||||
[Parameter(Mandatory=$true)][String]$OrgName,
|
|
||||||
[Parameter(Mandatory=$true)][String]$SddcName
|
|
||||||
)
|
|
||||||
|
|
||||||
if (-not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect"; break }
|
|
||||||
|
|
||||||
$orgId = Get-VMCOrg -Name $OrgName | Select-Object -ExpandProperty Id
|
|
||||||
$sddcId = Get-VMCSDDC -Name $SDDCName -Org $OrgName | Select-Object -ExpandProperty Id
|
|
||||||
|
|
||||||
if(-not $orgId) {
|
|
||||||
Write-Host -ForegroundColor red "Unable to find Org $OrgName, please verify input"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if(-not $sddcId) {
|
|
||||||
Write-Host -ForegroundColor red "Unable to find SDDC $SDDCName, please verify input"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
$clusterOutput = @()
|
|
||||||
$sddcClusters = Get-VMCSDDC -Org $OrgName -Name $SDDCName | Select-Object -ExpandProperty resource_config | Select-Object -ExpandProperty clusters
|
|
||||||
foreach ($c in $sddcClusters) {
|
|
||||||
$tempCluster = "" | Select-Object Id, Name, State
|
|
||||||
$tempCluster.Id = $c.cluster_id
|
|
||||||
$tempCluster.Name = $c.cluster_name
|
|
||||||
$tempCluster.State = $c.cluster_state
|
|
||||||
$clusterOutput += $tempCluster
|
|
||||||
}
|
|
||||||
return $clusterOutput
|
|
||||||
}
|
|
||||||
Function New-VMCSDDCCluster {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: Kyle Ruddy
|
|
||||||
Date: 03/16/2019
|
|
||||||
Organization: VMware
|
|
||||||
Blog: https://www.kmruddy.com
|
|
||||||
Twitter: @kmruddy
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Creates a new cluster for the designated SDDC
|
|
||||||
.DESCRIPTION
|
|
||||||
Creates a new cluster
|
|
||||||
.EXAMPLE
|
|
||||||
New-VMCSDDCCluster -OrgName <Org Name> -SDDCName <SDDC Name> -HostCount 1 -CPUCoreCount 8
|
|
||||||
#>
|
|
||||||
[cmdletbinding(SupportsShouldProcess = $true,ConfirmImpact='High')]
|
|
||||||
param(
|
|
||||||
[Parameter(Mandatory=$true)][String]$OrgName,
|
|
||||||
[Parameter(Mandatory=$true)][String]$SddcName,
|
|
||||||
[Parameter(Mandatory=$true)][Int]$HostCount,
|
|
||||||
[Parameter(Mandatory=$false)][ValidateSet("8","16","36","48")]$CPUCoreCount
|
|
||||||
)
|
|
||||||
|
|
||||||
if (-not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect"; break }
|
|
||||||
|
|
||||||
$orgId = Get-VMCOrg -Name $OrgName | Select-Object -ExpandProperty Id
|
|
||||||
$sddcId = Get-VMCSDDC -Name $SDDCName -Org $OrgName | Select-Object -ExpandProperty Id
|
|
||||||
|
|
||||||
if(-not $orgId) {
|
|
||||||
Write-Host -ForegroundColor red "Unable to find Org $OrgName, please verify input"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if(-not $sddcId) {
|
|
||||||
Write-Host -ForegroundColor red "Unable to find SDDC $SDDCName, please verify input"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
$sddcClusterSvc = Get-VmcService -Name com.vmware.vmc.orgs.sddcs.clusters
|
|
||||||
|
|
||||||
$sddcClusterCreateSpec = $sddcClusterSvc.Help.create.cluster_config.Create()
|
|
||||||
$sddcClusterCreateSpec.host_cpu_cores_count = $CPUCoreCount
|
|
||||||
$sddcClusterCreateSpec.num_hosts = $HostCount
|
|
||||||
|
|
||||||
$sddcClusterTask = $sddcClusterSvc.Create($org.Id, $sddc.Id, $sddcClusterCreateSpec)
|
|
||||||
$sddcClusterTask | Select-Object Id,Task_Type,Status,Created | Format-Table
|
|
||||||
}
|
|
||||||
Function Remove-VMCSDDCCluster {
|
|
||||||
<#
|
|
||||||
.NOTES
|
|
||||||
===========================================================================
|
|
||||||
Created by: Kyle Ruddy
|
|
||||||
Date: 03/16/2019
|
|
||||||
Organization: VMware
|
|
||||||
Blog: https://www.kmruddy.com
|
|
||||||
Twitter: @kmruddy
|
|
||||||
===========================================================================
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Removes a specified cluster from the designated SDDC
|
|
||||||
.DESCRIPTION
|
|
||||||
Deletes a cluster from an SDDC
|
|
||||||
.EXAMPLE
|
|
||||||
Remove-VMCSDDCCluster -OrgName <Org Name> -SDDCName <SDDC Name> -Cluster <Cluster Name>
|
|
||||||
#>
|
|
||||||
[cmdletbinding(SupportsShouldProcess = $true,ConfirmImpact='High')]
|
|
||||||
param(
|
|
||||||
[Parameter(Mandatory=$true)][String]$OrgName,
|
|
||||||
[Parameter(Mandatory=$true)][String]$SDDCName,
|
|
||||||
[Parameter(Mandatory=$true)][String]$ClusterName
|
|
||||||
)
|
|
||||||
|
|
||||||
if (-not $global:DefaultVMCServers) { Write-error "No VMC Connection found, please use the Connect-VMC to connect"; break }
|
|
||||||
|
|
||||||
$orgId = Get-VMCOrg -Name $OrgName | Select-Object -ExpandProperty Id
|
|
||||||
$sddcId = Get-VMCSDDC -Name $SDDCName -Org $OrgName | Select-Object -ExpandProperty Id
|
|
||||||
$clusterId = Get-VMCSDDCCluster -SddcName $SDDCName -OrgName $OrgName | Where-Object {$_.Name -eq $ClusterName} | Select-Object -ExpandProperty Id
|
|
||||||
|
|
||||||
if(-not $orgId) {
|
|
||||||
Write-Host -ForegroundColor red "Unable to find Org $OrgName, please verify input"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if(-not $sddcId) {
|
|
||||||
Write-Host -ForegroundColor red "Unable to find SDDC $SDDCName, please verify input"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if(-not $clusterId) {
|
|
||||||
Write-Host -ForegroundColor red "Unable to find cluster $ClusterName, please verify input"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
$sddcClusterTask = $sddcClusterSvc.Delete($orgId, $sddcId, $clusterId)
|
|
||||||
$sddcClusterTask | Select-Object Id,Task_Type,Status,Created | Format-Table
|
|
||||||
}
|
|
||||||
|
|
||||||
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',
|
|
||||||
'Get-VMCEdge', 'Get-VMCEdgeNic', 'Get-VMCEdgeStatus', 'Get-VMCEdgeNicStat', 'Get-VMCEdgeUplinkStat',
|
|
||||||
'Get-VMCSDDCCluster', 'New-VMCSDDCCluster', 'Remove-VMCSDDCCluster'
|
|
||||||
Reference in New Issue
Block a user