mirror of https://github.com/apache/jclouds.git
Issue 112: added expiryTime to task
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2656 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
63073ae3f4
commit
b85dbd8109
|
@ -40,6 +40,7 @@ public interface Task extends Comparable<Task> {
|
||||||
|
|
||||||
Date getEndTime();
|
Date getEndTime();
|
||||||
|
|
||||||
|
Date getExpiryTime();
|
||||||
/**
|
/**
|
||||||
* A link to the vDC in which the task was started
|
* A link to the vDC in which the task was started
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -112,6 +112,8 @@ public class TaskImpl implements Task {
|
||||||
private final Date startTime;
|
private final Date startTime;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Date endTime;
|
private final Date endTime;
|
||||||
|
@Nullable
|
||||||
|
private final Date expiryTime;
|
||||||
private final NamedResource owner;
|
private final NamedResource owner;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final NamedResource result;
|
private final NamedResource result;
|
||||||
|
@ -119,13 +121,14 @@ public class TaskImpl implements Task {
|
||||||
private final Error error;
|
private final Error error;
|
||||||
|
|
||||||
public TaskImpl(String id, URI location, TaskStatus status, Date startTime,
|
public TaskImpl(String id, URI location, TaskStatus status, Date startTime,
|
||||||
@Nullable Date endTime, NamedResource owner,
|
@Nullable Date endTime,@Nullable Date expiryTime, NamedResource owner,
|
||||||
@Nullable NamedResource result, Error error) {
|
@Nullable NamedResource result, Error error) {
|
||||||
this.id = checkNotNull(id, "id");
|
this.id = checkNotNull(id, "id");
|
||||||
this.location = checkNotNull(location, "location");
|
this.location = checkNotNull(location, "location");
|
||||||
this.status = checkNotNull(status, "status");
|
this.status = checkNotNull(status, "status");
|
||||||
this.startTime = startTime;
|
this.startTime = startTime;
|
||||||
this.endTime = endTime;
|
this.endTime = endTime;
|
||||||
|
this.expiryTime = expiryTime;
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.error = error;
|
this.error = error;
|
||||||
|
@ -173,13 +176,12 @@ public class TaskImpl implements Task {
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + ((endTime == null) ? 0 : endTime.hashCode());
|
result = prime * result + ((endTime == null) ? 0 : endTime.hashCode());
|
||||||
result = prime * result + ((error == null) ? 0 : error.hashCode());
|
result = prime * result + ((error == null) ? 0 : error.hashCode());
|
||||||
|
result = prime * result + ((expiryTime == null) ? 0 : expiryTime.hashCode());
|
||||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||||
result = prime * result + ((location == null) ? 0 : location.hashCode());
|
result = prime * result + ((location == null) ? 0 : location.hashCode());
|
||||||
result = prime * result + ((owner == null) ? 0 : owner.hashCode());
|
result = prime * result + ((owner == null) ? 0 : owner.hashCode());
|
||||||
result = prime * result
|
result = prime * result + ((this.result == null) ? 0 : this.result.hashCode());
|
||||||
+ ((this.result == null) ? 0 : this.result.hashCode());
|
result = prime * result + ((startTime == null) ? 0 : startTime.hashCode());
|
||||||
result = prime * result
|
|
||||||
+ ((startTime == null) ? 0 : startTime.hashCode());
|
|
||||||
result = prime * result + ((status == null) ? 0 : status.hashCode());
|
result = prime * result + ((status == null) ? 0 : status.hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -203,6 +205,11 @@ public class TaskImpl implements Task {
|
||||||
return false;
|
return false;
|
||||||
} else if (!error.equals(other.error))
|
} else if (!error.equals(other.error))
|
||||||
return false;
|
return false;
|
||||||
|
if (expiryTime == null) {
|
||||||
|
if (other.expiryTime != null)
|
||||||
|
return false;
|
||||||
|
} else if (!expiryTime.equals(other.expiryTime))
|
||||||
|
return false;
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
if (other.id != null)
|
if (other.id != null)
|
||||||
return false;
|
return false;
|
||||||
|
@ -243,4 +250,8 @@ public class TaskImpl implements Task {
|
||||||
+ result + ", startTime=" + startTime + ", status=" + status + "]";
|
+ result + ", startTime=" + startTime + ", status=" + status + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Date getExpiryTime() {
|
||||||
|
return expiryTime;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -209,4 +209,9 @@ public class VDCImpl implements VDC {
|
||||||
public int compareTo(NamedResource o) {
|
public int compareTo(NamedResource o) {
|
||||||
return (this == o) ? 0 : getId().compareTo(o.getId());
|
return (this == o) ? 0 : getId().compareTo(o.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[id=" + id + ", name=" + name + ", description=" + description + "]";
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -48,13 +48,13 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
||||||
private TaskStatus status;
|
private TaskStatus status;
|
||||||
private Date startTime;
|
private Date startTime;
|
||||||
private Date endTime;
|
private Date endTime;
|
||||||
|
private Date expiryTime;
|
||||||
private Task task;
|
private Task task;
|
||||||
private Error error;
|
private Error error;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TaskHandler(DateService dateService) {
|
public TaskHandler(DateService dateService) {
|
||||||
this.dateService = dateService;
|
this.dateService = dateService;
|
||||||
|
@ -73,9 +73,10 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
||||||
status = TaskStatus.fromValue(attributes.getValue(attributes.getIndex("status")));
|
status = TaskStatus.fromValue(attributes.getValue(attributes.getIndex("status")));
|
||||||
if (attributes.getIndex("startTime") != -1)
|
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");
|
||||||
}
|
if (attributes.getIndex("expiryTime") != -1)
|
||||||
|
expiryTime = parseDate(attributes, "expiryTime");
|
||||||
} else if (qName.equals("Owner")) {
|
} else if (qName.equals("Owner")) {
|
||||||
owner = Utils.newNamedResource(attributes);
|
owner = Utils.newNamedResource(attributes);
|
||||||
} else if (qName.equals("Link") && attributes.getIndex("rel") != -1
|
} else if (qName.equals("Link") && attributes.getIndex("rel") != -1
|
||||||
|
@ -89,14 +90,14 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Date parseDate(Attributes attributes, String attribute) {
|
private Date parseDate(Attributes attributes, String attribute) {
|
||||||
String toParse =attributes.getValue(attributes.getIndex(attribute));
|
String toParse = attributes.getValue(attributes.getIndex(attribute));
|
||||||
try {
|
try {
|
||||||
return dateService.iso8601DateParse(toParse);
|
return dateService.iso8601DateParse(toParse);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
if (e.getCause() instanceof ParseException) {
|
if (e.getCause() instanceof ParseException) {
|
||||||
try {
|
try {
|
||||||
if (!toParse.endsWith("Z"))
|
if (!toParse.endsWith("Z"))
|
||||||
toParse+="Z";
|
toParse += "Z";
|
||||||
return dateService.iso8601SecondsDateParse(toParse);
|
return dateService.iso8601SecondsDateParse(toParse);
|
||||||
} catch (RuntimeException ex) {
|
} catch (RuntimeException ex) {
|
||||||
logger.error(e, "error parsing date");
|
logger.error(e, "error parsing date");
|
||||||
|
@ -111,7 +112,8 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
||||||
@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.equalsIgnoreCase("Task")) {
|
if (qName.equalsIgnoreCase("Task")) {
|
||||||
this.task = new TaskImpl(taskLink.getId(), taskLink.getLocation(), status, startTime, endTime, owner, result, error);
|
this.task = new TaskImpl(taskLink.getId(), taskLink.getLocation(), status, startTime,
|
||||||
|
endTime, expiryTime, owner, result, error);
|
||||||
taskLink = null;
|
taskLink = null;
|
||||||
status = null;
|
status = null;
|
||||||
startTime = null;
|
startTime = null;
|
||||||
|
|
|
@ -53,9 +53,9 @@ public class VCloudClientLiveTest {
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertNotNull(response.getId());
|
assertNotNull(response.getId());
|
||||||
assertNotNull(account);
|
assertNotNull(account);
|
||||||
assert response.getCatalogs().size() >=1;
|
assert response.getCatalogs().size() >= 1;
|
||||||
assert response.getTasksLists().size() >=1;
|
assert response.getTasksLists().size() >= 1;
|
||||||
assert response.getVDCs().size() >=1;
|
assert response.getVDCs().size() >= 1;
|
||||||
assertEquals(connection.getOrganization(response.getId()), response);
|
assertEquals(connection.getOrganization(response.getId()), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ public class VCloudClientLiveTest {
|
||||||
assertNotNull(response.getLocation());
|
assertNotNull(response.getLocation());
|
||||||
assertNotNull(response.getResourceEntities());
|
assertNotNull(response.getResourceEntities());
|
||||||
assertNotNull(response.getAvailableNetworks());
|
assertNotNull(response.getAvailableNetworks());
|
||||||
assertEquals(connection.getVDC(response.getId()), response);
|
assertEquals(connection.getVDC(response.getId()).getId(), response.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -138,8 +138,10 @@ public class VCloudClientLiveTest {
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertNotNull(response.getLocation());
|
assertNotNull(response.getLocation());
|
||||||
assertNotNull(response.getTasks());
|
assertNotNull(response.getTasks());
|
||||||
Task task = response.getTasks().last();
|
if (response.getTasks().size() > 0) {
|
||||||
assertEquals(connection.getTask(task.getId()).getLocation(), task.getLocation());
|
Task task = response.getTasks().last();
|
||||||
|
assertEquals(connection.getTask(task.getId()).getLocation(), task.getLocation());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -53,30 +53,18 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
||||||
public void testApplyInputStream() {
|
public void testApplyInputStream() {
|
||||||
InputStream is = getClass().getResourceAsStream("/task.xml");
|
InputStream is = getClass().getResourceAsStream("/task.xml");
|
||||||
|
|
||||||
Task result = factory.create(injector.getInstance(TaskHandler.class))
|
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||||
.parse(is);
|
|
||||||
|
|
||||||
Task expects = new TaskImpl(
|
Task expects = new TaskImpl("3299", URI
|
||||||
"3299",
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
|
||||||
URI
|
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"),
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
|
dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"), null,
|
||||||
TaskStatus.SUCCESS,
|
new NamedResourceImpl("1", "VDC Name", VCloudMediaType.VDC_XML, URI
|
||||||
dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"),
|
|
||||||
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")),
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
|
||||||
new NamedResourceImpl(
|
new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI
|
||||||
"4012",
|
|
||||||
"Server1",
|
|
||||||
VCloudMediaType.VAPP_XML,
|
|
||||||
URI
|
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")
|
||||||
|
|
||||||
), null
|
), null
|
||||||
|
|
||||||
);
|
);
|
||||||
assertEquals(result, expects);
|
assertEquals(result, expects);
|
||||||
|
@ -86,14 +74,11 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
||||||
public void testSelf() {
|
public void testSelf() {
|
||||||
InputStream is = getClass().getResourceAsStream("/task-self.xml");
|
InputStream is = getClass().getResourceAsStream("/task-self.xml");
|
||||||
|
|
||||||
Task result = factory.create(injector.getInstance(TaskHandler.class))
|
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||||
.parse(is);
|
|
||||||
|
|
||||||
Task expects = new TaskImpl(
|
Task expects = new TaskImpl("d188849-78", URI
|
||||||
"d188849-78",
|
.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"),
|
||||||
URI
|
TaskStatus.QUEUED, null, null, null, null, null, null);
|
||||||
.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"),
|
|
||||||
TaskStatus.QUEUED, null, null, null, null, null);
|
|
||||||
assertEquals(result, expects);
|
assertEquals(result, expects);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -101,45 +86,34 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
||||||
public void testApplyInputStream2() {
|
public void testApplyInputStream2() {
|
||||||
InputStream is = getClass().getResourceAsStream("/task-hosting.xml");
|
InputStream is = getClass().getResourceAsStream("/task-hosting.xml");
|
||||||
|
|
||||||
Task result = factory.create(injector.getInstance(TaskHandler.class))
|
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||||
.parse(is);
|
|
||||||
|
|
||||||
Task expects = new TaskImpl(
|
Task expects = new TaskImpl("97806", URI
|
||||||
"d188849-72",
|
.create("https://vcloud.safesecureweb.com/api/v0.8/task/97806"), TaskStatus.SUCCESS,
|
||||||
URI
|
dateService.iso8601SecondsDateParse("2010-01-14T20:04:51Z"), dateService
|
||||||
.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-72"),
|
.iso8601SecondsDateParse("2010-01-14T20:05:02Z"), dateService
|
||||||
TaskStatus.RUNNING,
|
.iso8601SecondsDateParse("2010-01-15T20:05:02Z"),
|
||||||
dateService.iso8601SecondsDateParse("2001-01-01T05:00:00Z"),
|
|
||||||
null,
|
new NamedResourceImpl("188849-96", "188849-96", VCloudMediaType.VAPP_XML, URI
|
||||||
new NamedResourceImpl(
|
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96")), null,
|
||||||
"188849",
|
null);
|
||||||
"188849",
|
|
||||||
VCloudMediaType.VDC_XML,
|
|
||||||
URI
|
|
||||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/188849")),
|
|
||||||
null, null);
|
|
||||||
assertEquals(result, expects);
|
assertEquals(result, expects);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testError() {
|
public void testError() {
|
||||||
InputStream is = getClass().getResourceAsStream("/task-error.xml");
|
InputStream is = getClass().getResourceAsStream("/task-error.xml");
|
||||||
|
|
||||||
Task result = factory.create(injector.getInstance(TaskHandler.class))
|
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||||
.parse(is);
|
|
||||||
|
|
||||||
Task expects = new TaskImpl(
|
Task expects = new TaskImpl("23", URI.create("http://10.150.4.49/api/v0.8/task/23"),
|
||||||
"23",
|
TaskStatus.ERROR, dateService.iso8601SecondsDateParse("2009-12-07T19:05:02Z"),
|
||||||
URI.create("http://10.150.4.49/api/v0.8/task/23"),
|
dateService.iso8601SecondsDateParse("2009-12-10T14:40:32Z"), null,
|
||||||
TaskStatus.ERROR,
|
new NamedResourceImpl("1", "APIOrg", VCloudMediaType.ORG_XML, URI
|
||||||
dateService.iso8601SecondsDateParse("2009-12-07T19:05:02Z"),
|
.create("http://10.150.4.49/api/v0.8/org/1")), new NamedResourceImpl("1",
|
||||||
dateService.iso8601SecondsDateParse("2009-12-10T14:40:32Z"),
|
"testapp1", VCloudMediaType.VAPP_XML, URI
|
||||||
new NamedResourceImpl("1", "APIOrg", VCloudMediaType.ORG_XML, URI
|
.create("http://10.150.4.49/api/v0.8/vapp/1")),
|
||||||
.create("http://10.150.4.49/api/v0.8/org/1")),
|
new TaskImpl.ErrorImpl("Error processing job", "500",
|
||||||
new NamedResourceImpl("1", "testapp1", VCloudMediaType.VAPP_XML,
|
" Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00"));
|
||||||
URI.create("http://10.150.4.49/api/v0.8/vapp/1")),
|
|
||||||
new TaskImpl.ErrorImpl("Error processing job", "500",
|
|
||||||
" Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00"));
|
|
||||||
assertEquals(result, expects);
|
assertEquals(result, expects);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,24 +60,30 @@ public class TasksListHandlerTest extends BaseHandlerTest {
|
||||||
TasksList result = factory.create(injector.getInstance(TasksListHandler.class)).parse(is);
|
TasksList result = factory.create(injector.getInstance(TasksListHandler.class)).parse(is);
|
||||||
assertEquals(result.getLocation(), URI
|
assertEquals(result.getLocation(), URI
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/1"));
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/1"));
|
||||||
Task task1 = new TaskImpl("3300", URI
|
Task task1 = new TaskImpl(
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3300"),
|
"3300",
|
||||||
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:30:19.587Z"),
|
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3300"),
|
||||||
dateService.iso8601DateParse("2009-08-24T21:30:32.63Z"), new NamedResourceImpl("1",
|
TaskStatus.SUCCESS,
|
||||||
"VDC Name", VCloudMediaType.VDC_XML,
|
dateService.iso8601DateParse("2009-08-24T21:30:19.587Z"),
|
||||||
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
|
dateService.iso8601DateParse("2009-08-24T21:30:32.63Z"),
|
||||||
|
null,
|
||||||
|
new NamedResourceImpl("1", "VDC Name", VCloudMediaType.VDC_XML, URI
|
||||||
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
|
||||||
new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI
|
new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")),null);
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")),
|
||||||
Task task2 = new TaskImpl("3299", URI
|
null);
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
|
Task task2 = new TaskImpl(
|
||||||
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"),
|
"3299",
|
||||||
dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"), new NamedResourceImpl("1",
|
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
|
||||||
"VDC Name", VCloudMediaType.VDC_XML,
|
TaskStatus.SUCCESS,
|
||||||
URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
|
dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"),
|
||||||
|
dateService.iso8601DateParse("2009-08-24T21:29:44.65Z"),
|
||||||
|
null,
|
||||||
|
new NamedResourceImpl("1", "VDC Name", VCloudMediaType.VDC_XML, URI
|
||||||
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/1")),
|
||||||
new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI
|
new NamedResourceImpl("4012", "Server1", VCloudMediaType.VAPP_XML, URI
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")),
|
||||||
), null
|
null);
|
||||||
);
|
|
||||||
assertEquals(result.getTasks(), ImmutableSortedSet.of(task1, task2));
|
assertEquals(result.getTasks(), ImmutableSortedSet.of(task1, task2));
|
||||||
assertEquals(
|
assertEquals(
|
||||||
result.getTasksByResult(),
|
result.getTasksByResult(),
|
||||||
|
|
|
@ -48,14 +48,14 @@ import com.google.common.collect.ListMultimap;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "vcloud.VAppHandlerTest")
|
@Test(groups = "unit", testName = "vcloud.VAppHandlerTest")
|
||||||
public class VAppHandlerTest extends BaseHandlerTest {
|
public class VAppHandlerTest extends BaseHandlerTest {
|
||||||
@Test(enabled=false)
|
@Test(enabled = false)
|
||||||
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.59.147"));
|
.<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");
|
||||||
|
|
||||||
|
@ -76,28 +76,27 @@ public class VAppHandlerTest extends BaseHandlerTest {
|
||||||
null, "20971520", null, 0, 3, null, 20971520, "byte * 2^20"))
|
null, "20971520", null, 0, 3, null, 20971520, "byte * 2^20"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
VApp expects = new VAppImpl("188849-74", "188849-74", URI
|
VApp expects = new VAppImpl("188849-96", "188849-96", URI
|
||||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-74"), VAppStatus.ON,
|
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96"), VAppStatus.OFF,
|
||||||
new Long(20971520),null,
|
new Long(20971520), null, networkToAddresses, null, system, resourceAllocations);
|
||||||
networkToAddresses, null, system, resourceAllocations);
|
|
||||||
|
|
||||||
assertEquals(result, expects);
|
assertEquals(result, expects);
|
||||||
}
|
}
|
||||||
|
|
||||||
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(
|
VApp result = factory.create(injector.getInstance(VAppHandler.class)).parse(is);
|
||||||
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"),
|
.create("http://10.150.4.49/api/v0.8/vApp/10"), VAppStatus.RESOLVED, 123456789l,
|
||||||
VAppStatus.RESOLVED, 123456789l, new NamedResourceImpl("4", null,
|
new NamedResourceImpl("4", null, "application/vnd.vmware.vcloud.vdc+xml", URI
|
||||||
"application/vnd.vmware.vcloud.vdc+xml", URI
|
.create("http://10.150.4.49/api/v0.8/vdc/4")), ImmutableListMultimap
|
||||||
.create("http://10.150.4.49/api/v0.8/vdc/4")),
|
.<String, InetAddress> of(), null, null, ImmutableSet
|
||||||
ImmutableListMultimap.<String, InetAddress> of(),
|
.<ResourceAllocation> 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)
|
@Test(enabled = false)
|
||||||
public void testDefault() throws UnknownHostException {
|
public void testDefault() throws UnknownHostException {
|
||||||
|
@ -106,7 +105,7 @@ public class VAppHandlerTest extends BaseHandlerTest {
|
||||||
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();
|
||||||
|
|
||||||
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "Oracle", "vmx-07");
|
VirtualSystem system = new VirtualSystem(0, "Virtual Hardware Family", "Oracle", "vmx-07");
|
||||||
|
|
||||||
|
@ -121,21 +120,21 @@ public class VAppHandlerTest extends BaseHandlerTest {
|
||||||
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller",
|
new ResourceAllocation(3, "SCSI Controller 0", "SCSI Controller",
|
||||||
ResourceType.SCSI_CONTROLLER, "lsilogic", null, 0, null, null,
|
ResourceType.SCSI_CONTROLLER, "lsilogic", null, 0, null, null,
|
||||||
null, 1, null)).add(
|
null, 1, null)).add(
|
||||||
new ResourceAllocation(8, "Network Adapter 1", "PCNet32 ethernet adapter on \"Internal\" network",
|
new ResourceAllocation(8, "Network Adapter 1",
|
||||||
|
"PCNet32 ethernet adapter on \"Internal\" network",
|
||||||
ResourceType.ETHERNET_ADAPTER, "PCNet32", null, null, 7, null,
|
ResourceType.ETHERNET_ADAPTER, "PCNet32", null, null, 7, null,
|
||||||
true, 1, null)).add(
|
true, 1, null)).add(
|
||||||
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE,
|
new ResourceAllocation(9, "Hard Disk 1", null, ResourceType.DISK_DRIVE,
|
||||||
null, "104857", null, 0, 3, null, 104857, "byte * 2^20"))
|
null, "104857", null, 0, 3, null, 104857, "byte * 2^20")).build();
|
||||||
.build();
|
|
||||||
|
|
||||||
VApp expects = new VAppImpl("4", "Oracle", URI
|
VApp expects = new VAppImpl("4", "Oracle", URI.create("http://10.150.4.49/api/v0.8/vApp/4"),
|
||||||
.create("http://10.150.4.49/api/v0.8/vApp/4"), VAppStatus.ON,
|
VAppStatus.ON, new Long(104857),
|
||||||
new Long(104857), new NamedResourceImpl("32", null,
|
new NamedResourceImpl("32", null, "application/vnd.vmware.vcloud.vdc+xml", URI
|
||||||
"application/vnd.vmware.vcloud.vdc+xml", URI
|
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")),
|
||||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32")),
|
networkToAddresses, "Other Linux (32-bit)", system, resourceAllocations);
|
||||||
networkToAddresses, "Other Linux (32-bit)", system, resourceAllocations);
|
|
||||||
|
|
||||||
assertEquals(result, expects);
|
assertEquals(result, expects);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Task href="https://vcloud.safesecureweb.com/api/v0.8/task/d188849-72"
|
<Task href="https://vcloud.safesecureweb.com/api/v0.8/task/97806" xmlns="http://www.vmware.com/vcloud/v0.8"
|
||||||
xmlns="http://www.vmware.com/vcloud/v0.8" xmlns:common="http://www.vmware.com/vcloud/common"
|
xmlns:common="http://www.vmware.com/vcloud/common"
|
||||||
xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8/task
|
xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8/task
|
||||||
https://vcloud.safesecureweb.com/ns/vcloud/task-1.0.xsd
|
https://vcloud.safesecureweb.com/ns/vcloud/task-1.0.xsd
|
||||||
http://www.vmware.com/vcloud/common
|
http://www.vmware.com/vcloud/common
|
||||||
https://vcloud.safesecureweb.com/ns/vcloud/common-1.0.xsd"
|
https://vcloud.safesecureweb.com/ns/vcloud/common-1.0.xsd"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" status="running"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
startTime="2001-01-01T05:00:00Z">
|
status="success" startTime="2010-01-14T20:04:51Z" endTime="2010-01-14T20:05:02Z" expiryTime="2010-01-15T20:05:02Z">
|
||||||
<Link rel="task:cancel" href="https://vcloud.safesecureweb.com/api/v0.8/task/d188849-72/action/cancel" />
|
|
||||||
<Owner href="https://vcloud.safesecureweb.com/api/v0.8/vdc/188849"
|
<Owner href="https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96" type="application/vnd.vmware.vcloud.vApp+xml" name="188849-96" />
|
||||||
type="application/vnd.vmware.vcloud.vdc+xml" name="188849" />
|
|
||||||
</Task>
|
</Task>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<VApp href="https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-74"
|
<VApp href="https://vcloud.safesecureweb.com/api/v0.8/vapp/188849-96"
|
||||||
type="application/vnd.vmware.vcloud.vApp+xml" name="188849-74"
|
type="application/vnd.vmware.vcloud.vApp+xml" name="188849-96"
|
||||||
status="4" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 vapp.xsd"
|
status="2" xsi:schemaLocation="http://www.vmware.com/vcloud/v0.8 vapp.xsd"
|
||||||
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns="http://www.vmware.com/vcloud/v0.8"
|
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns="http://www.vmware.com/vcloud/v0.8"
|
||||||
xmlns:vmw="http://www.vmware.com/schema/ovf"
|
xmlns:vmw="http://www.vmware.com/schema/ovf"
|
||||||
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
|
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData"
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
<NetworkConnectionSection>
|
<NetworkConnectionSection>
|
||||||
<Info xmlns="http://schemas.dmtf.org/ovf/envelope/1">Network Information about the vApp</Info>
|
<Info xmlns="http://schemas.dmtf.org/ovf/envelope/1">Network Information about the vApp</Info>
|
||||||
<NetworkConnection Network="Network 1">
|
<NetworkConnection Network="Network 1">
|
||||||
<IpAddress>204.12.59.147</IpAddress>
|
<IpAddress>204.12.11.167</IpAddress>
|
||||||
</NetworkConnection>
|
</NetworkConnection>
|
||||||
</NetworkConnectionSection>
|
</NetworkConnectionSection>
|
||||||
|
|
||||||
|
@ -233,4 +233,3 @@
|
||||||
</Item>
|
</Item>
|
||||||
</VirtualHardwareSection>
|
</VirtualHardwareSection>
|
||||||
</VApp>
|
</VApp>
|
||||||
|
|
||||||
|
|
|
@ -53,10 +53,10 @@ import com.google.inject.internal.ImmutableMap;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", enabled = false, sequential = true, testName = "vcloud.HostingDotComVCloudClientLiveTest")
|
@Test(groups = "live", enabled = true, sequential = true, testName = "vcloud.HostingDotComVCloudClientLiveTest")
|
||||||
public class HostingDotComVCloudComputeClientLiveTest {
|
public class HostingDotComVCloudComputeClientLiveTest {
|
||||||
HostingDotComVCloudComputeClient client;
|
HostingDotComVCloudComputeClient client;
|
||||||
HostingDotComVCloudClient tmClient;
|
HostingDotComVCloudClient hostingClient;
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private InetAddress privateAddress;
|
private InetAddress privateAddress;
|
||||||
|
@ -79,11 +79,12 @@ public class HostingDotComVCloudComputeClientLiveTest {
|
||||||
Image.RHEL_53,
|
Image.RHEL_53,
|
||||||
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).put(
|
new Expectation(4194304 / 2 * 10, "Red Hat Enterprise Linux 5 (64-bit)")).put(
|
||||||
Image.UBUNTU_90, new Expectation(4194304, "Ubuntu Linux (64-bit)")).put(
|
Image.UBUNTU_90, new Expectation(4194304, "Ubuntu Linux (64-bit)")).put(
|
||||||
Image.UBUNTU_JEOS_90, new Expectation(4194304, "Ubuntu Linux (32-bit)")).build();
|
Image.UBUNTU_JEOS_90, new Expectation(4194304, "Ubuntu Linux (32-bit)"))
|
||||||
|
.build();
|
||||||
|
|
||||||
private Predicate<InetAddress> addressTester;
|
private Predicate<InetAddress> addressTester;
|
||||||
|
|
||||||
@Test
|
@Test(enabled = true)
|
||||||
public void testPowerOn() throws InterruptedException, ExecutionException, TimeoutException,
|
public void testPowerOn() throws InterruptedException, ExecutionException, TimeoutException,
|
||||||
IOException {
|
IOException {
|
||||||
Image toTest = Image.CENTOS_53;
|
Image toTest = Image.CENTOS_53;
|
||||||
|
@ -97,7 +98,7 @@ public class HostingDotComVCloudComputeClientLiveTest {
|
||||||
id = client.start(serverName, toTest, processorCount, memory, disk, properties).get("id");
|
id = client.start(serverName, toTest, processorCount, memory, disk, properties).get("id");
|
||||||
Expectation expectation = expectationMap.get(toTest);
|
Expectation expectation = expectationMap.get(toTest);
|
||||||
|
|
||||||
VApp vApp = tmClient.getVApp(id);
|
VApp vApp = hostingClient.getVApp(id);
|
||||||
verifyConfigurationOfVApp(vApp, serverName, expectation.os, processorCount, memory,
|
verifyConfigurationOfVApp(vApp, serverName, expectation.os, processorCount, memory,
|
||||||
expectation.hardDisk);
|
expectation.hardDisk);
|
||||||
assertEquals(vApp.getStatus(), VAppStatus.ON);
|
assertEquals(vApp.getStatus(), VAppStatus.ON);
|
||||||
|
@ -110,7 +111,7 @@ public class HostingDotComVCloudComputeClientLiveTest {
|
||||||
return serverName;
|
return serverName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = "testPowerOn")
|
@Test(dependsOnMethods = "testPowerOn", enabled = true)
|
||||||
public void testGetAnyPrivateAddress() {
|
public void testGetAnyPrivateAddress() {
|
||||||
privateAddress = client.getAnyPrivateAddress(id);
|
privateAddress = client.getAnyPrivateAddress(id);
|
||||||
assert !addressTester.apply(privateAddress);
|
assert !addressTester.apply(privateAddress);
|
||||||
|
@ -150,7 +151,7 @@ public class HostingDotComVCloudComputeClientLiveTest {
|
||||||
new HostingDotComVCloudPropertiesBuilder(account, key).relaxSSLHostname().build())
|
new HostingDotComVCloudPropertiesBuilder(account, key).relaxSSLHostname().build())
|
||||||
.withModules(new Log4JLoggingModule(), new JschSshClientModule()).buildInjector();
|
.withModules(new Log4JLoggingModule(), new JschSshClientModule()).buildInjector();
|
||||||
client = injector.getInstance(HostingDotComVCloudComputeClient.class);
|
client = injector.getInstance(HostingDotComVCloudComputeClient.class);
|
||||||
tmClient = injector.getInstance(HostingDotComVCloudClient.class);
|
hostingClient = injector.getInstance(HostingDotComVCloudClient.class);
|
||||||
addressTester = injector.getInstance(Key.get(new TypeLiteral<Predicate<InetAddress>>() {
|
addressTester = injector.getInstance(Key.get(new TypeLiteral<Predicate<InetAddress>>() {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class ParseTaskFromLocationHeader implements Function<HttpResponse, Task>
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
String taskId = location.substring(location.lastIndexOf('/') + 1);
|
String taskId = location.substring(location.lastIndexOf('/') + 1);
|
||||||
return new TaskImpl(taskId, URI.create(location), TaskStatus.QUEUED, new Date(), null,
|
return new TaskImpl(taskId, URI.create(location), TaskStatus.QUEUED, new Date(), null,
|
||||||
null, null, null);
|
null, null, null, null);
|
||||||
} else {
|
} else {
|
||||||
throw new HttpResponseException("no uri in headers or content", null, from);
|
throw new HttpResponseException("no uri in headers or content", null, from);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue