// test for a single vm, as savvis response times are very slow. So if there are multiple vpdc's with numerous vm's,
// test execution will invariably take a long time
@Test
public void testVM() throws Exception {
for (Resource org1 : restContext.getApi().listOrgs()) {
Org org = api.getOrg(org1.getId());
VDC_LOOP : for (Resource vdc : org.getVDCs()) {
VDC VDC = api.getVDCInOrg(org.getId(), vdc.getId());
for (Resource vApp : Iterables.filter(VDC.getResourceEntities(), new Predicate<Resource>() {
@Override
public boolean apply(Resource arg0) {
return VCloudMediaType.VAPP_XML.equals(arg0.getType());
}
})) {
VM response = api.getVMInVDC(org.getId(), vdc.getId(), vApp.getId());
assertNotNull(response);
assertNotNull(response.getId());
assertNotNull(response.getHref());
assertNotNull(response.getName());
assertEquals(response.getType(), "application/vnd.vmware.vcloud.vApp+xml");
assert (response.getNetworkConnectionSections().size() > 0) : response;
for (NetworkConnectionSection networkConnection : response.getNetworkConnectionSections())
assertNotNull(networkConnection.getIpAddress());
assertNotNull(response.getStatus());
assertNotNull(response.getOperatingSystemSection().getDescription());
assertNotNull(response.getOperatingSystemSection().getId());
assertNotNull(response.getNetworkSection());
assertNotNull(response.getVirtualHardwareSections());
// power state is the only thing that should change
assertEquals(api.getVMInVDC(org.getId(), vdc.getId(), response.getId(), withPowerState()).toString()
.replaceFirst("status=[A-Z]+", ""), response.toString().replaceFirst("status=[A-Z]+", ""));
// check one ip is valid
String ip = Iterables.get(response.getNetworkConnectionSections(), 0).getIpAddress();
assert HostSpecifier.isValid(ip) : response;