mirror of https://github.com/apache/jclouds.git
corrected Ip address handling in default vcloud impl
This commit is contained in:
parent
9ba88797a0
commit
8921dfcdc2
|
@ -96,7 +96,7 @@ public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
|
||||||
}
|
}
|
||||||
} else if (qName.equals("OperatingSystemSection")) {
|
} else if (qName.equals("OperatingSystemSection")) {
|
||||||
inOs = true;
|
inOs = true;
|
||||||
} else if (qName.equals("NetworkConnection")) {
|
} else if (qName.endsWith("NetworkConnection")) {
|
||||||
networkName = attributes.getValue(attributes.getIndex("Network"));
|
networkName = attributes.getValue(attributes.getIndex("Network"));
|
||||||
} else {
|
} else {
|
||||||
systemHandler.startElement(uri, localName, qName, attributes);
|
systemHandler.startElement(uri, localName, qName, attributes);
|
||||||
|
@ -111,7 +111,7 @@ public class VAppHandler extends ParseSax.HandlerWithResult<VApp> {
|
||||||
inOs = false;
|
inOs = false;
|
||||||
} else if (inOs && qName.equals("Description")) {
|
} else if (inOs && qName.equals("Description")) {
|
||||||
operatingSystemDescription = currentText.toString().trim();
|
operatingSystemDescription = currentText.toString().trim();
|
||||||
} else if (qName.equals("IpAddress")) {
|
} else if (qName.endsWith("IpAddress")) {
|
||||||
networkToAddresses.put(networkName, parseInetAddress(currentText.toString().trim()));
|
networkToAddresses.put(networkName, parseInetAddress(currentText.toString().trim()));
|
||||||
} else if (qName.equals("System")) {
|
} else if (qName.equals("System")) {
|
||||||
systemHandler.endElement(uri, localName, qName);
|
systemHandler.endElement(uri, localName, qName);
|
||||||
|
|
|
@ -52,33 +52,40 @@ public class VAppHandlerTest extends BaseHandlerTest {
|
||||||
public void testHosting() throws UnknownHostException {
|
public void testHosting() throws UnknownHostException {
|
||||||
InputStream is = getClass().getResourceAsStream("/vapp-hosting.xml");
|
InputStream is = getClass().getResourceAsStream("/vapp-hosting.xml");
|
||||||
|
|
||||||
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
|
VApp result = factory.create(injector.getInstance(VAppHandler.class))
|
||||||
|
.parse(is);
|
||||||
|
|
||||||
ListMultimap<String, InetAddress> networkToAddresses = ImmutableListMultimap
|
ListMultimap<String, InetAddress> networkToAddresses = ImmutableListMultimap
|
||||||
.<String, InetAddress> of("Network 1", InetAddress.getByName("204.12.11.167"));
|
.<String, InetAddress> of("Network 1", InetAddress
|
||||||
|
.getByName("204.12.11.167"));
|
||||||
|
|
||||||
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "SimpleVM", "vmx-07");
|
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family",
|
||||||
|
"SimpleVM", "vmx-07");
|
||||||
|
|
||||||
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet
|
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet
|
||||||
.<ResourceAllocation> naturalOrder().add(
|
.<ResourceAllocation> naturalOrder().add(
|
||||||
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs",
|
new ResourceAllocation(1, "1 virtual CPU(s)",
|
||||||
ResourceType.PROCESSOR, null, null, null, null, null, null, 1,
|
"Number of Virtual CPUs", ResourceType.PROCESSOR, null,
|
||||||
"hertz * 10^6"),
|
null, null, null, null, null, 1, "hertz * 10^6"),
|
||||||
new ResourceAllocation(2, "512MB of memory", "Memory Size",
|
new ResourceAllocation(2, "512MB of memory", "Memory Size",
|
||||||
ResourceType.MEMORY, null, null, null, null, null, null, 512,
|
ResourceType.MEMORY, null, null, null, null, null,
|
||||||
"byte * 2^20")).add(
|
null, 512, "byte * 2^20")).add(
|
||||||
|
|
||||||
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller",
|
new ResourceAllocation(3, "SCSI Controller 0",
|
||||||
ResourceType.SCSI_CONTROLLER, "lsilogic", null, 0, null, null,
|
"SCSI Controller", ResourceType.SCSI_CONTROLLER,
|
||||||
null, 1, null)).add(
|
"lsilogic", null, 0, null, null, null, 1, null)).add(
|
||||||
|
|
||||||
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE,
|
new ResourceAllocation(9, "Hard Disk 1", null,
|
||||||
null, "20971520", null, 0, 3, null, 20971520, "byte * 2^20"))
|
ResourceType.DISK_DRIVE, null, "20971520", null, 0, 3,
|
||||||
.build();
|
null, 20971520, "byte * 2^20")).build();
|
||||||
|
|
||||||
VApp expects = new VAppImpl("188849-96", "188849-96", URI
|
VApp expects = new VAppImpl(
|
||||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96"), VAppStatus.OFF,
|
"188849-96",
|
||||||
new Long(20971520), null, networkToAddresses, null, system, resourceAllocations);
|
"188849-96",
|
||||||
|
URI
|
||||||
|
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96"),
|
||||||
|
VAppStatus.OFF, new Long(20971520), null, networkToAddresses, null,
|
||||||
|
system, resourceAllocations);
|
||||||
|
|
||||||
assertEquals(result, expects);
|
assertEquals(result, expects);
|
||||||
}
|
}
|
||||||
|
@ -86,55 +93,77 @@ public class VAppHandlerTest extends BaseHandlerTest {
|
||||||
public void testInstantiated() throws UnknownHostException {
|
public void testInstantiated() throws UnknownHostException {
|
||||||
InputStream is = getClass().getResourceAsStream("/instantiatedvapp.xml");
|
InputStream is = getClass().getResourceAsStream("/instantiatedvapp.xml");
|
||||||
|
|
||||||
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
|
VApp result = factory.create(injector.getInstance(VAppHandler.class))
|
||||||
|
.parse(is);
|
||||||
|
|
||||||
VApp expects = new VAppImpl("10", "centos53", URI
|
VApp expects = new VAppImpl("10", "centos53", URI
|
||||||
.create("http://10.150.4.49/api/v0.8/vApp/10"), VAppStatus.RESOLVED, 123456789l,
|
.create("http://10.150.4.49/api/v0.8/vApp/10"),
|
||||||
new NamedResourceImpl("4", null, "application/vnd.vmware.vcloud.vdc+xml", URI
|
VAppStatus.RESOLVED, 123456789l, new NamedResourceImpl("4", null,
|
||||||
.create("http://10.150.4.49/api/v0.8/vdc/4")), ImmutableListMultimap
|
"application/vnd.vmware.vcloud.vdc+xml", URI
|
||||||
.<String, InetAddress> of(), null, null, ImmutableSet
|
.create("http://10.150.4.49/api/v0.8/vdc/4")),
|
||||||
.<ResourceAllocation> of());
|
ImmutableListMultimap.<String, InetAddress> of(), null, null,
|
||||||
|
ImmutableSet.<ResourceAllocation> of());
|
||||||
assertEquals(result, expects);
|
assertEquals(result, expects);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO why does this fail?
|
// TODO why does this fail?
|
||||||
@Test(enabled = false)
|
|
||||||
public void testDefault() throws UnknownHostException {
|
public void testDefault() throws UnknownHostException {
|
||||||
InputStream is = getClass().getResourceAsStream("/vapp.xml");
|
InputStream is = getClass().getResourceAsStream("/vapp.xml");
|
||||||
|
|
||||||
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
|
VApp result = factory.create(injector.getInstance(VAppHandler.class))
|
||||||
|
.parse(is);
|
||||||
|
|
||||||
ListMultimap<String, InetAddress> networkToAddresses = ImmutableListMultimap
|
ListMultimap<String, InetAddress> networkToAddresses = ImmutableListMultimap
|
||||||
.<String, InetAddress> of();
|
.<String, InetAddress> of("Public Network", InetAddress
|
||||||
|
.getByName("10.150.4.93"));
|
||||||
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "Oracle", "vmx-07");
|
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family",
|
||||||
|
"centos53", "vmx-07");
|
||||||
|
|
||||||
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet
|
SortedSet<ResourceAllocation> resourceAllocations = ImmutableSortedSet
|
||||||
.<ResourceAllocation> naturalOrder().add(
|
.<ResourceAllocation> naturalOrder().add(
|
||||||
new ResourceAllocation(1, "1 virtual CPU(s)", "Number of Virtual CPUs",
|
new ResourceAllocation(1, "1 virtual CPU(s)",
|
||||||
ResourceType.PROCESSOR, null, null, null, null, null, null, 1,
|
"Number of Virtual CPUs", ResourceType.PROCESSOR, null,
|
||||||
"hertz * 10^6"),
|
null, null, null, null, null, 1, "hertz * 10^6"),
|
||||||
new ResourceAllocation(2, "16MB of memory", "Memory Size",
|
new ResourceAllocation(2, "16MB of memory", "Memory Size",
|
||||||
ResourceType.MEMORY, null, null, null, null, null, null, 16,
|
ResourceType.MEMORY, null, null, null, null, null,
|
||||||
"byte * 2^20")).add(
|
null, 16, "byte * 2^20")).add(
|
||||||
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller",
|
new ResourceAllocation(3, "SCSI Controller 0",
|
||||||
ResourceType.SCSI_CONTROLLER, "lsilogic", null, 0, null, null,
|
"SCSI Controller", ResourceType.SCSI_CONTROLLER,
|
||||||
null, 1, null)).add(
|
"lsilogic", null, 0, null, null, null, 1, null)).add(
|
||||||
new ResourceAllocation(8, "Network Adapter 1",
|
new ResourceAllocation(8, "Network Adapter 1",
|
||||||
"PCNet32 ethernet adapter on \"Internal\" network",
|
"PCNet32 ethernet adapter on \"Internal\" network",
|
||||||
ResourceType.ETHERNET_ADAPTER, "PCNet32", null, null, 7, null,
|
ResourceType.ETHERNET_ADAPTER, "PCNet32", null, null,
|
||||||
true, 1, null)).add(
|
7, null, true, 1, null)).add(
|
||||||
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE,
|
new ResourceAllocation(9, "Hard Disk 1", null,
|
||||||
null, "104857", null, 0, 3, null, 104857, "byte * 2^20")).build();
|
ResourceType.DISK_DRIVE, null, "104857", null, 0, 3,
|
||||||
|
null, 104857, "byte * 2^20")).build();
|
||||||
VApp expects = new VAppImpl("4", "Oracle", URI.create("http://10.150.4.49/api/v0.8/vApp/4"),
|
|
||||||
VAppStatus.ON, new Long(104857),
|
|
||||||
new NamedResourceImpl("32", null, "application/vnd.vmware.vcloud.vdc+xml", URI
|
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")),
|
|
||||||
networkToAddresses, "Other Linux (32-bit)", system, resourceAllocations);
|
|
||||||
|
|
||||||
assertEquals(result, expects);
|
|
||||||
|
|
||||||
|
VApp expects = new VAppImpl(
|
||||||
|
"10",
|
||||||
|
"centos53",
|
||||||
|
URI.create("http://10.150.4.49/api/v0.8/vApp/10"),
|
||||||
|
VAppStatus.ON,
|
||||||
|
new Long(104857),
|
||||||
|
new NamedResourceImpl(
|
||||||
|
"4",
|
||||||
|
null,
|
||||||
|
"application/vnd.vmware.vcloud.vdc+xml",
|
||||||
|
URI
|
||||||
|
.create("http://10.150.4.49/api/v0.8/vdc/4")),
|
||||||
|
networkToAddresses, "Other Linux (32-bit)", system,
|
||||||
|
resourceAllocations);
|
||||||
|
assertEquals(result.getId(), expects.getId());
|
||||||
|
assertEquals(result.getLocation(), expects.getLocation());
|
||||||
|
assertEquals(result.getName(), expects.getName());
|
||||||
|
assertEquals(result.getNetworkToAddresses(), expects.getNetworkToAddresses());
|
||||||
|
assertEquals(result.getOperatingSystemDescription(), expects.getOperatingSystemDescription());
|
||||||
|
assertEquals(result.getResourceAllocationByType(), expects.getResourceAllocationByType());
|
||||||
|
assertEquals(result.getResourceAllocations(), expects.getResourceAllocations());
|
||||||
|
assertEquals(result.getSize(), expects.getSize());
|
||||||
|
assertEquals(result.getStatus(), expects.getStatus());
|
||||||
|
assertEquals(result.getSystem(), expects.getSystem());
|
||||||
|
assertEquals(result.getType(), expects.getType());
|
||||||
|
assertEquals(result.getVDC(), expects.getVDC());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue