updated xml parsers in savvis

This commit is contained in:
Adrian Cole 2011-03-24 14:52:07 -07:00
parent 2f3bd3d66a
commit 0e55bff1cd
17 changed files with 153 additions and 116 deletions

View File

@ -56,6 +56,7 @@
<test.savvis-symphonyvpdc.apiversion>0.8</test.savvis-symphonyvpdc.apiversion>
<test.savvis-symphonyvpdc.identity>FIXME</test.savvis-symphonyvpdc.identity>
<test.savvis-symphonyvpdc.credential>FIXME</test.savvis-symphonyvpdc.credential>
<test.savvis-symphonyvpdc.email>FIXME</test.savvis-symphonyvpdc.email>
<test.savvis-symphonyvpdc.loginUser>FIXME</test.savvis-symphonyvpdc.loginUser>
<test.savvis-symphonyvpdc.loginPassword>FIXME</test.savvis-symphonyvpdc.loginPassword>
</properties>
@ -141,6 +142,10 @@
<name>test.savvis-symphonyvpdc.credential</name>
<value>${test.savvis-symphonyvpdc.credential}</value>
</property>
<property>
<name>test.savvis-symphonyvpdc.email</name>
<value>${test.savvis-symphonyvpdc.email}</value>
</property>
<property>
<name>test.savvis-symphonyvpdc.loginUser</name>
<value>${test.savvis-symphonyvpdc.loginUser}</value>

View File

@ -207,8 +207,9 @@ public class Task extends Resource {
@Override
public String toString() {
return "[status=" + status + ", startTime=" + startTime + ", endTime=" + endTime + ", owner=" + owner
+ ", result=" + result + ", error=" + error + "]";
return "[id=" + id + ", name=" + name + ", type=" + type + ", href=" + href + ", status=" + status
+ ", startTime=" + startTime + ", endTime=" + endTime + ", owner=" + owner + ", result=" + result
+ ", error=" + error + "]";
}
}

View File

@ -1,5 +1,7 @@
package org.jclouds.savvis.vpdc.predicates;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Resource;
import javax.inject.Singleton;
@ -30,13 +32,18 @@ public class TaskSuccess implements Predicate<String> {
}
public boolean apply(String taskId) {
logger.trace("looking for status on task %s", taskId);
Task task = client.getBrowsingClient().getTask(taskId);
logger.trace("%s: looking for status %s: currently: %s", task, Task.Status.SUCCESS, task.getStatus());
if (task.getStatus() == Task.Status.ERROR || task.getStatus() == Task.Status.NONE)
throw new RuntimeException("error on task: " + task.getHref() + " error: " + task.getError());
logger.trace("looking for status on task %s", checkNotNull(taskId, "taskId"));
Task task = refresh(taskId);
if (task == null)
return false;
logger.trace("%s: looking for task status %s: currently: %s", task.getId(), Task.Status.SUCCESS, task.getStatus());
if (task.getError() != null)
throw new IllegalStateException(String.format("task %s failed with exception %s", task.getId(), task
.getError().toString()));
return task.getStatus() == Task.Status.SUCCESS;
}
private Task refresh(String taskId) {
return client.getBrowsingClient().getTask(taskId);
}
}

View File

@ -20,6 +20,7 @@
package org.jclouds.savvis.vpdc.xml;
import static org.jclouds.util.SaxUtils.currentOrNull;
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.savvis.vpdc.domain.FirewallRule;
@ -47,33 +48,33 @@ public class FirewallRuleHandler extends ParseSax.HandlerWithResult<FirewallRule
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
String current = currentOrNull(currentText);
if(current != null){
if (qName.endsWith("Type")) {
builder.firewallType(current);
} else if (qName.endsWith("IsEnabled")) {
builder.isEnabled(Boolean.parseBoolean(current));
} else if (qName.endsWith("Source")) {
builder.source(current);
} else if (qName.endsWith("Destination")) {
builder.destination(current);
} else if (qName.endsWith("Port")) {
builder.port(current);
} else if (qName.endsWith("Policy")) {
builder.policy(current);
} else if (qName.endsWith("Description")) {
builder.description(current);
} else if (qName.endsWith("Log")) {
builder.isLogged(Boolean.parseBoolean(current));
} else if (qName.endsWith("Tcp")) {
builder.protocol("Tcp");
} else if (qName.contains("Udp") || qName.contains("udp")) {
builder.protocol("Udp");
} else if (qName.contains("Icmp") || qName.contains("icmp") ||
qName.contains("Ping") || qName.contains("ping")) {
builder.protocol("Icmp-ping");
}
}
String current = currentOrNull(currentText);
if (current != null) {
if (equalsOrSuffix(qName, "Type")) {
builder.firewallType(current);
} else if (equalsOrSuffix(qName, "IsEnabled")) {
builder.isEnabled(Boolean.parseBoolean(current));
} else if (equalsOrSuffix(qName, "Source")) {
builder.source(current);
} else if (equalsOrSuffix(qName, "Destination")) {
builder.destination(current);
} else if (equalsOrSuffix(qName, "Port")) {
builder.port(current);
} else if (equalsOrSuffix(qName, "Policy")) {
builder.policy(current);
} else if (equalsOrSuffix(qName, "Description")) {
builder.description(current);
} else if (equalsOrSuffix(qName, "Log")) {
builder.isLogged(Boolean.parseBoolean(current));
} else if (equalsOrSuffix(qName, "Tcp")) {
builder.protocol("Tcp");
} else if (qName.contains("Udp") || qName.contains("udp")) {
builder.protocol("Udp");
} else if (qName.contains("Icmp") || qName.contains("icmp") || qName.contains("Ping")
|| qName.contains("ping")) {
builder.protocol("Icmp-ping");
}
}
currentText = new StringBuilder();
}

View File

