Issue 181: add extra system metadata to vcloud services

This commit is contained in:
Adrian Cole 2010-02-22 18:45:16 -08:00
parent 99cc8000e8
commit 300963078c
6 changed files with 64 additions and 60 deletions

View File

@ -19,18 +19,14 @@
package org.jclouds.vcloud.bluelock.compute; package org.jclouds.vcloud.bluelock.compute;
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.util.Map; import java.util.Map;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.ssh.jsch.config.JschSshClientModule;
import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest;
import org.jclouds.vcloud.domain.NamedResource; import org.jclouds.vcloud.domain.NamedResource;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -44,22 +40,13 @@ import com.google.common.collect.Maps;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", enabled = true, sequential = true, testName = "compute.BlueLockVCloudComputeServiceLiveTest") @Test(groups = "live", enabled = true, sequential = true, testName = "compute.BlueLockVCloudComputeServiceLiveTest")
public class BlueLockVCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { public class BlueLockVCloudComputeServiceLiveTest extends VCloudComputeServiceLiveTest {
@BeforeClass @BeforeClass
@Override @Override
public void setServiceDefaults() { public void setServiceDefaults() {
service = "bluelock"; service = "bluelock";
} }
protected Template buildTemplate(TemplateBuilder templateBuilder) {
return templateBuilder.osFamily(UBUNTU).smallest().build();
}
@Override
protected JschSshClientModule getSshModule() {
return new JschSshClientModule();
}
@Override @Override
public void testListImages() throws Exception { public void testListImages() throws Exception {
super.testListImages(); super.testListImages();

View File

@ -73,6 +73,8 @@ import org.jclouds.vcloud.compute.BaseVCloudComputeClient;
import org.jclouds.vcloud.compute.VCloudComputeClient; import org.jclouds.vcloud.compute.VCloudComputeClient;
import org.jclouds.vcloud.config.VCloudContextModule; import org.jclouds.vcloud.config.VCloudContextModule;
import org.jclouds.vcloud.domain.NamedResource; import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.ResourceAllocation;
import org.jclouds.vcloud.domain.ResourceType;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppStatus; import org.jclouds.vcloud.domain.VAppStatus;
@ -264,9 +266,23 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
return new NodeMetadataImpl(vApp.getId(), vApp.getName(), vDCId, vApp.getLocation(), return new NodeMetadataImpl(vApp.getId(), vApp.getName(), vDCId, vApp.getLocation(),
ImmutableMap.<String, String> of(), tag, vAppStatusToNodeState.get(vApp ImmutableMap.<String, String> of(), tag, vAppStatusToNodeState.get(vApp
.getStatus()), computeClient.getPublicAddresses(id), computeClient .getStatus()), computeClient.getPublicAddresses(id), computeClient
.getPrivateAddresses(id), ImmutableMap.<String, String> of(), null); .getPrivateAddresses(id), getExtra(vApp), null);
}
} }
private static Map<String, String> getExtra(VApp vApp) {
Map<String, String> extra = Maps.newHashMap();
extra.put("memory/mb", Iterables.getOnlyElement(
vApp.getResourceAllocationByType().get(ResourceType.MEMORY)).getVirtualQuantity()
+ "");
extra.put("processor/count", Iterables.getOnlyElement(
vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR)).getVirtualQuantity()
+ "");
for (ResourceAllocation disk : vApp.getResourceAllocationByType().get(ResourceType.PROCESSOR)) {
extra.put(String.format("disk_drive/%s/kb", disk.getId()), disk.getVirtualQuantity() + "");
}
return extra;
} }
@Provides @Provides

View File

