mirror of https://github.com/apache/jclouds.git
get/put vAppLeaseSettings
This commit is contained in:
parent
a05d76fabf
commit
d4843a5c31
|
@ -137,6 +137,8 @@ public class VCloudDirectorMediaType {
|
|||
|
||||
public static final String ORG_VAPP_TEMPLATE_LEASE_SETTINGS = "application/vnd.vmware.admin.vAppTemplateLeaseSettings+xml";
|
||||
|
||||
public static final String ORG_LEASE_SETTINGS = "application/vnd.vmware.admin.vAppLeaseSettings+xml";
|
||||
|
||||
/**
|
||||
*
|
||||
* All acceptable media types.
|
||||
|
@ -155,8 +157,7 @@ public class VCloudDirectorMediaType {
|
|||
CONTROL_ACCESS, VAPP_TEMPLATE, CUSTOMIZATION_SECTION, GUEST_CUSTOMIZATION_SECTION,
|
||||
NETWORK_SECTION, NETWORK_CONFIG_SECTION, NETWORK_CONNECTION_SECTION,
|
||||
CLONE_MEDIA_PARAMS, LEASE_SETTINGS_SECTION, RELOCATE_TEMPLATE, ENVELOPE,
|
||||
PUBLISH_CATALOG_PARAMS, GROUP, ORG_VAPP_TEMPLATE_LEASE_SETTINGS
|
||||
PUBLISH_CATALOG_PARAMS, GROUP, ORG_VAPP_TEMPLATE_LEASE_SETTINGS,
|
||||
ORG_LEASE_SETTINGS
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.Set;
|
|||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
@ -60,7 +61,8 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "OrgLeaseSettings", propOrder = {
|
||||
@XmlRootElement(name = "VAppLeaseSettings")
|
||||
@XmlType(propOrder = {
|
||||
"deleteOnStorageLeaseExpiration",
|
||||
"deploymentLeaseSeconds",
|
||||
"storageLeaseSeconds"
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.jclouds.rest.annotations.JAXBResponseParser;
|
|||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.binders.BindToXMLPayload;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
|
||||
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
|
||||
|
@ -70,6 +71,30 @@ public interface AdminOrgAsyncClient extends OrgAsyncClient {
|
|||
|
||||
// PUT /admin/org/{id}/settings/passwordPolicy
|
||||
|
||||
/**
|
||||
* @see AdminOrgClient#getVAppLeaseSettings(URI)
|
||||
*/
|
||||
@GET
|
||||
@Path("/settings/vAppLeaseSettings")
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<OrgLeaseSettings> getVAppLeaseSettings(
|
||||
@EndpointParam URI orgRef);
|
||||
|
||||
/**
|
||||
* @see AdminOrgClient#updateVAppLeaseSettings(URI, OrgVAppLeaseSettings)
|
||||
*/
|
||||
@PUT
|
||||
@Path("/settings/vAppLeaseSettings")
|
||||
@Consumes(VCloudDirectorMediaType.ORG_LEASE_SETTINGS)
|
||||
@Produces(VCloudDirectorMediaType.ORG_LEASE_SETTINGS)
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<OrgLeaseSettings> updateVAppLeaseSettings(
|
||||
@EndpointParam URI orgRef,
|
||||
@BinderParam(BindToXMLPayload.class) OrgLeaseSettings group);
|
||||
|
||||
/**
|
||||
* @see AdminOrgClient#getVAppTemplateLeaseSettings(URI)
|
||||
*/
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Group;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
|
||||
|
||||
/**
|
||||
|
@ -58,9 +59,30 @@ public interface AdminOrgClient extends OrgClient {
|
|||
|
||||
// PUT /admin/org/{id}/settings/passwordPolicy
|
||||
|
||||
// GET /admin/org/{id}/settings/vAppLeaseSettings
|
||||
/**
|
||||
* Gets organization resource cleanup settings on the level of vApp.
|
||||
*
|
||||
* <pre>
|
||||
* GET /admin/org/{id}/settings/vAppLeaseSettings
|
||||
* </pre>
|
||||
*
|
||||
* @param orgRef the reference for the admin org
|
||||
* @return the lease settings
|
||||
*/
|
||||
OrgLeaseSettings getVAppLeaseSettings(URI orgRef);
|
||||
|
||||
// PUT /admin/org/{id}/settings/vAppLeaseSettings
|
||||
/**
|
||||
* Updates organization resource cleanup settings on the level of vApp.
|
||||
*
|
||||
* <pre>
|
||||
* PUT /admin/org/{id}/settings/vAppLeaseSettings
|
||||
* </pre>
|
||||
* @param orgRef the reference for the admin org
|
||||
* @param newSettings the requested updated settings
|
||||
* @return the resultant settings
|
||||
*/
|
||||
OrgLeaseSettings updateVAppLeaseSettings(URI orgRef,
|
||||
OrgLeaseSettings newSettings);
|
||||
|
||||
/**
|
||||
* Retrieves expiration and storage policy for vApp templates in an organization.
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.net.URI;
|
|||
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
|
||||
|
@ -67,9 +68,53 @@ public class AdminOrgClientExpectTest extends BaseVCloudDirectorRestClientExpect
|
|||
|
||||
// PUT /admin/org/{id}/settings/passwordPolicy
|
||||
|
||||
// GET /admin/org/{id}/settings/vAppLeaseSettings
|
||||
@Test(enabled = false)
|
||||
public void testGetVAppLeaseSettings() {
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("GET", "/admin/org/???/settings/vAppLeaseSettings")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.xmlFilePayload("/org/admin/vAppLeaseSettings.xml",
|
||||
VCloudDirectorMediaType.ORG_LEASE_SETTINGS)
|
||||
.httpResponseBuilder().build());
|
||||
|
||||
// PUT /admin/org/{id}/settings/vAppLeaseSettings
|
||||
OrgLeaseSettings expected = orgVAppLeaseSettings();
|
||||
|
||||
assertEquals(client.getAdminOrgClient().getVAppLeaseSettings(orgRef.getURI()), expected);
|
||||
}
|
||||
|
||||
public static final OrgLeaseSettings orgVAppLeaseSettings() {
|
||||
return OrgLeaseSettings.builder()
|
||||
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testUpdateOrgVAppLeaseSettings() {
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("PUT", "/admin/org/???/settings/vAppLeaseSettings")
|
||||
.xmlFilePayload("/org/admin/updateVAppLeaseSettingsSource.xml",
|
||||
VCloudDirectorMediaType.ORG_LEASE_SETTINGS)
|
||||
.acceptMedia(VCloudDirectorMediaType.ORG_LEASE_SETTINGS)
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.xmlFilePayload("/org/admin/updateVAppLeaseSettings.xml",
|
||||
VCloudDirectorMediaType.ORG_LEASE_SETTINGS)
|
||||
.httpResponseBuilder().build());
|
||||
|
||||
OrgLeaseSettings expected = updateOrgVAppLeaseSettings();
|
||||
|
||||
assertEquals(client.getAdminOrgClient().updateVAppLeaseSettings(orgRef.getURI(), expected), expected);
|
||||
}
|
||||
|
||||
public static final OrgLeaseSettings updateOrgVAppLeaseSettings() {
|
||||
return orgVAppLeaseSettings().toBuilder()
|
||||
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testGetVAppTemplateLeaseSettings() {
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.jclouds.vcloud.director.v1_5.domain.AdminOrg;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Group;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgLeaseSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgVAppTemplateLeaseSettings;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||
|
@ -54,6 +55,7 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
private ReferenceType<?> orgRef;
|
||||
private AdminOrg org;
|
||||
OrgVAppTemplateLeaseSettings vAppTemplateLeaseSettings;
|
||||
OrgLeaseSettings vAppLeaseSettings;
|
||||
|
||||
@Override
|
||||
@BeforeClass(inheritGroups = true)
|
||||
|
@ -87,9 +89,54 @@ public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
// PUT /admin/org/{id}/settings/passwordPolicy
|
||||
|
||||
// GET /admin/org/{id}/settings/vAppLeaseSettings
|
||||
@Test(testName = "GET /admin/org/{id}/settings/vAppLeaseSettings")
|
||||
public void testGetVAppLeaseSettings() {
|
||||
vAppLeaseSettings = orgClient.getVAppLeaseSettings(orgRef.getURI());
|
||||
|
||||
// PUT /admin/org/{id}/settings/vAppLeaseSettings
|
||||
Checks.checkVAppLeaseSettings(vAppLeaseSettings);
|
||||
}
|
||||
|
||||
@Test(testName = "PUT /admin/org/{id}/settings/vAppLeaseSettings",
|
||||
dependsOnMethods = { "testGetVAppLeaseSettings" }, enabled = false) // FIXME: fails with 403 forbidden
|
||||
public void testUpdateVAppLeaseSettings() {
|
||||
boolean deleteOnStorageLeaseExpiration = vAppLeaseSettings.deleteOnStorageLeaseExpiration();
|
||||
Integer storageLeaseSeconds = vAppLeaseSettings.getStorageLeaseSeconds();
|
||||
Integer deploymentLeaseSeconds = vAppLeaseSettings.getDeploymentLeaseSeconds();
|
||||
|
||||
try {
|
||||
vAppLeaseSettings = vAppLeaseSettings.toBuilder()
|
||||
.deleteOnStorageLeaseExpiration(!deleteOnStorageLeaseExpiration)
|
||||
.storageLeaseSeconds(storageLeaseSeconds+1)
|
||||
.deploymentLeaseSeconds(deploymentLeaseSeconds+1)
|
||||
.build();
|
||||
|
||||
vAppLeaseSettings = orgClient.updateVAppLeaseSettings(
|
||||
orgRef.getURI(), vAppLeaseSettings);
|
||||
|
||||
assertTrue(equal(vAppLeaseSettings.deleteOnStorageLeaseExpiration(), !deleteOnStorageLeaseExpiration),
|
||||
String.format(OBJ_FIELD_UPDATABLE,
|
||||
"vAppLeaseSettings", "deleteOnStorageLeaseExpiration"));
|
||||
assertTrue(equal(vAppLeaseSettings.getStorageLeaseSeconds(), storageLeaseSeconds+1),
|
||||
String.format(OBJ_FIELD_UPDATABLE,
|
||||
"vAppLeaseSettings", "storageLeaseSeconds"));
|
||||
assertTrue(equal(vAppLeaseSettings.getDeploymentLeaseSeconds(), deploymentLeaseSeconds+1),
|
||||
String.format(OBJ_FIELD_UPDATABLE,
|
||||
"vAppLeaseSettings", "deploymentLeaseSeconds"));
|
||||
|
||||
//TODO negative tests?
|
||||
|
||||
Checks.checkVAppLeaseSettings(vAppLeaseSettings);
|
||||
} finally {
|
||||
vAppLeaseSettings = vAppLeaseSettings.toBuilder()
|
||||
.deleteOnStorageLeaseExpiration(deleteOnStorageLeaseExpiration)
|
||||
.storageLeaseSeconds(storageLeaseSeconds)
|
||||
.deploymentLeaseSeconds(deploymentLeaseSeconds)
|
||||
.build();
|
||||
|
||||
vAppLeaseSettings = orgClient.updateVAppLeaseSettings(
|
||||
orgRef.getURI(), vAppLeaseSettings);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(testName = "GET /admin/org/{id}/settings/vAppTemplateLeaseSettings")
|
||||
public void testGetVAppTemplateLeaseSettings() {
|
||||
|
|
Loading…
Reference in New Issue