Merge pull request #223 from lamw/master

SDDC Summary data using GET /sddc
This commit is contained in:
Kyle Ruddy
2018-09-14 09:49:24 -04:00
committed by GitHub

View File

@@ -855,4 +855,157 @@ Function New-VMCLogicalNetwork {
Get-VMCLogicalNetwork -OrgName $OrgName -SDDCName $SDDCName -LogicalNetworkName $LogicalNetworkName
}
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'
Function Get-VMCSDDCSummary {
<#
.NOTES
===========================================================================
Created by: VMware
Date: 09/04/18
Organization: VMware
Blog: https://www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.SYNOPSIS
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)]$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 $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;
}
$results
}
}
Function Get-VMCPublicIP {
<#
.NOTES
===========================================================================
Created by: William Lam
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)
}
}
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'