diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Task.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Task.java index d11837f6ba..9f9de6e50f 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Task.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/Task.java @@ -26,7 +26,7 @@ package org.jclouds.vcloud.domain; import java.util.Date; import org.jclouds.rest.domain.Link; -import org.jclouds.rest.domain.NamedLink; +import org.jclouds.rest.domain.NamedResource; import org.jclouds.vcloud.domain.internal.TaskImpl; import com.google.inject.ImplementedBy; @@ -43,7 +43,7 @@ public interface Task extends Link, Comparable { Date getEndTime(); - NamedLink getOwner(); + NamedResource getOwner(); - NamedLink getResult(); + NamedResource getResult(); } \ No newline at end of file diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java index c2414c4790..09f90849a0 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java @@ -28,8 +28,9 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.net.URI; import java.util.Date; -import org.jclouds.rest.domain.NamedLink; +import org.jclouds.rest.domain.NamedResource; import org.jclouds.rest.domain.internal.LinkImpl; +import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.TaskStatus; @@ -46,13 +47,13 @@ public class TaskImpl extends LinkImpl implements Task { private final Date startTime; @Nullable private final Date endTime; - private final NamedLink owner; + private final NamedResource owner; @Nullable - private final NamedLink result; + private final NamedResource result; - public TaskImpl(String type, URI location, TaskStatus status, Date startTime, - @Nullable Date endTime, NamedLink owner, @Nullable NamedLink result) { - super(type, location); + public TaskImpl(URI location, TaskStatus status, Date startTime, @Nullable Date endTime, + NamedResource owner, @Nullable NamedResource result) { + super(VCloudMediaType.TASK_XML, location); this.status = checkNotNull(status, "status"); this.startTime = startTime; this.endTime = endTime; @@ -68,11 +69,11 @@ public class TaskImpl extends LinkImpl implements Task { return startTime; } - public NamedLink getOwner() { + public NamedResource getOwner() { return owner; } - public NamedLink getResult() { + public NamedResource getResult() { return result; } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java b/vcloud/core/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java index bcce2e2c12..fe42214f1c 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java @@ -75,7 +75,7 @@ public class TaskSuccess implements Predicate { } catch (InterruptedException e) { logger.warn(e, "%s interrupted, returning false", taskUri); } catch (ExecutionException e) { - logger.warn(e, "%s exception, returning false", taskUri); + throw new RuntimeException(e.getCause()); } catch (TimeoutException e) { logger.warn(e, "%s timeout, returning false", taskUri); } diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java index 9055ccbea1..abbdf0e757 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java @@ -33,7 +33,7 @@ import org.jclouds.date.DateService; import org.jclouds.http.functions.ParseSax; import org.jclouds.logging.Logger; import org.jclouds.rest.domain.Link; -import org.jclouds.rest.domain.NamedLink; +import org.jclouds.rest.domain.NamedResource; import org.jclouds.rest.util.Utils; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.TaskStatus; @@ -48,8 +48,8 @@ public class TaskHandler extends ParseSax.HandlerWithResult { protected final DateService dateService; private Link taskLink; - private NamedLink owner; - private NamedLink result; + private NamedResource owner; + private NamedResource result; private TaskStatus status; private Date startTime; private Date endTime; @@ -71,7 +71,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult { public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (qName.equalsIgnoreCase("Task")) { - if (attributes.getIndex("type") != -1) + if (attributes.getIndex("href") != -1)// queued tasks may not have an href yet taskLink = Utils.newLink(attributes); status = TaskStatus.fromValue(attributes.getValue(attributes.getIndex("status"))); if (attributes.getIndex("startTime") != -1) @@ -80,11 +80,12 @@ public class TaskHandler extends ParseSax.HandlerWithResult { endTime = parseDate(attributes, "endTime"); } } else if (qName.equals("Owner")) { - owner = Utils.newNamedLink(attributes); - } else if (qName.equals("Link")) { + owner = Utils.newNamedResource(attributes); + } else if (qName.equals("Link") && attributes.getIndex("rel") != -1 + && attributes.getValue(attributes.getIndex("rel")).equals("self")) { taskLink = Utils.newNamedLink(attributes); } else if (qName.equals("Result")) { - result = Utils.newNamedLink(attributes); + result = Utils.newNamedResource(attributes); } } @@ -110,8 +111,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult { @Override public void endElement(String uri, String localName, String qName) throws SAXException { if (qName.equalsIgnoreCase("Task")) { - this.task = new TaskImpl(taskLink.getType(), taskLink.getLocation(), status, startTime, - endTime, owner, result); + this.task = new TaskImpl(taskLink.getLocation(), status, startTime, endTime, owner, result); taskLink = null; status = null; startTime = null; diff --git a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java index 4838a4a923..913f6289cc 100644 --- a/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java +++ b/vcloud/core/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java @@ -92,7 +92,7 @@ public class VAppHandler extends ParseSax.HandlerWithResult { } else if (qName.equals("OperatingSystemSection")) { inOs = true; } else if (qName.equals("NetworkConnection")) { - networkName = attributes.getValue(attributes.getIndex("name")); + networkName = attributes.getValue(attributes.getIndex("Network")); } else { systemHandler.startElement(uri, localName, qName, attributes); allocationHandler.startElement(uri, localName, qName, attributes); @@ -106,7 +106,7 @@ public class VAppHandler extends ParseSax.HandlerWithResult { inOs = false; } else if (inOs && qName.equals("Description")) { operatingSystemDescription = currentText.toString().trim(); - } else if (qName.equals("IPAddress")) { + } else if (qName.equals("IpAddress")) { networkToAddresses.put(networkName, parseInetAddress(currentText.toString().trim())); } else if (qName.equals("System")) { systemHandler.endElement(uri, localName, qName); diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java index e6a8eb7e47..6fe3de52bc 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java @@ -30,7 +30,7 @@ import java.net.URI; import org.jclouds.date.DateService; import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.rest.domain.internal.NamedLinkImpl; +import org.jclouds.rest.internal.NamedResourceImpl; import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.TaskStatus; @@ -60,13 +60,13 @@ public class TaskHandlerTest extends BaseHandlerTest { Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); - Task expects = new TaskImpl(VCloudMediaType.TASK_XML, URI + Task expects = new TaskImpl(URI .create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"), TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), - dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"), new NamedLinkImpl( + dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"), new NamedResourceImpl("1", "VDC Name", VCloudMediaType.VDC_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")), - new NamedLinkImpl("Server1", VCloudMediaType.VAPP_XML, URI + new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012") ) @@ -76,15 +76,14 @@ public class TaskHandlerTest extends BaseHandlerTest { } - public void testApplyInputStream3() { - InputStream is = getClass().getResourceAsStream("/task-hosting-baddate.xml"); + public void testSelf() { + InputStream is = getClass().getResourceAsStream("/task-self.xml"); Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); - Task expects = new TaskImpl(VCloudMediaType.TASK_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-37"), - TaskStatus.RUNNING, null, null, new NamedLinkImpl("188849", VCloudMediaType.VDC_XML, - URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849")), null + Task expects = new TaskImpl(URI + .create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"), + TaskStatus.QUEUED, null, null, null, null ); assertEquals(result, expects); @@ -95,11 +94,12 @@ public class TaskHandlerTest extends BaseHandlerTest { Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is); - Task expects = new TaskImpl(VCloudMediaType.TASK_XML, URI - .create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-34"), - TaskStatus.QUEUED, null, null, null, null); + Task expects = new TaskImpl(URI + .create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-72"), + TaskStatus.RUNNING, dateService.iso8601SecondsDateParse("2001-01-01T05:00:00Z"), + null, new NamedResourceImpl("188849", "188849", VCloudMediaType.VDC_XML, URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849")), null); assertEquals(result, expects); } - } diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java index ead800fbe3..a9b01c905a 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java @@ -30,7 +30,7 @@ import java.net.URI; import org.jclouds.date.DateService; import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.rest.domain.internal.NamedLinkImpl; +import org.jclouds.rest.internal.NamedResourceImpl; import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.TaskStatus; @@ -65,21 +65,21 @@ public class TasksListHandlerTest extends BaseHandlerTest { TasksList result = factory.create(injector.getInstance(TasksListHandler.class)).parse(is); assertEquals(result.getLocation(), URI .create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/1")); - Task task1 = new TaskImpl(VCloudMediaType.TASK_XML, URI + Task task1 = new TaskImpl(URI .create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3300"), TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:30:19.587Z"), - dateService.iso8601DateParse("2009-08-24T21:30:32.63Z"), new NamedLinkImpl( + dateService.iso8601DateParse("2009-08-24T21:30:32.63Z"), new NamedResourceImpl("1", "VDC Name", VCloudMediaType.VDC_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")), - new NamedLinkImpl("Server1", VCloudMediaType.VAPP_XML, URI + new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012"))); - Task task2 = new TaskImpl(VCloudMediaType.TASK_XML, URI + Task task2 = new TaskImpl(URI .create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"), TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), - dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"), new NamedLinkImpl( + dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"), new NamedResourceImpl("1", "VDC Name", VCloudMediaType.VDC_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")), - new NamedLinkImpl("Server1", VCloudMediaType.VAPP_XML, URI + new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI .create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012") ) diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java index 6356980860..b106586552 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java @@ -58,7 +58,7 @@ public class VAppHandlerTest extends BaseHandlerTest { VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is); ListMultimap networkToAddresses = ImmutableListMultimap - . of("Network 1", InetAddress.getByName("204.12.55.199")); + . of("Network 1", InetAddress.getByName("204.12.59.147")); VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "SimpleVM", "vmx-07"); @@ -78,9 +78,9 @@ public class VAppHandlerTest extends BaseHandlerTest { new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE, null, null, 0, 3, null, 20971520, "byte * 2^20")).build(); - VApp expects = new VAppImpl("188849-44", "188849-44", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-44"), VAppStatus.ON, - new Long(20971520), networkToAddresses, "", system, resourceAllocations); + VApp expects = new VAppImpl("188849-74", "188849-74", URI + .create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-74"), VAppStatus.ON, + new Long(20971520), networkToAddresses, null, system, resourceAllocations); assertEquals(result, expects); diff --git a/vcloud/core/src/test/resources/task-hosting-baddate.xml b/vcloud/core/src/test/resources/task-hosting-baddate.xml deleted file mode 100644 index a3a4720e7d..0000000000 --- a/vcloud/core/src/test/resources/task-hosting-baddate.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - diff --git a/vcloud/core/src/test/resources/task-hosting.xml b/vcloud/core/src/test/resources/task-hosting.xml index c1f36ff7ce..05d10f0968 100644 --- a/vcloud/core/src/test/resources/task-hosting.xml +++ b/vcloud/core/src/test/resources/task-hosting.xml @@ -1,11 +1,13 @@ - - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" status="running" + startTime="2001-01-01T05:00:00Z"> + + + diff --git a/vcloud/core/src/test/resources/task-self.xml b/vcloud/core/src/test/resources/task-self.xml new file mode 100644 index 0000000000..4a174248ee --- /dev/null +++ b/vcloud/core/src/test/resources/task-self.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/vcloud/core/src/test/resources/task.xml b/vcloud/core/src/test/resources/task.xml index f24173d00f..bd0514e376 100644 --- a/vcloud/core/src/test/resources/task.xml +++ b/vcloud/core/src/test/resources/task.xml @@ -1,6 +1,5 @@ + status="success" startTime="2009-08-24T21:29:32.983Z" endTime="2009-08-24T21:29:44.65Z"> - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" size="20971520"> - - - 204.12.55.199 - - + + Network Information about the vApp + + 204.12.59.147 + + - - The kind of installed guest operating system - - + + Virtual hardware + + + + + + + + + + + + + Virtual Hardware Family + 0 + + + + + + SimpleVM + vmx-07 + + +
+ + hertz * 10^6 + + + + + Number of Virtual CPUs + 1 virtual CPU(s) + 1 + + + + + + + + 3 + 1 + + + +
+ + byte * 2^20 + + + + + Memory Size + 512MB of memory + 2 + + + + + + + + 4 + 512 + + + +
0
+ + + + + + + SCSI Controller + SCSI Controller 0 + 3 + + + + + + + lsilogic + 6 + + +
+ +
+ 0 + + + + + + + Hard Disk 1 + 20971520 + 9 + + + + 3 + + + + 17 + 20971520 + + + + - - Virtual hardware - - - - - - - - - - - - - - - - - - Virtual Hardware Family - 0 - SimpleVM - vmx-07 - - -
- - - - - - - - - - - - - - hertz * 10^6 - Number of Virtual CPUs - 1 virtual CPU(s) - 1 - 3 - 1 - count - - -
- - - - - - - - - - - - - - byte * 2^20 - Memory Size - 512MB of memory - 2 - 4 - 512 - byte * 2^20 - - - - - - - - - - - - - - - - - -
0
- SCSI Controller - SCSI Controller 0 - 3 - lsilogic - 6 -
- -
- - - - - - - - - - - - - - - 0 - Hard Disk 1 - 20971520 - 9 - 3 - 17 - 20971520 - - - \ No newline at end of file diff --git a/vcloud/hostingdotcom/src/test/resources/log4j.xml b/vcloud/hostingdotcom/src/test/resources/log4j.xml new file mode 100755 index 0000000000..e6caf35848 --- /dev/null +++ b/vcloud/hostingdotcom/src/test/resources/log4j.xml @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file