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

View File

@ -73,6 +73,8 @@ import org.jclouds.vcloud.compute.BaseVCloudComputeClient;
import org.jclouds.vcloud.compute.VCloudComputeClient;
import org.jclouds.vcloud.config.VCloudContextModule;
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.VApp;
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(),
ImmutableMap.<String, String> of(), tag, vAppStatusToNodeState.get(vApp
.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

View File

@ -2,9 +2,15 @@ package org.jclouds.vcloud.compute;
import static com.google.common.base.Preconditions.checkNotNull;
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.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.TemplateBuilder;
import org.jclouds.rest.RestContext;
@ -16,7 +22,6 @@ import org.testng.annotations.Test;
/**
*
* Generally disabled, as it incurs higher fees.
*
* @author Adrian Cole
*/
@ -46,4 +51,18 @@ public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
RestContext<VCloudAsyncClient, VCloudClient> tmContext = new ComputeServiceContextFactory()
.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 org.jclouds.compute.BaseComputeServiceLiveTest;
import org.jclouds.compute.domain.Template;
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.Test;
@ -34,39 +33,35 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "live", enabled = true, sequential = true, testName = "compute.HostingDotComVCloudComputeServiceLiveTest")
public class HostingDotComVCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
public class HostingDotComVCloudComputeServiceLiveTest extends VCloudComputeServiceLiveTest {
@BeforeClass
@Override
public void setServiceDefaults() {
service = "hostingdotcom";
}
@Override
protected Template buildTemplate(TemplateBuilder templateBuilder) {
return templateBuilder.osFamily(CENTOS).smallest().build();
}
// Takes too long
@Override
protected JschSshClientModule getSshModule() {
return new JschSshClientModule();
@Test(enabled = false)
public void testCreate() throws Exception {
super.testCreate();
}
@Override
@Test(enabled = false)
public void testGet() throws Exception {
super.testGet();
}
@Override
@Test(enabled = false)
public void testReboot() throws Exception {
super.testReboot();
}
// //Takes too long
// @Override
// @Test(enabled = false)
// public void testCreate() throws Exception {
// super.testCreate();
// }
//
// @Override
// @Test(enabled = false)
// public void testGet() throws Exception {
// 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();
// 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
SortedSet<ComputeOptions> sizeOptions = tmClient.getComputeOptionsOfCatalogItem(itemId);

View File

@ -19,14 +19,9 @@
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.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder;
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.TerremarkVCloudClient;
import org.testng.annotations.BeforeClass;
@ -34,12 +29,11 @@ import org.testng.annotations.Test;
/**
*
* Generally disabled, as it incurs higher fees.
*
* @author Adrian Cole
*/
@Test(groups = "live", enabled = true, sequential = true, testName = "terremark.TerremarkVCloudComputeServiceLiveTest")
public class TerremarkVCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest {
public class TerremarkVCloudComputeServiceLiveTest extends VCloudComputeServiceLiveTest {
@BeforeClass
@Override
@ -47,18 +41,10 @@ public class TerremarkVCloudComputeServiceLiveTest extends BaseComputeServiceLiv
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 {
@SuppressWarnings("unused")
RestContext<TerremarkVCloudAsyncClient, TerremarkVCloudClient> tmContext = new ComputeServiceContextFactory()
.createContext(service, user, password).getProviderSpecificContext();
}
}