mirror of https://github.com/apache/jclouds.git
add checks for: ComputeCapacity, CapacityWithUsage, CapacityType, ResourceEntities, AvailableNetworks, Capabilities, SupportedHardwareVersions, Metadata, MetadataValue
This commit is contained in:
parent
95cb736a18
commit
52717c3135
|
@ -20,6 +20,8 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.CONDITION_FMT;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.CONDITION_FMT;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MUST_BE_WELL_FORMED_FMT;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MUST_BE_WELL_FORMED_FMT;
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_ATTRB_REQ;
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MUST_CONTAIN_FMT;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MUST_CONTAIN_FMT;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.NOT_NULL_OBJECT_FMT;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.NOT_NULL_OBJECT_FMT;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_GTE_0;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_GTE_0;
|
||||||
|
@ -269,19 +271,15 @@ public class Checks {
|
||||||
if (config.getIpScope() != null) {
|
if (config.getIpScope() != null) {
|
||||||
checkIpScope(config.getIpScope());
|
checkIpScope(config.getIpScope());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.getParentNetwork() != null) {
|
if (config.getParentNetwork() != null) {
|
||||||
checkReferenceType(config.getParentNetwork());
|
checkReferenceType(config.getParentNetwork());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.getNetworkFeatures() != null) {
|
if (config.getNetworkFeatures() != null) {
|
||||||
checkNetworkFeatures(config.getNetworkFeatures());
|
checkNetworkFeatures(config.getNetworkFeatures());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.getSyslogServerSettings() != null) {
|
if (config.getSyslogServerSettings() != null) {
|
||||||
checkSyslogServerSettings(config.getSyslogServerSettings());
|
checkSyslogServerSettings(config.getSyslogServerSettings());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.getRouterInfo() != null) {
|
if (config.getRouterInfo() != null) {
|
||||||
checkRouterInfo(config.getRouterInfo());
|
checkRouterInfo(config.getRouterInfo());
|
||||||
}
|
}
|
||||||
|
@ -327,7 +325,6 @@ public class Checks {
|
||||||
if (settings.getSyslogServerIp1() != null) {
|
if (settings.getSyslogServerIp1() != null) {
|
||||||
checkIpAddress(settings.getSyslogServerIp1());
|
checkIpAddress(settings.getSyslogServerIp1());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.getSyslogServerIp2() != null) {
|
if (settings.getSyslogServerIp2() != null) {
|
||||||
checkIpAddress(settings.getSyslogServerIp2());
|
checkIpAddress(settings.getSyslogServerIp2());
|
||||||
}
|
}
|
||||||
|
@ -370,6 +367,95 @@ public class Checks {
|
||||||
public static void checkIpAddress(String ip) {
|
public static void checkIpAddress(String ip) {
|
||||||
InetAddresses.isInetAddress(ip);
|
InetAddresses.isInetAddress(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void checkComputeCapacity(ComputeCapacity computeCapacity) {
|
||||||
|
// Check required fields
|
||||||
|
assertNotNull(computeCapacity.getCpu(), "The cpu attribute of a ComputeCapacity must be set");
|
||||||
|
checkCapacityWithUsage(computeCapacity.getCpu());
|
||||||
|
|
||||||
|
assertNotNull(computeCapacity.getMemory(), "The memory attribute of a ComputeCapacity must be set");
|
||||||
|
checkCapacityWithUsage(computeCapacity.getMemory());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkCapacityWithUsage(CapacityWithUsage capacityWithUsage) {
|
||||||
|
// Check optional fields
|
||||||
|
if (capacityWithUsage.getUsed() != null) {
|
||||||
|
assertTrue(capacityWithUsage.getUsed() >= 0, "used must be greater than or equal to 0");
|
||||||
|
}
|
||||||
|
if (capacityWithUsage.getOverhead() != null) {
|
||||||
|
assertTrue(capacityWithUsage.getOverhead() >= 0, "overhead must be greater than or equal to 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check parent type
|
||||||
|
checkCapacityType(capacityWithUsage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkCapacityType(CapacityType<?> capacity) {
|
||||||
|
// Check required fields
|
||||||
|
assertNotNull(capacity.getUnits(), "The unit attribute of a CapacityWithUsage must be set");
|
||||||
|
|
||||||
|
assertNotNull(capacity.getLimit(), "The limit attribute of a CapacityWithUsage must be set");
|
||||||
|
assertTrue(capacity.getLimit() >= 0, "Limit must be greater than or equal to 0");
|
||||||
|
|
||||||
|
|
||||||
|
// Check optional fields
|
||||||
|
if (capacity.getAllocated() != null) {
|
||||||
|
assertTrue(capacity.getAllocated() >= 0, "allocated must be greater than or equal to 0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkResourceEntities(ResourceEntities resourceEntities) {
|
||||||
|
for (Reference resourceEntity : resourceEntities.getResourceEntities()) {
|
||||||
|
checkReferenceType(resourceEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkAvailableNetworks(AvailableNetworks availableNetworks) {
|
||||||
|
for (Reference network : availableNetworks.getNetworks()) {
|
||||||
|
checkReferenceType(network);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkCapabilities(Capabilities capabilities) {
|
||||||
|
// Check optional fields
|
||||||
|
if (capabilities.getSupportedHardwareVersions() != null) {
|
||||||
|
checkSupportedHardwareVersions(capabilities.getSupportedHardwareVersions());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void checkSupportedHardwareVersions(SupportedHardwareVersions supportedHardwareVersions) {
|
||||||
|
for (String supportedHardwareVersion : supportedHardwareVersions.getSupportedHardwareVersions()) {
|
||||||
|
// NOTE supportedHardwareVersion cannot be checked?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkMetadataFor(String client, Metadata metadata) {
|
||||||
|
for (MetadataEntry entry : metadata.getMetadataEntries()) {
|
||||||
|
// Check required fields
|
||||||
|
assertNotNull(entry.getKey(),
|
||||||
|
String.format(OBJ_FIELD_ATTRB_REQ, client, "MetadataEntry", entry.getKey(), "key"));
|
||||||
|
assertNotNull(entry.getValue(),
|
||||||
|
String.format(OBJ_FIELD_ATTRB_REQ, client, "MetadataEntry", entry.getValue(), "value"));
|
||||||
|
|
||||||
|
// Check parent type
|
||||||
|
checkResourceType(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check parent type
|
||||||
|
checkResourceType(metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void checkMetadataValueFor(String client, MetadataValue metadataValue) {
|
||||||
|
// Check required fields
|
||||||
|
String value = metadataValue.getValue();
|
||||||
|
assertNotNull(value,
|
||||||
|
String.format(OBJ_FIELD_ATTRB_REQ, client, "MetadataEntry",
|
||||||
|
metadataValue.toString(), "value"));
|
||||||
|
assertEquals(value, "value",
|
||||||
|
String.format(OBJ_FIELD_EQ, client, "metadataEntry.value", "value", value));
|
||||||
|
|
||||||
|
// Check parent type
|
||||||
|
checkResourceType(metadataValue);
|
||||||
|
}
|
||||||
|
|
||||||
public static void checkVApp(VApp vApp) {
|
public static void checkVApp(VApp vApp) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
Loading…
Reference in New Issue