2. VMware vCloud Director Server Resource Kit : 2.2 vCloud Provisioner : 2.2.4 Advanced Use of vCloud Provisioner
   
2.2.4 Advanced Use of vCloud Provisioner
Advanced use includes cleaning, comparing two instances of the CloudProvisionData container, appending, and modifying.
2.2.4.1. Cleaning
You can clean up all entities that were flushed to the vCloud using the following method:
CloudProvisionData.cleanUp(boolean onlyOwnedEntities);
Use the onlyOwnedEntities argument if only the entities that were created from this CloudProvisionData should be cleaned.
Example:
// Provision some networks and vApps
CloudProvisionData pdNewEntities = CloudProvisionData.fromXml("network-new.xml", restServiceBundle);
try {
pdNewEntities.toCloud();
// Verify it works OK
....
} finally {
pdNewEntities.cleanUp();
}
 
2.2.4.2. Comparing Two Instances of the CloudProvisionDataContainer
Comparing two instances is useful for tests that need to verify the state of the two vCloud instances, such as before and after an upgrade.
Example:
CloudProvisionData pdBefore = CloudProvisionData.fromXml("network-prequisities.xml", restServiceBundle);
upgradeToT2(ssh);
CloudProvisionData pdAfter = CloudProvisionData.fromCloud(restServiceBundle);
if (pdAfter.equals(pdBefore) {
// Success
} else {
// FAILURE!
}
 
2.2.4.3. Appending Entities
You can append the entities from one CloudProvisionData container to another and then operate on the latter.
pdFirst.append(pdSecond);
2.2.4.4. Modifying Entities
You can modify existing entities by using the modify()method of individual entities, or the modify() method of the CloudProvisionData container.