Skip to content

Commit

Permalink
Review for Nov 17th release of CDS and adjusted
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianBegg committed Nov 18, 2020
1 parent 39e671e commit b39ce0b
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 128 deletions.
88 changes: 0 additions & 88 deletions Public/Environment/Get-VCDSTemplates.ps1

This file was deleted.

100 changes: 100 additions & 0 deletions Public/Environment/Get-VCDSUpgradeTracks.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
function Get-VCDSUpgradeTracks(){
<#
.SYNOPSIS
Returns the configurable upgrade tracks and stations for the provided Cloud Director Service environment.
.DESCRIPTION
Returns the configurable upgrade tracks and stations for the provided Cloud Director Service environment.
.PARAMETER EnvironmentId
Optionally The Cloud Director Service Environment Id (Default is used if none is provided)
.PARAMETER TrackName
Optionally the Upgrade Track to filter.
.PARAMETER StationName
Optionally the Station Name to filter.
.PARAMETER DefaultStation
If set returns the deafult station for the provided environment
.EXAMPLE
Get-VCDSUpgradeTracks
Returns a collection of all upgrade tracks and stations available for the default environment
.EXAMPLE
Get-VCDSUpgradeTracks -DefaultStation
Returns the default station for the current
.EXAMPLE
Get-VCDSUpgradeTracks -EnvironmentId "urn:vcdc:environment:3fccbd2a-003c-4303-8f1a-8569853236ac" -TrackName "sp-main"
Returns all of the stations under the Upgrade Track named "sp-main" in the environment with the id urn:vcdc:environment:3fccbd2a-003c-4303-8f1a-8569853236ac if it exists.
.NOTES
AUTHOR: Adrian Begg
LASTEDIT: 2020-11-17
VERSION: 1.0
#>
[CmdletBinding(DefaultParameterSetName="Default")]
Param(
[Parameter(Mandatory=$True, ParameterSetName="TrackName")]
[ValidateNotNullorEmpty()] [string] $TrackName,
[Parameter(Mandatory=$True, ParameterSetName="StationName")]
[ValidateNotNullorEmpty()] [string] $StationName,
[Parameter(Mandatory=$False)]
[ValidateNotNullorEmpty()] [string] $EnvironmentId,
[Parameter(Mandatory=$False, ParameterSetName="Default")]
[switch]$DefaultStation
)
if(!$global:VCDService.IsConnected){
throw "You are not currently connected to the VMware Console Services Portal (CSP) for VMware Cloud Director Service. Please use Connect-VCDService cmdlet to connect to the service and try again."
}
# Next check if the EnvironmentId has been provided and is valid
if($PSBoundParameters.ContainsKey("EnvironmentId")){
$Environment = $global:VCDService.VCDSEnvironments | Where-Object {$_.id -eq $EnvironmentId}
if($Environment.count -eq 0){
throw "An VCDS Environment with the Id $EnvironmentId can not be found. Please check the Id and try again."
}
} else {
$Environment = $global:VCDService.DefaultEnvironment
}
# Setup a Service URI for the environment
$ServiceURI = $Environment.url

# Setup a HashTable for the API call to the Cloud Gateway
$TemplateAPIEndpoint = "$ServiceURI/environment/$($Environment.id)/upgrade-tracks-and-stations"

# A Hashtable of Request Parameters
[Hashtable] $RequestParameters = @{
URI = $TemplateAPIEndpoint
Method = "Get"
ContentType = "application/json"
Headers = @{
"Authorization" = "Bearer $($global:VCDService.AccessToken)"
"Accept" = "application/json"
}
UseBasicParsing = $true
}
try{
# First return the environments collection from CSP
$colUpgradeTracks = ((Invoke-WebRequest @RequestParameters).Content | ConvertFrom-Json)
if($DefaultStation){
return $colUpgradeTracks.defaultStation
} else {
if($PSBoundParameters.ContainsKey("TrackName")){
return $colUpgradeTracks.tracks | Where-Object {$_.name -eq $TrackName}
}
elseif($PSBoundParameters.ContainsKey("StationName")){
foreach($Station in $colUpgradeTracks.tracks.stations){
if($Station -eq $StationName){
return $StationName
}
}
} else {
return $colUpgradeTracks.tracks
}
}
} catch {
throw "An exception has occurred attempting to make the API call. $_"
}
}
55 changes: 28 additions & 27 deletions Public/Environment/New-VCDSInstance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,35 @@ function New-VCDSInstance(){
.PARAMETER EnvironmentId
Optionally The Cloud Director Service Environment Id (Default is used if none is provided)
.PARAMETER TemplateId
The Cloud Director Template Id of the image to deploy.
.PARAMETER Domain
The FQDN for the service. If none is provided a random one will be generated under .vdp.vmware.com
.PARAMETER UpgradeCategory
The Cloud Director Upgrade "Station" for the deployed instance. Use the Get-VCDSUpgradeTracks cmdlet to view valid Stations.
If none is provided the default will be used for the environment.
.PARAMETER AdministratorPassword
The password for the administrator user in the System Org
.EXAMPLE
New-VCDSInstance -Name "CDS-Instanace-01" -TemplateId "urn:vcdc:deploymentTemplate:cf4e35ce-65f0-4590-8f6f-79a86d270d06" -AdministratorPassword "Welcome@123"
Creates a new VCDS Instance in the default environment using Template with the Id urn:vcdc:deploymentTemplate:cf4e35ce-65f0-4590-8f6f-79a86d270d06
New-VCDSInstance -Name "CDS-Instanace-01" -AdministratorPassword "Welcome@123"
Creates a new VCDS Instance named "CDS-Instance-01" in the default environment with the default upgrade catagory.
.EXAMPLE
New-VCDSInstance -Name "CDS-Instanace-01" -UpgradeCategory "sp-main:alpha" -AdministratorPassword "Welcome@123"
Creates a new VCDS Instance in the default environment using Upgrade Catagory "sp-main:alpha"
.EXAMPLE
New-VCDSInstance -Name "CDS-Instanace-01" -EnvironmentId "urn:vcdc:environment:3fccbd2a-003c-4303-8f1a-8569853236ac" -TemplateId "urn:vcdc:deploymentTemplate:cf4e35ce-65f0-4590-8f6f-79a86d270d06" -AdministratorPassword "Welcome@123"
Creates a new VCDS Instance in the environment with the Id "urn:vcdc:environment:3fccbd2a-003c-4303-8f1a-8569853236ac" using Template with the Id urn:vcdc:deploymentTemplate:cf4e35ce-65f0-4590-8f6f-79a86d270d06
New-VCDSInstance -Name "CDS-Instanace-01" -EnvironmentId "urn:vcdc:environment:3fccbd2a-003c-4303-8f1a-8569853236ac" -UpgradeCategory "sp-release:production" -AdministratorPassword "Welcome@123"
Creates a new VCDS Instance in the environment with the Id "urn:vcdc:environment:3fccbd2a-003c-4303-8f1a-8569853236ac" using UpgradeCatagory "sp-release:production"
.NOTES
AUTHOR: Adrian Begg
LASTEDIT: 2020-02-14
VERSION: 1.0
LASTEDIT: 2020-11-17
VERSION: 1.1
#>
Param(
[Parameter(Mandatory=$True)]
[ValidateNotNullorEmpty()] [String] $Name,
[Parameter(Mandatory=$True)]
[ValidateNotNullorEmpty()] [String] $TemplateId,
[Parameter(Mandatory=$False)]
[ValidateNotNullorEmpty()] [String] $Domain,
[ValidateNotNullorEmpty()] [String] $UpgradeCategory,
[Parameter(Mandatory=$True)]
[ValidateNotNullorEmpty()] [String] $AdministratorPassword,
[Parameter(Mandatory=$False)]
Expand All @@ -64,36 +64,37 @@ function New-VCDSInstance(){
# Setup a Service URI for the environment
$ServiceURI = $Environment.url

# TemplateId valid ?
$Template = Get-VCDSTemplates -EnvironmentId $Environment.id -Id $TemplateId
if($Template.count -eq 0){
throw "An VCDS Template with the Id $TemplateId can not be found. Please check the Id and try again."
# Check if the UpgradeCategory was provided, if yes check if its valid, if no then retireve the default for the environment
if($PSBoundParameters.ContainsKey("UpgradeCategory")){
# Check if the provided Station is valid for the provided environment
$UpgradeCategory = Get-VCDSUpgradeTracks -EnvironmentId $Environment.id -StationName $UpgradeCategory
if($UpgradeCategory.Count -eq 0){
throw "The provided Station Name $UpgradeCategory is not compatible with the provided environment VCDS Environment with the Id $EnvironmentId. Please check the Station Name is correct and try again."
}
} else {
$UpgradeCategory = Get-VCDSUpgradeTracks -EnvironmentId $Environment.id -DefaultStation
}

# Check if an instance already exists with the provided Name
$NamedInstance = Get-VCDSInstances -EnvironmentId $Environment.id -Name $Name
if($NamedInstance.count -ne 0){
throw "An instance with the Name $Name already exists in the environment, please check the Name and try again."
}

# Setup the URI for a single Task
if($PSBoundParameters.ContainsKey("Domain")){
Write-Warning "The Domain parameter does not currently function. A default will be used."
}

# Setup a HashTable for the API call to the Cloud Gateway
$TemplateAPIEndpoint = "$ServiceURI/environment/$($Environment.id)/instances"
$InstancesAPIEndpoint = "$ServiceURI/environment/$($Environment.id)/instances"
[Hashtable] $htPayload = @{
name = $Name
domain = $Domain
domain = $null
environmentId = $($Environment.id)
templateId = $TemplateId
upgradeCategory = $UpgradeCategory
instanceParams = @{}
password = $AdministratorPassword
}

# A Hashtable of Request Parameters
[Hashtable] $RequestParameters = @{
URI = $TemplateAPIEndpoint
URI = $InstancesAPIEndpoint
Method = "Post"
ContentType = "application/json"
Headers = @{
Expand Down
2 changes: 1 addition & 1 deletion Public/Operations/New-VCDSSupportBundle.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function New-VCDSSupportBundle(){
}

# Setup a HashTable for the API call to the Cloud Gateway
$InstanceOperationAPIEndpoint = "$ServiceURI/environment/$($Environment.id)/instances/$($Instance.id)/operations/invoke"
$InstanceOperationAPIEndpoint = "$ServiceURI/environment/$($Environment.id)/instances/$($Instance.id)/operations/invokeOperation"
[Hashtable] $htPayload = @{
operationType = "createSupportBundle"
arguments = @{}
Expand Down
22 changes: 18 additions & 4 deletions Public/Operations/Register-VCDSSDDC.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,21 @@ function Register-VCDSSDDC(){
.PARAMETER SDDCName
The name of the VMC you would like to associate with Cloud Director Service.
.PARAMETER UseVMCProxy
If provided will Associate a VMC SDDC via Proxy
.EXAMPLE
Register-VCDSSDDC -EnvironmentId "urn:vcdc:environment:3fccbd2a-003c-4303-8f1a-8569853236ac" -InstanceName "CDS-Instance-01" -VMCOrganisationUUID "398712a64b-5462-21e4-b4e1-29b0452ac82d" -SDDCName "CDS-Dev-SDDC-01" -VMCAPIToken "ATduasdE1kBpsajdasdRF0HgFtA22jKazpmu4KXdIES1J2esGuwWKYmDpT4OIpNA"
Registers the VMC SDDC named "CDS-Dev-SDDC-01" in Org with UUID "398712a64b-5462-21e4-b4e1-29b0452ac82d" to the CDS instance named CDS-Instance-01 in the environment with the Id "urn:vcdc:environment:3fccbd2a-003c-4303-8f1a-8569853236ac"
.EXAMPLE
Register-VCDSSDDC -UseVMCProxy -EnvironmentId "urn:vcdc:environment:3fccbd2a-003c-4303-8f1a-8569853236ac" -InstanceName "CDS-Instance-01" -VMCOrganisationUUID "398712a64b-5462-21e4-b4e1-29b0452ac82d" -SDDCName "CDS-Dev-SDDC-01" -VMCAPIToken "ATduasdE1kBpsajdasdRF0HgFtA22jKazpmu4KXdIES1J2esGuwWKYmDpT4OIpNA"
Uses the VMC Proxy to register the VMC SDDC named "CDS-Dev-SDDC-01" in Org with UUID "398712a64b-5462-21e4-b4e1-29b0452ac82d" to the CDS instance named CDS-Instance-01 in the environment with the Id "urn:vcdc:environment:3fccbd2a-003c-4303-8f1a-8569853236ac"
.NOTES
AUTHOR: Adrian Begg
LASTEDIT: 2020-04-02
VERSION: 1.1
LASTEDIT: 2020-11-17
VERSION: 2.0
#>
[CmdletBinding(DefaultParameterSetName="ByInstanceId")]
Param(
Expand All @@ -46,7 +53,9 @@ function Register-VCDSSDDC(){
[ValidateNotNullorEmpty()] [string] $SDDCName,
[Parameter(Mandatory=$False, ParameterSetName="ByInstanceId")]
[Parameter(Mandatory=$False, ParameterSetName="ByInstanceName")]
[ValidateNotNullorEmpty()] [String] $EnvironmentId
[ValidateNotNullorEmpty()] [String] $EnvironmentId,
[Parameter(Mandatory=$False)]
[switch]$UseVMCProxy
)
if(!$global:VCDService.IsConnected){
throw "You are not currently connected to the VMware Console Services Portal (CSP) for VMware Cloud Director Service. Please use Connect-VCDService cmdlet to connect to the service and try again."
Expand Down Expand Up @@ -79,7 +88,7 @@ function Register-VCDSSDDC(){
}

# Setup a HashTable for the API call to the Cloud Gateway
$InstanceOperationAPIEndpoint = "$ServiceURI/environment/$($Environment.id)/instances/$($Instance.id)/operations/invoke"
$InstanceOperationAPIEndpoint = "$ServiceURI/environment/$($Environment.id)/instances/$($Instance.id)/operations/invokeOperation"
[Hashtable] $htPayload = @{
operationType = "associateVmc"
arguments = @{
Expand All @@ -88,6 +97,11 @@ function Register-VCDSSDDC(){
vmcName = $SDDCName
}
}
# Check if the "-UseVMCProxy" switch has been provided
if($UseVMCProxy){
Write-Warning "The -UseVMCProxy option is not currently implemented in Cloud Director service. This switch currently has no effect."
#$htPayload.operationType = "associateVmcViaProxy"
}

# A Hashtable of Request Parameters
[Hashtable] $RequestParameters = @{
Expand Down
2 changes: 1 addition & 1 deletion Public/Operations/Set-VCDSDomain.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ function Set-VCDSDomain(){
}

# Setup a HashTable for the API call to the Cloud Gateway
$InstanceOperationAPIEndpoint = "$ServiceURI/environment/$($Environment.id)/instances/$($Instance.id)/operations/invoke"
$InstanceOperationAPIEndpoint = "$ServiceURI/environment/$($Environment.id)/instances/$($Instance.id)/operations/invokeOperation"
[Hashtable] $htPayload = @{
operationType = "associateCustomDomain"
arguments = @{}
Expand Down
Loading

0 comments on commit b39ce0b

Please sign in to comment.