mirror of https://github.com/apache/jclouds.git
Merge pull request #507 from grkvlt/vapp-test-fixes
Issue 830: VApp test fixes
This commit is contained in:
commit
32cb85968d
|
@ -0,0 +1,379 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.domain.query;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents the results from a Media vCloud query as a record.
|
||||
*
|
||||
* @author Aled Sage
|
||||
*/
|
||||
public class QueryResultMediaRecord extends QueryResultRecordType {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder<?> toBuilder() {
|
||||
return builder().fromQueryResultMediaRecord(this);
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
}
|
||||
|
||||
public static class Builder<B extends Builder<B>> extends QueryResultRecordType.Builder<B> {
|
||||
|
||||
private String ownerName;
|
||||
private String catalogName;
|
||||
private Boolean isPublished;
|
||||
private String name;
|
||||
private String vdc;
|
||||
private String vdcName;
|
||||
private String org;
|
||||
private Date creationDate;
|
||||
private Boolean isBusy;
|
||||
private Long storageB;
|
||||
private String owner;
|
||||
private String catalog;
|
||||
private String catalogItem;
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* @see QueryResultMediaRecord#getOwnerName()
|
||||
*/
|
||||
public B ownerName(String val) {
|
||||
this.ownerName = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultMediaRecord#getCatalogName()
|
||||
*/
|
||||
public B catalogName(String val) {
|
||||
this.catalogName = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultMediaRecord#isPublished()
|
||||
*/
|
||||
public B isPublished(Boolean val) {
|
||||
this.isPublished = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultMediaRecord#getName()
|
||||
*/
|
||||
public B name(String val) {
|
||||
this.name = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultMediaRecord#getVdc()
|
||||
*/
|
||||
public B vdc(String val) {
|
||||
this.vdc = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultMediaRecord#getVdcName()
|
||||
*/
|
||||
public B vdcName(String val) {
|
||||
this.vdcName = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultMediaRecord#getOrg()
|
||||
*/
|
||||
public B org(String val) {
|
||||
this.org = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultMediaRecord#getCreationDate()
|
||||
*/
|
||||
public B creationDate(Date val) {
|
||||
this.creationDate = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultMediaRecord#isBusy()
|
||||
*/
|
||||
public B isBusy(Boolean val) {
|
||||
this.isBusy = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultMediaRecord#getStorageB()
|
||||
*/
|
||||
public B storageB(Long val) {
|
||||
this.storageB = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultMediaRecord#getOwner()
|
||||
*/
|
||||
public B owner(String val) {
|
||||
this.owner = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultMediaRecord#getCatalog()
|
||||
*/
|
||||
public B catalog(String val) {
|
||||
this.catalog = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultMediaRecord#getCatalogItem()
|
||||
*/
|
||||
public B catalogItem(String val) {
|
||||
this.catalogItem = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see QueryResultMediaRecord#getStatus()
|
||||
*/
|
||||
public B status(String val) {
|
||||
this.status = val;
|
||||
return self();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryResultMediaRecord build() {
|
||||
return new QueryResultMediaRecord(this);
|
||||
}
|
||||
|
||||
public B fromQueryResultMediaRecord(QueryResultMediaRecord in) {
|
||||
return fromQueryResultRecordType(in)
|
||||
.ownerName(in.getOwnerName())
|
||||
.catalogName(in.getCatalogName())
|
||||
.isPublished(in.isPublished())
|
||||
.name(in.getName())
|
||||
.vdc(in.getVdc())
|
||||
.vdcName(in.getVdcName())
|
||||
.org(in.getOrg())
|
||||
.creationDate(in.getCreationDate())
|
||||
.isBusy(in.isBusy())
|
||||
.storageB(in.getStorageB())
|
||||
.owner(in.getOwner())
|
||||
.catalog(in.getCatalog())
|
||||
.catalogItem(in.getCatalogItem())
|
||||
.status(in.getStatus());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
private String ownerName;
|
||||
@XmlAttribute
|
||||
private String catalogName;
|
||||
@XmlAttribute
|
||||
private Boolean isPublished;
|
||||
@XmlAttribute
|
||||
private String name;
|
||||
@XmlAttribute
|
||||
private String vdc;
|
||||
@XmlAttribute
|
||||
private String vdcName;
|
||||
@XmlAttribute
|
||||
private String org;
|
||||
@XmlAttribute
|
||||
private Date creationDate;
|
||||
@XmlAttribute
|
||||
private Boolean isBusy;
|
||||
@XmlAttribute
|
||||
private Long storageB;
|
||||
@XmlAttribute
|
||||
private String owner;
|
||||
@XmlAttribute
|
||||
private String catalog;
|
||||
@XmlAttribute
|
||||
private String catalogItem;
|
||||
@XmlAttribute
|
||||
private String status;
|
||||
|
||||
protected QueryResultMediaRecord(Builder<?> builder) {
|
||||
super(builder);
|
||||
this.ownerName = builder.ownerName;
|
||||
this.catalogName = builder.catalogName;
|
||||
this.isPublished = builder.isPublished;
|
||||
this.name = builder.name;
|
||||
this.vdc = builder.vdc;
|
||||
this.vdcName = builder.vdcName;
|
||||
this.org = builder.org;
|
||||
this.creationDate = builder.creationDate;
|
||||
this.isBusy = builder.isBusy;
|
||||
this.storageB = builder.storageB;
|
||||
this.owner = builder.owner;
|
||||
this.catalog = builder.catalog;
|
||||
this.catalogItem = builder.catalogItem;
|
||||
this.status = builder.status;
|
||||
}
|
||||
|
||||
protected QueryResultMediaRecord() {
|
||||
// for JAXB
|
||||
}
|
||||
|
||||
/**
|
||||
* Owner name
|
||||
*/
|
||||
public String getOwnerName() {
|
||||
return ownerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Catalog name
|
||||
*/
|
||||
public String getCatalogName() {
|
||||
return catalogName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows whether it is in published catalog
|
||||
*/
|
||||
public Boolean isPublished() {
|
||||
return isPublished;
|
||||
}
|
||||
|
||||
/**
|
||||
* Media name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* vDC reference or id
|
||||
*/
|
||||
public String getVdc() {
|
||||
return vdc;
|
||||
}
|
||||
|
||||
/**
|
||||
* vDC name
|
||||
*/
|
||||
public String getVdcName() {
|
||||
return vdcName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Organization reference or id
|
||||
*/
|
||||
public String getOrg() {
|
||||
return org;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creation date
|
||||
*/
|
||||
public Date getCreationDate() {
|
||||
return creationDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows whether it is busy
|
||||
*/
|
||||
public Boolean isBusy() {
|
||||
return isBusy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Media storage in Bytes
|
||||
*/
|
||||
public Long getStorageB() {
|
||||
return storageB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Owner reference or id
|
||||
*/
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Catalog reference or id
|
||||
*/
|
||||
public String getCatalog() {
|
||||
return catalog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Catalog item reference or id
|
||||
*/
|
||||
public String getCatalogItem() {
|
||||
return catalogItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Media status
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
QueryResultMediaRecord that = QueryResultMediaRecord.class.cast(o);
|
||||
|
||||
return super.equals(that) && equal(ownerName, that.ownerName) && equal(catalogName, that.catalogName)
|
||||
&& equal(isPublished, that.isPublished) && equal(name, that.name) && equal(vdc, that.vdc)
|
||||
&& equal(vdcName, that.vdcName) && equal(org, that.org) && equal(creationDate, that.creationDate)
|
||||
&& equal(isBusy, that.isBusy) && equal(storageB, that.storageB) && equal(owner, that.owner)
|
||||
&& equal(catalog, that.catalog) && equal(catalogItem, that.catalogItem) && equal(status, that.status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), ownerName, catalogName, isPublished, name, vdc, vdcName, org,
|
||||
creationDate, isBusy, storageB, owner, catalog, catalogItem, status);
|
||||
}
|
||||
@Override
|
||||
public ToStringHelper string() {
|
||||
return super.string().add("ownerName", ownerName).add("catalogName", catalogName)
|
||||
.add("isPublished", isPublished).add("name", name).add("vdc", vdc).add("vdcName", vdcName)
|
||||
.add("org", org).add("creationDate", creationDate).add("isBusy", isBusy).add("storageB", storageB)
|
||||
.add("owner", owner).add("catalog", catalog).add("catalogItem", catalogItem).add("status", status);
|
||||
}
|
||||
}
|
|
@ -54,7 +54,8 @@ import com.google.common.collect.Sets;
|
|||
QueryResultAdminGroupRecord.class,
|
||||
QueryResultAdminVdcRecord.class,
|
||||
QueryResultAdminUserRecord.class,
|
||||
QueryResultStrandedUserRecord.class}
|
||||
QueryResultStrandedUserRecord.class,
|
||||
QueryResultMediaRecord.class}
|
||||
)
|
||||
public class QueryResultRecordType {
|
||||
|
||||
|
|
|
@ -18,18 +18,25 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.features;
|
||||
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType.CONTROL_ACCESS;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
import org.jclouds.rest.annotations.JAXBResponseParser;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||
import org.jclouds.rest.binders.BindToXMLPayload;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Org;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
||||
|
@ -61,6 +68,28 @@ public interface OrgAsyncClient {
|
|||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<? extends Org> getOrg(@EndpointParam URI orgUri);
|
||||
|
||||
/**
|
||||
* @see OrgClient#modifyControlAccess(URI, URI, ControlAccessParams)
|
||||
*/
|
||||
@POST
|
||||
@Path("/catalog/{catalogId}/action/controlAccess")
|
||||
@Produces(CONTROL_ACCESS)
|
||||
@Consumes(CONTROL_ACCESS)
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<ControlAccessParams> modifyControlAccess(@EndpointParam URI orgURI, @PathParam("catalogId") String catalogId,
|
||||
@BinderParam(BindToXMLPayload.class) ControlAccessParams params);
|
||||
|
||||
/**
|
||||
* @see OrgClient#getControlAccess(URI, URI, ControlAccessParams)
|
||||
*/
|
||||
@POST
|
||||
@Path("/catalog/{catalogId}/controlAccess")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<ControlAccessParams> getControlAccess(@EndpointParam URI orgURI, @PathParam("catalogId") String catalogId);
|
||||
|
||||
/**
|
||||
* @return asynchronous access to {@link Metadata.Readable} features
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Org;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||
|
||||
|
@ -58,6 +58,28 @@ public interface OrgClient {
|
|||
* @return the org or null if not found
|
||||
*/
|
||||
Org getOrg(URI orgRef);
|
||||
|
||||
/**
|
||||
* Modifies a catalog control access.
|
||||
*
|
||||
* <pre>
|
||||
* POST /org/{id}/catalog/{catalogId}/action/controlAccess
|
||||
* </pre>
|
||||
*
|
||||
* @return the control access information
|
||||
*/
|
||||
ControlAccessParams modifyControlAccess(URI orgRef, String catalogId, ControlAccessParams params);
|
||||
|
||||
/**
|
||||
* Retrieves the catalog control access information.
|
||||
*
|
||||
* <pre>
|
||||
* GET /org/{id}/catalog/{catalogId}/controlAccess
|
||||
* </pre>
|
||||
*
|
||||
* @return the control access information
|
||||
*/
|
||||
ControlAccessParams getControlAccess(URI orgRef, String catalogId);
|
||||
|
||||
/**
|
||||
* @return synchronous access to {@link Metadata.Readable} features
|
||||
|
|
|
@ -25,6 +25,7 @@ import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadata;
|
|||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataValue;
|
||||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkOrg;
|
||||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkReferenceType;
|
||||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.*;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
@ -32,6 +33,7 @@ import static org.testng.Assert.assertNotNull;
|
|||
import java.net.URI;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ControlAccessParams;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Org;
|
||||
|
@ -142,4 +144,19 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
checkMetadataValue(value);
|
||||
assertEquals(value.getValue(), expected, String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", expected, value.getValue()));
|
||||
}
|
||||
|
||||
@Test(testName = "GET /org/{id}/catalog/{catalogId}/controlAccess")
|
||||
public void testGetontrolAccess() {
|
||||
String catalogId = "";
|
||||
ControlAccessParams params = orgClient.getControlAccess(orgURI, catalogId);
|
||||
checkControlAccessParams(params);
|
||||
}
|
||||
|
||||
@Test(testName = "GET /org/{id}/catalog/{catalogId}/action/controlAccess", dependsOnMethods = { "testGetontrolAccess" })
|
||||
public void testModifyControlAccess() {
|
||||
String catalogId = "";
|
||||
ControlAccessParams params = orgClient.getControlAccess(orgURI, catalogId);
|
||||
ControlAccessParams modified = orgClient.modifyControlAccess(orgURI, catalogId, params);
|
||||
checkControlAccessParams(modified);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.jclouds.vcloud.director.v1_5.domain.VApp;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Vm;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultMediaRecord;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecordType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultVAppRecord;
|
||||
|
@ -121,7 +122,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
Set<URI> hrefs = toHrefs(queryResult);
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP_TEMPLATE, null), QueryResultVAppTemplateRecord.class);
|
||||
assertEquals(hrefs, Collections.singleton(vAppTemplateURI), "VAppTemplates query result should have found vAppTemplate "+vAppTemplateURI);
|
||||
assertTrue(hrefs.contains(vAppTemplateURI), "VAppTemplates query result should have found vAppTemplate "+vAppTemplateURI);
|
||||
}
|
||||
|
||||
@Test(testName = "GET /vApps/query")
|
||||
|
@ -180,6 +181,21 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
assertEquals(hrefs, vmHrefs, "VMs query result should equal vms of vApp "+vApp.getName()+" ("+vmHrefs+"); but only has "+hrefs);
|
||||
}
|
||||
|
||||
@Test(testName = "GET /mediaList/query")
|
||||
public void testQueryAllMedia() {
|
||||
QueryResultRecords queryResult = queryClient.mediaListQueryAll();
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultMediaRecord.class);
|
||||
}
|
||||
|
||||
@Test(testName = "GET /mediaList/query?filter")
|
||||
public void testQueryMediaWithFilter() {
|
||||
String mediaName = "abc";
|
||||
QueryResultRecords queryResult = queryClient.mediaListQuery(String.format("name==%s", mediaName));
|
||||
|
||||
assertRecordTypes(queryResult, Arrays.asList(VCloudDirectorMediaType.VAPP, null), QueryResultMediaRecord.class);
|
||||
}
|
||||
|
||||
private static void assertRecordTypes(QueryResultRecords queryResult, Collection<String> validTypes, Class<?> validClazz) {
|
||||
for (QueryResultRecordType record : queryResult.getRecords()) {
|
||||
assertTrue(validTypes.contains(record.getType()), "invalid type for query result record, "+record.getType()+"; valid types are "+validTypes);
|
||||
|
|
|
@ -484,7 +484,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
|
|||
// Copy existing section and update fields
|
||||
GuestCustomizationSection oldSection = vAppClient.getGuestCustomizationSection(vm.getHref());
|
||||
GuestCustomizationSection newSection = oldSection.toBuilder()
|
||||
.computerName("newComputerName")
|
||||
.computerName(name("n"))
|
||||
.enabled(Boolean.FALSE)
|
||||
.adminPassword(null) // Not allowed
|
||||
.build();
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.NetworkConfigSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.NetworkConnection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.NetworkConnectionSection;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Owner;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ProductSectionList;
|
||||
|
@ -60,6 +61,7 @@ import org.jclouds.vcloud.director.v1_5.domain.References;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.RelocateParams;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.NetworkConnection.IpAddressAllocationMode;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.Envelope;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -280,9 +282,9 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
|
|||
|
||||
@Test(testName = "PUT /vAppTemplate/{id}/guestCustomizationSection")
|
||||
public void testEditGuestCustomizationSection() {
|
||||
String computerName = name("server-");
|
||||
String computerName = name("n");
|
||||
GuestCustomizationSection newSection = GuestCustomizationSection.builder()
|
||||
.info("my info")
|
||||
.info("")
|
||||
.computerName(computerName)
|
||||
.build();
|
||||
|
||||
|
@ -301,7 +303,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
|
|||
boolean newVal = !oldVal;
|
||||
|
||||
CustomizationSection customizationSection = CustomizationSection.builder()
|
||||
.info("my info")
|
||||
.info("")
|
||||
.customizeOnInstantiate(newVal)
|
||||
.build();
|
||||
|
||||
|
@ -368,13 +370,20 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
|
|||
|
||||
@Test(testName = "PUT /vAppTemplate/{id}/networkConnectionSection")
|
||||
public void testEditNetworkConnectionSection() {
|
||||
// TODO Modify a field so can assert that the change really took effect
|
||||
|
||||
NetworkConnectionSection oldSection = vAppTemplateClient.getVAppTemplateNetworkConnectionSection(vm.getHref());
|
||||
// Look up a network in the Vdc
|
||||
Set<Reference> networks = vdc.getAvailableNetworks().getNetworks();
|
||||
Reference network = Iterables.getLast(networks);
|
||||
|
||||
// Copy existing section and update fields
|
||||
NetworkConnectionSection oldSection = vAppClient.getNetworkConnectionSection(vm.getHref());
|
||||
NetworkConnectionSection newSection = oldSection.toBuilder()
|
||||
.build();
|
||||
.networkConnection(NetworkConnection.builder()
|
||||
.ipAddressAllocationMode(IpAddressAllocationMode.DHCP.toString())
|
||||
.network(network.getName())
|
||||
.build())
|
||||
.build();
|
||||
|
||||
final Task task = vAppTemplateClient.editVAppTemplateNetworkConnectionSection(vm.getHref(), newSection);
|
||||
Task task = vAppTemplateClient.editVAppTemplateNetworkConnectionSection(vm.getHref(), newSection);
|
||||
assertTaskSucceeds(task);
|
||||
|
||||
NetworkConnectionSection modified = vAppTemplateClient.getVAppTemplateNetworkConnectionSection(vm.getHref());
|
||||
|
@ -445,11 +454,10 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
|
|||
|
||||
@Test(testName = "POST /vAppTemplate/{id}/action/consolidate")
|
||||
public void testConsolidateVAppTemplate() throws Exception {
|
||||
// TODO Need assertion that command had effect
|
||||
|
||||
System.out.println("About to try to consolidate "+vm);
|
||||
final Task task = vAppTemplateClient.consolidateVappTemplate(vm.getHref());
|
||||
assertTaskSucceedsLong(task);
|
||||
|
||||
// TODO Need assertion that command had effect
|
||||
}
|
||||
|
||||
@Test(testName = "POST /vAppTemplate/{id}/action/relocate") // FIXME Need a datastore reference
|
||||
|
@ -478,18 +486,16 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
|
|||
// Kick off a task, and wait for it to complete
|
||||
vAppTemplateClient.disableDownloadVappTemplate(vAppTemplateURI);
|
||||
final Task task = vAppTemplateClient.enableDownloadVappTemplate(vAppTemplateURI);
|
||||
retryTaskSuccess.apply(task);
|
||||
assertTaskDoneEventually(task);
|
||||
|
||||
// Ask the VAppTemplate for its tasks, and the status of the matching task if it exists
|
||||
VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
|
||||
Set<Task> tasks = vAppTemplate.getTasks();
|
||||
if (tasks != null) {
|
||||
for (Task contender : tasks) {
|
||||
if (task.getId().equals(contender.getId())) {
|
||||
String status = contender.getStatus();
|
||||
if (status.equals(Task.Status.QUEUED) || status.equals(Task.Status.PRE_RUNNING) || status.equals(Task.Status.RUNNING)) {
|
||||
fail("Task "+contender+" reported complete, but is included in VAppTemplate in status "+status);
|
||||
}
|
||||
for (Task contender : tasks) {
|
||||
if (task.getId().equals(contender.getId())) {
|
||||
String status = contender.getStatus();
|
||||
if (status.equals(Task.Status.QUEUED) || status.equals(Task.Status.PRE_RUNNING) || status.equals(Task.Status.RUNNING)) {
|
||||
fail("Task "+contender+" reported complete, but is included in VAppTemplate in status "+status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue