VMware Cloud Community
ccinatl
Enthusiast
Enthusiast
Jump to solution

Modify vApp network - set all to "Retain IP / MAC Resources"

vCloud Director 5.1.3

having a power outage, and looking to modify all vApp networks and set "Reatin IP / MAC Resources" to true so the NAT addresses are retained while vApps are down. 

Anyone have a sample script for something like this.

TIA

0 Kudos
1 Solution

Accepted Solutions
snoopj
Enthusiast
Enthusiast
Jump to solution

If you still need assistance with this, I'll drop this here (with the assumption that I only could modify the check box if the device was Fenced):

Connect-CIServer <vCloud instance>

$allvApps = Get-CIVApp

foreach ($vApp in $allvApps)

{

     $vAppNetConfig = $vApp.ExtensionData.GetNetworkingConfigSection()                    # Retrieves the vApps Networking Configuration

     $vAppNetConfig.NetworkConfig[0].Configuration.RetainNetInfoAcrossDeployments = $true     # Sets the checkbox for the 1st vApp Network

     $vAppNetConfig.UpdateServerData()          # Pushes the setting to vCloud; refresh vApp screen to ensure checkbox is now checked.

}

This should at least show how to do this.  Keep in mind that the NetworkConfig value returned by the GetNetworkingConfigSection() method is an array.  Even if it is only one, you have to reference it with [0] to actually edit it.  If you don't put [0], it'll return $null values.  You may have to setup a for...each loop to change all of the vApp networks in a vApp if you have more than one.

View solution in original post

0 Kudos
1 Reply
snoopj
Enthusiast
Enthusiast
Jump to solution

If you still need assistance with this, I'll drop this here (with the assumption that I only could modify the check box if the device was Fenced):

Connect-CIServer <vCloud instance>

$allvApps = Get-CIVApp

foreach ($vApp in $allvApps)

{

     $vAppNetConfig = $vApp.ExtensionData.GetNetworkingConfigSection()                    # Retrieves the vApps Networking Configuration

     $vAppNetConfig.NetworkConfig[0].Configuration.RetainNetInfoAcrossDeployments = $true     # Sets the checkbox for the 1st vApp Network

     $vAppNetConfig.UpdateServerData()          # Pushes the setting to vCloud; refresh vApp screen to ensure checkbox is now checked.

}

This should at least show how to do this.  Keep in mind that the NetworkConfig value returned by the GetNetworkingConfigSection() method is an array.  Even if it is only one, you have to reference it with [0] to actually edit it.  If you don't put [0], it'll return $null values.  You may have to setup a for...each loop to change all of the vApp networks in a vApp if you have more than one.

0 Kudos