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;
if (InetAddresses2.isPrivateIPAddress(ip)) {
// get public ip
ip = Iterables.get(response.getNetworkConfigSections(), 0).getInternalToExternalNATRules().get(ip);
// could be null
if(ip != null){
assert HostSpecifier.isValid(ip) : response;
}
}