mirror of https://github.com/apache/jclouds.git
Added more checks
This commit is contained in:
parent
af39fd4b32
commit
21925dde2b
|
@ -22,25 +22,29 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.*
|
|||
import static org.testng.Assert.*;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.CustomOrgLdapSettings.AuthenticationMechanism;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.CustomOrgLdapSettings.ConnectorType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgLdapSettings.LdapMode;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.cim.VirtualSystemSettingData;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.Disk;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.DiskSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.Envelope;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.Network;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.OperatingSystemSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.ProductSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.SectionType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualHardwareSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.VirtualSystem;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.environment.EnvironmentType;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.net.InetAddresses;
|
||||
|
||||
/**
|
||||
|
@ -423,6 +427,11 @@ public class Checks {
|
|||
InetAddresses.isInetAddress(ip);
|
||||
}
|
||||
|
||||
private static void checkMacAddress(String macAddress) {
|
||||
assertNotNull(macAddress, String.format(NOT_NULL_OBJECT_FMT, "macAddress", ""));
|
||||
assertTrue(macAddress.matches("^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$"));
|
||||
}
|
||||
|
||||
public static void checkComputeCapacity(ComputeCapacity computeCapacity) {
|
||||
// Check required fields
|
||||
assertNotNull(computeCapacity.getCpu(), "The cpu attribute of a ComputeCapacity must be set");
|
||||
|
@ -549,6 +558,9 @@ public class Checks {
|
|||
}
|
||||
|
||||
public static void checkVAppTemplate(VAppTemplate template) {
|
||||
// Check required fields
|
||||
assertNotNull(template.getName(), String.format(NOT_NULL_OBJECT_FMT, "Name", "VAppTemplate"));
|
||||
|
||||
// Check optional fields
|
||||
Owner owner = template.getOwner();
|
||||
if (owner != null) checkOwner(owner);
|
||||
|
@ -558,6 +570,17 @@ public class Checks {
|
|||
for (SectionType<?> section : template.getSections()) {
|
||||
checkSectionType(section);
|
||||
}
|
||||
if (template.getTasks() != null) {
|
||||
for (Task task : template.getTasks()) {
|
||||
checkTask(task);
|
||||
}
|
||||
}
|
||||
if (template.getFiles() != null) {
|
||||
for (File file : template.getFiles().getFiles()) { // TODO FileList should implement List
|
||||
checkFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE vAppScopedLocalId cannot be checked
|
||||
// NOTE ovfDescriptorUploaded cannot be checked
|
||||
// NOTE goldMaster cannot be checked
|
||||
|
@ -635,7 +658,7 @@ public class Checks {
|
|||
public static void checkResourceAllocationSettingData(ResourceAllocationSettingData item) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
public static void checkMediaFor(String client, Media media) {
|
||||
// required
|
||||
assertNotNull(media.getImageType(), String.format(OBJ_FIELD_REQ, client, "imageType"));
|
||||
|
@ -908,6 +931,258 @@ public class Checks {
|
|||
// TODO: regex validate telephone
|
||||
}
|
||||
|
||||
public static void checkCustomizationSection(CustomizationSection val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "CustomizationSection", ""));
|
||||
|
||||
// Check optional fields
|
||||
if (val.getLinks() != null) {
|
||||
for (Link link : val.getLinks()) {
|
||||
checkLink(link);
|
||||
}
|
||||
}
|
||||
if (val.getType() != null) {
|
||||
checkType(val.getType());
|
||||
}
|
||||
if (val.getHref() != null) {
|
||||
checkHref(val.getHref());
|
||||
}
|
||||
|
||||
checkOvfSectionType(val);
|
||||
}
|
||||
|
||||
public static void checkProductSectionList(ProductSectionList val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "ProductSectionList", ""));
|
||||
|
||||
for (ProductSection productSection : val.getProductSections()) { // TODO Should implement List
|
||||
checkOvfProductSection(productSection);
|
||||
}
|
||||
|
||||
checkResourceType(val);
|
||||
}
|
||||
|
||||
public static void checkGuestCustomizationSection(GuestCustomizationSection val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "GuestCustomizationSection", ""));
|
||||
|
||||
if (!val.isJoinDomainEnabled()) {
|
||||
assertFalse(val.isUseOrgSettings());
|
||||
assertNull(val.getDomainName());
|
||||
assertNull(val.getDomainUserName());
|
||||
assertNull(val.getDomainUserPassword());
|
||||
}
|
||||
|
||||
if (!val.isAdminPasswordEnabled()) {
|
||||
assertFalse(val.isAdminPasswordAuto());
|
||||
assertFalse(val.isResetPasswordRequired());
|
||||
if (val.isAdminPasswordAuto()) {
|
||||
assertNull(val.getAdminPassword());
|
||||
}
|
||||
}
|
||||
|
||||
checkOvfSectionType(val);
|
||||
}
|
||||
|
||||
public static void checkLeaseSettingsSection(LeaseSettingsSection val) {
|
||||
if (val.getLinks() != null) {
|
||||
for (Link link : val.getLinks()) {
|
||||
checkLink(link);
|
||||
}
|
||||
}
|
||||
|
||||
checkOvfSectionType(val);
|
||||
}
|
||||
|
||||
public static void checkNetworkConfigSection(NetworkConfigSection val) {
|
||||
if (val.getNetworkConfigs() != null) {
|
||||
for (VAppNetworkConfiguration networkConfig : val.getNetworkConfigs()) {
|
||||
checkVAppNetworkConfig(networkConfig);
|
||||
}
|
||||
}
|
||||
if (val.getLinks() != null) {
|
||||
for (Link link : val.getLinks()) {
|
||||
checkLink(link);
|
||||
}
|
||||
}
|
||||
if (val.getHref() != null) {
|
||||
checkHref(val.getHref());
|
||||
}
|
||||
|
||||
checkOvfSectionType(val);
|
||||
}
|
||||
|
||||
private static void checkVAppNetworkConfig(VAppNetworkConfiguration val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "VAppNetworkConfiguration", ""));
|
||||
|
||||
// required fields
|
||||
assertNotNull(val.getNetworkName(), String.format(NOT_NULL_OBJECT_FMT, "NetworkName", "VAppNetworkConfiguration"));
|
||||
checkNetworkConfiguration(val.getConfiguration());
|
||||
|
||||
checkResourceType(val);
|
||||
}
|
||||
|
||||
public static void checkNetworkConnectionSection(NetworkConnectionSection val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "VAppConnectionSection", ""));
|
||||
|
||||
// Check optional fields
|
||||
if (val.getLinks() != null) {
|
||||
for (Link link : val.getLinks()) {
|
||||
checkLink(link);
|
||||
}
|
||||
}
|
||||
if (val.getHref() != null) {
|
||||
checkHref(val.getHref());
|
||||
}
|
||||
if (val.getNetworkConnections() != null) {
|
||||
for (NetworkConnection networkConnection : val.getNetworkConnections()) {
|
||||
checkNetworkConnection(networkConnection);
|
||||
}
|
||||
}
|
||||
if (val.getType() != null) {
|
||||
checkType(val.getType());
|
||||
}
|
||||
|
||||
checkOvfSectionType(val);
|
||||
}
|
||||
|
||||
private static void checkNetworkConnection(NetworkConnection val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "NetworkConnection", ""));
|
||||
|
||||
// Check required fields
|
||||
assertNotNull(val.getNetwork(), String.format(NOT_NULL_OBJECT_FMT, "Network", "NetworkConnection"));
|
||||
assertNotNull(val.getIpAddressAllocationMode(), String.format(NOT_NULL_OBJECT_FMT, "IpAddressAllocationMode", "NetworkConnection"));
|
||||
assertTrue(NetworkConnection.IpAddressAllocationMode.ALL.contains(val.getIpAddressAllocationMode()),
|
||||
String.format(REQUIRED_VALUE_OBJECT_FMT, "IpAddressAllocationMode", "NetworkConnection", val.getIpAddressAllocationMode(), Iterables.toString(NetworkConnection.IpAddressAllocationMode.ALL)));
|
||||
|
||||
// Check optional fields
|
||||
if (val.getIpAddress() != null) {
|
||||
checkIpAddress(val.getIpAddress());
|
||||
}
|
||||
if (val.getExternalIpAddress() != null) {
|
||||
checkIpAddress(val.getExternalIpAddress());
|
||||
}
|
||||
|
||||
if (val.getMACAddress() != null) {
|
||||
checkMacAddress(val.getMACAddress());
|
||||
}
|
||||
|
||||
// FIXME Missing?
|
||||
//val.getVCloudExtension();
|
||||
}
|
||||
|
||||
public static void checkOvfSectionType(SectionType<?> section) {
|
||||
assertNotNull(section, String.format(NOT_NULL_OBJECT_FMT, "SectionType", ""));
|
||||
}
|
||||
|
||||
public static void checkOvfProductSection(ProductSection val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "ProductSection", ""));
|
||||
|
||||
if (val.getProperties() != null) {
|
||||
for (org.jclouds.vcloud.director.v1_5.domain.ovf.Property property : val.getProperties()) {
|
||||
checkOvfProperty(property);
|
||||
}
|
||||
}
|
||||
|
||||
checkOvfSectionType(val);
|
||||
}
|
||||
|
||||
private static void checkOvfProperty(org.jclouds.vcloud.director.v1_5.domain.ovf.Property val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "Property", ""));
|
||||
}
|
||||
|
||||
public static void checkOvfNetworkSection(NetworkSection val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "NetworkSection", ""));
|
||||
|
||||
if (val.getNetworks() != null) {
|
||||
for (Network network : val.getNetworks()) {
|
||||
checkOvfNetwork(network);
|
||||
}
|
||||
}
|
||||
|
||||
checkOvfSectionType(val);
|
||||
}
|
||||
|
||||
private static void checkOvfNetwork(Network val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "Network", ""));
|
||||
}
|
||||
|
||||
public static void checkOvfEnvelope(Envelope val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "Envelope", ""));
|
||||
|
||||
if (val.getDiskSections() != null) {
|
||||
for (DiskSection diskSection : val.getDiskSections()) {
|
||||
checkOvfDiskSection(diskSection);
|
||||
}
|
||||
}
|
||||
if (val.getNetworkSections() != null) {
|
||||
for (NetworkSection networkSection : val.getNetworkSections()) {
|
||||
checkOvfNetworkSection(networkSection);
|
||||
}
|
||||
}
|
||||
if (val.getVirtualSystem() != null) {
|
||||
checkOvfVirtualSystem(val.getVirtualSystem());
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkOvfVirtualSystem(VirtualSystem val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "VirtualSystem", ""));
|
||||
|
||||
if (val.getProductSections() != null) {
|
||||
for (ProductSection productSection : val.getProductSections()) {
|
||||
checkOvfProductSection(productSection);
|
||||
}
|
||||
}
|
||||
if (val.getVirtualHardwareSections() != null) {
|
||||
for (VirtualHardwareSection virtualHardwareSection : val.getVirtualHardwareSections()) {
|
||||
checkOvfVirtualHardwareSection(virtualHardwareSection);
|
||||
}
|
||||
}
|
||||
if (val.getOperatingSystemSection() != null) {
|
||||
checkOvfOperationSystemSection(val.getOperatingSystemSection());
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkOvfDiskSection(DiskSection val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "DiskSection", ""));
|
||||
|
||||
if (val.getDisks() != null) {
|
||||
for (Disk disk : val.getDisks()) {
|
||||
checkOvfDisk(disk);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkOvfDisk(Disk val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "Disk", ""));
|
||||
}
|
||||
|
||||
private static void checkOvfOperationSystemSection(OperatingSystemSection val) {
|
||||
checkOvfSectionType(val);
|
||||
}
|
||||
|
||||
private static void checkOvfVirtualHardwareSection(VirtualHardwareSection val) {
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "VirtualHardwareSection", ""));
|
||||
|
||||
if (val.getItems() != null) {
|
||||
for (ResourceAllocationSettingData item : val.getItems()) {
|
||||
checkCimResourceAllocationSettingData(item);
|
||||
}
|
||||
}
|
||||
if (val.getSystem() != null) {
|
||||
checkCimVirtualSystemSettingData(val.getSystem());
|
||||
}
|
||||
|
||||
checkOvfSectionType(val);
|
||||
}
|
||||
|
||||
private static void checkCimVirtualSystemSettingData(VirtualSystemSettingData val) {
|
||||
// TODO Could do more assertions...
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "VirtualSystemSettingData", ""));
|
||||
}
|
||||
|
||||
private static void checkCimResourceAllocationSettingData(ResourceAllocationSettingData val) {
|
||||
// TODO Could do more assertions...
|
||||
assertNotNull(val, String.format(NOT_NULL_OBJECT_FMT, "ResouorceAllocatoinSettingData", ""));
|
||||
}
|
||||
|
||||
public static void checkAdminVdc(AdminVdc vdc) {
|
||||
// optional
|
||||
// NOTE isThinProvision cannot be checked
|
||||
|
|
Loading…
Reference in New Issue