mirror of https://github.com/apache/jclouds.git
Isue 112: hostingdotcom progress
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2367 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
1173689417
commit
dcd2eb3403
|
@ -54,9 +54,9 @@ public class TaskImpl extends LinkImpl implements Task {
|
||||||
@Nullable DateTime endTime, NamedLink owner, @Nullable NamedLink result) {
|
@Nullable DateTime endTime, NamedLink owner, @Nullable NamedLink result) {
|
||||||
super(type, location);
|
super(type, location);
|
||||||
this.status = checkNotNull(status, "status");
|
this.status = checkNotNull(status, "status");
|
||||||
this.startTime = checkNotNull(startTime, "startTime");
|
this.startTime = startTime;
|
||||||
this.endTime = endTime;
|
this.endTime = endTime;
|
||||||
this.owner = checkNotNull(owner, "owner");
|
this.owner = owner;
|
||||||
this.result = result;
|
this.result = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,11 @@ package org.jclouds.vcloud.xml;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.rest.domain.Link;
|
import org.jclouds.rest.domain.Link;
|
||||||
import org.jclouds.rest.domain.NamedLink;
|
import org.jclouds.rest.domain.NamedLink;
|
||||||
import org.jclouds.rest.util.Utils;
|
import org.jclouds.rest.util.Utils;
|
||||||
|
@ -53,6 +55,9 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
||||||
private DateTime endTime;
|
private DateTime endTime;
|
||||||
private Task task;
|
private Task task;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TaskHandler(DateService dateService) {
|
public TaskHandler(DateService dateService) {
|
||||||
this.dateService = dateService;
|
this.dateService = dateService;
|
||||||
|
@ -65,15 +70,19 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName, Attributes attributes)
|
public void startElement(String uri, String localName, String qName, Attributes attributes)
|
||||||
throws SAXException {
|
throws SAXException {
|
||||||
if (qName.equals("Task")) {
|
if (qName.equalsIgnoreCase("Task")) {
|
||||||
|
if (attributes.getIndex("type") != -1)
|
||||||
taskLink = Utils.newLink(attributes);
|
taskLink = Utils.newLink(attributes);
|
||||||
status = TaskStatus.fromValue(attributes.getValue(attributes.getIndex("status")));
|
status = TaskStatus.fromValue(attributes.getValue(attributes.getIndex("status")));
|
||||||
|
if (attributes.getIndex("startTime") != -1)
|
||||||
startTime = parseDate(attributes, "startTime");
|
startTime = parseDate(attributes, "startTime");
|
||||||
if (attributes.getIndex("endTime") != -1) {
|
if (attributes.getIndex("endTime") != -1) {
|
||||||
endTime = parseDate(attributes, "endTime");
|
endTime = parseDate(attributes, "endTime");
|
||||||
}
|
}
|
||||||
} else if (qName.equals("Owner")) {
|
} else if (qName.equals("Owner")) {
|
||||||
owner = Utils.newNamedLink(attributes);
|
owner = Utils.newNamedLink(attributes);
|
||||||
|
} else if (qName.equals("Link")) {
|
||||||
|
taskLink = Utils.newNamedLink(attributes);
|
||||||
} else if (qName.equals("Result")) {
|
} else if (qName.equals("Result")) {
|
||||||
result = Utils.newNamedLink(attributes);
|
result = Utils.newNamedLink(attributes);
|
||||||
}
|
}
|
||||||
|
@ -85,17 +94,22 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
||||||
|
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
if (e.getCause() instanceof ParseException) {
|
if (e.getCause() instanceof ParseException) {
|
||||||
|
try {
|
||||||
return dateService.iso8601SecondsDateParse(attributes.getValue(attributes
|
return dateService.iso8601SecondsDateParse(attributes.getValue(attributes
|
||||||
.getIndex(attribute)));
|
.getIndex(attribute)));
|
||||||
|
} catch (RuntimeException ex) {
|
||||||
|
logger.error(e, "error parsing date");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
logger.error(e, "error parsing date");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||||
if (qName.equals("Task")) {
|
if (qName.equalsIgnoreCase("Task")) {
|
||||||
this.task = new TaskImpl(taskLink.getType(), taskLink.getLocation(), status, startTime,
|
this.task = new TaskImpl(taskLink.getType(), taskLink.getLocation(), status, startTime,
|
||||||
endTime, owner, result);
|
endTime, owner, result);
|
||||||
taskLink = null;
|
taskLink = null;
|
||||||
|
|
|
@ -46,7 +46,6 @@ public class SetVCloudTokenCookieTest {
|
||||||
@BeforeTest
|
@BeforeTest
|
||||||
void setUp() {
|
void setUp() {
|
||||||
filter = new SetVCloudTokenCookie(new Provider<String>() {
|
filter = new SetVCloudTokenCookie(new Provider<String>() {
|
||||||
|
|
||||||
public String get() {
|
public String get() {
|
||||||
return "token";
|
return "token";
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testApplyInputStream() {
|
public void testApplyInputStream() {
|
||||||
InputStream is = getClass().getResourceAsStream("/taskslist.xml");
|
InputStream is = getClass().getResourceAsStream("/task.xml");
|
||||||
|
|
||||||
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||||
|
|
||||||
|
@ -75,4 +75,31 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
||||||
assertEquals(result, expects);
|
assertEquals(result, expects);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testApplyInputStream3() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/task-hosting-baddate.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
|
||||||
|
);
|
||||||
|
assertEquals(result, expects);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testApplyInputStream2() {
|
||||||
|
InputStream is = getClass().getResourceAsStream("/task-hosting.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-34"),
|
||||||
|
TaskStatus.QUEUED, null, null, null, null);
|
||||||
|
assertEquals(result, expects);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Task xmlns="http://www.vmware.com/vcloud/v0.8/task"
|
||||||
|
xmlns:common="http://www.vmware.com/vcloud/common"
|
||||||
|
xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8/task
|
||||||
|
https://vcloud.safesecureweb.com/ns/vcloud/task-1.0.xsd
|
||||||
|
http://www.vmware.com/vcloud/common
|
||||||
|
https://vcloud.safesecureweb.com/ns/vcloud/common-1.0.xsd"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
status="running" startTime="1/1/2001 12:00:00 AM">
|
||||||
|
|
||||||
|
<Link rel="self" href="https://vcloud.safesecureweb.com/api/v0.8/task/d188849-37" type="application/vnd.vmware.vcloud.task+xml" />
|
||||||
|
|
||||||
|
<Owner href="https://vcloud.safesecureweb.com/api/v0.8/vdc/188849" type="application/vnd.vmware.vcloud.vdc+xml" name="188849" />
|
||||||
|
</Task>
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<task xmlns="http://www.vmware.com/vcloud/v0.8/task"
|
||||||
|
xmlns:common="http://www/vmware.com/vcloud/common"
|
||||||
|
xsi:schemaLocation="http://www/vmware.com/vcloud/task
|
||||||
|
https://vcloud.safesecureweb.com/ns/vcloud/task-1.0.xsd
|
||||||
|
http://www.vmware.com/vcloud/common
|
||||||
|
https://vcloud.safesecureweb.com/ns/vcloud/common-1.0.xsd"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
status="queued">
|
||||||
|
<Link rel="self" href="https://vcloud.safesecureweb.com/api/v0.8/task/d188849-34" type="application/vnd.vmware.vcloud.task+xml" />
|
||||||
|
</task>
|
|
@ -37,10 +37,11 @@ import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||||
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
|
* @see <a href="https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx" />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Timeout(duration = 45, timeUnit = TimeUnit.SECONDS)
|
@Timeout(duration = 90, timeUnit = TimeUnit.SECONDS)
|
||||||
public interface HostingDotComVCloudClient extends VCloudClient {
|
public interface HostingDotComVCloudClient extends VCloudClient {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
|
||||||
HostingDotComVApp instantiateVAppTemplate(String appName, String templateId,
|
HostingDotComVApp instantiateVAppTemplate(String appName, String templateId,
|
||||||
InstantiateVAppTemplateOptions... options);
|
InstantiateVAppTemplateOptions... options);
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import org.jclouds.vcloud.hostingdotcom.domain.internal.HostingDotComVAppImpl;
|
||||||
import org.jclouds.vcloud.xml.ResourceAllocationHandler;
|
import org.jclouds.vcloud.xml.ResourceAllocationHandler;
|
||||||
import org.jclouds.vcloud.xml.VAppHandler;
|
import org.jclouds.vcloud.xml.VAppHandler;
|
||||||
import org.jclouds.vcloud.xml.VirtualSystemHandler;
|
import org.jclouds.vcloud.xml.VirtualSystemHandler;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,15 +30,17 @@ public class HostingDotComVAppHandler extends VAppHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
public void startElement(String uri, String localName, String qName, Attributes attributes)
|
||||||
if (qName.equals("hmsns:username")) {
|
throws SAXException {
|
||||||
username = currentText.toString().trim();
|
super.startElement(uri, localName, qName, attributes);
|
||||||
} else if (qName.equals("hmsns:password")) {
|
if (attributes.getIndex("key") != -1) {
|
||||||
password = currentText.toString().trim();
|
String key = attributes.getValue(attributes.getIndex("key"));
|
||||||
} else {
|
if ("username".equals(key)) {
|
||||||
super.endElement(uri, localName, qName);
|
username = attributes.getValue(attributes.getIndex("value"));
|
||||||
|
} else if ("password".equals(key)) {
|
||||||
|
password = attributes.getValue(attributes.getIndex("value"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
currentText = new StringBuilder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,16 +93,9 @@ public class HostingDotComVCloudComputeClient {
|
||||||
minMegs));
|
minMegs));
|
||||||
this.username = vAppResponse.getUsername();
|
this.username = vAppResponse.getUsername();
|
||||||
this.password = vAppResponse.getPassword();
|
this.password = vAppResponse.getPassword();
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
tmClient.getVApp(vAppResponse.getId());
|
|
||||||
logger.debug("<< instantiated VApp(%s)", vAppResponse.getId());
|
logger.debug("<< instantiated VApp(%s)", vAppResponse.getId());
|
||||||
|
|
||||||
logger.debug(">> deploying vApp(%s)", vAppResponse.getId());
|
logger.debug(">> deploying vApp(%s)", vAppResponse.getId());
|
||||||
|
|
||||||
VApp vApp = blockUntilVAppStatusOrThrowException(vAppResponse, tmClient
|
VApp vApp = blockUntilVAppStatusOrThrowException(vAppResponse, tmClient
|
||||||
.deployVApp(vAppResponse.getId()), "deploy", VAppStatus.OFF);
|
.deployVApp(vAppResponse.getId()), "deploy", VAppStatus.OFF);
|
||||||
logger.debug("<< deployed vApp(%s)", vApp.getId());
|
logger.debug("<< deployed vApp(%s)", vApp.getId());
|
||||||
|
|
|
@ -158,7 +158,7 @@ public class HostingDotComVCloudComputeClientLiveTest {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Provides
|
@Provides
|
||||||
private Predicate<URI> successTester(TaskSuccess success) {
|
private Predicate<URI> successTester(TaskSuccess success) {
|
||||||
return new RetryablePredicate<URI>(success, 300, 10, TimeUnit.SECONDS);
|
return new RetryablePredicate<URI>(success, 600, 10, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
}).buildInjector();
|
}).buildInjector();
|
||||||
|
|
|
@ -54,12 +54,11 @@ public class HostingDotComVAppHandlerTest extends BaseHandlerTest {
|
||||||
HostingDotComVApp result = (HostingDotComVApp) factory.create(
|
HostingDotComVApp result = (HostingDotComVApp) factory.create(
|
||||||
injector.getInstance(HostingDotComVAppHandler.class)).parse(is);
|
injector.getInstance(HostingDotComVAppHandler.class)).parse(is);
|
||||||
|
|
||||||
HostingDotComVApp expects = new HostingDotComVAppImpl("188849-13", "188849-13", URI
|
HostingDotComVApp expects = new HostingDotComVAppImpl("188849-33", "188849-33", URI
|
||||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-13"),
|
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-33"),
|
||||||
VAppStatus.TODO_I_DONT_KNOW, ImmutableListMultimap.<String, InetAddress> of(), null,
|
VAppStatus.TODO_I_DONT_KNOW, ImmutableListMultimap.<String, InetAddress> of(), null,
|
||||||
null, ImmutableSortedSet.<ResourceAllocation> of(), "root", "peoplearelovely");
|
null, ImmutableSortedSet.<ResourceAllocation> of(), "root", "meatisyummy");
|
||||||
|
|
||||||
assertEquals(result, expects);
|
assertEquals(result, expects);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<VApp name="188849-13" status="1"
|
<VApp name="188849-33" status="1"
|
||||||
href="https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-13"
|
href="https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-33"
|
||||||
xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:hmsns="https://vcloud.safesecureweb.com/ns/v1/VApp"
|
xmlns="http://www.vmware.com/vcloud/v0.8"
|
||||||
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:hmsns="https://vcloud.safesecureweb.com/ns/v1/VApp"
|
||||||
|
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://www.vmware.com/vcloud/1
|
xsi:schemaLocation="http://www.vmware.com/vcloud/1
|
||||||
https://vcloud.safesecureweb.com/ns/vcloud.xsd">
|
https://vcloud.safesecureweb.com/ns/vcloud.xsd">
|
||||||
<Link rel="up"
|
<Link rel="up" href="https://vcloud.safesecureweb.com/api/v0.8/vdc/188849" type="application/vnd.vmware.vcloud.vdc+xml" />
|
||||||
href="https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"
|
<ovf:ProductSection>
|
||||||
type="application/vnd.vmware.vcloud.vdc+xml" />
|
<ovf:Info>Product Section Details</ovf:Info>
|
||||||
<hmsns:username>root</hmsns:username>
|
<Property key="username" value="root" />
|
||||||
<hmsns:password>peoplearelovely</hmsns:password>
|
<Property key="password" value="meatisyummy" />
|
||||||
|
</ovf:ProductSection>
|
||||||
</VApp>
|
</VApp>
|
||||||
|
|
Loading…
Reference in New Issue