alokkrathore
Contributor
Contributor

convert edge gateway to advanced gateway

Was trying to get a PowerShell script to convert edge gateway to advanced gateway on vCloud Director 9.1, we have some 100's of edges and would like to automate this process as we are planning an upgrade of VCD

0 Kudos
1 Reply
bdmpastx
Contributor
Contributor

Here is a simple rest call powershell command I wrote because I had about 4000 or more.

This is not complete but hopefully you get the gist (I didn't want to have to rip all my code up and sanitize it for web).

$vcloud = connect-ciserver

$sessionid = $vcloud.sessionid

        $AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'

        [System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols

$egws = get-edgegateway

foreach($edgegateway in $egws){

        $edgeid = $edgegateway.id.replace("urn:vcloud:gateway:","")

        $upgradeURI = ("https://$vcloud/api/admin/edgeGateway/$edgeid/action/convertToAdvancedGateway")

       

        $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

        $Headers.Add('x-vcloud-authorization', $sessionkey)

        $Headers.Add('accept','application/*+xml;version=31.0')

        $Headers.Add('Content-Type','application/xml')

        $wr = (Invoke-WebRequest -uri $upgradeURI -Method Post -Headers $headers -UseBasicParsing).content

        #check the status of the changes

        [xml]$wrxml = $wr

        $wrtaskhref= $wrxml.Task.href

        Write-Verbose  "wrtaskhref: $wrtaskhref"

        try{

            while($ts -ne 'success')

            {

            [xml]$taskstatus = (Invoke-WebRequest -uri $wrtaskhref -Method get -Headers $headers).content

            $ts = $taskstatus.Task.Status

            Write-Verbose "ts: $ts"

            start-sleep -Seconds 3}

            }

            catch{}

}

0 Kudos