@ -20,6 +20,7 @@
package org.jclouds.savvis.vpdc.xml;
import static org.jclouds.util.SaxUtils.currentOrNull;
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
import javax.inject.Inject;
@ -37,12 +38,12 @@ public class FirewallServiceHandler extends ParseSax.HandlerWithResult<FirewallS
private FirewallService.Builder builder = FirewallService.builder();
boolean inFirewallService;
boolean inFirewallRule;
@Inject
public FirewallServiceHandler(FirewallRuleHandler firewallRuleHandler) {
this.firewallRuleHandler = firewallRuleHandler;
}
public FirewallService getResult() {
try {
return builder.build();
@ -52,32 +53,32 @@ public class FirewallServiceHandler extends ParseSax.HandlerWithResult<FirewallS
}
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
if (qName.endsWith("FirewallService")) {
inFirewallService = true;
} else if (qName.endsWith("FirewallRule")) {
inFirewallRule = true;
firewallRuleHandler.startElement(uri, localName, qName, attrs);
if (equalsOrSuffix(qName, "FirewallService")) {
inFirewallService = true;
} else if (equalsOrSuffix(qName, "FirewallRule")) {
inFirewallRule = true;
firewallRuleHandler.startElement(uri, localName, qName, attrs);
}
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (qName.endsWith("FirewallService")) {
inFirewallService = false;
} else if(qName.endsWith("FirewallRule")) {
builder.firewallRule(firewallRuleHandler.getResult());
inFirewallRule = false;
} else if (qName.endsWith("isEnabled")) {
if(inFirewallService){
String current = currentOrNull(currentText);
if(current != null){
builder.isEnabled(Boolean.parseBoolean(current));
}
}
if (equalsOrSuffix(qName, "FirewallService")) {
inFirewallService = false;
} else if (equalsOrSuffix(qName, "FirewallRule")) {
builder.firewallRule(firewallRuleHandler.getResult());
inFirewallRule = false;
} else if (equalsOrSuffix(qName, "isEnabled")) {
if (inFirewallService) {
String current = currentOrNull(currentText);
if (current != null) {
builder.isEnabled(Boolean.parseBoolean(current));
}
}
}
if (inFirewallRule) {
firewallRuleHandler.endElement(uri, localName, qName);
if (inFirewallRule) {
firewallRuleHandler.endElement(uri, localName, qName);
}
currentText = new StringBuilder();
}

View File

@ -22,6 +22,7 @@ package org.jclouds.savvis.vpdc.xml;
import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes;
import static org.jclouds.savvis.vpdc.util.Utils.currentOrNull;
import static org.jclouds.savvis.vpdc.util.Utils.newResource;
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
import java.util.Map;
@ -53,22 +54,22 @@ public class NetworkHandler extends ParseSax.HandlerWithResult<Network> {
@Override
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
Map<String, String> attributes = cleanseAttributes(attrs);
if (qName.endsWith("Network")) {
if (equalsOrSuffix(qName, "Network")) {
// savvis doesn't add href in the header for some reason
if (!attributes.containsKey("href") && getRequest() != null)
attributes = ImmutableMap.<String, String> builder().putAll(attributes)
.put("href", getRequest().getEndpoint().toASCIIString()).build();
Resource org = newResource(attributes);
builder.name(org.getName()).type(org.getType()).id(org.getId()).href(org.getHref());
} else if (qName.endsWith("NatRule")) {
} else if (equalsOrSuffix(qName, "NatRule")) {
builder.internalToExternalNATRule(attributes.get("internalIP"), attributes.get("externalIP"));
}
}
public void endElement(String uri, String name, String qName) {
if (qName.endsWith("Gateway")) {
if (equalsOrSuffix(qName, "Gateway")) {
builder.gateway(currentOrNull(currentText));
} else if (qName.endsWith("Netmask")) {
} else if (equalsOrSuffix(qName, "Netmask")) {
builder.netmask(currentOrNull(currentText));
}
currentText = new StringBuilder();

View File

@ -22,6 +22,7 @@ package org.jclouds.savvis.vpdc.xml;
import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes;
import static org.jclouds.savvis.vpdc.util.Utils.currentOrNull;
import static org.jclouds.savvis.vpdc.util.Utils.newResource;
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
import java.util.Map;
@ -54,14 +55,14 @@ public class OrgHandler extends ParseSax.HandlerWithResult<Org> {
@Override
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
Map<String, String> attributes = cleanseAttributes(attrs);
if (qName.endsWith("Org")) {
if (equalsOrSuffix(qName, "Org")) {
// savvis doesn't add href in the header for some reason
if (!attributes.containsKey("href") && getRequest() != null)
attributes = ImmutableMap.<String, String> builder().putAll(attributes)
.put("href", getRequest().getEndpoint().toASCIIString()).build();
Resource org = newResource(attributes);
builder.name(org.getName()).type(org.getType()).id(org.getId()).href(org.getHref());
} else if (qName.endsWith("Link")) {
} else if (equalsOrSuffix(qName, "Link")) {
Link link = Link.class.cast(newResource(attributes));
if ("down".equals(link.getRel()))
builder.vDC(link);
@ -71,7 +72,7 @@ public class OrgHandler extends ParseSax.HandlerWithResult<Org> {
}
public void endElement(String uri, String name, String qName) {
if (qName.endsWith("Description")) {
if (equalsOrSuffix(qName, "Description")) {
builder.description(currentOrNull(currentText));
}
currentText = new StringBuilder();

View File

@ -2,6 +2,7 @@ package org.jclouds.savvis.vpdc.xml;
import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes;
import static org.jclouds.savvis.vpdc.util.Utils.newResource;
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
import java.util.Map;
import java.util.Set;
@ -32,7 +33,7 @@ public class OrgListHandler extends ParseSax.HandlerWithResult<Set<Resource>> {
@Override
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
Map<String, String> attributes = cleanseAttributes(attrs);
if (qName.endsWith("Org")) {
if (equalsOrSuffix(qName, "Org")) {
org.add(newResource(attributes));
}
}

View File

@ -21,6 +21,7 @@ package org.jclouds.savvis.vpdc.xml;
import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes;
import static org.jclouds.savvis.vpdc.util.Utils.newResource;
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
import java.util.Date;
import java.util.Map;
@ -65,7 +66,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
@Override
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
Map<String, String> attributes = cleanseAttributes(attrs);
if (qName.endsWith("Task")) {
if (equalsOrSuffix(qName, "Task")) {
Resource task = newResource(attributes);
builder.id(task.getId());
builder.type(task.getType());
@ -75,11 +76,11 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
if (attributes.containsKey("endTime"))
builder.endTime(parseDate(attributes.get("endTime")));
builder.status(Task.Status.fromValue(attributes.get("status")));
} else if (qName.endsWith("Owner")) {
} else if (equalsOrSuffix(qName, "Owner")) {
builder.owner(Utils.newResource(attributes));
} else if (qName.endsWith("Result")) {
} else if (equalsOrSuffix(qName, "Result")) {
builder.result(Utils.newResource(attributes));
} else if (qName.endsWith("Error")) {
} else if (equalsOrSuffix(qName, "Error")) {
builder.error(new TaskError(attributes.get("message"), Integer.parseInt(attributes.get("majorErrorCode")),
Integer.parseInt(attributes.get("minorErrorCode")), attributes.get("vendorSpecificErrorCode")));
}

View File

@ -19,6 +19,8 @@
package org.jclouds.savvis.vpdc.xml;
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
import java.util.Set;
import javax.inject.Inject;
@ -60,7 +62,7 @@ public class TasksListHandler extends ParseSax.HandlerWithResult<Set<Task>> {
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
taskHandler.endElement(uri, localName, qName);
if (qName.equals("Task")) {
if (equalsOrSuffix(qName, "Task")) {
this.tasks.add(taskHandler.getResult());
}
}

View File

@ -22,6 +22,7 @@ package org.jclouds.savvis.vpdc.xml;
import static org.jclouds.savvis.vpdc.util.Utils.cleanseAttributes;
import static org.jclouds.savvis.vpdc.util.Utils.currentOrNull;
import static org.jclouds.savvis.vpdc.util.Utils.newResource;
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
import java.util.Map;
@ -54,24 +55,24 @@ public class VDCHandler extends ParseSax.HandlerWithResult<VDC> {
@Override
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
Map<String, String> attributes = cleanseAttributes(attrs);
if (qName.endsWith("Vdc")) {
if (equalsOrSuffix(qName, "Vdc")) {
// savvis doesn't add href in the header for some reason
if (!attributes.containsKey("href") && getRequest() != null)
attributes = ImmutableMap.<String, String> builder().putAll(attributes)
.put("href", getRequest().getEndpoint().toASCIIString()).build();
Resource vDC = newResource(attributes);
builder.name(vDC.getName()).type(vDC.getType()).id(vDC.getId()).href(vDC.getHref());
} else if (qName.endsWith("Network")) {
} else if (equalsOrSuffix(qName, "Network")) {
builder.availableNetwork(newResource(attributes));
} else if (qName.endsWith("ResourceEntity")) {
} else if (equalsOrSuffix(qName, "ResourceEntity")) {
builder.resourceEntity(newResource(attributes));
}
}
public void endElement(String uri, String name, String qName) {
if (qName.endsWith("Description")) {
if (equalsOrSuffix(qName, "Description")) {
builder.description(currentOrNull(currentText));
} else if (qName.endsWith("OfferingTag")) {
} else if (equalsOrSuffix(qName, "OfferingTag")) {
builder.status(Status.fromValue(currentOrNull(currentText)));
}
currentText = new StringBuilder();

View File

@ -20,6 +20,7 @@
package org.jclouds.savvis.vpdc.xml;
import static org.jclouds.savvis.vpdc.util.Utils.newResource;
import static org.jclouds.util.SaxUtils.equalsOrSuffix;
import java.util.Map;
@ -63,7 +64,7 @@ public class VMHandler extends ParseSax.HandlerWithResult<VM> {
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
Map<String, String> attributes = Utils.cleanseAttributes(attrs);
if (qName.endsWith("VApp")) {
if (equalsOrSuffix(qName, "VApp")) {
// savvis doesn't add href in the header for some reason
if (!attributes.containsKey("href") && getRequest() != null)
attributes = ImmutableMap.<String, String> builder().putAll(attributes)
@ -71,7 +72,7 @@ public class VMHandler extends ParseSax.HandlerWithResult<VM> {
Resource vApp = newResource(attributes);
builder.name(vApp.getName()).type(vApp.getType()).id(vApp.getId()).href(vApp.getHref());
builder.status(VM.Status.fromValue(attributes.get("status")));
} else if (qName.endsWith("OperatingSystemSection")) {
} else if (equalsOrSuffix(qName, "OperatingSystemSection")) {
inOs = true;
if (attributes.containsKey("id"))
builder.osType(Integer.parseInt(attributes.get("id")));
@ -84,16 +85,16 @@ public class VMHandler extends ParseSax.HandlerWithResult<VM> {
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
if (qName.endsWith("OperatingSystemSection")) {
if (equalsOrSuffix(qName, "OperatingSystemSection")) {
inOs = false;
} else if (inOs && qName.endsWith("Description")) {
} else if (inOs && equalsOrSuffix(qName, "Description")) {
builder.osDescripton(Utils.currentOrNull(currentText));
} else if (qName.endsWith("IpAddress")) {
} else if (equalsOrSuffix(qName, "IpAddress")) {
builder.ipAddress(Utils.currentOrNull(currentText));
} else if (qName.endsWith("NetworkSection")) {
} else if (equalsOrSuffix(qName, "NetworkSection")) {
networkSectionHandler.endElement(uri, localName, qName);
builder.networkSection(networkSectionHandler.getResult());
} else if (qName.endsWith("Item")) {
} else if (equalsOrSuffix(qName, "Item")) {
allocationHandler.endElement(uri, localName, qName);
builder.resourceAllocation(allocationHandler.getResult());
} else {

View File

@ -32,6 +32,7 @@ import org.jclouds.domain.Credentials;
import org.jclouds.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.savvis.vpdc.domain.Resource;
import org.jclouds.savvis.vpdc.domain.Task;
import org.jclouds.savvis.vpdc.domain.VM;
import org.jclouds.savvis.vpdc.domain.VMSpec;
@ -58,6 +59,7 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
private RetryablePredicate<IPSocket> socketTester;
private RetryablePredicate<String> taskTester;
private String email = checkNotNull(System.getProperty("test." + provider + ".email"), "test." + provider + ".email");
private String username = checkNotNull(System.getProperty("test." + provider + ".loginUser"), "test." + provider
+ ".loginUser");
private String password = checkNotNull(System.getProperty("test." + provider + ".loginPassword"), "test." + provider
@ -79,7 +81,20 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
public void testCreateVirtualMachine() throws Exception {
billingSiteId = context.getApi().getBrowsingClient().getOrg(null).getId();// default
vpdcId = Iterables.get(context.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(), 0).getId();
vpdcId = Iterables.find(context.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(),
new Predicate<Resource>() {
// try to find the first VDC owned by the current user
// check here for what the email property might be, or in
// the jclouds-wire.log
@Override
public boolean apply(Resource arg0) {
String description = context.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, arg0.getId())
.getDescription();
return description.indexOf(email) != -1;
}
}).getId();
String networkTierName = Iterables.get(
context.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId).getAvailableNetworks(), 0)
.getName();
@ -95,8 +110,13 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
});
System.out.printf("vpdcId %s, networkName %s, name %s, os %s%n", vpdcId, networkTierName, name, os);
// TODO: determine the sizes available in the VDC, for example there's
// a minimum size of boot disk, and also a preset combination of cpu count vs ram
Task task = client.addVMIntoVDC(billingSiteId, vpdcId, networkTierName, name, VMSpec.builder()
.operatingSystem(os).build());
.operatingSystem(os).memoryInGig(2).build());
// make sure there's no error
assert task.getId() != null && task.getError() != null : task;
assert this.taskTester.apply(task.getId());
vm = context.getApi().getBrowsingClient().getVMInVDC(billingSiteId, vpdcId, task.getOwner().getId());

View File

@ -37,6 +37,7 @@ public class TaskHandlerTest extends BaseHandlerTest {
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
Task expects = Task
.builder()
.id("21-1002")
.endTime(dateService.iso8601DateParse("2010-05-26T08:09:09.000+08:00"))
.startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00"))
.status(Task.Status.SUCCESS)
@ -70,6 +71,7 @@ public class TaskHandlerTest extends BaseHandlerTest {
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
Task expects = Task
.builder()
.id("21-1002")
.endTime(dateService.iso8601DateParse("2010-05-26T08:09:09.000+08:00"))
.startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00"))
.status(Task.Status.SUCCESS)
@ -103,10 +105,11 @@ public class TaskHandlerTest extends BaseHandlerTest {
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
Task expects = Task
.builder()
.id("6904")
.startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00"))
.status(Task.Status.RUNNING)
.type("application/vnd.vmware.vcloud.task+xml")
.href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/21-1002"))
.href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904"))
.owner(
Resource
.builder()
@ -136,31 +139,31 @@ public class TaskHandlerTest extends BaseHandlerTest {
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
Task expects = Task
.builder()
.id("6904")
.startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00"))
.id("113927-1005")
.startTime(dateService.iso8601DateParse("2011-03-24T20:37:34.000Z"))
.status(Task.Status.QUEUED)
.type("application/vnd.vmware.vcloud.task+xml")
.href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904"))
.href(URI.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/task/113927-1005"))
.owner(
Resource
.builder()
.id("2736")
.name("mockVpdc8")
.id("4253")
.name("Foo")
.type("application/vnd.vmware.vcloud.vdc+xml")
.href(URI
.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"))
.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/4253"))
.build())
.result(
Resource
.builder()
.id("1002")
.name("mock_vpdc_item_007")
.type("application/vnd.vmware.vcloud.catalogItem+xml")
.id("1005")
.name("adriancole")
.type("application/vnd.vmware.vcloud.vApp+xml")
.href(URI
.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002"))
.create("https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/4253/vApp/1005"))
.build()).build();
assertEquals(result.toString(), expects.toString());
assertEquals(result.getError(), null);
assert result.getId() != null;
}
public void testFailed() {
@ -203,12 +206,9 @@ public class TaskHandlerTest extends BaseHandlerTest {
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
Task expects = Task
.builder()
.id("6904-123")
.startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00"))
.endTime(dateService.iso8601DateParse("2010-05-26T08:09:09.000+08:00"))
.status(Task.Status.ERROR)
.type("application/vnd.vmware.vcloud.task+xml")
.href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904-123"))
.error(
TaskError
.builder()
@ -228,12 +228,12 @@ public class TaskHandlerTest extends BaseHandlerTest {
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
Task expects = Task
.builder()
.id("6904-123")
.id("3904-1002")
.startTime(dateService.iso8601DateParse("2010-05-26T08:08:08.000+08:00"))
.endTime(dateService.iso8601DateParse("2010-05-26T08:09:09.000+08:00"))
.status(Task.Status.NONE)
.type("application/vnd.vmware.vcloud.task+xml")
.href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904-123"))
.href(URI.create("https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/3904-1002"))
.error(
TaskError
.builder()

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><vApp:TasksList xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:vApp="http://www.vmware.com/vcloud/v0.8" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"><vApp:Task status="error"><vApp:Error vendorSpecificErrorCode="1016" minorErrorCode="471" majorErrorCode="500" message="The vApp CPU : {3 GHz * 1} and Memory : {1} is not to be supported."/></vApp:Task></vApp:TasksList>

View File

@ -1,15 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<vApp:TasksList xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common"
xmlns:vApp="http://www.vmware.com/vcloud/v0.8"
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
<!--If Task status is queued, Savvis is not displaying endTime.-->
<vApp:Task startTime="2010-05-26T08:08:08.000+08:00" status="queued" type="application/vnd.vmware.vcloud.task+xml"
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/task/6904">
<vApp:Owner name="mockVpdc8" type="application/vnd.vmware.vcloud.vdc+xml"
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736"/>
<vApp:Result name="mock_vpdc_item_007" type="application/vnd.vmware.vcloud.catalogItem+xml"
href="https://api.symphonyvpdc.savvis.net/rest/api/v0.8/org/100000.0/vdc/2736/vApp/1002"/>
</vApp:Task>
</vApp:TasksList>
<vApp:TasksList xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:vApp="http://www.vmware.com/vcloud/v0.8" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
<vApp:Task startTime="2011-03-24T20:37:34.000Z" status="queued" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/task/113927-1005">
<vApp:Owner name="Foo" type="application/vnd.vmware.vcloud.vdc+xml" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/4253"/>
<vApp:Result name="adriancole" type="application/vnd.vmware.vcloud.vApp+xml" href="https://api.symphonyVPDC.savvis.net/rest/api/v0.8/org/606677.0/vdc/4253/vApp/1005"/>
</vApp:Task>
</vApp:TasksList>

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><vApp:TasksList xmlns:common="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:vApp="http://www.vmware.com/vcloud/v0.8" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"><vApp:Task status="error"><vApp:Error vendorSpecificErrorCode="-1" minorErrorCode="0" majorErrorCode="500" message="Please finish your previously deployment for vpdcId:1619"/></vApp:Task></vApp:TasksList>