private static ComputeDescriptionService.ComputeDescription createComputeDescription( TestHost host, String instanceAdapterLink, String bootAdapterLink) throws Throwable { // Create ComputeDescription ComputeDescriptionService.ComputeDescription cd = new ComputeDescriptionService.ComputeDescription(); cd.environmentName = ComputeDescriptionService.ComputeDescription.ENVIRONMENT_NAME_ON_PREMISE; cd.costPerMinute = 1; cd.cpuMhzPerCore = 1000; cd.cpuCount = 2; cd.gpuCount = 1; cd.currencyUnit = "USD"; cd.totalMemoryBytes = Integer.MAX_VALUE; cd.id = UUID.randomUUID().toString(); cd.name = "friendly-name"; cd.regionId = "provider-specific-regions"; cd.zoneId = "provider-specific-zone"; // disable periodic maintenance for tests by default. cd.healthAdapterReference = null; if (instanceAdapterLink != null) { cd.instanceAdapterReference = UriUtils.buildUri(host, instanceAdapterLink); cd.powerAdapterReference = URI.create("http://powerAdapter"); } if (bootAdapterLink != null) { cd.bootAdapterReference = UriUtils.buildUri(host, bootAdapterLink); } return host.postServiceSynchronously( ComputeDescriptionFactoryService.SELF_LINK, cd, ComputeDescriptionService.ComputeDescription.class); }
private static ComputeService.ComputeState createParentCompute( TestHost host, String resourcePool, String zoneId) throws Throwable { // Create parent ComputeDescription ComputeDescriptionService.ComputeDescription cd = new ComputeDescriptionService.ComputeDescription(); cd.bootAdapterReference = new URI("http://bootAdapterReference"); cd.powerAdapterReference = new URI("http://powerAdapterReference"); cd.instanceAdapterReference = new URI("http://instanceAdapterReference"); cd.healthAdapterReference = null; cd.enumerationAdapterReference = new URI("http://enumerationAdapterReference"); cd.supportedChildren = new ArrayList<>(); cd.supportedChildren.add(ComputeType.VM_GUEST.toString()); cd.environmentName = ComputeDescriptionService.ComputeDescription.ENVIRONMENT_NAME_ON_PREMISE; cd.costPerMinute = 1; cd.cpuMhzPerCore = 1000; cd.cpuCount = 2; cd.gpuCount = 1; cd.currencyUnit = "USD"; cd.totalMemoryBytes = Integer.MAX_VALUE; cd.id = UUID.randomUUID().toString(); cd.name = "friendly-name"; cd.regionId = "provider-specific-regions"; cd.zoneId = zoneId; ComputeDescriptionService.ComputeDescription cd1 = host.postServiceSynchronously( ComputeDescriptionFactoryService.SELF_LINK, cd, ComputeDescriptionService.ComputeDescription.class); // Create parent Compute ComputeService.ComputeState cs = new ComputeService.ComputeState(); cs.id = UUID.randomUUID().toString(); cs.descriptionLink = cd1.documentSelfLink; cs.resourcePoolLink = resourcePool; cs.adapterManagementReference = URI.create("https://esxhost-01:443/sdk"); ComputeService.ComputeState cs1 = host.postServiceSynchronously( ComputeFactoryService.SELF_LINK, cs, ComputeService.ComputeState.class); return cs1; }