@ -2,9 +2,15 @@ package org.jclouds.vcloud.compute;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.compute.domain.OsFamily.UBUNTU; import static org.jclouds.compute.domain.OsFamily.UBUNTU;
import static org.testng.Assert.assertEquals;
import java.util.Map.Entry;
import org.jclouds.compute.BaseComputeServiceLiveTest; import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.ComputeType;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
@ -16,7 +22,6 @@ import org.testng.annotations.Test;
/** /**
* *
* Generally disabled, as it incurs higher fees.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@ -46,4 +51,18 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
RestContext<VCloudAsyncClient, VCloudClient> tmContext = new ComputeServiceContextFactory() RestContext<VCloudAsyncClient, VCloudClient> tmContext = new ComputeServiceContextFactory()
.createContext(service, user, password).getProviderSpecificContext(); .createContext(service, user, password).getProviderSpecificContext();
} }
@Override
public void testListNodes() throws Exception {
for (Entry<String, ? extends ComputeMetadata> node : client.getNodes().entrySet()) {
assertEquals(node.getKey(), node.getValue().getId());
assert node.getValue().getId() != null;
assert node.getValue().getLocationId() != null;
assertEquals(node.getValue().getType(), ComputeType.NODE);
NodeMetadata allData = client.getNodeMetadata(node.getValue());
assert allData.getExtra().get("processor/count") != null;
assert allData.getExtra().get("disk_drive/1/kb") != null;
assert allData.getExtra().get("memory/mb") != null;
}
}
} }

View File

@ -21,10 +21,9 @@ package org.jclouds.vcloud.hostingdotcom.compute;
import static org.jclouds.compute.domain.OsFamily.CENTOS; import static org.jclouds.compute.domain.OsFamily.CENTOS;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -34,39 +33,35 @@ import org.testng.annotations.Test;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", enabled = true, sequential = true, testName = "compute.HostingDotComVCloudComputeServiceLiveTest") @Test(groups = "live", enabled = true, sequential = true, testName = "compute.HostingDotComVCloudComputeServiceLiveTest")
public class HostingDotComVCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { public class HostingDotComVCloudComputeServiceLiveTest extends VCloudComputeServiceLiveTest {
@BeforeClass @BeforeClass
@Override @Override
public void setServiceDefaults() { public void setServiceDefaults() {
service = "hostingdotcom"; service = "hostingdotcom";
} }
@Override
protected Template buildTemplate(TemplateBuilder templateBuilder) { protected Template buildTemplate(TemplateBuilder templateBuilder) {
return templateBuilder.osFamily(CENTOS).smallest().build(); return templateBuilder.osFamily(CENTOS).smallest().build();
} }
// Takes too long
@Override @Override
protected JschSshClientModule getSshModule() { @Test(enabled = false)
return new JschSshClientModule(); public void testCreate() throws Exception {
super.testCreate();
} }
// //Takes too long @Override
// @Override @Test(enabled = false)
// @Test(enabled = false) public void testGet() throws Exception {
// public void testCreate() throws Exception { super.testGet();
// super.testCreate(); }
// }
// @Override
// @Override @Test(enabled = false)
// @Test(enabled = false) public void testReboot() throws Exception {
// public void testGet() throws Exception { super.testReboot();
// super.testGet(); }
// }
//
// @Override
// @Test(enabled = false)
// public void testReboot() throws Exception {
// super.testReboot();
// }
} }

View File

@ -168,7 +168,8 @@ public class TerremarkVCloudClientLiveTest extends VCloudClientLiveTest {
String vDCId = tmClient.getDefaultVDC().getId(); String vDCId = tmClient.getDefaultVDC().getId();
// lookup the id of the item in the catalog you wish to deploy by name // lookup the id of the item in the catalog you wish to deploy by name
String itemId = tmClient.getDefaultCatalog().get("Ubuntu JeOS 9.04 (32-bit)").getId(); Catalog catalog = tmClient.getDefaultCatalog();
String itemId = catalog.get("Ubuntu JeOS 9.10 (32-bit)").getId();
// determine the cheapest configuration size // determine the cheapest configuration size
SortedSet<ComputeOptions> sizeOptions = tmClient.getComputeOptionsOfCatalogItem(itemId); SortedSet<ComputeOptions> sizeOptions = tmClient.getComputeOptionsOfCatalogItem(itemId);

View File

@ -19,14 +19,9 @@
package org.jclouds.vcloud.terremark.compute; package org.jclouds.vcloud.terremark.compute;
import static org.jclouds.compute.domain.OsFamily.UBUNTU;
import org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.jclouds.vcloud.compute.VCloudComputeServiceLiveTest;
import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient; import org.jclouds.vcloud.terremark.TerremarkVCloudAsyncClient;
import org.jclouds.vcloud.terremark.TerremarkVCloudClient; import org.jclouds.vcloud.terremark.TerremarkVCloudClient;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
@ -34,12 +29,11 @@ import org.testng.annotations.Test;
/** /**
* *
* Generally disabled, as it incurs higher fees.
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", enabled = true, sequential = true, testName = "terremark.TerremarkVCloudComputeServiceLiveTest") @Test(groups = "live", enabled = true, sequential = true, testName = "terremark.TerremarkVCloudComputeServiceLiveTest")
public class TerremarkVCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { public class TerremarkVCloudComputeServiceLiveTest extends VCloudComputeServiceLiveTest {
@BeforeClass @BeforeClass
@Override @Override
@ -47,18 +41,10 @@ public class TerremarkVCloudComputeServiceLiveTest extends BaseComputeServiceLiv
service = "terremark"; service = "terremark";
} }
protected Template buildTemplate(TemplateBuilder templateBuilder) {
return templateBuilder.osFamily(UBUNTU).smallest().build();
}
@Override
protected JschSshClientModule getSshModule() {
return new JschSshClientModule();
}
public void testAssignability() throws Exception { public void testAssignability() throws Exception {
@SuppressWarnings("unused") @SuppressWarnings("unused")
RestContext<TerremarkVCloudAsyncClient, TerremarkVCloudClient> tmContext = new ComputeServiceContextFactory() RestContext<TerremarkVCloudAsyncClient, TerremarkVCloudClient> tmContext = new ComputeServiceContextFactory()
.createContext(service, user, password).getProviderSpecificContext(); .createContext(service, user, password).getProviderSpecificContext();
} }
} }