Tag : vcloud-director

VMware How To: Shut Down vCloud Director Cell Cleanly

To cleanly shut down a vCloud Director cell run the following commands.

Display the current state of the cell to view any active jobs.
#  /opt/vmware/vcloud-director/bin/cell-management-tool -u <USERNAME> cell --status

Then Quiesce the active jobs.
#  /opt/vmware/vcloud-director/bin/cell-management-tool -u <USERNAME> cell --quiesce true

Check the cell isn’t processing any active jobs.
#  /opt/vmware/vcloud-director/bin/cell-management-tool -u <USERNAME> cell --status

Shut the cell down to prevent any other jobs from becoming active on the cell.
#  /opt/vmware/vcloud-director/bin/cell-management-tool -u <USERNAME> cell --shutdown

Now run the status command again to check that job count says zero.
#  /opt/vmware/vcloud-director/bin/cell-management-tool -u <USERNAME> cell --status

vCD cell status

Then stop the vCD service.
# service vmware-vcd stop

When you want to bring the host back up again start the service.
# service vmware-vcd start

A typical service start takes around 2-5 minutes.  You can monitor the progess of the restart by tailing the cell.log file.
# tail -f /opt/vmware/vcloud-director/logs/cell.log

cell starting

Once it say’s 100%, it is done.

PowerCLI: Remap vCD Network When Duplicate Exists

Ok so it’s a bit of a long title.

When you import a virtual machine into vCloud Director from the underlying vCenter Server you can remap the network as mentioned in my previous blog post Import VMs from vCenter to vCloud Director using PowerCLI.
This works great up to the point when you have more than one vApp network with the same name, something that grows increasingly likely the bigger your vCD environment gets.

There is a way around this issue.  You can get PowerCLI to query the vApp that you are trying to connect the imported VM to and use the output of the vApp network name in the remap command.  Let me show you.

First connect PowerCLI to the vCD cell and the underlying vCenter.

$ciserver = vclouddirector.domain.com
$viserver = vcenter.domain.com

Connect-VIServer -Server $viserver
Connect-CIServer -Server $ciserver

Now specify the vApp name

$civapp = vApp_Name

Then specify the vApp network name so you can call it when you get the VM to do the remap.

$cinetwork = get-civapp $civapp | Get-CIVAppNetwork Network_Name

Finally run the remap command

Get-CINetworkAdapter | Set-CINetworkAdapter -vappnetwork $cinetwork -IPaddressAllocationMode Pool -Connected $True

To simplify this further you can run this all as part of a script to query all the VMs that are added to the vApp and remap all their networks to use the same one.  To use this just copy and paste it into a text editor and save it as a .PS1 file.

$ciserver = 'vclouddirector.domain.com'
$viserver = 'vcenter.domain.com'

Connect-VIServer -Server $viserver
Connect-CIServer -Server $ciserver

<$civapp = 'vApp_Name'
$cinetwork = get-civapp $civapp | Get-CIVAppNetwork 'Network_Name'
foreach ($civm in $civms) {
$civm | Get-CINetworkAdapter | Set-CINetworkAdapter -vappnetwork $cinetwork -IPaddressAllocationMode Pool -Connected $True
}

You can add an extra layer to this by specifying a variable to query Organisation Virtual Datacenter first then add this to the $cinetwork variable as follows.

$orgvdc = OrgvDC_Name
$cinetwork = get-orgvdc $orgvdc | get-civapp $civapp | Get-CIVAppNetwork Network_Name