mirror of https://github.com/apache/jclouds.git
Merge pull request #539 from danikov/vcloud-director-admin-refactor3
Issue 830: vCloud director Admin Refactor
This commit is contained in:
commit
83b72d483a
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5;
|
||||||
|
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.ENTITY_NON_NULL;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.ENTITY_NON_NULL;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
|
||||||
|
@ -49,6 +49,13 @@ import org.jclouds.vcloud.director.v1_5.domain.cim.CimString;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.cim.CimUnsignedInt;
|
import org.jclouds.vcloud.director.v1_5.domain.cim.CimUnsignedInt;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.cim.CimUnsignedLong;
|
import org.jclouds.vcloud.director.v1_5.domain.cim.CimUnsignedLong;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData;
|
import org.jclouds.vcloud.director.v1_5.domain.cim.ResourceAllocationSettingData;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.CatalogClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.MetadataClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.QueryClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.VAppClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.VAppTemplateClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.VdcClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.MetadataClient.Writeable;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
import org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates;
|
import org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates;
|
||||||
import org.jclouds.xml.internal.JAXBParser;
|
import org.jclouds.xml.internal.JAXBParser;
|
|
@ -87,29 +87,33 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
if (adminCatalog != null) return;
|
if (adminCatalog != null) return;
|
||||||
catalogClient = context.getApi().getCatalogClient();
|
catalogClient = context.getApi().getCatalogClient();
|
||||||
Reference orgRef = Iterables.getFirst(context.getApi().getOrgClient().getOrgList().getOrgs(), null).toAdminReference(endpoint);
|
Reference orgRef = Iterables.getFirst(context.getApi().getOrgClient().getOrgList().getOrgs(), null).toAdminReference(endpoint);
|
||||||
|
|
||||||
AdminCatalog newCatalog = AdminCatalog.builder()
|
|
||||||
.name(name("Test Catalog "))
|
|
||||||
.description("created by CatalogClientLiveTest")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
AdminCatalogClient adminCatalogClient = adminContext.getApi().getCatalogClient();
|
if (adminContext != null) {
|
||||||
adminCatalog = adminCatalogClient.createCatalog(orgRef.getHref(), newCatalog);
|
AdminCatalog newCatalog = AdminCatalog.builder()
|
||||||
catalogRef = find(adminCatalog.getLinks(), and(relEquals("alternate"), typeEquals(VCloudDirectorMediaType.CATALOG)));
|
.name(name("Test Catalog "))
|
||||||
|
.description("created by CatalogClientLiveTest")
|
||||||
Metadata newMetadata = Metadata.builder()
|
.build();
|
||||||
.entry(MetadataEntry.builder().entry("KEY", "MARMALADE").build())
|
|
||||||
.build();
|
AdminCatalogClient adminCatalogClient = adminContext.getApi().getCatalogClient();
|
||||||
|
adminCatalog = adminCatalogClient.createCatalog(orgRef.getHref(), newCatalog);
|
||||||
Task mergeCatalogMetadata = adminCatalogClient.getMetadataClient().mergeMetadata(adminCatalog.getHref(), newMetadata);
|
catalogRef = find(adminCatalog.getLinks(), and(relEquals("alternate"), typeEquals(VCloudDirectorMediaType.CATALOG)));
|
||||||
checkTask(mergeCatalogMetadata);
|
|
||||||
assertTrue(retryTaskSuccess.apply(mergeCatalogMetadata), String.format(TASK_COMPLETE_TIMELY, "setupRequiredClients"));
|
Metadata newMetadata = Metadata.builder()
|
||||||
|
.entry(MetadataEntry.builder().entry("KEY", "MARMALADE").build())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Task mergeCatalogMetadata = adminCatalogClient.getMetadataClient().mergeMetadata(adminCatalog.getHref(), newMetadata);
|
||||||
|
checkTask(mergeCatalogMetadata);
|
||||||
|
assertTrue(retryTaskSuccess.apply(mergeCatalogMetadata), String.format(TASK_COMPLETE_TIMELY, "setupRequiredClients"));
|
||||||
|
} else {
|
||||||
|
catalogRef = Reference.builder().href(catalogURI).build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
@AfterClass(alwaysRun = true)
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
if (catalogItem != null)
|
if (catalogItem != null)
|
||||||
catalogClient.deleteCatalogItem(catalogItem.getHref());
|
catalogClient.deleteCatalogItem(catalogItem.getHref());
|
||||||
|
|
||||||
if (media != null)
|
if (media != null)
|
||||||
context.getApi().getMediaClient().deleteMedia(media.getHref());
|
context.getApi().getMediaClient().deleteMedia(media.getHref());
|
||||||
|
|
|
@ -65,6 +65,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
|
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -87,14 +88,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
*/
|
*/
|
||||||
protected VdcClient vdcClient;
|
protected VdcClient vdcClient;
|
||||||
protected MediaClient mediaClient;
|
protected MediaClient mediaClient;
|
||||||
|
|
||||||
@Override
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void setupRequiredClients() {
|
|
||||||
vdcClient = context.getApi().getVdcClient();
|
|
||||||
mediaClient = context.getApi().getMediaClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shared state between dependent tests.
|
* Shared state between dependent tests.
|
||||||
*/
|
*/
|
||||||
|
@ -103,6 +97,23 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
private Metadata metadata;
|
private Metadata metadata;
|
||||||
private MetadataValue metadataValue;
|
private MetadataValue metadataValue;
|
||||||
private String metadataEntryValue = "value";
|
private String metadataEntryValue = "value";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@BeforeClass(alwaysRun = true)
|
||||||
|
public void setupRequiredClients() {
|
||||||
|
vdcClient = context.getApi().getVdcClient();
|
||||||
|
mediaClient = context.getApi().getMediaClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass(alwaysRun = true)
|
||||||
|
protected void tidyUp() {
|
||||||
|
if (media != null) {
|
||||||
|
assertTaskSucceeds(mediaClient.deleteMedia(media.getHref()));
|
||||||
|
}
|
||||||
|
if (oldMedia != null) {
|
||||||
|
assertTaskSucceeds(mediaClient.deleteMedia(oldMedia.getHref()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test(description = "POST /vdc/{id}/media")
|
@Test(description = "POST /vdc/{id}/media")
|
||||||
public void testCreateMedia() throws URISyntaxException {
|
public void testCreateMedia() throws URISyntaxException {
|
||||||
|
@ -419,5 +430,8 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
deleteMedia = mediaClient.deleteMedia(oldMedia.getHref());
|
deleteMedia = mediaClient.deleteMedia(oldMedia.getHref());
|
||||||
Checks.checkTask(deleteMedia);
|
Checks.checkTask(deleteMedia);
|
||||||
|
assertTrue(retryTaskSuccess.apply(deleteMedia),
|
||||||
|
String.format(TASK_COMPLETE_TIMELY, "deleteMedia"));
|
||||||
|
oldMedia = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,19 +57,21 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
* Convenience reference to API client.
|
* Convenience reference to API client.
|
||||||
*/
|
*/
|
||||||
protected NetworkClient networkClient;
|
protected NetworkClient networkClient;
|
||||||
|
|
||||||
|
private boolean metadataSet = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeClass(alwaysRun = true)
|
@BeforeClass(alwaysRun = true)
|
||||||
public void setupRequiredClients() {
|
public void setupRequiredClients() {
|
||||||
networkClient = context.getApi().getNetworkClient();
|
networkClient = context.getApi().getNetworkClient();
|
||||||
adminContext.getApi().getNetworkClient().getMetadataClient().setMetadata(toAdminUri(networkURI),
|
|
||||||
"key", MetadataValue.builder().value("value").build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(groups = { "live" })
|
@AfterClass(alwaysRun = true)
|
||||||
public void cleanUp() throws Exception {
|
public void cleanUp() throws Exception {
|
||||||
adminContext.getApi().getNetworkClient().getMetadataClient()
|
if (metadataSet) {
|
||||||
.deleteMetadataEntry(toAdminUri(networkURI), "key");
|
adminContext.getApi().getNetworkClient().getMetadataClient()
|
||||||
|
.deleteMetadataEntry(toAdminUri(networkURI), "key");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "GET /network/{id}")
|
@Test(description = "GET /network/{id}")
|
||||||
|
@ -87,8 +89,18 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
Checks.checkOrgNetwork(network);
|
Checks.checkOrgNetwork(network);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "GET /network/{id}/metadata")
|
private void setupMetadata() {
|
||||||
|
adminContext.getApi().getNetworkClient().getMetadataClient().setMetadata(toAdminUri(networkURI),
|
||||||
|
"key", MetadataValue.builder().value("value").build());
|
||||||
|
metadataSet = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(description = "GET /network/{id}/metadata", dependsOnMethods = { "testGetNetwork" })
|
||||||
public void testGetMetadata() {
|
public void testGetMetadata() {
|
||||||
|
if (adminContext != null) {
|
||||||
|
setupMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
Metadata metadata = networkClient.getMetadataClient().getMetadata(networkURI);
|
Metadata metadata = networkClient.getMetadataClient().getMetadata(networkURI);
|
||||||
// required for testing
|
// required for testing
|
||||||
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()),
|
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()),
|
||||||
|
@ -109,7 +121,7 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "GET /network/{id}/metadata/{key}")
|
@Test(description = "GET /network/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadata" })
|
||||||
public void testGetMetadataValue() {
|
public void testGetMetadataValue() {
|
||||||
MetadataValue metadataValue = networkClient.getMetadataClient().getMetadataValue(networkURI, "key");
|
MetadataValue metadataValue = networkClient.getMetadataClient().getMetadataValue(networkURI, "key");
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
public void cleanUp() throws Exception {
|
public void cleanUp() throws Exception {
|
||||||
if (metadataSet) {
|
if (metadataSet) {
|
||||||
adminContext.getApi().getOrgClient().getMetadataClient()
|
adminContext.getApi().getOrgClient().getMetadataClient()
|
||||||
.deleteMetadataEntry(toAdminUri(orgURI), "key");
|
.deleteMetadataEntry(toAdminUri(orgURI), "KEY");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,15 +112,18 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
checkOrg(org);
|
checkOrg(org);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "orgClient admin metadata setup", dependsOnMethods = { "testGetOrg" })
|
private void setupMetadata() {
|
||||||
public void testSetupMetadata() {
|
|
||||||
adminContext.getApi().getOrgClient().getMetadataClient().setMetadata(toAdminUri(orgURI),
|
adminContext.getApi().getOrgClient().getMetadataClient().setMetadata(toAdminUri(orgURI),
|
||||||
"KEY", MetadataValue.builder().value("VALUE").build());
|
"KEY", MetadataValue.builder().value("VALUE").build());
|
||||||
metadataSet = true;
|
metadataSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "GET /org/{id}/metadata", dependsOnMethods = { "testSetupMetadata" })
|
@Test(description = "GET /org/{id}/metadata", dependsOnMethods = { "testGetOrg" })
|
||||||
public void testGetOrgMetadata() {
|
public void testGetOrgMetadata() {
|
||||||
|
if (adminContext != null) {
|
||||||
|
setupMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
// Call the method being tested
|
// Call the method being tested
|
||||||
Metadata metadata = orgClient.getMetadataClient().getMetadata(orgURI);
|
Metadata metadata = orgClient.getMetadataClient().getMetadata(orgURI);
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.AbstractVAppClientLiveTest;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.AccessSetting;
|
import org.jclouds.vcloud.director.v1_5.domain.AccessSetting;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
||||||
|
|
|
@ -41,6 +41,7 @@ import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.jclouds.vcloud.director.v1_5.AbstractVAppClientLiveTest;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams;
|
import org.jclouds.vcloud.director.v1_5.domain.CloneVAppTemplateParams;
|
||||||
|
@ -64,6 +65,7 @@ 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.VAppTemplate;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.Envelope;
|
import org.jclouds.vcloud.director.v1_5.domain.ovf.Envelope;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection;
|
import org.jclouds.vcloud.director.v1_5.domain.ovf.NetworkSection;
|
||||||
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -80,6 +82,16 @@ import com.google.common.collect.Iterables;
|
||||||
@Test(groups = { "live", "user", "vapptemplate" }, singleThreaded = true, testName = "VAppTemplateClientLiveTest")
|
@Test(groups = { "live", "user", "vapptemplate" }, singleThreaded = true, testName = "VAppTemplateClientLiveTest")
|
||||||
public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
|
public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
private String val;
|
||||||
|
|
||||||
|
@AfterClass(alwaysRun = true)
|
||||||
|
protected void tidyUp() {
|
||||||
|
if (key != null) {
|
||||||
|
assertTaskSucceeds(vAppTemplateClient.getMetadataClient().deleteMetadataEntry(vAppTemplateURI, key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME cloneVAppTemplate is giving back 500 error
|
// FIXME cloneVAppTemplate is giving back 500 error
|
||||||
private VAppTemplate cloneVAppTemplate(boolean waitForTask) throws Exception {
|
private VAppTemplate cloneVAppTemplate(boolean waitForTask) throws Exception {
|
||||||
CloneVAppTemplateParams cloneVAppTemplateParams = CloneVAppTemplateParams.builder()
|
CloneVAppTemplateParams cloneVAppTemplateParams = CloneVAppTemplateParams.builder()
|
||||||
|
@ -227,13 +239,11 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
|
||||||
|
|
||||||
@Test(description = "POST /vAppTemplate/{id}/metadata", dependsOnMethods = { "testGetVAppTemplate" })
|
@Test(description = "POST /vAppTemplate/{id}/metadata", dependsOnMethods = { "testGetVAppTemplate" })
|
||||||
public void testEditMetadata() {
|
public void testEditMetadata() {
|
||||||
// TODO Cleanup after ourselves..
|
|
||||||
|
|
||||||
Metadata oldMetadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI);
|
Metadata oldMetadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI);
|
||||||
Map<String,String> oldMetadataMap = metadataToMap(oldMetadata);
|
Map<String,String> oldMetadataMap = metadataToMap(oldMetadata);
|
||||||
|
|
||||||
String key = name("key-");
|
key = name("key-");
|
||||||
String val = name("value-");
|
val = name("value-");
|
||||||
MetadataEntry metadataEntry = MetadataEntry.builder().entry(key, val).build();
|
MetadataEntry metadataEntry = MetadataEntry.builder().entry(key, val).build();
|
||||||
Metadata metadata = Metadata.builder().fromMetadata(oldMetadata).entry(metadataEntry).build();
|
Metadata metadata = Metadata.builder().fromMetadata(oldMetadata).entry(metadataEntry).build();
|
||||||
|
|
||||||
|
@ -250,10 +260,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
|
||||||
|
|
||||||
@Test(description = "PUT /vAppTemplate/{id}/metadata/{key}", dependsOnMethods = { "testEditMetadata" })
|
@Test(description = "PUT /vAppTemplate/{id}/metadata/{key}", dependsOnMethods = { "testEditMetadata" })
|
||||||
public void testEditMetadataValue() {
|
public void testEditMetadataValue() {
|
||||||
// TODO Cleanup after ourselves..
|
val = "new"+val;
|
||||||
|
|
||||||
String key = name("key-");
|
|
||||||
String val = name("value-");
|
|
||||||
MetadataValue metadataValue = MetadataValue.builder().value(val).build();
|
MetadataValue metadataValue = MetadataValue.builder().value(val).build();
|
||||||
|
|
||||||
final Task task = vAppTemplateClient.getMetadataClient().setMetadata(vAppTemplateURI, key, metadataValue);
|
final Task task = vAppTemplateClient.getMetadataClient().setMetadata(vAppTemplateURI, key, metadataValue);
|
||||||
|
@ -265,19 +272,12 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
|
||||||
|
|
||||||
@Test(description = "DELETE /vAppTemplate/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadataValue" })
|
@Test(description = "DELETE /vAppTemplate/{id}/metadata/{key}", dependsOnMethods = { "testGetMetadataValue" })
|
||||||
public void testDeleteVAppTemplateMetadataValue() {
|
public void testDeleteVAppTemplateMetadataValue() {
|
||||||
// First store a value
|
|
||||||
String key = name("key-");
|
|
||||||
MetadataValue metadataValue = MetadataValue.builder().value("myval").build();
|
|
||||||
final Task task = vAppTemplateClient.getMetadataClient().setMetadata(vAppTemplateURI, key, metadataValue);
|
|
||||||
retryTaskSuccess.apply(task);
|
|
||||||
|
|
||||||
// Then delete the entry
|
|
||||||
final Task deletionTask = vAppTemplateClient.getMetadataClient().deleteMetadataEntry(vAppTemplateURI, key);
|
final Task deletionTask = vAppTemplateClient.getMetadataClient().deleteMetadataEntry(vAppTemplateURI, key);
|
||||||
retryTaskSuccess.apply(deletionTask);
|
retryTaskSuccess.apply(deletionTask);
|
||||||
|
|
||||||
// Then confirm the entry is not there
|
|
||||||
Metadata newMetadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI);
|
Metadata newMetadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI);
|
||||||
checkMetadataKeyAbsentFor("vAppTemplate", newMetadata, key);
|
checkMetadataKeyAbsentFor("vAppTemplate", newMetadata, key);
|
||||||
|
key = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "PUT /vAppTemplate/{id}/guestCustomizationSection")
|
@Test(description = "PUT /vAppTemplate/{id}/guestCustomizationSection")
|
||||||
|
|
|
@ -83,6 +83,17 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
private VAppTemplate clonedVAppTemplate;
|
private VAppTemplate clonedVAppTemplate;
|
||||||
private VAppTemplate capturedVAppTemplate;
|
private VAppTemplate capturedVAppTemplate;
|
||||||
private VAppTemplate uploadedVAppTemplate;
|
private VAppTemplate uploadedVAppTemplate;
|
||||||
|
private boolean metadataSet = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@BeforeClass(alwaysRun = true)
|
||||||
|
public void setupRequiredClients() {
|
||||||
|
vdcClient = context.getApi().getVdcClient();
|
||||||
|
vappTemplateClient = context.getApi().getVAppTemplateClient();
|
||||||
|
vappClient = context.getApi().getVAppClient();
|
||||||
|
|
||||||
|
assertNotNull(vdcURI, String.format(REF_REQ_LIVE, VDC));
|
||||||
|
}
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
@AfterClass(alwaysRun = true)
|
||||||
public void cleanUp() throws Exception {
|
public void cleanUp() throws Exception {
|
||||||
|
@ -105,18 +116,10 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
cleanUpVApp(composedVApp);
|
cleanUpVApp(composedVApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
adminContext.getApi().getVdcClient().getMetadataClient()
|
if (metadataSet) {
|
||||||
.deleteMetadataEntry(toAdminUri(vdcURI), "key");
|
adminContext.getApi().getVdcClient().getMetadataClient()
|
||||||
}
|
.deleteMetadataEntry(toAdminUri(vdcURI), "key");
|
||||||
|
}
|
||||||
@Override
|
|
||||||
@BeforeClass(alwaysRun = true)
|
|
||||||
public void setupRequiredClients() {
|
|
||||||
vdcClient = context.getApi().getVdcClient();
|
|
||||||
vappTemplateClient = context.getApi().getVAppTemplateClient();
|
|
||||||
vappClient = context.getApi().getVAppClient();
|
|
||||||
|
|
||||||
assertNotNull(vdcURI, String.format(REF_REQ_LIVE, VDC));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "GET /vdc/{id}")
|
@Test(description = "GET /vdc/{id}")
|
||||||
|
@ -307,14 +310,18 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "vdcClient admin metadata configuration", dependsOnMethods = { "testGetVdc" } )
|
private void setupMetadata() {
|
||||||
public void testSetupMetadata() {
|
|
||||||
adminContext.getApi().getVdcClient().getMetadataClient().setMetadata(toAdminUri(vdcURI),
|
adminContext.getApi().getVdcClient().getMetadataClient().setMetadata(toAdminUri(vdcURI),
|
||||||
"key", MetadataValue.builder().value("value").build());
|
"key", MetadataValue.builder().value("value").build());
|
||||||
|
metadataSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "GET /vdc/{id}/metadata", dependsOnMethods = { "testSetupMetadata" } )
|
@Test(description = "GET /vdc/{id}/metadata", dependsOnMethods = { "testGetVdc" } )
|
||||||
public void testGetMetadata() {
|
public void testGetMetadata() {
|
||||||
|
if(adminContext != null) {
|
||||||
|
setupMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
Metadata metadata = vdcClient.getMetadataClient().getMetadata(vdcURI);
|
Metadata metadata = vdcClient.getMetadataClient().getMetadata(vdcURI);
|
||||||
|
|
||||||
// required for testing
|
// required for testing
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features.admin;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
|
@ -16,13 +16,14 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features.admin;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.NOT_NULL_OBJ_FMT;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.NOT_NULL_OBJ_FMT;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_DEL;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_DEL;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkError;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertNull;
|
import static org.testng.Assert.assertNull;
|
||||||
|
@ -79,6 +80,20 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
||||||
orgRef = Iterables.getFirst(context.getApi().getOrgClient().getOrgList().getOrgs(), null).toAdminReference(endpoint);
|
orgRef = Iterables.getFirst(context.getApi().getOrgClient().getOrgList().getOrgs(), null).toAdminReference(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterClass(alwaysRun = true)
|
||||||
|
protected void tidyUp() {
|
||||||
|
if (catalog != null) {
|
||||||
|
catalogClient.deleteCatalog(catalog.getHref());
|
||||||
|
try {
|
||||||
|
catalogClient.getCatalog(catalog.getHref());
|
||||||
|
fail("The Catalog should have been deleted");
|
||||||
|
} catch (VCloudDirectorException vcde) {
|
||||||
|
checkError(vcde.getError());
|
||||||
|
assertEquals(vcde.getError().getMajorErrorCode(), Integer.valueOf(403), "The majorErrorCode should be 403 since the item has been deleted");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test(description = "POST /admin/org/{id}/catalogs")
|
@Test(description = "POST /admin/org/{id}/catalogs")
|
||||||
public void testCreateCatalog() {
|
public void testCreateCatalog() {
|
||||||
AdminCatalog newCatalog = AdminCatalog.builder()
|
AdminCatalog newCatalog = AdminCatalog.builder()
|
||||||
|
@ -224,11 +239,4 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
||||||
assertNull(deleteCatalog, String.format(OBJ_DEL, CATALOG, deleteCatalog.toString()));
|
assertNull(deleteCatalog, String.format(OBJ_DEL, CATALOG, deleteCatalog.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
|
||||||
protected void tidyUp() {
|
|
||||||
if (catalog != null) {
|
|
||||||
catalogClient.deleteCatalog(catalog.getHref());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features.admin;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.NetworkClientExpectTest;
|
||||||
import org.jclouds.vcloud.director.v1_5.features.admin.AdminNetworkClient;
|
import org.jclouds.vcloud.director.v1_5.features.admin.AdminNetworkClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features.admin;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features.admin;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features.admin;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features.admin;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features.admin;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features.admin;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient;
|
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
|
import org.jclouds.vcloud.director.v1_5.domain.AdminVdc;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.VdcClientExpectTest;
|
||||||
import org.jclouds.vcloud.director.v1_5.features.admin.AdminVdcClient;
|
import org.jclouds.vcloud.director.v1_5.features.admin.AdminVdcClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminClientExpectTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features.admin;
|
||||||
|
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
|
||||||
|
@ -33,6 +33,9 @@ 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.MetadataEntry;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.MetadataClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.VdcClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.features.MetadataClient.Writeable;
|
||||||
import org.jclouds.vcloud.director.v1_5.features.admin.AdminVdcClient;
|
import org.jclouds.vcloud.director.v1_5.features.admin.AdminVdcClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features.admin;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features.admin;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features.admin;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.features;
|
package org.jclouds.vcloud.director.v1_5.features.admin;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
|
||||||
|
@ -217,7 +217,7 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
dependsOnMethods = { "testCreateUser" } )
|
dependsOnMethods = { "testCreateUser" } )
|
||||||
public void testDeleteUser() {
|
public void testDeleteUser() {
|
||||||
// Create a user to be deleted (so we remove dependencies on test ordering)
|
// Create a user to be deleted (so we remove dependencies on test ordering)
|
||||||
User newUser = randomTestUser("testDeleteUser");
|
User newUser = randomTestUser("testDeleteUser"+getTestDateTimeStamp());
|
||||||
User userToBeDeleted = userClient.createUser(orgRef.getHref(), newUser);
|
User userToBeDeleted = userClient.createUser(orgRef.getHref(), newUser);
|
||||||
|
|
||||||
// Delete the user
|
// Delete the user
|
|
@ -19,7 +19,6 @@
|
||||||
package org.jclouds.vcloud.director.v1_5.internal;
|
package org.jclouds.vcloud.director.v1_5.internal;
|
||||||
|
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.ENTITY_NON_NULL;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.ENTITY_NON_NULL;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
|
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
@ -40,13 +39,9 @@ import javax.inject.Inject;
|
||||||
import org.jclouds.compute.BaseVersionedServiceLiveTest;
|
import org.jclouds.compute.BaseVersionedServiceLiveTest;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.RestContextFactory;
|
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
|
||||||
import org.jclouds.vcloud.director.testng.FormatApiResultsListener;
|
import org.jclouds.vcloud.director.testng.FormatApiResultsListener;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncClient;
|
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncClient;
|
||||||
|
@ -79,8 +74,9 @@ import org.jclouds.vcloud.director.v1_5.predicates.TaskStatusEquals;
|
||||||
import org.jclouds.vcloud.director.v1_5.predicates.TaskSuccess;
|
import org.jclouds.vcloud.director.v1_5.predicates.TaskSuccess;
|
||||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient;
|
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterSuite;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.BeforeSuite;
|
||||||
import org.testng.annotations.Listeners;
|
import org.testng.annotations.Listeners;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -94,7 +90,6 @@ import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.inject.Guice;
|
import com.google.inject.Guice;
|
||||||
import com.google.inject.Module;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@link VCloudDirectorClient} and acts as parent for other client live tests.
|
* Tests behavior of {@link VCloudDirectorClient} and acts as parent for other client live tests.
|
||||||
|
@ -127,6 +122,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
protected Session session;
|
protected Session session;
|
||||||
|
|
||||||
protected String catalogId;
|
protected String catalogId;
|
||||||
|
protected URI catalogURI;
|
||||||
protected URI vAppTemplateURI;
|
protected URI vAppTemplateURI;
|
||||||
protected URI mediaURI;
|
protected URI mediaURI;
|
||||||
protected URI networkURI;
|
protected URI networkURI;
|
||||||
|
@ -142,6 +138,10 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
|
|
||||||
protected DateService dateService;
|
protected DateService dateService;
|
||||||
|
|
||||||
|
private static VCloudDirectorTestSession testSession;
|
||||||
|
|
||||||
|
private static String testStamp;
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
@BeforeClass(alwaysRun = true)
|
||||||
protected void setupDateService() {
|
protected void setupDateService() {
|
||||||
dateService = Guice.createInjector().getInstance(DateService.class);
|
dateService = Guice.createInjector().getInstance(DateService.class);
|
||||||
|
@ -160,53 +160,37 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
protected void initTaskSuccessLong(TaskSuccess taskSuccess) {
|
protected void initTaskSuccessLong(TaskSuccess taskSuccess) {
|
||||||
retryTaskSuccessLong = new RetryablePredicate<Task>(taskSuccess, LONG_TASK_TIMEOUT_SECONDS * 1000L);
|
retryTaskSuccessLong = new RetryablePredicate<Task>(taskSuccess, LONG_TASK_TIMEOUT_SECONDS * 1000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@BeforeSuite(alwaysRun = true)
|
||||||
|
protected void setupTestSession() {
|
||||||
|
setupCredentials();
|
||||||
|
Properties overrides = setupProperties();
|
||||||
|
testSession = VCloudDirectorTestSession.builder()
|
||||||
|
.identity(identity)
|
||||||
|
.credential(credential)
|
||||||
|
.provider(provider)
|
||||||
|
.overrides(overrides)
|
||||||
|
.endpoint(endpoint)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterSuite(alwaysRun = true)
|
||||||
|
protected void tearDownTestSession() {
|
||||||
|
testSession.close();
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true)
|
@BeforeClass(alwaysRun = true)
|
||||||
protected void setupContext() throws Exception {
|
protected void setupContext() throws Exception {
|
||||||
setupCredentials();
|
setupCredentials();
|
||||||
Properties overrides = setupProperties();
|
|
||||||
|
|
||||||
VCloudDirectorContext rootContext = VCloudDirectorContext.class.cast(
|
context = testSession.getUserContext();
|
||||||
new RestContextFactory().createContext(provider, identity, credential, ImmutableSet.<Module> of(
|
adminContext = testSession.getAdminContext();
|
||||||
new Log4JLoggingModule(), new SshjSshClientModule()), overrides));
|
|
||||||
adminContext = rootContext.getAdminContext();
|
|
||||||
|
|
||||||
rootContext.utils().injector().injectMembers(this);
|
if(adminContext != null) {
|
||||||
Reference orgRef = Iterables.getFirst(rootContext.getApi().getOrgClient().getOrgList().getOrgs(), null)
|
adminSession = adminContext.getApi().getCurrentSession();
|
||||||
.toAdminReference(endpoint);
|
adminContext.utils().injector().injectMembers(this);
|
||||||
assertNotNull(orgRef, String.format(REF_REQ_LIVE, "admin org"));
|
}
|
||||||
|
|
||||||
String adminIdentity = "testAdmin"+new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
|
||||||
String adminCredential = "testAdminPassword";
|
|
||||||
rootContext.getAdminContext().getApi().getUserClient().createUser(orgRef.getHref(), User.builder()
|
|
||||||
.name(adminIdentity)
|
|
||||||
.password(adminCredential)
|
|
||||||
.description("test user with user-level privileges") //TODO desc
|
|
||||||
.role(getRoleReferenceFor(DefaultRoles.ORG_ADMIN))
|
|
||||||
.deployedVmQuota(REQUIRED_ADMIN_VM_QUOTA)
|
|
||||||
.isEnabled(true)
|
|
||||||
.build());
|
|
||||||
|
|
||||||
rootContext.close(); rootContext = null;
|
|
||||||
|
|
||||||
adminContext = VCloudDirectorContext.class.cast(new RestContextFactory().createContext(provider, adminIdentity, adminCredential, ImmutableSet.<Module> of(
|
|
||||||
new Log4JLoggingModule(), new SshjSshClientModule()), overrides)).getAdminContext();
|
|
||||||
adminSession = adminContext.getApi().getCurrentSession();
|
|
||||||
adminContext.utils().injector().injectMembers(this);
|
|
||||||
String userIdentity = "test"+new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
|
||||||
String userCredential = "testPassword";
|
|
||||||
|
|
||||||
adminContext.getApi().getUserClient().createUser(orgRef.getHref(), User.builder()
|
|
||||||
.name(userIdentity)
|
|
||||||
.password(userCredential)
|
|
||||||
.description("test user with user-level privileges")
|
|
||||||
.role(getRoleReferenceFor(DefaultRoles.USER))
|
|
||||||
.deployedVmQuota(REQUIRED_USER_VM_QUOTA)
|
|
||||||
.isEnabled(true)
|
|
||||||
.build());
|
|
||||||
|
|
||||||
context = new RestContextFactory().createContext(provider, userIdentity, userCredential, ImmutableSet.<Module> of(
|
|
||||||
new Log4JLoggingModule(), new SshjSshClientModule()), overrides);
|
|
||||||
session = context.getApi().getCurrentSession();
|
session = context.getApi().getCurrentSession();
|
||||||
context.utils().injector().injectMembers(this);
|
context.utils().injector().injectMembers(this);
|
||||||
|
|
||||||
|
@ -214,7 +198,19 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
setupRequiredClients();
|
setupRequiredClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getTestDateTimeStamp() {
|
||||||
|
if (testStamp == null) {
|
||||||
|
testStamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
return testStamp;
|
||||||
|
}
|
||||||
|
|
||||||
public Reference getRoleReferenceFor(String name) {
|
public Reference getRoleReferenceFor(String name) {
|
||||||
|
return getRoleReferenceFor(name, adminContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Reference getRoleReferenceFor(String name, RestContext<VCloudDirectorAdminClient, VCloudDirectorAdminAsyncClient> adminContext) {
|
||||||
RoleReferences roles = adminContext.getApi().getQueryClient().roleReferencesQueryAll();
|
RoleReferences roles = adminContext.getApi().getQueryClient().roleReferencesQueryAll();
|
||||||
// wrapped in a builder to strip out unwanted xml cruft that the api chokes on
|
// wrapped in a builder to strip out unwanted xml cruft that the api chokes on
|
||||||
return Reference.builder().fromReference(Iterables.find(roles.getReferences(), ReferencePredicates.nameEquals(name))).build();
|
return Reference.builder().fromReference(Iterables.find(roles.getReferences(), ReferencePredicates.nameEquals(name))).build();
|
||||||
|
@ -226,7 +222,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
|
|
||||||
public User randomTestUser(String prefix, Reference role) {
|
public User randomTestUser(String prefix, Reference role) {
|
||||||
return User.builder()
|
return User.builder()
|
||||||
.name(name(prefix)+random.nextInt(999999))
|
.name(name(prefix)+getTestDateTimeStamp())
|
||||||
.fullName("testFullName")
|
.fullName("testFullName")
|
||||||
.emailAddress("test@test.com")
|
.emailAddress("test@test.com")
|
||||||
.telephone("555-1234")
|
.telephone("555-1234")
|
||||||
|
@ -245,6 +241,9 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
// TODO change properties to URI, not id
|
// TODO change properties to URI, not id
|
||||||
protected void initTestParametersFromPropertiesOrLazyDiscover() {
|
protected void initTestParametersFromPropertiesOrLazyDiscover() {
|
||||||
catalogId = Strings.emptyToNull(System.getProperty("test." + provider + ".catalog-id"));
|
catalogId = Strings.emptyToNull(System.getProperty("test." + provider + ".catalog-id"));
|
||||||
|
if (catalogId != null) {
|
||||||
|
catalogURI = URI.create(endpoint + "/catalog/" + catalogId);
|
||||||
|
}
|
||||||
|
|
||||||
String vAppTemplateId = Strings.emptyToNull(System.getProperty("test." + provider + ".vapptemplate-id"));
|
String vAppTemplateId = Strings.emptyToNull(System.getProperty("test." + provider + ".vapptemplate-id"));
|
||||||
if (vAppTemplateId != null)
|
if (vAppTemplateId != null)
|
||||||
|
@ -287,14 +286,6 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
|
||||||
protected void tearDown() {
|
|
||||||
if (context != null)
|
|
||||||
context.close();
|
|
||||||
if (adminContext != null)
|
|
||||||
adminContext.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public URI toAdminUri(Reference ref) {
|
public URI toAdminUri(Reference ref) {
|
||||||
return toAdminUri(ref.getHref());
|
return toAdminUri(ref.getHref());
|
||||||
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
package org.jclouds.vcloud.director.v1_5.internal;
|
||||||
|
|
||||||
|
import static com.google.common.base.Objects.equal;
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
import org.jclouds.rest.RestContext;
|
||||||
|
import org.jclouds.rest.RestContextFactory;
|
||||||
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminAsyncClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.User;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.inject.Module;
|
||||||
|
|
||||||
|
public class VCloudDirectorTestSession {
|
||||||
|
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private String provider;
|
||||||
|
private String identity;
|
||||||
|
private String credential;
|
||||||
|
private Properties overrides;
|
||||||
|
private String endpoint;
|
||||||
|
|
||||||
|
public Builder provider(String provider) {
|
||||||
|
this.provider = provider;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder identity(String identity) {
|
||||||
|
this.identity = identity;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder credential(String credential) {
|
||||||
|
this.credential = credential;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder overrides(Properties overrides) {
|
||||||
|
this.overrides = overrides;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder endpoint(String endpoint) {
|
||||||
|
this.endpoint = endpoint;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VCloudDirectorTestSession build() {
|
||||||
|
return new VCloudDirectorTestSession(provider, identity, credential, overrides, endpoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private RestContext<VCloudDirectorAdminClient, VCloudDirectorAdminAsyncClient> adminContext;
|
||||||
|
private RestContext<VCloudDirectorClient, VCloudDirectorAsyncClient> userContext;
|
||||||
|
|
||||||
|
private User createdAdminUser;
|
||||||
|
private User createdUser;
|
||||||
|
|
||||||
|
private VCloudDirectorTestSession(String provider, String identity, String credential, Properties overrides, String endpoint) {
|
||||||
|
VCloudDirectorContext rootContext = VCloudDirectorContext.class.cast(
|
||||||
|
new RestContextFactory().createContext(provider, identity, credential, ImmutableSet.<Module> of(
|
||||||
|
new Log4JLoggingModule(), new SshjSshClientModule()), overrides));
|
||||||
|
|
||||||
|
if (rootContext.getApi().getCurrentSession().getLinks().contains(Link.builder()
|
||||||
|
.rel("down")
|
||||||
|
.type("application/vnd.vmware.admin.vcloud+xml")
|
||||||
|
.href(URI.create(endpoint+"/admin/"))
|
||||||
|
.build())) {
|
||||||
|
|
||||||
|
adminContext = rootContext.getAdminContext();
|
||||||
|
|
||||||
|
Reference orgRef = Iterables.getFirst(rootContext.getApi().getOrgClient().getOrgList().getOrgs(), null)
|
||||||
|
.toAdminReference(endpoint);
|
||||||
|
assertNotNull(orgRef, String.format(REF_REQ_LIVE, "admin org"));
|
||||||
|
|
||||||
|
Reference userRef = Iterables.find(adminContext.getApi().getOrgClient().getOrg(orgRef.getHref()).getUsers(),
|
||||||
|
ReferencePredicates.nameEquals(adminContext.getApi().getCurrentSession().getUser()));
|
||||||
|
|
||||||
|
User user = adminContext.getApi().getUserClient().getUser(userRef.getHref());
|
||||||
|
Reference orgAdmin = user.getRole();
|
||||||
|
assertTrue(equal(orgAdmin.getName(), DefaultRoles.ORG_ADMIN), "must give org admin or user-only credentials");
|
||||||
|
|
||||||
|
String adminIdentity = "testAdmin"+BaseVCloudDirectorClientLiveTest.getTestDateTimeStamp();
|
||||||
|
String adminCredential = "testAdminPassword";
|
||||||
|
|
||||||
|
createdAdminUser = rootContext.getAdminContext().getApi().getUserClient().createUser(orgRef.getHref(), User.builder()
|
||||||
|
.name(adminIdentity)
|
||||||
|
.password(adminCredential)
|
||||||
|
.description("test user with user-level privileges")
|
||||||
|
.role(orgAdmin)
|
||||||
|
.deployedVmQuota(BaseVCloudDirectorClientLiveTest.REQUIRED_ADMIN_VM_QUOTA)
|
||||||
|
.isEnabled(true)
|
||||||
|
.build());
|
||||||
|
|
||||||
|
rootContext.close(); rootContext = null;
|
||||||
|
|
||||||
|
adminContext = VCloudDirectorContext.class.cast(new RestContextFactory().createContext(provider, adminIdentity, adminCredential, ImmutableSet.<Module> of(
|
||||||
|
new Log4JLoggingModule(), new SshjSshClientModule()), overrides)).getAdminContext();
|
||||||
|
String userIdentity = "test"+BaseVCloudDirectorClientLiveTest.getTestDateTimeStamp();
|
||||||
|
String userCredential = "testPassword";
|
||||||
|
|
||||||
|
createdUser = adminContext.getApi().getUserClient().createUser(orgRef.getHref(), User.builder()
|
||||||
|
.name(userIdentity)
|
||||||
|
.password(userCredential)
|
||||||
|
.description("test user with user-level privileges")
|
||||||
|
.role(BaseVCloudDirectorClientLiveTest.getRoleReferenceFor(DefaultRoles.USER, adminContext))
|
||||||
|
.deployedVmQuota(BaseVCloudDirectorClientLiveTest.REQUIRED_USER_VM_QUOTA)
|
||||||
|
.isEnabled(true)
|
||||||
|
.build());
|
||||||
|
|
||||||
|
userContext = new RestContextFactory().createContext(provider, userIdentity, userCredential, ImmutableSet.<Module> of(
|
||||||
|
new Log4JLoggingModule(), new SshjSshClientModule()), overrides);
|
||||||
|
} else {
|
||||||
|
userContext = rootContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
if (createdUser != null) {
|
||||||
|
adminContext.getApi().getUserClient().deleteUser(createdUser.getHref());
|
||||||
|
}
|
||||||
|
if (userContext != null)
|
||||||
|
userContext.close();
|
||||||
|
if (createdAdminUser != null) {
|
||||||
|
// TODO: may have to preserve root context if we can't delete the user for it's own context here
|
||||||
|
adminContext.getApi().getUserClient().deleteUser(createdAdminUser.getHref());
|
||||||
|
}
|
||||||
|
if (adminContext != null)
|
||||||
|
adminContext.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RestContext<VCloudDirectorClient, VCloudDirectorAsyncClient> getUserContext() {
|
||||||
|
return userContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RestContext<VCloudDirectorAdminClient, VCloudDirectorAdminAsyncClient> getAdminContext() {
|
||||||
|
return adminContext;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue