Merge pull request #499 from danikov/vclouds-director-bugfixes-2

Issue 830: vCloud director Bugfix
This commit is contained in:
Adrian Cole 2012-03-20 22:29:21 -07:00
commit ac2528ef6f
17 changed files with 82 additions and 16 deletions

View File

@ -120,7 +120,7 @@ public class VCloudDirectorRestClientModule extends RestClientModule<VCloudDirec
.put(VAppTemplateClient.class, VAppTemplateAsyncClient.class) .put(VAppTemplateClient.class, VAppTemplateAsyncClient.class)
.put(UploadClient.class, UploadAsyncClient.class) .put(UploadClient.class, UploadAsyncClient.class)
.put(MetadataClient.Readable.class, MetadataAsyncClient.Readable.class) .put(MetadataClient.Readable.class, MetadataAsyncClient.Readable.class)
.put(MetadataClient.Writeable.class, MetadataAsyncClient.Writable.class) .put(MetadataClient.Writeable.class, MetadataAsyncClient.Writeable.class)
.put(GroupClient.class, GroupAsyncClient.class) .put(GroupClient.class, GroupAsyncClient.class)
.put(UserClient.class, UserAsyncClient.class) .put(UserClient.class, UserAsyncClient.class)
.put(AdminNetworkClient.class, AdminNetworkAsyncClient.class) .put(AdminNetworkClient.class, AdminNetworkAsyncClient.class)

View File

@ -129,10 +129,10 @@ public interface AdminCatalogAsyncClient extends CatalogAsyncClient {
@BinderParam(BindToXMLPayload.class) PublishCatalogParams params); @BinderParam(BindToXMLPayload.class) PublishCatalogParams params);
/** /**
* @return synchronous access to {@link Metadata.Writable} features * @return synchronous access to {@link Metadata.Writeable} features
*/ */
@Override @Override
@Delegate @Delegate
MetadataAsyncClient.Writable getMetadataClient(); MetadataAsyncClient.Writeable getMetadataClient();
} }

View File

@ -116,7 +116,7 @@ public interface AdminCatalogClient extends CatalogClient {
//void publishCatalog(URI catalogRef) //void publishCatalog(URI catalogRef)
/** /**
* @return synchronous access to {@link Metadata.Writable} features * @return synchronous access to {@link Metadata.Writeable} features
*/ */
@Override @Override
@Delegate @Delegate

View File

@ -28,6 +28,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.JAXBResponseParser;
@ -79,4 +80,11 @@ public interface AdminNetworkAsyncClient extends NetworkAsyncClient {
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<Task> resetNetwork(@EndpointParam URI networkRef); ListenableFuture<Task> resetNetwork(@EndpointParam URI networkRef);
/**
* @return asynchronous access to admin {@link MetadataAsyncClient.Writeable} features
*/
@Override
@Delegate
MetadataAsyncClient.Writeable getMetadataClient();
} }

View File

@ -22,6 +22,7 @@ import java.net.URI;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.vcloud.director.v1_5.domain.Network; import org.jclouds.vcloud.director.v1_5.domain.Network;
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.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
@ -81,5 +82,12 @@ public interface AdminNetworkClient extends NetworkClient {
* returned task status in order to check when it is completed. * returned task status in order to check when it is completed.
*/ */
Task resetNetwork(URI networkRef); Task resetNetwork(URI networkRef);
/**
* @return synchronous access to admin {@link MetadataClient.Writeable} features
*/
@Override
@Delegate
MetadataClient.Writeable getMetadataClient();
} }

View File

@ -27,6 +27,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.annotations.JAXBResponseParser; import org.jclouds.rest.annotations.JAXBResponseParser;
@ -217,4 +218,10 @@ public interface AdminOrgAsyncClient extends OrgAsyncClient {
@EndpointParam URI orgRef, @EndpointParam URI orgRef,
@BinderParam(BindToXMLPayload.class) OrgVAppTemplateLeaseSettings settings); @BinderParam(BindToXMLPayload.class) OrgVAppTemplateLeaseSettings settings);
/**
* @return asynchronous access to admin {@link MetadataAsyncClient.Writeable} features
*/
@Override
@Delegate
MetadataAsyncClient.Writeable getMetadataClient();
} }

View File

@ -22,6 +22,7 @@ import java.net.URI;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.vcloud.director.v1_5.domain.AdminOrg; import org.jclouds.vcloud.director.v1_5.domain.AdminOrg;
import org.jclouds.vcloud.director.v1_5.domain.Group; import org.jclouds.vcloud.director.v1_5.domain.Group;
import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings; import org.jclouds.vcloud.director.v1_5.domain.OrgEmailSettings;
@ -216,5 +217,12 @@ public interface AdminOrgClient extends OrgClient {
*/ */
OrgVAppTemplateLeaseSettings updateVAppTemplateLeaseSettings(URI orgRef, OrgVAppTemplateLeaseSettings updateVAppTemplateLeaseSettings(URI orgRef,
OrgVAppTemplateLeaseSettings newSettings); OrgVAppTemplateLeaseSettings newSettings);
/**
* @return synchronous access to admin {@link MetadataClient.Writeable} features
*/
@Override
@Delegate
MetadataClient.Writeable getMetadataClient();
} }

View File

@ -36,7 +36,7 @@ import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType; import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
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.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient.Writable; import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient.Writeable;
import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest; import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationToRequest;
import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx; import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
@ -86,8 +86,8 @@ public interface AdminVdcAsyncClient extends VdcAsyncClient {
ListenableFuture<Void> disableVdc(@EndpointParam URI vdcRef); ListenableFuture<Void> disableVdc(@EndpointParam URI vdcRef);
/** /**
* @return asynchronous access to {@link Writable} features * @return asynchronous access to {@link Writeable} features
*/ */
@Delegate @Delegate
MetadataAsyncClient.Writable getMetadataClient(); MetadataAsyncClient.Writeable getMetadataClient();
} }

View File

@ -26,7 +26,7 @@ import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
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.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient.Writable; import org.jclouds.vcloud.director.v1_5.features.MetadataAsyncClient.Writeable;
/** /**
* Provides synchronous access to Network. * Provides synchronous access to Network.
@ -78,7 +78,7 @@ public interface AdminVdcClient extends VdcClient {
void disableVdc(URI vdcRef); void disableVdc(URI vdcRef);
/** /**
* @return synchronous access to {@link Writable} features * @return synchronous access to {@link Writeable} features
*/ */
@Delegate @Delegate
MetadataClient.Writeable getMetadataClient(); MetadataClient.Writeable getMetadataClient();

View File

@ -111,5 +111,5 @@ public interface CatalogAsyncClient {
* @return asynchronous access to {@link Metadata.Writeable} features for CatalogItems * @return asynchronous access to {@link Metadata.Writeable} features for CatalogItems
*/ */
@Delegate @Delegate
MetadataAsyncClient.Writable getCatalogItemMetadataClient(); MetadataAsyncClient.Writeable getCatalogItemMetadataClient();
} }

View File

@ -119,5 +119,5 @@ public interface MediaAsyncClient {
* @return asynchronous access to {@link Metadata.Writeable} features * @return asynchronous access to {@link Metadata.Writeable} features
*/ */
@Delegate @Delegate
MetadataAsyncClient.Writable getMetadataClient(); MetadataAsyncClient.Writeable getMetadataClient();
} }

View File

@ -74,7 +74,7 @@ public interface MetadataAsyncClient {
} }
@RequestFilters(AddVCloudAuthorizationToRequest.class) @RequestFilters(AddVCloudAuthorizationToRequest.class)
public static interface Writable extends Readable { public static interface Writeable extends Readable {
/** /**
* @see MetadataClient.Writable#mergeMetadata(URI, Metadata)) * @see MetadataClient.Writable#mergeMetadata(URI, Metadata))
*/ */

View File

@ -722,6 +722,6 @@ public interface VAppAsyncClient {
* @return asynchronous access to {@link Metadata} features * @return asynchronous access to {@link Metadata} features
*/ */
@Delegate @Delegate
MetadataAsyncClient.Writable getMetadataClient(); MetadataAsyncClient.Writeable getMetadataClient();
} }

View File

@ -369,5 +369,5 @@ public interface VAppTemplateAsyncClient {
* @return asynchronous access to {@link Metadata} features * @return asynchronous access to {@link Metadata} features
*/ */
@Delegate @Delegate
MetadataAsyncClient.Writable getMetadataClient(); MetadataAsyncClient.Writeable getMetadataClient();
} }

View File

@ -38,6 +38,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Network;
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.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;
@ -62,6 +63,14 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@BeforeClass(inheritGroups = true) @BeforeClass(inheritGroups = true)
public void setupRequiredClients() { public void setupRequiredClients() {
networkClient = context.getApi().getNetworkClient(); networkClient = context.getApi().getNetworkClient();
context.getApi().getAdminNetworkClient().getMetadataClient().setMetadata(toAdminUri(networkURI),
"key", MetadataValue.builder().value("value").build());
}
@AfterClass(groups = { "live" })
public void cleanUp() throws Exception {
context.getApi().getAdminNetworkClient().getMetadataClient()
.deleteMetadataEntry(toAdminUri(networkURI), "key");
} }
@Test(testName = "GET /network/{id}") @Test(testName = "GET /network/{id}")

View File

@ -38,6 +38,7 @@ 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.domain.OrgList;
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.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;
@ -62,6 +63,14 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public void setupRequiredClients() { public void setupRequiredClients() {
orgClient = context.getApi().getOrgClient(); orgClient = context.getApi().getOrgClient();
} }
@AfterClass(groups = { "live" })
public void cleanUp() throws Exception {
if (metadataSet) {
context.getApi().getAdminOrgClient().getMetadataClient()
.deleteMetadataEntry(toAdminUri(orgURI), "key");
}
}
/* /*
* Shared state between dependant tests. * Shared state between dependant tests.
@ -70,6 +79,7 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
private OrgList orgList; private OrgList orgList;
private URI orgURI; private URI orgURI;
private Org org; private Org org;
private boolean metadataSet = false;
@Test(testName = "GET /org/") @Test(testName = "GET /org/")
public void testGetOrgList() { public void testGetOrgList() {
@ -100,7 +110,14 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
checkOrg(org); checkOrg(org);
} }
@Test(testName = "GET /org/{id}/metadata/", dependsOnMethods = { "testGetOrg" }) @Test(dependsOnMethods = { "testGetOrg" })
public void testSetupMetadata() {
context.getApi().getAdminOrgClient().getMetadataClient().setMetadata(toAdminUri(orgURI),
"KEY", MetadataValue.builder().value("VALUE").build());
metadataSet = true;
}
@Test(testName = "GET /org/{id}/metadata/", dependsOnMethods = { "testSetupMetadata" })
public void testGetOrgMetadata() { public void testGetOrgMetadata() {
// Call the method being tested // Call the method being tested
Metadata metadata = orgClient.getMetadataClient().getMetadata(orgURI); Metadata metadata = orgClient.getMetadataClient().getMetadata(orgURI);

View File

@ -104,6 +104,9 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
if (composedVApp != null) { if (composedVApp != null) {
cleanUpVApp(composedVApp); cleanUpVApp(composedVApp);
} }
context.getApi().getAdminVdcClient().getMetadataClient()
.deleteMetadataEntry(toAdminUri(vdcURI), "key");
} }
@Override @Override
@ -304,7 +307,13 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
} }
@Test(testName = "GET /network/{id}/metadata") @Test(dependsOnMethods = { "testGetVdc" } )
public void testSetupMetadata() {
context.getApi().getAdminVdcClient().getMetadataClient().setMetadata(toAdminUri(vdcURI),
"key", MetadataValue.builder().value("value").build());
}
@Test(testName = "GET /network/{id}/metadata", dependsOnMethods = { "testSetupMetadata" } )
public void testGetMetadata() { public void testGetMetadata() {
Metadata metadata = vdcClient.getMetadataClient().getMetadata(vdcURI); Metadata metadata = vdcClient.getMetadataClient().getMetadata(vdcURI);