From b58060599bb9c0ea01ed9a1c749b4bae6cb6a706 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 6 Jun 2012 14:57:50 -0700 Subject: [PATCH 1/9] Issue 815: repackaged keystone classes into their own api --- .../cloudfiles/CloudFilesApiMetadata.java | 3 +- .../CloudLoadBalancersApiMetadata.java | 3 +- .../cloudservers/CloudServersApiMetadata.java | 3 +- .../openstack/nova/NovaAsyncClientTest.java | 2 +- apis/openstack-keystone/.pom.xml.swp | Bin 0 -> 16384 bytes {labs => apis}/openstack-keystone/pom.xml | 17 +- .../v2_0/AuthenticationAsyncClient.java | 0 .../keystone/v2_0/AuthenticationClient.java | 0 .../keystone/v2_0/KeystoneApiMetadata.java | 8 +- .../keystone/v2_0/KeystoneAsyncClient.java | 2 + .../keystone/v2_0/KeystoneClient.java | 2 + .../v2_0/binders/BindAuthToJsonPayload.java | 0 .../keystone/v2_0/config/Authentication.java | 38 ++++ .../keystone/v2_0/config/CredentialType.java | 0 .../config/KeystoneAuthenticationModule.java | 1 - .../v2_0/config/KeystoneParserModule.java | 0 .../v2_0/config/KeystoneProperties.java | 2 +- .../v2_0/config/KeystoneRestClientModule.java | 11 +- .../keystone/v2_0/domain/Access.java | 0 .../v2_0/domain/ApiAccessKeyCredentials.java | 0 .../keystone/v2_0/domain/ApiMetadata.java | 2 +- .../keystone/v2_0/domain/Endpoint.java | 0 .../keystone/v2_0/domain/MediaType.java | 0 .../v2_0/domain/PasswordCredentials.java | 0 .../openstack/keystone/v2_0/domain/Role.java | 0 .../keystone/v2_0/domain/Service.java | 0 .../keystone/v2_0/domain/Tenant.java | 0 .../openstack/keystone/v2_0/domain/Token.java | 0 .../openstack/keystone/v2_0/domain/User.java | 0 .../v2_0/features}/AdminAsyncClient.java | 4 +- .../keystone/v2_0/features}/AdminClient.java | 2 +- .../v2_0/features}/ServiceAsyncClient.java | 4 +- .../v2_0/features}/ServiceClient.java | 2 +- .../v2_0/filters/AuthenticateRequest.java | 54 +++++ .../keystone/v2_0/functions/AdminURL.java | 0 .../AuthenticateApiAccessKeyCredentials.java | 0 .../AuthenticatePasswordCredentials.java | 0 .../v2_0/functions/EndpointToRegion.java | 0 .../functions/EndpointToSupplierAdminURI.java | 0 .../v2_0/functions/EndpointToSupplierURI.java | 0 .../functions/PublicURLOrInternalIfNull.java | 0 .../functions/RegionToAdminEndpointURI.java | 0 .../keystone/v2_0/functions/ReturnRegion.java | 0 .../v2_0/handlers/KeystoneErrorHandler.java | 0 .../keystone/v2_0/handlers/RetryOnRenew.java | 5 +- ...RIFromAccessForTypeAndVersionSupplier.java | 0 ...RIFromAccessForTypeAndVersionSupplier.java | 0 .../suppliers/RegionIdToAdminURISupplier.java | 0 ...RIFromAccessForTypeAndVersionSupplier.java | 0 ...RIFromAccessForTypeAndVersionSupplier.java | 0 .../jclouds/openstack/v2_0/ServiceType.java | 52 +++++ .../jclouds/openstack/v2_0/domain/Link.java | 207 ++++++++++++++++++ .../openstack/v2_0/domain/Resource.java | 185 ++++++++++++++++ .../v2_0/options/BaseListOptions.java | 100 +++++++++ .../v2_0/predicates/LinkPredicates.java | 103 +++++++++ .../openstack/v2_0/reference/AuthHeaders.java | 31 +++ .../openstack/v2_0/services/Compute.java | 43 ++++ .../openstack/v2_0/services/Extension.java | 79 +++++++ .../openstack/v2_0/services/Image.java | 43 ++++ .../openstack/v2_0/services/ObjectStore.java | 43 ++++ .../services/org.jclouds.apis.ApiMetadata | 0 .../v2_0/features}/AdminClientExpectTest.java | 5 +- .../v2_0/features}/AdminClientLiveTest.java | 7 +- .../v2_0/features}/UserClientExpectTest.java | 5 +- .../v2_0/features}/UserClientLiveTest.java | 2 +- .../keystone/v2_0/functions/AdminURLTest.java | 0 .../PublicURLOrInternalIfNullTest.java | 0 .../v2_0/functions/ReturnRegionTest.java | 0 .../v2_0/handlers/RetryOnRenewTest.java | 0 .../internal/BaseKeystoneClientLiveTest.java | 0 .../BaseKeystoneRestClientExpectTest.java | 2 +- .../v2_0/internal/KeystoneFixture.java | 0 .../keystone/v2_0/parse/ParseAccessTest.java | 0 .../v2_0/parse/ParseApiMetadataTest.java | 2 +- ...omAccessForTypeAndVersionSupplierTest.java | 0 ...omAccessForTypeAndVersionSupplierTest.java | 0 ...omAccessForTypeAndVersionSupplierTest.java | 0 .../v2_0/options/BaseListOptionsTest.java | 77 +++++++ .../v2_0/predicates/LinkPredicatesTest.java | 51 +++++ .../test/resources/apiMetadataResponse.json | 0 .../src/test/resources/api_metadata.json | 0 .../test/resources/keystoneAuthResponse.json | 0 .../keystoneAuthResponse_trystack.json | 0 .../src/test/resources/logback.xml | 115 +++++----- .../src/test/resources/tenant_details.json | 0 .../src/test/resources/tenant_list.json | 0 .../src/test/resources/token_details.json | 0 .../src/test/resources/user_details.json | 0 .../src/test/resources/user_endpoints.json | 0 .../src/test/resources/user_list.json | 0 .../src/test/resources/user_role_list.json | 0 .../test/resources/user_tenant_role_list.json | 0 apis/openstack-nova/pom.xml | 8 +- .../openstack/nova/v1_1/NovaApiMetadata.java | 6 +- .../openstack/nova/v1_1/NovaAsyncClient.java | 15 +- .../openstack/nova/v1_1/NovaClient.java | 15 +- .../v1_1/config/NovaRestClientModule.java | 29 ++- .../openstack/nova/v1_1/domain/Extension.java | 2 +- .../openstack/nova/v1_1/domain/Flavor.java | 2 +- .../nova/v1_1/domain/HostAggregate.java | 2 +- .../openstack/nova/v1_1/domain/Image.java | 2 +- .../openstack/nova/v1_1/domain/Server.java | 2 +- .../nova/v1_1/domain/ServerCreated.java | 2 +- .../nova/v1_1/domain/VolumeType.java | 2 +- .../extensions/AdminActionsAsyncClient.java | 6 +- .../v1_1/extensions/AdminActionsClient.java | 4 +- .../FlavorExtraSpecsAsyncClient.java | 6 +- .../extensions/FlavorExtraSpecsClient.java | 6 +- .../extensions/FloatingIPAsyncClient.java | 6 +- .../v1_1/extensions/FloatingIPClient.java | 4 +- .../HostAdministrationAsyncClient.java | 6 +- .../extensions/HostAdministrationClient.java | 4 +- .../extensions/HostAggregateAsyncClient.java | 6 +- .../v1_1/extensions/HostAggregateClient.java | 6 +- .../v1_1/extensions/KeyPairAsyncClient.java | 6 +- .../nova/v1_1/extensions/KeyPairClient.java | 4 +- .../v1_1/extensions/QuotaAsyncClient.java | 6 +- .../extensions/QuotaClassAsyncClient.java | 7 +- .../v1_1/extensions/QuotaClassClient.java | 7 +- .../nova/v1_1/extensions/QuotaClient.java | 6 +- .../extensions/SecurityGroupAsyncClient.java | 6 +- .../v1_1/extensions/SecurityGroupClient.java | 4 +- .../ServerWithSecurityGroupsAsyncClient.java | 6 +- .../ServerWithSecurityGroupsClient.java | 4 +- .../SimpleTenantUsageAsyncClient.java | 6 +- .../extensions/SimpleTenantUsageClient.java | 4 +- .../VirtualInterfaceAsyncClient.java | 6 +- .../extensions/VirtualInterfaceClient.java | 4 +- .../v1_1/extensions/VolumeAsyncClient.java | 7 +- .../nova/v1_1/extensions/VolumeClient.java | 4 +- .../extensions/VolumeTypeAsyncClient.java | 6 +- .../v1_1/extensions/VolumeTypeClient.java | 6 +- .../v1_1/features/ExtensionAsyncClient.java | 2 +- .../nova/v1_1/features/FlavorAsyncClient.java | 4 +- .../nova/v1_1/features/FlavorClient.java | 2 +- .../nova/v1_1/features/ImageAsyncClient.java | 4 +- .../nova/v1_1/features/ImageClient.java | 2 +- .../nova/v1_1/features/ServerAsyncClient.java | 6 +- .../nova/v1_1/features/ServerClient.java | 4 +- ...paceEqualsAnyNamespaceInExtensionsSet.java | 4 +- .../nova/v1_1/options/ListOptions.java | 2 +- .../ServerInZoneToNodeMetadataTest.java | 4 +- .../FlavorExtraSpecsClientLiveTest.java | 2 +- .../QuotaClassClientExpectTest.java | 1 - .../extensions/QuotaClassClientLiveTest.java | 1 - ...erverWithSecurityGroupsClientLiveTest.java | 2 +- .../v1_1/features/FlavorClientLiveTest.java | 2 +- .../v1_1/features/ImageClientLiveTest.java | 2 +- .../v1_1/features/ServerClientLiveTest.java | 2 +- ...EqualsAnyNamespaceInExtensionsSetTest.java | 6 +- .../v1_1/internal/BaseNovaClientLiveTest.java | 2 +- .../v1_1/parse/ParseCreatedServerTest.java | 4 +- .../v1_1/parse/ParseExtensionListTest.java | 4 +- .../nova/v1_1/parse/ParseExtensionTest.java | 4 +- .../nova/v1_1/parse/ParseFlavorListTest.java | 6 +- .../nova/v1_1/parse/ParseFlavorTest.java | 4 +- .../nova/v1_1/parse/ParseImageListTest.java | 6 +- .../nova/v1_1/parse/ParseImageTest.java | 6 +- .../parse/ParseServerDetailsEssexTest.java | 8 +- .../nova/v1_1/parse/ParseServerListTest.java | 6 +- .../nova/v1_1/parse/ParseServerTest.java | 6 +- .../ParseServerWithAllExtensionsTest.java | 8 +- .../ParseServerWithInternetAddressesTest.java | 6 +- ...licIpsInPrivateAddressBlockExpectTest.java | 6 +- apis/pom.xml | 1 + .../openstack/swift/SwiftApiMetadata.java | 3 +- .../swift/CommonSwiftClientTest.java | 2 +- common/openstack/pom.xml | 13 +- .../config/OpenStackAuthenticationModule.java | 6 +- .../filters/AuthenticateRequest.java | 2 +- .../{ => internal}/Authentication.java | 2 +- .../OpenStackAuthAsyncClient.java | 3 +- .../{ => internal}/OpenStackAuthClient.java | 2 +- .../config/AuthenticationServiceModule.java | 2 +- .../OpenStackAuthAsyncClientTest.java | 3 +- .../TestOpenStackAuthenticationModule.java | 2 +- labs/openstack-glance/pom.xml | 8 +- .../glance/v1_0/GlanceApiMetadata.java | 2 +- .../openstack/glance/v1_0/domain/Image.java | 2 +- .../v1_0/features/ImageAsyncClient.java | 13 +- .../glance/v1_0/features/ImageClient.java | 3 +- .../ParseImageDetailsFromHeaders.java | 16 +- .../glance/v1_0/options/ImageField.java | 7 - .../glance/v1_0/options/ListImageOptions.java | 11 +- .../v1_0/options/UpdateImageOptions.java | 14 +- .../v1_0/features/ImageClientExpectTest.java | 1 - labs/openstack-quantum/pom.xml | 8 +- .../quantum/v1_0/QuantumApiMetadata.java | 2 +- .../quantum/v1_0/domain/Network.java | 4 +- .../v1_0/features/NetworkAsyncClient.java | 2 +- .../v1_0/features/PortAsyncClient.java | 2 +- labs/openstack-swift/pom.xml | 8 +- .../openstack/swift/v1/SwiftApiMetadata.java | 2 +- .../swift/v1/features/AccountAsyncClient.java | 2 +- .../v1/features/ContainerAsyncClient.java | 2 +- .../swift/v1/features/ObjectAsyncClient.java | 2 +- labs/pom.xml | 1 - providers/hpcloud-objectstorage/pom.xml | 9 +- .../HPCloudObjectStorageAsyncClient.java | 2 +- .../extensions/HPCloudCDNAsyncClient.java | 2 +- 200 files changed, 1532 insertions(+), 319 deletions(-) create mode 100644 apis/openstack-keystone/.pom.xml.swp rename {labs => apis}/openstack-keystone/pom.xml (90%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationAsyncClient.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationClient.java (100%) rename {labs => apis}/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java (92%) rename {labs => apis}/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncClient.java (93%) rename {labs => apis}/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneClient.java (94%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java (100%) create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/Authentication.java rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialType.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java (99%) rename {labs => apis}/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneParserModule.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java (97%) rename {labs => apis}/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java (87%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Access.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiAccessKeyCredentials.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiMetadata.java (98%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Endpoint.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/MediaType.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/PasswordCredentials.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Role.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Service.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Tenant.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Token.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/User.java (100%) rename {labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0 => apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features}/AdminAsyncClient.java (98%) rename {labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0 => apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features}/AdminClient.java (98%) rename {labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0 => apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features}/ServiceAsyncClient.java (94%) rename {labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0 => apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features}/ServiceClient.java (96%) create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/filters/AuthenticateRequest.java rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURL.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticateApiAccessKeyCredentials.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticatePasswordCredentials.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToRegion.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierAdminURI.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierURI.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNull.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/RegionToAdminEndpointURI.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegion.java (100%) rename {labs => apis}/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/KeystoneErrorHandler.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenew.java (92%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersionSupplier.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplier.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURISupplier.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionSupplier.java (100%) rename {common/openstack => apis/openstack-keystone}/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplier.java (100%) create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/ServiceType.java create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/domain/Link.java create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/domain/Resource.java create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/options/BaseListOptions.java create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/predicates/LinkPredicates.java create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/reference/AuthHeaders.java create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/Compute.java create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/Extension.java create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/Image.java create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/ObjectStore.java rename {labs => apis}/openstack-keystone/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata (100%) rename {labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0 => apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features}/AdminClientExpectTest.java (99%) rename {labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0 => apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features}/AdminClientLiveTest.java (96%) rename {labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0 => apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features}/UserClientExpectTest.java (96%) rename {labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0 => apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features}/UserClientLiveTest.java (97%) rename {common/openstack => apis/openstack-keystone}/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURLTest.java (100%) rename {common/openstack => apis/openstack-keystone}/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNullTest.java (100%) rename {common/openstack => apis/openstack-keystone}/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionTest.java (100%) rename {common/openstack => apis/openstack-keystone}/src/test/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenewTest.java (100%) rename {labs => apis}/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneClientLiveTest.java (100%) rename {labs => apis}/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestClientExpectTest.java (98%) rename {common/openstack => apis/openstack-keystone}/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/KeystoneFixture.java (100%) rename {common/openstack => apis/openstack-keystone}/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseAccessTest.java (100%) rename {common/openstack => apis/openstack-keystone}/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseApiMetadataTest.java (98%) rename {common/openstack => apis/openstack-keystone}/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplierTest.java (100%) rename {common/openstack => apis/openstack-keystone}/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionSupplierTest.java (100%) rename {common/openstack => apis/openstack-keystone}/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplierTest.java (100%) create mode 100644 apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/options/BaseListOptionsTest.java create mode 100644 apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/predicates/LinkPredicatesTest.java rename {common/openstack => apis/openstack-keystone}/src/test/resources/apiMetadataResponse.json (100%) rename {labs => apis}/openstack-keystone/src/test/resources/api_metadata.json (100%) rename {common/openstack => apis/openstack-keystone}/src/test/resources/keystoneAuthResponse.json (100%) rename {common/openstack => apis/openstack-keystone}/src/test/resources/keystoneAuthResponse_trystack.json (100%) rename {labs => apis}/openstack-keystone/src/test/resources/logback.xml (63%) rename {labs => apis}/openstack-keystone/src/test/resources/tenant_details.json (100%) rename {labs => apis}/openstack-keystone/src/test/resources/tenant_list.json (100%) rename {labs => apis}/openstack-keystone/src/test/resources/token_details.json (100%) rename {labs => apis}/openstack-keystone/src/test/resources/user_details.json (100%) rename {labs => apis}/openstack-keystone/src/test/resources/user_endpoints.json (100%) rename {labs => apis}/openstack-keystone/src/test/resources/user_list.json (100%) rename {labs => apis}/openstack-keystone/src/test/resources/user_role_list.json (100%) rename {labs => apis}/openstack-keystone/src/test/resources/user_tenant_role_list.json (100%) rename common/openstack/src/main/java/org/jclouds/openstack/{ => internal}/Authentication.java (97%) rename common/openstack/src/main/java/org/jclouds/openstack/{ => internal}/OpenStackAuthAsyncClient.java (96%) rename common/openstack/src/main/java/org/jclouds/openstack/{ => internal}/OpenStackAuthClient.java (97%) rename common/openstack/src/test/java/org/jclouds/openstack/{ => internal}/OpenStackAuthAsyncClientTest.java (97%) rename common/openstack/src/test/java/org/jclouds/openstack/{ => internal}/TestOpenStackAuthenticationModule.java (98%) diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java index d2211b8395..c9b381c02f 100644 --- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java +++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java @@ -28,7 +28,6 @@ import org.jclouds.apis.ApiMetadata; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule; import org.jclouds.cloudfiles.config.CloudFilesRestClientModule; -import org.jclouds.openstack.OpenStackAuthAsyncClient; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.BaseRestApiMetadata; @@ -81,7 +80,7 @@ public class CloudFilesApiMetadata extends BaseRestApiMetadata { .identityName("Username") .credentialName("API Key") .documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html")) - .version(OpenStackAuthAsyncClient.VERSION) + .version("1.0") .defaultProperties(CloudFilesApiMetadata.defaultProperties()) .view(TypeToken.of(BlobStoreContext.class)) .defaultModules(ImmutableSet.>of(CloudFilesRestClientModule.class, CloudFilesBlobStoreContextModule.class)); diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java index 28c904566e..e59e3b9808 100644 --- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java +++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java @@ -25,7 +25,6 @@ import org.jclouds.apis.ApiMetadata; import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule; import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule; import org.jclouds.loadbalancer.LoadBalancerServiceContext; -import org.jclouds.openstack.OpenStackAuthAsyncClient; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.BaseRestApiMetadata; @@ -75,7 +74,7 @@ public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata { .identityName("Username") .credentialName("API Key") .documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html")) - .version(OpenStackAuthAsyncClient.VERSION) + .version("1.0") .defaultEndpoint("https://auth.api.rackspacecloud.com") .defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties()) .view(TypeToken.of(LoadBalancerServiceContext.class)) diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java index 954355dfbe..0a394dbebe 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java @@ -25,7 +25,6 @@ import org.jclouds.apis.ApiMetadata; import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule; import org.jclouds.cloudservers.config.CloudServersRestClientModule; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.openstack.OpenStackAuthAsyncClient; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.BaseRestApiMetadata; @@ -74,7 +73,7 @@ public class CloudServersApiMetadata extends BaseRestApiMetadata { .identityName("Username") .credentialName("API Key") .documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html")) - .version(OpenStackAuthAsyncClient.VERSION) + .version("1.0") .defaultEndpoint("https://auth.api.rackspacecloud.com") .defaultProperties(CloudServersApiMetadata.defaultProperties()) .view(TypeToken.of(ComputeServiceContext.class)) diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java index 792101bb3c..4c1fd65c7d 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java @@ -35,9 +35,9 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.http.functions.UnwrapOnlyJsonValue; -import org.jclouds.openstack.TestOpenStackAuthenticationModule; import org.jclouds.openstack.filters.AddTimestampQuery; import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.internal.TestOpenStackAuthenticationModule; import org.jclouds.openstack.nova.config.NovaRestClientModule; import org.jclouds.openstack.nova.domain.RebootType; import org.jclouds.openstack.nova.options.CreateServerOptions; diff --git a/apis/openstack-keystone/.pom.xml.swp b/apis/openstack-keystone/.pom.xml.swp new file mode 100644 index 0000000000000000000000000000000000000000..2e445a32b1607b1a6362553fd4b61348037193d3 GIT binary patch literal 16384 zcmeHOO^h5z8LgNQLP$(-6e5IBDnpQxXuEsXb^tl;F~fST4A~#!Sv#?0X;a%>GgG@g z-JPzUogE@#2`Pvx5|JWt3>?BCNN^0f5OPBz5I~9q7Y+~(h@YI`0i7t7~`aS6b`z3-&33=Uzg7_Tyh{ik}=D`*eC6VSXZ5=tTink@KHs zW@oLyP+DT0d3F$aESO2~!q}lRjFLSWGmkr6kvh9x5Dk3k1Z+n-QOrY`GH=h?<0F|y zA$Q`aZy)q$JCYLr$GsuB+(J)*hnwowz*L(nJ^qi~>dhqkvJsC}0#Y z3K#{90{?por13Fw9mP7Pi?*$Q-!}F8-}<>3D?#BuFHSiAbUBCyHfWICm zPXhM?cL0C-C?Vehc7X?gH}52554aon{znM;9`IG*PT((hfD7;v-~-oyCa?_Dfd_%( zz@I-%$Q!`7f$KmBw1Ce5f4`lO-vF-zuL3Uv0dNku5BTSYzzO&*@EUL(cow(-oCa#Z zgTM*kcHnO~VEF^^Ht+`UBJdSp8F&Er2lW3bpz7gORTnc4oqF7E!~)qMQ^C}Ydrb0% z2vgooSSq5>O1Vs3Cl8;s7k<^)b?`oAsL0io9`3F*a<%inHAQ!y zCsN6`Y}f6&>lCj=bVZCH>h7q!FJ8c;6y9M%l@fV9`?*NswoR5~N*K2!tqI;D<%ge# zG`rkOZO!`Y3;FA-JeCYPr*{{!R~4+SZQLM&_y2MU(vhwWYnQ=y_F5=j)W9v4&WjQ> zo=UY9ev7tQDcmiU>I1`X+>Elek8)xpNzl&G!^fSWsK-clg)RDVl%z$kcuY%EQRJ~F zbn(vCX7#Tv%_guDj9|7J(vpw`M@a3?CFB;D&FqXTKd5r8aJ0*7Xm)W8&E7w`U0=+d zX51%p*I69y`^GMpFqz_U)v!|bmy(i~aEwc-V1bpj?--*7?$-G$WjF@Rqb03mQc&>9xz^S>EKar9y~s+Djd;Nhr)_n|lRl;Ic&gcH>`~3sDu5k^$atLdHMf^8_z)^r=o*Iar52A!OXo9j;Ipq5*nIgp~X9u9~0@RY6WPS)$o z&NJ(4ZLHk-%o6G@Z|HHPlH!ca0@rXoST&q7`TWf2JUaQZa{u&peYE^X(Dz8Dfed!MunU( zh(hp3>dPT+VoRFv=LT4E`*df7-Vz7GV>n~BSVb0PSuRER4JtEsP^a+ zbfi;-QA!6=X^QfxMLA^mc$_MtYKRHct#l6sFc6sZ9^~Kt`2JZM1au@dAUjx+szxclYJM8t}1YQA# zz`wA+Pl5NauipdS!(RRx-~h*g_mTcx;4R=sz$?IafNugX0?PjgFpp8dC}0#Y3K#{9 z0!9I&fKlN8Q-SOlRc*YpO>6e1_B!SF1#HWU4-yoQ>r8yXPyzabNO91bTTOom$wSKz zIOPWs6|NrFDdVb+ib(8SI-)zsKP1f>sPq#5q|5sk^Yf$86^4Hr#x`>%Bkl2MXORy- zev?@_2JTfx=`#_Jzq!W1.5.0-SNAPSHOT ../../project/pom.xml - org.jclouds.labs + org.jclouds.api openstack-keystone jcloud openstack-keystone api jclouds components to access an implementation of OpenStack Keystone @@ -43,7 +43,9 @@ FIXME_CREDENTIALS passwordCredentials - org.jclouds.openstack.keystone.v2_0*;version="${project.version}" + org.jclouds.openstack.v2_0*;version="${project.version}", + org.jclouds.openstack.keystone.v2_0*;version="${project.version}" + org.jclouds.rest.internal;version="${project.version}", org.jclouds*;version="${project.version}", @@ -53,8 +55,8 @@ - org.jclouds.common - openstack-common + org.jclouds + jclouds-core ${project.version} @@ -64,13 +66,6 @@ test-jar test - - org.jclouds.common - openstack-common - ${project.version} - test-jar - test - org.jclouds.driver jclouds-slf4j diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationAsyncClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationAsyncClient.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationAsyncClient.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationAsyncClient.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationClient.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationClient.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationClient.java diff --git a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java similarity index 92% rename from labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java index 7e038f26c6..a9c8f69310 100644 --- a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java @@ -26,7 +26,7 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.BaseRestApiMetadata; @@ -45,6 +45,9 @@ public class KeystoneApiMetadata extends BaseRestApiMetadata { private static final long serialVersionUID = 6725672099385580694L; public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + + /** The serialVersionUID */ + private static final long serialVersionUID = 3030344682235783904L; }; @Override @@ -62,9 +65,6 @@ public class KeystoneApiMetadata extends BaseRestApiMetadata { public static Properties defaultProperties() { Properties properties = BaseRestApiMetadata.defaultProperties(); - // auth fail can happen while cloud-init applies keypair updates - properties.setProperty("jclouds.ssh.max-retries", "7"); - properties.setProperty("jclouds.ssh.retry-auth", "true"); // TODO: this doesn't actually do anything yet. properties.setProperty(KeystoneProperties.VERSION, "2.0"); properties.put(SERVICE_TYPE, ServiceType.IDENTITY); diff --git a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncClient.java similarity index 93% rename from labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncClient.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncClient.java index cb88070c2f..1d23d251f4 100644 --- a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncClient.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncClient.java @@ -26,6 +26,8 @@ import org.jclouds.Constants; import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.Region; import org.jclouds.location.functions.RegionToEndpoint; +import org.jclouds.openstack.keystone.v2_0.features.AdminAsyncClient; +import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncClient; import org.jclouds.openstack.keystone.v2_0.functions.RegionToAdminEndpointURI; import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; diff --git a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneClient.java similarity index 94% rename from labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneClient.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneClient.java index 2c63a5b074..ae23238227 100644 --- a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneClient.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneClient.java @@ -25,6 +25,8 @@ import org.jclouds.concurrent.Timeout; import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.Region; import org.jclouds.location.functions.RegionToEndpoint; +import org.jclouds.openstack.keystone.v2_0.features.AdminClient; +import org.jclouds.openstack.keystone.v2_0.features.ServiceClient; import org.jclouds.openstack.keystone.v2_0.functions.RegionToAdminEndpointURI; import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.EndpointParam; diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/Authentication.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/Authentication.java new file mode 100644 index 0000000000..a6ed4f9bfa --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/Authentication.java @@ -0,0 +1,38 @@ +/** + * 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.openstack.keystone.v2_0.config; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +/** + * + * @author Adrian Cole + * + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface Authentication { + +} \ No newline at end of file diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialType.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialType.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialType.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialType.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java similarity index 99% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java index 21b1733918..5379e3f4f1 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java @@ -39,7 +39,6 @@ import org.jclouds.location.suppliers.ZoneIdToURISupplier; import org.jclouds.location.suppliers.ZoneIdsSupplier; import org.jclouds.location.suppliers.derived.RegionIdsFromRegionIdToURIKeySet; import org.jclouds.location.suppliers.derived.ZoneIdsFromZoneIdToURIKeySet; -import org.jclouds.openstack.Authentication; import org.jclouds.openstack.keystone.v2_0.AuthenticationAsyncClient; import org.jclouds.openstack.keystone.v2_0.AuthenticationClient; import org.jclouds.openstack.keystone.v2_0.domain.Access; diff --git a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneParserModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneParserModule.java similarity index 100% rename from labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneParserModule.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneParserModule.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java similarity index 97% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java index 9f6bfb4f83..a180e101d6 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java @@ -18,7 +18,7 @@ */ package org.jclouds.openstack.keystone.v2_0.config; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; /** * Configuration properties and constants used in Keystone connections. diff --git a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java similarity index 87% rename from labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java index 70b672c5cf..7a07dd6444 100644 --- a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java @@ -24,12 +24,12 @@ import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; -import org.jclouds.openstack.keystone.v2_0.AdminAsyncClient; -import org.jclouds.openstack.keystone.v2_0.AdminClient; import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncClient; import org.jclouds.openstack.keystone.v2_0.KeystoneClient; -import org.jclouds.openstack.keystone.v2_0.ServiceAsyncClient; -import org.jclouds.openstack.keystone.v2_0.ServiceClient; +import org.jclouds.openstack.keystone.v2_0.features.AdminAsyncClient; +import org.jclouds.openstack.keystone.v2_0.features.AdminClient; +import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncClient; +import org.jclouds.openstack.keystone.v2_0.features.ServiceClient; import org.jclouds.openstack.keystone.v2_0.handlers.KeystoneErrorHandler; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.config.RestClientModule; @@ -45,7 +45,8 @@ import com.google.common.collect.ImmutableMap; public class KeystoneRestClientModule extends RestClientModule { public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder() - .put(ServiceClient.class, ServiceAsyncClient.class).put(AdminClient.class, AdminAsyncClient.class) + .put(ServiceClient.class, ServiceAsyncClient.class) + .put(AdminClient.class, AdminAsyncClient.class) .build(); public KeystoneRestClientModule() { diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Access.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Access.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Access.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Access.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiAccessKeyCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiAccessKeyCredentials.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiAccessKeyCredentials.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiAccessKeyCredentials.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiMetadata.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiMetadata.java similarity index 98% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiMetadata.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiMetadata.java index 768ad8c8c5..5b78d101c3 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiMetadata.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiMetadata.java @@ -25,7 +25,7 @@ import java.util.Date; import java.util.Set; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Resource; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Endpoint.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Endpoint.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Endpoint.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Endpoint.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/MediaType.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/MediaType.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/MediaType.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/MediaType.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/PasswordCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/PasswordCredentials.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/PasswordCredentials.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/PasswordCredentials.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Role.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Role.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Role.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Role.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Service.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Service.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Service.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Service.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Tenant.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Tenant.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Tenant.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Tenant.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Token.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Token.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Token.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Token.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/User.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/User.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/User.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/User.java diff --git a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AdminAsyncClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/AdminAsyncClient.java similarity index 98% rename from labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AdminAsyncClient.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/AdminAsyncClient.java index fa58e3b901..2c259af154 100644 --- a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AdminAsyncClient.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/AdminAsyncClient.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.openstack.keystone.v2_0; +package org.jclouds.openstack.keystone.v2_0.features; import java.util.Set; @@ -28,13 +28,13 @@ import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; import org.jclouds.openstack.keystone.v2_0.domain.Role; import org.jclouds.openstack.keystone.v2_0.domain.Tenant; import org.jclouds.openstack.keystone.v2_0.domain.Token; import org.jclouds.openstack.keystone.v2_0.domain.User; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; diff --git a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AdminClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/AdminClient.java similarity index 98% rename from labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AdminClient.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/AdminClient.java index def212949f..bbaa922aba 100644 --- a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AdminClient.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/AdminClient.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.openstack.keystone.v2_0; +package org.jclouds.openstack.keystone.v2_0.features; import java.util.Set; import java.util.concurrent.TimeUnit; diff --git a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/ServiceAsyncClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceAsyncClient.java similarity index 94% rename from labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/ServiceAsyncClient.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceAsyncClient.java index 9cc665fd91..7a7f10d209 100644 --- a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/ServiceAsyncClient.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceAsyncClient.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.openstack.keystone.v2_0; +package org.jclouds.openstack.keystone.v2_0.features; import java.util.Set; @@ -25,9 +25,9 @@ import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; import org.jclouds.openstack.keystone.v2_0.domain.Tenant; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; diff --git a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/ServiceClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceClient.java similarity index 96% rename from labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/ServiceClient.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceClient.java index a09a78e3eb..604f8d3705 100644 --- a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/ServiceClient.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceClient.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.openstack.keystone.v2_0; +package org.jclouds.openstack.keystone.v2_0.features; import java.util.Set; import java.util.concurrent.TimeUnit; diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/filters/AuthenticateRequest.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/filters/AuthenticateRequest.java new file mode 100644 index 0000000000..293ab1ce13 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/filters/AuthenticateRequest.java @@ -0,0 +1,54 @@ +/** + * 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.openstack.keystone.v2_0.filters; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.http.HttpException; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpRequestFilter; +import org.jclouds.http.utils.ModifyRequest; +import org.jclouds.openstack.keystone.v2_0.config.Authentication; +import org.jclouds.openstack.v2_0.reference.AuthHeaders; + +import com.google.common.base.Supplier; + +/** + * Signs the Keystone-based request. This will update the Authentication Token before 24 hours is up. + * + * @author Adrian Cole + * + */ +@Singleton +public class AuthenticateRequest implements HttpRequestFilter { + + private final Supplier authTokenProvider; + + @Inject + public AuthenticateRequest(@Authentication Supplier authTokenProvider) { + this.authTokenProvider = authTokenProvider; + } + + @Override + public HttpRequest filter(HttpRequest request) throws HttpException { + return ModifyRequest.replaceHeader(request, AuthHeaders.AUTH_TOKEN, authTokenProvider.get()); + } + +} \ No newline at end of file diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURL.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURL.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURL.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURL.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticateApiAccessKeyCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticateApiAccessKeyCredentials.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticateApiAccessKeyCredentials.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticateApiAccessKeyCredentials.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticatePasswordCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticatePasswordCredentials.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticatePasswordCredentials.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticatePasswordCredentials.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToRegion.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToRegion.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToRegion.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToRegion.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierAdminURI.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierAdminURI.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierAdminURI.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierAdminURI.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierURI.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierURI.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierURI.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/EndpointToSupplierURI.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNull.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNull.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNull.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNull.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/RegionToAdminEndpointURI.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/RegionToAdminEndpointURI.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/RegionToAdminEndpointURI.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/RegionToAdminEndpointURI.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegion.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegion.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegion.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegion.java diff --git a/labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/KeystoneErrorHandler.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/KeystoneErrorHandler.java similarity index 100% rename from labs/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/KeystoneErrorHandler.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/KeystoneErrorHandler.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenew.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenew.java similarity index 92% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenew.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenew.java index 91fc560eaa..339dbb6d2b 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenew.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenew.java @@ -29,7 +29,6 @@ import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpRetryHandler; import org.jclouds.logging.Logger; import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.reference.AuthHeaders; import com.google.common.cache.LoadingCache; import com.google.common.collect.Multimap; @@ -62,8 +61,8 @@ public class RetryOnRenew implements HttpRetryHandler { case 401: // Do not retry on 401 from authentication request Multimap headers = command.getCurrentRequest().getHeaders(); - if (headers != null && headers.containsKey(AuthHeaders.AUTH_USER) - && headers.containsKey(AuthHeaders.AUTH_KEY) && !headers.containsKey(AuthHeaders.AUTH_TOKEN)) { + if (headers != null && headers.containsKey("X-Auth-User") + && headers.containsKey("X-Auth-Key") && !headers.containsKey("X-Auth-Token")) { retry = false; } else { byte[] content = closeClientButKeepContentStream(response); diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersionSupplier.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersionSupplier.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersionSupplier.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersionSupplier.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplier.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplier.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplier.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplier.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURISupplier.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURISupplier.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURISupplier.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURISupplier.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionSupplier.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionSupplier.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionSupplier.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionSupplier.java diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplier.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplier.java similarity index 100% rename from common/openstack/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplier.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplier.java diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/ServiceType.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/ServiceType.java new file mode 100644 index 0000000000..f4f764739f --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/ServiceType.java @@ -0,0 +1,52 @@ +/** + * 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, Name 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.openstack.v2_0; + +/** + * An OpenStack service, such as Compute (Nova), Object Storage (Swift), or Image Service (Glance). + * A service provides one or more endpoints through which users can access resources and perform + * (presumably useful) operations. + * + * @author Adrian Cole + * @see + */ +public interface ServiceType { + /** + * Object Storage (Swift) + */ + public static final String OBJECT_STORE = "object-store"; + /** + * Compute (Nova) + */ + public static final String COMPUTE = "compute"; + /** + * Image Service (Glance) + */ + public static final String IMAGE = "image"; + /** + * Identity Service (Keystone) + */ + public static final String IDENTITY = "identity"; + /** + * Network Service (Quantum) + */ + public static final String NETWORK = "network"; +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/domain/Link.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/domain/Link.java new file mode 100644 index 0000000000..521bd30c29 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/domain/Link.java @@ -0,0 +1,207 @@ +/** + * 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, Href 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.openstack.v2_0.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Objects.toStringHelper; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; +import com.google.gson.annotations.SerializedName; + +/** + * For convenience, resources contain links to themselves. This allows a client to easily obtain a + * resource URIs rather than to construct them. + * + * @author AdrianCole + * @see + */ +public class Link { + /** + * Relations associated with resources. + */ + public static enum Relation { + /** + * a versioned link to the resource. These links should be used in cases where the link will + * be followed immediately. + */ + SELF, + /** + * a permanent link to a resource that is appropriate for long term storage. + */ + BOOKMARK, + /** + * + */ + DESCRIBEDBY, + /** + * an alternate representation of the resource. For example, an OpenStack Compute image may + * have an alternate representation in the OpenStack Image service. + */ + ALTERNATE, + /** + * the value returned by the OpenStack service was not recognized. + */ + UNRECOGNIZED; + + public String value() { + return name().toLowerCase(); + } + + public static Relation fromValue(String v) { + try { + return valueOf(v.toUpperCase()); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + + } + + public static Link create(Relation relation, URI href) { + return new Link(relation, null, href); + } + + public static Link create(Relation relation,String type, URI href) { + return new Link(relation, type, href); + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromLink(this); + } + + public static class Builder { + protected Relation relation; + protected String type; + protected URI href; + + /** + * @see Link#getRelation() + */ + public Builder relation(Relation relation) { + this.relation = checkNotNull(relation, "relation"); + return this; + } + + /** + * @see Link#getType() + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * @see Link#getHref() + */ + public Builder href(URI href) { + this.href = checkNotNull(href, "href"); + return this; + } + + public Link build(){ + return new Link(relation, type, href); + } + + public Builder fromLink(Link from) { + return relation(from.getRelation()).type(from.getType()).href(from.getHref()); + } + } + + protected Link() { + // we want serializers like Gson to work w/o using sun.misc.Unsafe, + // prohibited in GAE. This also implies fields are not final. + // see http://code.google.com/p/jclouds/issues/detail?id=925 + } + + @SerializedName("rel") + protected Relation relation; + protected String type; + protected URI href; + + protected Link(Relation relation, @Nullable String type, URI href) { + this.relation = checkNotNull(relation, "relation"); + this.type = type; + this.href = checkNotNull(href, "href"); + } + + /** + * There are three kinds of link relations associated with resources. A self link contains a + * versioned link to the resource. These links should be used in cases where the link will be + * followed immediately. A bookmark link provides a permanent link to a resource that is + * appropriate for long term storage. An alternate link can contain an alternate representation + * of the resource. For example, an OpenStack Compute image may have an alternate representation + * in the OpenStack Image service. Note that the type attribute here is used to provide a hint as + * to the type of representation to expect when following the link. + * + * @return the relation of the resource in the current OpenStack deployment + */ + public Relation getRelation() { + return relation; + } + + /** + * @return the type of the resource or null if not specified + */ + @Nullable + public String getType() { + return type; + } + + /** + * @return the href of the resource + */ + public URI getHref() { + return href; + } + + @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } + if (object instanceof Link) { + final Link other = Link.class.cast(object); + return equal(relation, other.relation) && equal(type, other.type) && equal(href, other.href); + } else { + return false; + } + } + + @Override + public int hashCode() { + return Objects.hashCode(relation, type, href); + } + + @Override + public String toString() { + return toStringHelper("").add("relation", relation).add("type", type).add("href", href).toString(); + } + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/domain/Resource.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/domain/Resource.java new file mode 100644 index 0000000000..84dd35eb1f --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/domain/Resource.java @@ -0,0 +1,185 @@ +/** + * 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, Name 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.openstack.v2_0.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Collections; +import java.util.Set; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableSet; + +/** + * Resource found in a paginated collection + * + * @author AdrianCole + * @see + */ +public class Resource implements Comparable { + + public static Builder builder() { + return new ConcreteBuilder(); + } + + public Builder toBuilder() { + return new ConcreteBuilder().fromResource(this); + } + + public static abstract class Builder> { + protected abstract T self(); + + private String id; + private String name; + private Set links = ImmutableSet.of(); + + /** + * @see Resource#getId() + */ + public T id(String id) { + this.id = id; + return self(); + } + + /** + * @see Resource#getName() + */ + public T name(String name) { + this.name = name; + return self(); + } + + /** + * @see Resource#getLinks() + */ + public T links(Link... links) { + return links(ImmutableSet.copyOf(checkNotNull(links, "links"))); + } + + /** + * @see Resource#getLinks() + */ + public T links(Set links) { + this.links = links; + return self(); + } + + public Resource build() { + return new Resource(this); + } + + public T fromResource(Resource in) { + return this + .id(in.getId()) + .name(in.getName()) + .links(in.getLinks()) + ; + } + } + + private static class ConcreteBuilder extends Builder { + @Override + protected ConcreteBuilder self() { + return this; + } + } + + protected Resource() { + // we want serializers like Gson to work w/o using sun.misc.Unsafe, + // prohibited in GAE. This also implies fields are not final. + // see http://code.google.com/p/jclouds/issues/detail?id=925 + } + + private String id; + private String name; + private Set links = ImmutableSet.of(); + + protected Resource(Builder builder) { + this.id = checkNotNull(builder.id, "id"); + this.name = builder.name; + this.links = ImmutableSet.copyOf(checkNotNull(builder.links, "links")); + } + + /** + * When providing an ID, it is assumed that the resource exists in the current OpenStack + * deployment + * + * @return the id of the resource in the current OpenStack deployment + */ + public String getId() { + return id; + } + + /** + * @return the name of the resource + */ + @Nullable + public String getName() { + return name; + } + + /** + * @return the links of the id address allocated to the new server + */ + public Set getLinks() { + return Collections.unmodifiableSet(this.links); + } + + @Override + public int hashCode() { + return Objects.hashCode(id, name, links); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + Resource that = Resource.class.cast(obj); + return Objects.equal(this.getId(), that.getId()) + && Objects.equal(this.name, that.name) + && Objects.equal(this.links, that.links); + } + + protected ToStringHelper string() { + return Objects.toStringHelper("") + .add("id", getId()) + .add("name", name) + .add("links", links); + } + + @Override + public String toString() { + return string().toString(); + } + @Override + public int compareTo(Resource that) { + if (that == null) + return 1; + if (this == that) + return 0; + return this.getId().compareTo(that.getId()); + } + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/options/BaseListOptions.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/options/BaseListOptions.java new file mode 100644 index 0000000000..f21f1d047d --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/options/BaseListOptions.java @@ -0,0 +1,100 @@ +/** + * 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.openstack.v2_0.options; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; + +import java.util.Date; + +import org.jclouds.http.options.BaseHttpRequestOptions; + +/** + * Options used to control paginated results (aka list commands). + * + * @see + * @author Adrian Cole + */ +public class BaseListOptions extends BaseHttpRequestOptions { + public static final BaseListOptions NONE = new BaseListOptions(); + + /** + * Only return objects changed since this time. + */ + public BaseListOptions changesSince(Date ifModifiedSince) { + this.queryParameters.put("changes-since", checkNotNull(ifModifiedSince, "ifModifiedSince") + .getTime() + / 1000 + ""); + return this; + } + + /** + * Indicates where to begin listing. The list will only include objects that occur after the + * offset. This is convenient for pagination: To get the next page of results use the last result + * number of the current page + current page offset as the offset. + */ + public BaseListOptions startAt(long offset) { + checkState(offset >= 0, "offset must be >= 0"); + queryParameters.put("offset", Long.toString(checkNotNull(offset, "offset"))); + return this; + } + + /** + * To reduce load on the service, list operations will return a maximum of 1,000 items at a time. + * To navigate the collection, the parameters limit and offset can be set in the URI + * (e.g.?limit=0&offset=0). If an offset is given beyond the end of a list an empty list will be + * returned. + *

+ * Note that list operations never return itemNotFound (404) faults. + */ + public BaseListOptions maxResults(int limit) { + checkState(limit >= 0, "limit must be >= 0"); + checkState(limit <= 10000, "limit must be <= 10000"); + queryParameters.put("limit", Integer.toString(limit)); + return this; + } + + public static class Builder { + + /** + * @see BaseListOptions#startAt(long) + */ + public static BaseListOptions startAt(long prefix) { + BaseListOptions options = new BaseListOptions(); + return options.startAt(prefix); + } + + /** + * @see BaseListOptions#maxResults + */ + public static BaseListOptions maxResults(int maxKeys) { + BaseListOptions options = new BaseListOptions(); + return options.maxResults(maxKeys); + } + + /** + * @see BaseListOptions#changesSince(Date) + */ + public static BaseListOptions changesSince(Date since) { + BaseListOptions options = new BaseListOptions(); + return options.changesSince(since); + } + + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/predicates/LinkPredicates.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/predicates/LinkPredicates.java new file mode 100644 index 0000000000..dc5b12505f --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/predicates/LinkPredicates.java @@ -0,0 +1,103 @@ +/* + * 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.openstack.v2_0.predicates; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Link.Relation; + +import com.google.common.base.Predicate; + +/** + * Predicates handy when working with Link Types + * + * @author Adrian Cole + */ + +public class LinkPredicates { + /** + * matches links of the given relation + * + * @param rel relation of the link + * @return predicate that will match links of the given rel + */ + public static Predicate relationEquals(final Relation rel) { + checkNotNull(rel, "rel must be defined"); + + return new Predicate() { + @Override + public boolean apply(Link link) { + return rel.equals(link.getRelation()); + } + + @Override + public String toString() { + return "relEquals(" + rel + ")"; + } + }; + } + + /** + * matches links of the given href + * + * @param href + * @return predicate that will match links of the given href + */ + public static Predicate hrefEquals(final URI href) { + checkNotNull(href, "href must be defined"); + + return new Predicate() { + @Override + public boolean apply(Link link) { + return href.equals(link.getHref()); + } + + @Override + public String toString() { + return "hrefEquals(" + href + ")"; + } + }; + } + + /** + * matches links of the given type + * + * @param type + * ex. application/pdf + * @return predicate that will match links of the given type + */ + public static Predicate typeEquals(final String type) { + checkNotNull(type, "type must be defined"); + + return new Predicate() { + @Override + public boolean apply(Link link) { + return type.equals(link.getType()); + } + + @Override + public String toString() { + return "typeEquals(" + type + ")"; + } + }; + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/reference/AuthHeaders.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/reference/AuthHeaders.java new file mode 100644 index 0000000000..900e19e98a --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/reference/AuthHeaders.java @@ -0,0 +1,31 @@ +/** + * 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.openstack.v2_0.reference; + +/** + * @author Adrian Cole + * + */ +public interface AuthHeaders { + + public static final String AUTH_USER = "X-Auth-User"; + public static final String AUTH_KEY = "X-Auth-Key"; + public static final String AUTH_TOKEN = "X-Auth-Token"; + +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/Compute.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/Compute.java new file mode 100644 index 0000000000..1b2a932b47 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/Compute.java @@ -0,0 +1,43 @@ +/** + * 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.openstack.v2_0.services; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import org.jclouds.openstack.v2_0.ServiceType; + +/** + * Compute (Nova) + * + * @author Adrian Cole + * @see + * @see ServiceType#COMPUTE + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface Compute { + +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/Extension.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/Extension.java new file mode 100644 index 0000000000..4425814196 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/Extension.java @@ -0,0 +1,79 @@ +/** + * 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.openstack.v2_0.services; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import org.jclouds.openstack.v2_0.ServiceType; + +/** + * An extension of a {@link ServiceType service}. In order for us to understand + * the context of the extension, we must consider the extensions call. + * + *
+ * For our purposes, the minimal context of an extension is the type of the + * service it extends ex. {@link ServiceType#COMPUTE}, and its namespace ex. http://docs.openstack.org + * /ext/keypairs/api/v1.1. + * + * @author Adrian Cole + * + * @see ServiceType + * @see + * @see + * @see + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface Extension { + + /** + * the service type this is an extension of. + * + *

note

+ * + * This isn't necessarily one of the built-in {@link ServiceType services}, + * it could be an extension of a custom service. + * + * @return the service type this is an extension of. + * + */ + String of(); + + /** + * namespace ex. http + * ://docs.openstack.org /ext/keypairs/api/v1.1. + * + * @return the namespace of the extension + */ + String namespace(); + +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/Image.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/Image.java new file mode 100644 index 0000000000..0baad0bb1d --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/Image.java @@ -0,0 +1,43 @@ +/** + * 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.openstack.v2_0.services; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import org.jclouds.openstack.v2_0.ServiceType; + +/** + * Image Service (Glance) + * + * @author Adrian Cole + * @see + * @see ServiceType#IMAGE + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface Image { + +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/ObjectStore.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/ObjectStore.java new file mode 100644 index 0000000000..e271ddb1c3 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/v2_0/services/ObjectStore.java @@ -0,0 +1,43 @@ +/** + * 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.openstack.v2_0.services; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import org.jclouds.openstack.v2_0.ServiceType; + +/** + * Object Storage (Swift) + * + * @author Adrian Cole + * @see + * @see ServiceType#OBJECT_STORE + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface ObjectStore { + +} \ No newline at end of file diff --git a/labs/openstack-keystone/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/apis/openstack-keystone/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata similarity index 100% rename from labs/openstack-keystone/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata rename to apis/openstack-keystone/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata diff --git a/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/AdminClientExpectTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/AdminClientExpectTest.java similarity index 99% rename from labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/AdminClientExpectTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/AdminClientExpectTest.java index 16753c99a7..9ca48068c4 100644 --- a/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/AdminClientExpectTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/AdminClientExpectTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.openstack.keystone.v2_0; +package org.jclouds.openstack.keystone.v2_0.features; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.testng.Assert.assertEquals; @@ -31,7 +31,7 @@ import java.util.Set; import org.jclouds.date.DateService; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.http.HttpResponseException; -import org.jclouds.openstack.domain.Link; +import org.jclouds.openstack.keystone.v2_0.KeystoneClient; import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; import org.jclouds.openstack.keystone.v2_0.domain.MediaType; @@ -40,6 +40,7 @@ import org.jclouds.openstack.keystone.v2_0.domain.Tenant; import org.jclouds.openstack.keystone.v2_0.domain.Token; import org.jclouds.openstack.keystone.v2_0.domain.User; import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest; +import org.jclouds.openstack.v2_0.domain.Link; import org.jclouds.rest.AuthorizationException; import org.testng.annotations.Test; diff --git a/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/AdminClientLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/AdminClientLiveTest.java similarity index 96% rename from labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/AdminClientLiveTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/AdminClientLiveTest.java index 82ab9fc504..62db6cd514 100644 --- a/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/AdminClientLiveTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/AdminClientLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.openstack.keystone.v2_0; +package org.jclouds.openstack.keystone.v2_0.features; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; @@ -28,15 +28,14 @@ import java.net.URI; import java.util.Set; import org.jclouds.http.HttpRequest; -import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; import org.jclouds.openstack.keystone.v2_0.domain.Role; import org.jclouds.openstack.keystone.v2_0.domain.Tenant; import org.jclouds.openstack.keystone.v2_0.domain.Token; import org.jclouds.openstack.keystone.v2_0.domain.User; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneClientLiveTest; -import org.jclouds.openstack.reference.AuthHeaders; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -57,7 +56,7 @@ public class AdminClientLiveTest extends BaseKeystoneClientLiveTest { public void grabToken() { AuthenticateRequest ar = keystoneContext.getUtils().getInjector().getInstance(AuthenticateRequest.class); HttpRequest test = ar.filter(HttpRequest.builder().method("GET").endpoint(URI.create(endpoint)).build()); - token = Iterables.getOnlyElement(test.getHeaders().get(AuthHeaders.AUTH_TOKEN)); + token = Iterables.getOnlyElement(test.getHeaders().get("X-Auth-Token")); } public void testGetApiMetaData() { diff --git a/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/UserClientExpectTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/UserClientExpectTest.java similarity index 96% rename from labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/UserClientExpectTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/UserClientExpectTest.java index 016b972b5c..d6e8504ecc 100644 --- a/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/UserClientExpectTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/UserClientExpectTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.openstack.keystone.v2_0; +package org.jclouds.openstack.keystone.v2_0.features; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.testng.Assert.assertEquals; @@ -29,11 +29,12 @@ import java.util.Set; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.openstack.domain.Link; +import org.jclouds.openstack.keystone.v2_0.KeystoneClient; import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; import org.jclouds.openstack.keystone.v2_0.domain.MediaType; import org.jclouds.openstack.keystone.v2_0.domain.Tenant; import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest; +import org.jclouds.openstack.v2_0.domain.Link; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; diff --git a/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/UserClientLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/UserClientLiveTest.java similarity index 97% rename from labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/UserClientLiveTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/UserClientLiveTest.java index 75788d0359..c1cf75acee 100644 --- a/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/UserClientLiveTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/UserClientLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.openstack.keystone.v2_0; +package org.jclouds.openstack.keystone.v2_0.features; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; diff --git a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURLTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURLTest.java similarity index 100% rename from common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURLTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/AdminURLTest.java diff --git a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNullTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNullTest.java similarity index 100% rename from common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNullTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/PublicURLOrInternalIfNullTest.java diff --git a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionTest.java similarity index 100% rename from common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionTest.java diff --git a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenewTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenewTest.java similarity index 100% rename from common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenewTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/handlers/RetryOnRenewTest.java diff --git a/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneClientLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneClientLiveTest.java similarity index 100% rename from labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneClientLiveTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneClientLiveTest.java diff --git a/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestClientExpectTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestClientExpectTest.java similarity index 98% rename from labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestClientExpectTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestClientExpectTest.java index a4ff58b447..102090a500 100644 --- a/labs/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestClientExpectTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestClientExpectTest.java @@ -27,7 +27,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.rest.internal.BaseRestClientExpectTest; import com.google.common.base.Objects; diff --git a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/KeystoneFixture.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/KeystoneFixture.java similarity index 100% rename from common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/KeystoneFixture.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/KeystoneFixture.java diff --git a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseAccessTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseAccessTest.java similarity index 100% rename from common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseAccessTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseAccessTest.java diff --git a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseApiMetadataTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseApiMetadataTest.java similarity index 98% rename from common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseApiMetadataTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseApiMetadataTest.java index a49337f776..df44b6d504 100644 --- a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseApiMetadataTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseApiMetadataTest.java @@ -25,8 +25,8 @@ import javax.ws.rs.core.MediaType; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; -import org.jclouds.openstack.domain.Link; import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; +import org.jclouds.openstack.v2_0.domain.Link; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplierTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplierTest.java similarity index 100% rename from common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplierTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplierTest.java diff --git a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionSupplierTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionSupplierTest.java similarity index 100% rename from common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionSupplierTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionSupplierTest.java diff --git a/common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplierTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplierTest.java similarity index 100% rename from common/openstack/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplierTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplierTest.java diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/options/BaseListOptionsTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/options/BaseListOptionsTest.java new file mode 100644 index 0000000000..5387aec178 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/options/BaseListOptionsTest.java @@ -0,0 +1,77 @@ +/** + * 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.openstack.v2_0.options; + +import static org.jclouds.openstack.v2_0.options.BaseListOptions.Builder.changesSince; +import static org.jclouds.openstack.v2_0.options.BaseListOptions.Builder.maxResults; +import static org.jclouds.openstack.v2_0.options.BaseListOptions.Builder.startAt; +import static org.testng.Assert.assertEquals; + +import java.util.Date; + +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; + +/** + * Tests behavior of {@code ListOptions} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class BaseListOptionsTest { + + public void testChangesSince() { + Date ifModifiedSince = new Date(); + BaseListOptions options = new BaseListOptions().changesSince(ifModifiedSince); + assertEquals(ImmutableList.of(ifModifiedSince.getTime() / 1000 + ""), options + .buildQueryParameters().get("changes-since")); + } + + public void testStartAt() { + long offset = 1; + BaseListOptions options = new BaseListOptions().startAt(offset); + assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("offset")); + } + + public void testMaxResults() { + int limit = 1; + BaseListOptions options = new BaseListOptions().maxResults(limit); + assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("limit")); + } + + public void testChangesSinceStatic() { + Date ifModifiedSince = new Date(); + BaseListOptions options = changesSince(ifModifiedSince); + assertEquals(ImmutableList.of(ifModifiedSince.getTime() / 1000 + ""), options + .buildQueryParameters().get("changes-since")); + } + + public void testStartAtStatic() { + long offset = 1; + BaseListOptions options = startAt(offset); + assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("offset")); + } + + public void testMaxResultsStatic() { + int limit = 1; + BaseListOptions options = maxResults(limit); + assertEquals(ImmutableList.of("1"), options.buildQueryParameters().get("limit")); + } +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/predicates/LinkPredicatesTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/predicates/LinkPredicatesTest.java new file mode 100644 index 0000000000..7160e36dff --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/v2_0/predicates/LinkPredicatesTest.java @@ -0,0 +1,51 @@ +package org.jclouds.openstack.v2_0.predicates; + +import static org.jclouds.openstack.v2_0.predicates.LinkPredicates.hrefEquals; +import static org.jclouds.openstack.v2_0.predicates.LinkPredicates.relationEquals; +import static org.jclouds.openstack.v2_0.predicates.LinkPredicates.typeEquals; + +import java.net.URI; + +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Link.Relation; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "LinkPredicatesTest") +public class LinkPredicatesTest { + Link ref = Link.builder().type("application/pdf").relation(Relation.DESCRIBEDBY).href( + URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1")).build(); + + @Test + public void testRelationEqualsWhenEqual() { + assert relationEquals(Relation.DESCRIBEDBY).apply(ref); + } + + @Test + public void testRelationEqualsWhenNotEqual() { + assert !relationEquals(Relation.UNRECOGNIZED).apply(ref); + } + + @Test + public void testTypeEqualsWhenEqual() { + assert typeEquals("application/pdf").apply(ref); + } + + @Test + public void testTypeEqualsWhenNotEqual() { + assert !typeEquals("foo").apply(ref); + } + + @Test + public void testHrefEqualsWhenEqual() { + assert hrefEquals(URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1")).apply(ref); + } + + @Test + public void testHrefEqualsWhenNotEqual() { + assert !hrefEquals(URI.create("foo")).apply(ref); + } +} diff --git a/common/openstack/src/test/resources/apiMetadataResponse.json b/apis/openstack-keystone/src/test/resources/apiMetadataResponse.json similarity index 100% rename from common/openstack/src/test/resources/apiMetadataResponse.json rename to apis/openstack-keystone/src/test/resources/apiMetadataResponse.json diff --git a/labs/openstack-keystone/src/test/resources/api_metadata.json b/apis/openstack-keystone/src/test/resources/api_metadata.json similarity index 100% rename from labs/openstack-keystone/src/test/resources/api_metadata.json rename to apis/openstack-keystone/src/test/resources/api_metadata.json diff --git a/common/openstack/src/test/resources/keystoneAuthResponse.json b/apis/openstack-keystone/src/test/resources/keystoneAuthResponse.json similarity index 100% rename from common/openstack/src/test/resources/keystoneAuthResponse.json rename to apis/openstack-keystone/src/test/resources/keystoneAuthResponse.json diff --git a/common/openstack/src/test/resources/keystoneAuthResponse_trystack.json b/apis/openstack-keystone/src/test/resources/keystoneAuthResponse_trystack.json similarity index 100% rename from common/openstack/src/test/resources/keystoneAuthResponse_trystack.json rename to apis/openstack-keystone/src/test/resources/keystoneAuthResponse_trystack.json diff --git a/labs/openstack-keystone/src/test/resources/logback.xml b/apis/openstack-keystone/src/test/resources/logback.xml similarity index 63% rename from labs/openstack-keystone/src/test/resources/logback.xml rename to apis/openstack-keystone/src/test/resources/logback.xml index a4f81d3fa6..8f628c3c44 100644 --- a/labs/openstack-keystone/src/test/resources/logback.xml +++ b/apis/openstack-keystone/src/test/resources/logback.xml @@ -1,51 +1,64 @@ - - - - target/test-data/jclouds.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-wire.log - - - %d %-5p [%c] [%thread] %m%n - - - - - target/test-data/jclouds-blobstore.log - - - %d %-5p [%c] [%thread] %m%n - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + target/test-data/jclouds.log + + + %d %-5p [%c] [%thread] %m%n + + + + + target/test-data/jclouds-wire.log + + + %d %-5p [%c] [%thread] %m%n + + + + + target/test-data/jclouds-compute.log + + + %d %-5p [%c] [%thread] %m%n + + + + + target/test-data/jclouds-ssh.log + + + %d %-5p [%c] [%thread] %m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/labs/openstack-keystone/src/test/resources/tenant_details.json b/apis/openstack-keystone/src/test/resources/tenant_details.json similarity index 100% rename from labs/openstack-keystone/src/test/resources/tenant_details.json rename to apis/openstack-keystone/src/test/resources/tenant_details.json diff --git a/labs/openstack-keystone/src/test/resources/tenant_list.json b/apis/openstack-keystone/src/test/resources/tenant_list.json similarity index 100% rename from labs/openstack-keystone/src/test/resources/tenant_list.json rename to apis/openstack-keystone/src/test/resources/tenant_list.json diff --git a/labs/openstack-keystone/src/test/resources/token_details.json b/apis/openstack-keystone/src/test/resources/token_details.json similarity index 100% rename from labs/openstack-keystone/src/test/resources/token_details.json rename to apis/openstack-keystone/src/test/resources/token_details.json diff --git a/labs/openstack-keystone/src/test/resources/user_details.json b/apis/openstack-keystone/src/test/resources/user_details.json similarity index 100% rename from labs/openstack-keystone/src/test/resources/user_details.json rename to apis/openstack-keystone/src/test/resources/user_details.json diff --git a/labs/openstack-keystone/src/test/resources/user_endpoints.json b/apis/openstack-keystone/src/test/resources/user_endpoints.json similarity index 100% rename from labs/openstack-keystone/src/test/resources/user_endpoints.json rename to apis/openstack-keystone/src/test/resources/user_endpoints.json diff --git a/labs/openstack-keystone/src/test/resources/user_list.json b/apis/openstack-keystone/src/test/resources/user_list.json similarity index 100% rename from labs/openstack-keystone/src/test/resources/user_list.json rename to apis/openstack-keystone/src/test/resources/user_list.json diff --git a/labs/openstack-keystone/src/test/resources/user_role_list.json b/apis/openstack-keystone/src/test/resources/user_role_list.json similarity index 100% rename from labs/openstack-keystone/src/test/resources/user_role_list.json rename to apis/openstack-keystone/src/test/resources/user_role_list.json diff --git a/labs/openstack-keystone/src/test/resources/user_tenant_role_list.json b/apis/openstack-keystone/src/test/resources/user_tenant_role_list.json similarity index 100% rename from labs/openstack-keystone/src/test/resources/user_tenant_role_list.json rename to apis/openstack-keystone/src/test/resources/user_tenant_role_list.json diff --git a/apis/openstack-nova/pom.xml b/apis/openstack-nova/pom.xml index 478c13c04d..49978653f6 100644 --- a/apis/openstack-nova/pom.xml +++ b/apis/openstack-nova/pom.xml @@ -58,8 +58,8 @@ - org.jclouds.common - openstack-common + org.jclouds.api + openstack-keystone ${project.version} @@ -75,8 +75,8 @@ test - org.jclouds.common - openstack-common + org.jclouds.api + openstack-keystone ${project.version} test-jar test diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java index 570fa8b7ce..870db664d8 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java @@ -19,6 +19,7 @@ package org.jclouds.openstack.nova.v1_1; import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; +import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.VERSION; import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS; import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_GENERATE_KEYPAIRS; import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.TIMEOUT_SECURITYGROUP_PRESENT; @@ -28,10 +29,9 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; import org.jclouds.openstack.nova.v1_1.compute.config.NovaComputeServiceContextModule; import org.jclouds.openstack.nova.v1_1.config.NovaRestClientModule; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.BaseRestApiMetadata; @@ -74,7 +74,7 @@ public class NovaApiMetadata extends BaseRestApiMetadata { properties.setProperty(SERVICE_TYPE, ServiceType.COMPUTE); // TODO: this doesn't actually do anything yet. - properties.setProperty(KeystoneProperties.VERSION, "2.0"); + properties.setProperty(VERSION, "2.0"); properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "false"); properties.setProperty(AUTO_GENERATE_KEYPAIRS, "false"); diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaAsyncClient.java index fc5ab0364d..10de3b2fc3 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaAsyncClient.java @@ -23,7 +23,20 @@ import java.util.Set; import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.Zone; import org.jclouds.location.functions.ZoneToEndpoint; -import org.jclouds.openstack.nova.v1_1.extensions.*; +import org.jclouds.openstack.nova.v1_1.extensions.AdminActionsAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.FlavorExtraSpecsAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.FloatingIPAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.HostAdministrationAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.HostAggregateAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.KeyPairAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.QuotaAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.QuotaClassAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.SecurityGroupAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.ServerWithSecurityGroupsAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.SimpleTenantUsageAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.VirtualInterfaceAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.VolumeAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.VolumeTypeAsyncClient; import org.jclouds.openstack.nova.v1_1.features.ExtensionAsyncClient; import org.jclouds.openstack.nova.v1_1.features.FlavorAsyncClient; import org.jclouds.openstack.nova.v1_1.features.ImageAsyncClient; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaClient.java index d7ca6c2081..7f692c639f 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaClient.java @@ -25,7 +25,20 @@ import org.jclouds.concurrent.Timeout; import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.Zone; import org.jclouds.location.functions.ZoneToEndpoint; -import org.jclouds.openstack.nova.v1_1.extensions.*; +import org.jclouds.openstack.nova.v1_1.extensions.AdminActionsClient; +import org.jclouds.openstack.nova.v1_1.extensions.FlavorExtraSpecsClient; +import org.jclouds.openstack.nova.v1_1.extensions.FloatingIPClient; +import org.jclouds.openstack.nova.v1_1.extensions.HostAdministrationClient; +import org.jclouds.openstack.nova.v1_1.extensions.HostAggregateClient; +import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClient; +import org.jclouds.openstack.nova.v1_1.extensions.QuotaClassClient; +import org.jclouds.openstack.nova.v1_1.extensions.QuotaClient; +import org.jclouds.openstack.nova.v1_1.extensions.SecurityGroupClient; +import org.jclouds.openstack.nova.v1_1.extensions.ServerWithSecurityGroupsClient; +import org.jclouds.openstack.nova.v1_1.extensions.SimpleTenantUsageClient; +import org.jclouds.openstack.nova.v1_1.extensions.VirtualInterfaceClient; +import org.jclouds.openstack.nova.v1_1.extensions.VolumeClient; +import org.jclouds.openstack.nova.v1_1.extensions.VolumeTypeClient; import org.jclouds.openstack.nova.v1_1.features.ExtensionClient; import org.jclouds.openstack.nova.v1_1.features.FlavorClient; import org.jclouds.openstack.nova.v1_1.features.ImageClient; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java index 231b5be658..b9bfa0ac86 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java @@ -35,7 +35,34 @@ import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.openstack.nova.v1_1.domain.Extension; -import org.jclouds.openstack.nova.v1_1.extensions.*; +import org.jclouds.openstack.nova.v1_1.extensions.AdminActionsAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.AdminActionsClient; +import org.jclouds.openstack.nova.v1_1.extensions.FlavorExtraSpecsAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.FlavorExtraSpecsClient; +import org.jclouds.openstack.nova.v1_1.extensions.FloatingIPAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.FloatingIPClient; +import org.jclouds.openstack.nova.v1_1.extensions.HostAdministrationAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.HostAdministrationClient; +import org.jclouds.openstack.nova.v1_1.extensions.HostAggregateAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.HostAggregateClient; +import org.jclouds.openstack.nova.v1_1.extensions.KeyPairAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClient; +import org.jclouds.openstack.nova.v1_1.extensions.QuotaAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.QuotaClassAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.QuotaClassClient; +import org.jclouds.openstack.nova.v1_1.extensions.QuotaClient; +import org.jclouds.openstack.nova.v1_1.extensions.SecurityGroupAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.SecurityGroupClient; +import org.jclouds.openstack.nova.v1_1.extensions.ServerWithSecurityGroupsAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.ServerWithSecurityGroupsClient; +import org.jclouds.openstack.nova.v1_1.extensions.SimpleTenantUsageAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.SimpleTenantUsageClient; +import org.jclouds.openstack.nova.v1_1.extensions.VirtualInterfaceAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.VirtualInterfaceClient; +import org.jclouds.openstack.nova.v1_1.extensions.VolumeAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.VolumeClient; +import org.jclouds.openstack.nova.v1_1.extensions.VolumeTypeAsyncClient; +import org.jclouds.openstack.nova.v1_1.extensions.VolumeTypeClient; import org.jclouds.openstack.nova.v1_1.features.ExtensionAsyncClient; import org.jclouds.openstack.nova.v1_1.features.ExtensionClient; import org.jclouds.openstack.nova.v1_1.features.FlavorAsyncClient; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Extension.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Extension.java index 25d2a922d0..7242b5afb5 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Extension.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Extension.java @@ -21,7 +21,7 @@ package org.jclouds.openstack.nova.v1_1.domain; import java.net.URI; import java.util.Date; -import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Resource; import com.google.common.base.Objects; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Flavor.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Flavor.java index 9aa94c14cc..1746539803 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Flavor.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Flavor.java @@ -18,7 +18,7 @@ */ package org.jclouds.openstack.nova.v1_1.domain; -import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Resource; import com.google.common.base.Objects; import com.google.common.base.Optional; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/HostAggregate.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/HostAggregate.java index b3e018ce52..13e1d176be 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/HostAggregate.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/HostAggregate.java @@ -26,8 +26,8 @@ import java.util.Map; import java.util.Set; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Optional; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.gson.annotations.SerializedName; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Image.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Image.java index dc374b8b57..a6292fdf59 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Image.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Image.java @@ -21,7 +21,7 @@ package org.jclouds.openstack.nova.v1_1.domain; import java.util.Date; import java.util.Map; -import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Resource; import com.google.common.base.Objects; import com.google.common.base.Predicates; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java index 376cc5eaea..d973dd2d14 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/Server.java @@ -25,8 +25,8 @@ import java.util.Map; import java.util.Set; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.domain.Resource; import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClient; +import org.jclouds.openstack.v2_0.domain.Resource; import org.jclouds.util.Multimaps2; import com.google.common.base.Optional; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/ServerCreated.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/ServerCreated.java index 6ca7505385..3ef956913b 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/ServerCreated.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/ServerCreated.java @@ -18,7 +18,7 @@ */ package org.jclouds.openstack.nova.v1_1.domain; -import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Resource; import com.google.common.base.Objects.ToStringHelper; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/VolumeType.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/VolumeType.java index 9fe73ef01e..796f3d5087 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/VolumeType.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/domain/VolumeType.java @@ -25,8 +25,8 @@ import java.util.Date; import java.util.Map; import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Optional; +import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableMap; import com.google.gson.annotations.SerializedName; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/AdminActionsAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/AdminActionsAsyncClient.java index 94cf140cf6..3801641704 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/AdminActionsAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/AdminActionsAsyncClient.java @@ -25,12 +25,12 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.BackupType; import org.jclouds.openstack.nova.v1_1.functions.ParseImageIdFromLocationHeader; import org.jclouds.openstack.nova.v1_1.options.CreateBackupOfServerOptions; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.Payload; import org.jclouds.rest.annotations.PayloadParam; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/AdminActionsClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/AdminActionsClient.java index 1c0ae5c3f6..28fd956db5 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/AdminActionsClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/AdminActionsClient.java @@ -23,8 +23,8 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.openstack.nova.v1_1.domain.BackupType; import org.jclouds.openstack.nova.v1_1.options.CreateBackupOfServerOptions; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; /** * Provide additional actions for servers: diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FlavorExtraSpecsAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FlavorExtraSpecsAsyncClient.java index 24ea199e4a..d86eec2aac 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FlavorExtraSpecsAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FlavorExtraSpecsAsyncClient.java @@ -32,9 +32,9 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jclouds.concurrent.Timeout; -import org.jclouds.openstack.filters.AuthenticateRequest; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.Payload; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FlavorExtraSpecsClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FlavorExtraSpecsClient.java index 01f0fb0847..f9c80c0649 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FlavorExtraSpecsClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FlavorExtraSpecsClient.java @@ -22,9 +22,9 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; -import org.jclouds.openstack.filters.AuthenticateRequest; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.RequestFilters; /** diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPAsyncClient.java index b25517d138..6c96f8a00b 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPAsyncClient.java @@ -29,11 +29,11 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.FloatingIP; import org.jclouds.openstack.nova.v1_1.features.ExtensionAsyncClient; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.Payload; import org.jclouds.rest.annotations.PayloadParam; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClient.java index caab0d5d1a..768ba9c0d7 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/FloatingIPClient.java @@ -23,8 +23,8 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.openstack.nova.v1_1.domain.FloatingIP; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; /** * Provides synchronous access to Floating IPs. diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAdministrationAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAdministrationAsyncClient.java index 93c9e32eb2..6758c67afd 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAdministrationAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAdministrationAsyncClient.java @@ -28,7 +28,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.Host; import org.jclouds.openstack.nova.v1_1.domain.HostResourceUsage; import org.jclouds.openstack.nova.v1_1.functions.FieldValueResponseParsers.MaintenanceModeDisabledResponseParser; @@ -38,8 +38,8 @@ import org.jclouds.openstack.nova.v1_1.functions.FieldValueResponseParsers.Power import org.jclouds.openstack.nova.v1_1.functions.FieldValueResponseParsers.PowerIsStartupResponseParser; import org.jclouds.openstack.nova.v1_1.functions.FieldValueResponseParsers.StatusDisabledResponseParser; import org.jclouds.openstack.nova.v1_1.functions.FieldValueResponseParsers.StatusEnabledResponseParser; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.Payload; import org.jclouds.rest.annotations.RequestFilters; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAdministrationClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAdministrationClient.java index 1e43480a97..b216930644 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAdministrationClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAdministrationClient.java @@ -24,8 +24,8 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.openstack.nova.v1_1.domain.Host; import org.jclouds.openstack.nova.v1_1.domain.HostResourceUsage; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; /** * Provides asynchronous access to Host Administration features via the REST API. diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAggregateAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAggregateAsyncClient.java index d5b492e649..6ebc533ad4 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAggregateAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAggregateAsyncClient.java @@ -32,10 +32,10 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jclouds.concurrent.Timeout; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.HostAggregate; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAggregateClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAggregateClient.java index 2548e2e301..c3f9e3c906 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAggregateClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/HostAggregateClient.java @@ -23,10 +23,10 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.HostAggregate; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.RequestFilters; /** diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairAsyncClient.java index 415a1490e9..0900524984 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairAsyncClient.java @@ -30,11 +30,11 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.KeyPair; import org.jclouds.openstack.nova.v1_1.features.ExtensionAsyncClient; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.Payload; import org.jclouds.rest.annotations.PayloadParam; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClient.java index 73a8c5ea76..5b1c1a4303 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/KeyPairClient.java @@ -24,8 +24,8 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.openstack.nova.v1_1.domain.KeyPair; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; /** * Provides synchronous access to Security Groups. diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaAsyncClient.java index f1e042fc80..7047cf5eaf 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaAsyncClient.java @@ -29,10 +29,10 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jclouds.concurrent.Timeout; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.Quotas; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.PayloadParam; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassAsyncClient.java index d307044c53..3a0cec28b4 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassAsyncClient.java @@ -29,16 +29,15 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jclouds.concurrent.Timeout; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.QuotaClass; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.annotations.WrapWith; import org.jclouds.rest.binders.BindToJsonPayload; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassClient.java index b4c3c8666b..93cb604307 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassClient.java @@ -21,11 +21,10 @@ package org.jclouds.openstack.nova.v1_1.extensions; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.QuotaClass; -import org.jclouds.openstack.nova.v1_1.domain.Quotas; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.RequestFilters; /** diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClient.java index e5ab08c73b..d47d8543fc 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClient.java @@ -21,10 +21,10 @@ package org.jclouds.openstack.nova.v1_1.extensions; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.Quotas; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.RequestFilters; /** diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupAsyncClient.java index 718ad18ce9..f001fd8b1a 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupAsyncClient.java @@ -29,13 +29,13 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.binders.BindSecurityGroupRuleToJsonPayload; import org.jclouds.openstack.nova.v1_1.domain.Ingress; import org.jclouds.openstack.nova.v1_1.domain.SecurityGroup; import org.jclouds.openstack.nova.v1_1.domain.SecurityGroupRule; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.Payload; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClient.java index f209417ce0..678bc246df 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SecurityGroupClient.java @@ -25,8 +25,8 @@ import org.jclouds.concurrent.Timeout; import org.jclouds.openstack.nova.v1_1.domain.Ingress; import org.jclouds.openstack.nova.v1_1.domain.SecurityGroup; import org.jclouds.openstack.nova.v1_1.domain.SecurityGroupRule; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; /** * Provides synchronous access to Security Groups. diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/ServerWithSecurityGroupsAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/ServerWithSecurityGroupsAsyncClient.java index 423d7ec97c..927ea7c51a 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/ServerWithSecurityGroupsAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/ServerWithSecurityGroupsAsyncClient.java @@ -24,10 +24,10 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.ServerWithSecurityGroups; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/ServerWithSecurityGroupsClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/ServerWithSecurityGroupsClient.java index 3fab8ec83b..cdf1b049f0 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/ServerWithSecurityGroupsClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/ServerWithSecurityGroupsClient.java @@ -22,8 +22,8 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.openstack.nova.v1_1.domain.ServerWithSecurityGroups; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; /** * Provides synchronous access to Server details including security group, referred to as the CREATESERVEREXT extension diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageAsyncClient.java index 4e2e2b80cf..1eb86ec163 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageAsyncClient.java @@ -26,10 +26,10 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.SimpleTenantUsage; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageClient.java index dcef9aafde..334bc180e2 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageClient.java @@ -23,8 +23,8 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.openstack.nova.v1_1.domain.SimpleTenantUsage; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; /** * Provides asynchronous access to Simple Tenant Usage via the REST API. diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VirtualInterfaceAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VirtualInterfaceAsyncClient.java index 4cd07f6737..8a258346b0 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VirtualInterfaceAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VirtualInterfaceAsyncClient.java @@ -26,10 +26,10 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.VirtualInterface; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VirtualInterfaceClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VirtualInterfaceClient.java index acf7692228..56688df397 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VirtualInterfaceClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VirtualInterfaceClient.java @@ -23,8 +23,8 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.openstack.nova.v1_1.domain.VirtualInterface; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; /** * Provides synchronous access to Virtual Interface features (VIFs). diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeAsyncClient.java index 33039a0a7b..7e6e0532bc 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeAsyncClient.java @@ -29,17 +29,16 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.Volume; import org.jclouds.openstack.nova.v1_1.domain.VolumeAttachment; import org.jclouds.openstack.nova.v1_1.domain.VolumeSnapshot; import org.jclouds.openstack.nova.v1_1.options.CreateVolumeOptions; import org.jclouds.openstack.nova.v1_1.options.CreateVolumeSnapshotOptions; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.Payload; import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeClient.java index b4b9c66eee..5b6d72cc99 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeClient.java @@ -27,8 +27,8 @@ import org.jclouds.openstack.nova.v1_1.domain.VolumeAttachment; import org.jclouds.openstack.nova.v1_1.domain.VolumeSnapshot; import org.jclouds.openstack.nova.v1_1.options.CreateVolumeOptions; import org.jclouds.openstack.nova.v1_1.options.CreateVolumeSnapshotOptions; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; /** * Provides synchronous access to Volumes. diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeTypeAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeTypeAsyncClient.java index dd7caf5ef7..4f190997a2 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeTypeAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeTypeAsyncClient.java @@ -31,11 +31,11 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.VolumeType; import org.jclouds.openstack.nova.v1_1.options.CreateVolumeTypeOptions; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.Payload; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeTypeClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeTypeClient.java index 39a1695bc3..d8992da616 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeTypeClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/extensions/VolumeTypeClient.java @@ -23,11 +23,11 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.VolumeType; import org.jclouds.openstack.nova.v1_1.options.CreateVolumeTypeOptions; -import org.jclouds.openstack.services.Extension; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; +import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.RequestFilters; /** diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ExtensionAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ExtensionAsyncClient.java index 37d099b85a..a051c81a28 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ExtensionAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ExtensionAsyncClient.java @@ -26,7 +26,7 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.Extension; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.RequestFilters; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FlavorAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FlavorAsyncClient.java index 887b7a7d90..00adfc8135 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FlavorAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FlavorAsyncClient.java @@ -26,9 +26,9 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.domain.Resource; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.Flavor; +import org.jclouds.openstack.v2_0.domain.Resource; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FlavorClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FlavorClient.java index 12780ce772..f3d1fa320c 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FlavorClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/FlavorClient.java @@ -22,8 +22,8 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; -import org.jclouds.openstack.domain.Resource; import org.jclouds.openstack.nova.v1_1.domain.Flavor; +import org.jclouds.openstack.v2_0.domain.Resource; /** * Provides asynchronous access to Flavors via their REST API. diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ImageAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ImageAsyncClient.java index baa1806fa2..784d08881a 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ImageAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ImageAsyncClient.java @@ -27,9 +27,9 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.domain.Resource; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.Image; +import org.jclouds.openstack.v2_0.domain.Resource; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ImageClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ImageClient.java index 9376901d7c..5c91cc24d2 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ImageClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ImageClient.java @@ -22,8 +22,8 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; -import org.jclouds.openstack.domain.Resource; import org.jclouds.openstack.nova.v1_1.domain.Image; +import org.jclouds.openstack.v2_0.domain.Resource; /** * Provides synchronous access to Images. diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerAsyncClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerAsyncClient.java index 93dbaea18b..0189dbc2b3 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerAsyncClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerAsyncClient.java @@ -30,14 +30,14 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.domain.Resource; -import org.jclouds.openstack.filters.AuthenticateRequest; -import org.jclouds.openstack.nova.v1_1.domain.ServerCreated; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v1_1.domain.RebootType; import org.jclouds.openstack.nova.v1_1.domain.Server; +import org.jclouds.openstack.nova.v1_1.domain.ServerCreated; import org.jclouds.openstack.nova.v1_1.functions.ParseImageIdFromLocationHeader; import org.jclouds.openstack.nova.v1_1.options.CreateServerOptions; import org.jclouds.openstack.nova.v1_1.options.RebuildServerOptions; +import org.jclouds.openstack.v2_0.domain.Resource; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.MapBinder; import org.jclouds.rest.annotations.Payload; diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerClient.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerClient.java index 064d05eed2..1fb3cb3a96 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerClient.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/features/ServerClient.java @@ -22,12 +22,12 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; -import org.jclouds.openstack.domain.Resource; -import org.jclouds.openstack.nova.v1_1.domain.ServerCreated; import org.jclouds.openstack.nova.v1_1.domain.RebootType; import org.jclouds.openstack.nova.v1_1.domain.Server; +import org.jclouds.openstack.nova.v1_1.domain.ServerCreated; import org.jclouds.openstack.nova.v1_1.options.CreateServerOptions; import org.jclouds.openstack.nova.v1_1.options.RebuildServerOptions; +import org.jclouds.openstack.v2_0.domain.Resource; /** * Provides synchronous access to Server. diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.java index c5d3219083..e3dbb2e24c 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.java @@ -94,8 +94,8 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio @Override public Optional apply(ClassMethodArgsAndReturnVal input) { - Optional ext = Optional.fromNullable(input.getClazz().getAnnotation( - org.jclouds.openstack.services.Extension.class)); + Optional ext = Optional.fromNullable(input.getClazz().getAnnotation( + org.jclouds.openstack.v2_0.services.Extension.class)); if (ext.isPresent()) { checkState(input.getArgs() != null && input.getArgs().length == 1, "expecting an arg %s", input); URI namespace = URI.create(ext.get().namespace()); diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/ListOptions.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/ListOptions.java index 1f922bbbd2..ca350111dd 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/ListOptions.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/options/ListOptions.java @@ -20,7 +20,7 @@ package org.jclouds.openstack.nova.v1_1.options; import java.util.Date; -import org.jclouds.openstack.options.BaseListOptions; +import org.jclouds.openstack.v2_0.options.BaseListOptions; /** * Options used to control the amount of detail in the request. diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerInZoneToNodeMetadataTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerInZoneToNodeMetadataTest.java index 6b9f64b290..2468bb4df8 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerInZoneToNodeMetadataTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/compute/functions/ServerInZoneToNodeMetadataTest.java @@ -37,12 +37,12 @@ import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; -import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Resource; import org.jclouds.openstack.nova.v1_1.compute.config.NovaComputeServiceContextModule; import org.jclouds.openstack.nova.v1_1.domain.Server; import org.jclouds.openstack.nova.v1_1.domain.zonescoped.ServerInZone; import org.jclouds.openstack.nova.v1_1.parse.ParseServerTest; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Resource; import org.testng.annotations.Test; import com.google.common.base.Supplier; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FlavorExtraSpecsClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FlavorExtraSpecsClientLiveTest.java index 1408af82e8..08a999b53c 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FlavorExtraSpecsClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/FlavorExtraSpecsClientLiveTest.java @@ -24,9 +24,9 @@ import static org.testng.Assert.assertTrue; import java.util.Map; -import org.jclouds.openstack.domain.Resource; import org.jclouds.openstack.nova.v1_1.features.FlavorClient; import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientLiveTest; +import org.jclouds.openstack.v2_0.domain.Resource; import org.testng.annotations.AfterGroups; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassClientExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassClientExpectTest.java index ff08699b0b..360917feda 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassClientExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassClientExpectTest.java @@ -29,7 +29,6 @@ import javax.ws.rs.core.MediaType; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.openstack.nova.v1_1.domain.QuotaClass; -import org.jclouds.openstack.nova.v1_1.domain.Quotas; import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientExpectTest; import org.jclouds.rest.ResourceNotFoundException; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassClientLiveTest.java index 0d1df006ee..9fc636e8a3 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/QuotaClassClientLiveTest.java @@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import org.jclouds.openstack.nova.v1_1.domain.QuotaClass; -import org.jclouds.openstack.nova.v1_1.domain.Quotas; import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientLiveTest; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/ServerWithSecurityGroupsClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/ServerWithSecurityGroupsClientLiveTest.java index 75a4227fdc..f8a69e04d8 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/ServerWithSecurityGroupsClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/ServerWithSecurityGroupsClientLiveTest.java @@ -21,11 +21,11 @@ package org.jclouds.openstack.nova.v1_1.extensions; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import org.jclouds.openstack.domain.Resource; import org.jclouds.openstack.nova.v1_1.domain.Server; import org.jclouds.openstack.nova.v1_1.domain.ServerWithSecurityGroups; import org.jclouds.openstack.nova.v1_1.features.ServerClient; import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientLiveTest; +import org.jclouds.openstack.v2_0.domain.Resource; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientLiveTest.java index 02974c2849..dcc4b5f6e6 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/FlavorClientLiveTest.java @@ -23,9 +23,9 @@ import static org.testng.Assert.assertTrue; import java.util.Set; -import org.jclouds.openstack.domain.Resource; import org.jclouds.openstack.nova.v1_1.domain.Flavor; import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientLiveTest; +import org.jclouds.openstack.v2_0.domain.Resource; import org.testng.annotations.Test; /** diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ImageClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ImageClientLiveTest.java index 23744fa8d2..bf532a6d10 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ImageClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ImageClientLiveTest.java @@ -24,9 +24,9 @@ import static org.testng.Assert.assertTrue; import java.util.Set; -import org.jclouds.openstack.domain.Resource; import org.jclouds.openstack.nova.v1_1.domain.Image; import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientLiveTest; +import org.jclouds.openstack.v2_0.domain.Resource; import org.testng.annotations.Test; /** diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientLiveTest.java index 470b4ba54b..81acbdb7b0 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/features/ServerClientLiveTest.java @@ -23,9 +23,9 @@ import static org.testng.Assert.assertTrue; import java.util.Set; -import org.jclouds.openstack.domain.Resource; import org.jclouds.openstack.nova.v1_1.domain.Server; import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientLiveTest; +import org.jclouds.openstack.v2_0.domain.Resource; import org.testng.annotations.Test; /** diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java index 07cb2df6c3..fe0a947e0b 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java @@ -12,7 +12,7 @@ import org.jclouds.internal.ClassMethodArgsAndReturnVal; import org.jclouds.openstack.nova.v1_1.domain.Extension; import org.jclouds.openstack.nova.v1_1.extensions.ExtensionNamespaces; import org.jclouds.openstack.nova.v1_1.extensions.KeyPairAsyncClient; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.rest.annotations.Delegate; import org.testng.annotations.Test; @@ -40,7 +40,7 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-08-08T00:00:00+00:00")).description( "Keypair Support").build(); - @org.jclouds.openstack.services.Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.KEYPAIRS) + @org.jclouds.openstack.v2_0.services.Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.KEYPAIRS) static interface KeyPairIPAsyncClient { } @@ -50,7 +50,7 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-06-16T00:00:00+00:00")).description( "Floating IPs support").build(); - @org.jclouds.openstack.services.Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.FLOATING_IPS) + @org.jclouds.openstack.v2_0.services.Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.FLOATING_IPS) static interface FloatingIPAsyncClient { } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java index fe683e4ea5..546a09ef40 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java @@ -26,8 +26,8 @@ import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.openstack.nova.v1_1.config.NovaProperties; import org.jclouds.openstack.nova.v1_1.domain.Flavor; -import org.jclouds.openstack.nova.v1_1.domain.ServerCreated; import org.jclouds.openstack.nova.v1_1.domain.Server; +import org.jclouds.openstack.nova.v1_1.domain.ServerCreated; import org.jclouds.openstack.nova.v1_1.domain.Server.Status; import org.jclouds.openstack.nova.v1_1.features.FlavorClient; import org.jclouds.openstack.nova.v1_1.features.ImageClient; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseCreatedServerTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseCreatedServerTest.java index f074f84e36..f260fe7aaa 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseCreatedServerTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseCreatedServerTest.java @@ -25,10 +25,10 @@ import javax.ws.rs.core.MediaType; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; -import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.ServerCreated; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Link.Relation; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseExtensionListTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseExtensionListTest.java index 437f1b1c0a..f46f65c120 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseExtensionListTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseExtensionListTest.java @@ -27,10 +27,10 @@ import javax.ws.rs.core.MediaType; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.config.GsonModule; -import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Extension; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Link.Relation; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseExtensionTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseExtensionTest.java index 02c2dd1026..1b06d895c2 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseExtensionTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseExtensionTest.java @@ -26,10 +26,10 @@ import javax.ws.rs.core.MediaType; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; -import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Extension; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Link.Relation; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorListTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorListTest.java index eb78746d73..d5c50ee7f6 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorListTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorListTest.java @@ -26,10 +26,10 @@ import javax.ws.rs.core.MediaType; import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.config.GsonModule; -import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Resource; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Link.Relation; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorTest.java index 68713e6b9b..031d8d2b32 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseFlavorTest.java @@ -25,10 +25,10 @@ import javax.ws.rs.core.MediaType; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; -import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Flavor; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Link.Relation; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java index da4a4c63bd..16b63e6da3 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageListTest.java @@ -26,10 +26,10 @@ import javax.ws.rs.core.MediaType; import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.config.GsonModule; -import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Resource; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Link.Relation; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java index c7579ee71d..e996565243 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseImageTest.java @@ -26,12 +26,12 @@ import javax.ws.rs.core.MediaType; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; -import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Resource; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Image; import org.jclouds.openstack.nova.v1_1.domain.Image.Status; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Link.Relation; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerDetailsEssexTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerDetailsEssexTest.java index 95f8a2ca7f..161ac73cae 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerDetailsEssexTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerDetailsEssexTest.java @@ -27,14 +27,14 @@ import javax.ws.rs.core.MediaType; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.config.GsonModule; -import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Resource; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; -import org.jclouds.openstack.nova.v1_1.domain.Server.Status; import org.jclouds.openstack.nova.v1_1.domain.ServerExtendedStatus; +import org.jclouds.openstack.nova.v1_1.domain.Server.Status; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Link.Relation; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerListTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerListTest.java index 7ad940b6a9..8c2f23c4ba 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerListTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerListTest.java @@ -26,10 +26,10 @@ import javax.ws.rs.core.MediaType; import org.jclouds.json.BaseSetParserTest; import org.jclouds.json.config.GsonModule; -import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Resource; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Link.Relation; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java index 7e54bd06c8..cddd00decd 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerTest.java @@ -26,13 +26,13 @@ import javax.ws.rs.core.MediaType; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; -import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Resource; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; import org.jclouds.openstack.nova.v1_1.domain.Server.Status; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Link.Relation; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithAllExtensionsTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithAllExtensionsTest.java index 52139fabac..2bbe63ea12 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithAllExtensionsTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithAllExtensionsTest.java @@ -26,15 +26,15 @@ import javax.ws.rs.core.MediaType; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; -import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Link.Relation; -import org.jclouds.openstack.domain.Resource; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; -import org.jclouds.openstack.nova.v1_1.domain.Server.Status; import org.jclouds.openstack.nova.v1_1.domain.ServerExtendedAttributes; import org.jclouds.openstack.nova.v1_1.domain.ServerExtendedStatus; +import org.jclouds.openstack.nova.v1_1.domain.Server.Status; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Link.Relation; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java index 15a0dae5bc..3f59844319 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseServerWithInternetAddressesTest.java @@ -26,13 +26,13 @@ import javax.ws.rs.core.MediaType; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; -import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Resource; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; import org.jclouds.openstack.nova.v1_1.domain.Server.Status; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Link.Relation; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/PublicIpsInPrivateAddressBlockExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/PublicIpsInPrivateAddressBlockExpectTest.java index 1d2513097b..d609554ea2 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/PublicIpsInPrivateAddressBlockExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/PublicIpsInPrivateAddressBlockExpectTest.java @@ -26,13 +26,13 @@ import javax.ws.rs.core.MediaType; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; -import org.jclouds.openstack.domain.Link; -import org.jclouds.openstack.domain.Resource; -import org.jclouds.openstack.domain.Link.Relation; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.Address; import org.jclouds.openstack.nova.v1_1.domain.Server; import org.jclouds.openstack.nova.v1_1.domain.Server.Status; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Link.Relation; import org.jclouds.rest.annotations.SelectJson; import org.testng.annotations.Test; diff --git a/apis/pom.xml b/apis/pom.xml index b45bd1ac1d..c8aa8f1e3e 100644 --- a/apis/pom.xml +++ b/apis/pom.xml @@ -47,6 +47,7 @@ elasticstack atmos nova + openstack-keystone openstack-nova openstack-nova-ec2 cloudwatch diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java index 2dae10ea7c..a261b8b395 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/SwiftApiMetadata.java @@ -26,7 +26,6 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.blobstore.BlobStoreContext; -import org.jclouds.openstack.OpenStackAuthAsyncClient; import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule; import org.jclouds.openstack.swift.config.SwiftRestClientModule; import org.jclouds.rest.RestContext; @@ -81,7 +80,7 @@ public class SwiftApiMetadata extends BaseRestApiMetadata { .identityName("tenantId:user") .credentialName("password") .documentation(URI.create("http://api.openstack.org/")) - .version(OpenStackAuthAsyncClient.VERSION) + .version("1.0") .defaultProperties(SwiftApiMetadata.defaultProperties()) .view(TypeToken.of(BlobStoreContext.class)) .defaultModules(ImmutableSet.>of(SwiftRestClientModule.class, SwiftBlobStoreContextModule.class)); diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java index cc74c180c1..cefb4ee76f 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/CommonSwiftClientTest.java @@ -28,7 +28,7 @@ import javax.inject.Singleton; import org.jclouds.apis.ApiMetadata; import org.jclouds.http.HttpRequest; -import org.jclouds.openstack.TestOpenStackAuthenticationModule; +import org.jclouds.openstack.internal.TestOpenStackAuthenticationModule; import org.jclouds.openstack.swift.config.BaseSwiftRestClientModule; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.BaseAsyncClientTest; diff --git a/common/openstack/pom.xml b/common/openstack/pom.xml index 1a0859f32d..af29166945 100644 --- a/common/openstack/pom.xml +++ b/common/openstack/pom.xml @@ -35,7 +35,18 @@ bundle - org.jclouds.openstack*;version="${project.version}" + org.jclouds.openstack.config*;version="${project.version}", + org.jclouds.openstack.domain*;version="${project.version}" + org.jclouds.openstack.filters*;version="${project.version}" + org.jclouds.openstack.functions*;version="${project.version}" + org.jclouds.openstack.handlers*;version="${project.version}" + org.jclouds.openstack.internal*;version="${project.version}" + org.jclouds.openstack.keystone.v1_1*;version="${project.version}" + org.jclouds.openstack.options*;version="${project.version}" + org.jclouds.openstack.predicates*;version="${project.version}" + org.jclouds.openstack.reference*;version="${project.version}" + org.jclouds.openstack.services*;version="${project.version}" + org.jclouds*;version="${project.version}",* diff --git a/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java b/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java index eca6fe8678..c9c27465c3 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/config/OpenStackAuthenticationModule.java @@ -35,12 +35,12 @@ import org.jclouds.domain.Credentials; import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.annotation.ClientError; import org.jclouds.location.Provider; -import org.jclouds.openstack.Authentication; -import org.jclouds.openstack.OpenStackAuthAsyncClient; -import org.jclouds.openstack.OpenStackAuthClient; import org.jclouds.openstack.domain.AuthenticationResponse; import org.jclouds.openstack.functions.URIFromAuthenticationResponseForService; import org.jclouds.openstack.handlers.RetryOnRenew; +import org.jclouds.openstack.internal.Authentication; +import org.jclouds.openstack.internal.OpenStackAuthAsyncClient; +import org.jclouds.openstack.internal.OpenStackAuthClient; import com.google.common.base.Function; import com.google.common.base.Supplier; diff --git a/common/openstack/src/main/java/org/jclouds/openstack/filters/AuthenticateRequest.java b/common/openstack/src/main/java/org/jclouds/openstack/filters/AuthenticateRequest.java index 216853f17e..8d2c5ab7d6 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/filters/AuthenticateRequest.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/filters/AuthenticateRequest.java @@ -25,7 +25,7 @@ import org.jclouds.http.HttpException; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.utils.ModifyRequest; -import org.jclouds.openstack.Authentication; +import org.jclouds.openstack.internal.Authentication; import org.jclouds.openstack.reference.AuthHeaders; import com.google.common.base.Supplier; diff --git a/common/openstack/src/main/java/org/jclouds/openstack/Authentication.java b/common/openstack/src/main/java/org/jclouds/openstack/internal/Authentication.java similarity index 97% rename from common/openstack/src/main/java/org/jclouds/openstack/Authentication.java rename to common/openstack/src/main/java/org/jclouds/openstack/internal/Authentication.java index 4dde744be5..8e1503c7b4 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/Authentication.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/internal/Authentication.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.openstack; +package org.jclouds.openstack.internal; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/common/openstack/src/main/java/org/jclouds/openstack/OpenStackAuthAsyncClient.java b/common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClient.java similarity index 96% rename from common/openstack/src/main/java/org/jclouds/openstack/OpenStackAuthAsyncClient.java rename to common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClient.java index 9292bb0946..93c30d676a 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/OpenStackAuthAsyncClient.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClient.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.openstack; +package org.jclouds.openstack.internal; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -42,7 +42,6 @@ import com.google.common.util.concurrent.ListenableFuture; @Path("/v{" + Constants.PROPERTY_API_VERSION + "}") @VirtualHost public interface OpenStackAuthAsyncClient { - public static final String VERSION = "1.0"; @GET @Consumes diff --git a/common/openstack/src/main/java/org/jclouds/openstack/OpenStackAuthClient.java b/common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthClient.java similarity index 97% rename from common/openstack/src/main/java/org/jclouds/openstack/OpenStackAuthClient.java rename to common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthClient.java index 8bdfd9482c..0f8cd5e48c 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/OpenStackAuthClient.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/internal/OpenStackAuthClient.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.openstack; +package org.jclouds.openstack.internal; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; diff --git a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java index 4f70bc4c0f..a96f524eec 100644 --- a/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java +++ b/common/openstack/src/main/java/org/jclouds/openstack/keystone/v1_1/config/AuthenticationServiceModule.java @@ -34,7 +34,7 @@ import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.annotation.ClientError; import org.jclouds.location.Provider; import org.jclouds.location.suppliers.RegionIdToURISupplier; -import org.jclouds.openstack.Authentication; +import org.jclouds.openstack.internal.Authentication; import org.jclouds.openstack.keystone.v1_1.AuthenticationAsyncClient; import org.jclouds.openstack.keystone.v1_1.AuthenticationClient; import org.jclouds.openstack.keystone.v1_1.domain.Auth; diff --git a/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java b/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java similarity index 97% rename from common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java rename to common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java index 1779fd979f..8e4ef7264c 100644 --- a/common/openstack/src/test/java/org/jclouds/openstack/OpenStackAuthAsyncClientTest.java +++ b/common/openstack/src/test/java/org/jclouds/openstack/internal/OpenStackAuthAsyncClientTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.openstack; +package org.jclouds.openstack.internal; import java.io.IOException; import java.lang.reflect.Method; @@ -26,6 +26,7 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; import org.jclouds.openstack.functions.ParseAuthenticationResponseFromHeaders; +import org.jclouds.openstack.internal.OpenStackAuthAsyncClient; import org.jclouds.rest.AnonymousRestApiMetadata; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.internal.BaseAsyncClientTest; diff --git a/common/openstack/src/test/java/org/jclouds/openstack/TestOpenStackAuthenticationModule.java b/common/openstack/src/test/java/org/jclouds/openstack/internal/TestOpenStackAuthenticationModule.java similarity index 98% rename from common/openstack/src/test/java/org/jclouds/openstack/TestOpenStackAuthenticationModule.java rename to common/openstack/src/test/java/org/jclouds/openstack/internal/TestOpenStackAuthenticationModule.java index 3835119c3b..8ee4ddc249 100644 --- a/common/openstack/src/test/java/org/jclouds/openstack/TestOpenStackAuthenticationModule.java +++ b/common/openstack/src/test/java/org/jclouds/openstack/internal/TestOpenStackAuthenticationModule.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.openstack; +package org.jclouds.openstack.internal; import java.net.URI; import java.util.Date; diff --git a/labs/openstack-glance/pom.xml b/labs/openstack-glance/pom.xml index 40633f5182..aa172d80bb 100644 --- a/labs/openstack-glance/pom.xml +++ b/labs/openstack-glance/pom.xml @@ -53,8 +53,8 @@ - org.jclouds.common - openstack-common + org.jclouds.api + openstack-keystone ${project.version} @@ -70,8 +70,8 @@ test - org.jclouds.common - openstack-common + org.jclouds.api + openstack-keystone ${project.version} test-jar test diff --git a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/GlanceApiMetadata.java b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/GlanceApiMetadata.java index cdb817696f..5d52819197 100644 --- a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/GlanceApiMetadata.java +++ b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/GlanceApiMetadata.java @@ -26,7 +26,7 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.openstack.glance.v1_0.config.GlanceRestClientModule; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.BaseRestApiMetadata; diff --git a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/domain/Image.java b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/domain/Image.java index 91b4db43f8..7b1d41388e 100644 --- a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/domain/Image.java +++ b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/domain/Image.java @@ -18,7 +18,7 @@ */ package org.jclouds.openstack.glance.v1_0.domain; -import org.jclouds.openstack.domain.Resource; +import org.jclouds.openstack.v2_0.domain.Resource; import com.google.common.base.Objects; import com.google.common.base.Optional; diff --git a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/features/ImageAsyncClient.java b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/features/ImageAsyncClient.java index da64dfceb6..2ba647ca65 100644 --- a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/features/ImageAsyncClient.java +++ b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/features/ImageAsyncClient.java @@ -21,17 +21,26 @@ package org.jclouds.openstack.glance.v1_0.features; import java.io.InputStream; import java.util.Set; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.jclouds.io.Payload; -import org.jclouds.openstack.filters.AuthenticateRequest; import org.jclouds.openstack.glance.v1_0.domain.Image; import org.jclouds.openstack.glance.v1_0.domain.ImageDetails; import org.jclouds.openstack.glance.v1_0.functions.ParseImageDetailsFromHeaders; import org.jclouds.openstack.glance.v1_0.options.CreateImageOptions; import org.jclouds.openstack.glance.v1_0.options.ListImageOptions; import org.jclouds.openstack.glance.v1_0.options.UpdateImageOptions; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; diff --git a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/features/ImageClient.java b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/features/ImageClient.java index 3e318e3fa9..017d624a34 100644 --- a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/features/ImageClient.java +++ b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/features/ImageClient.java @@ -25,12 +25,11 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.io.Payload; import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.glance.v1_0.domain.DiskFormat; import org.jclouds.openstack.glance.v1_0.domain.Image; import org.jclouds.openstack.glance.v1_0.domain.ImageDetails; import org.jclouds.openstack.glance.v1_0.options.CreateImageOptions; -import org.jclouds.openstack.glance.v1_0.options.UpdateImageOptions; import org.jclouds.openstack.glance.v1_0.options.ListImageOptions; +import org.jclouds.openstack.glance.v1_0.options.UpdateImageOptions; /** * Image Services diff --git a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/functions/ParseImageDetailsFromHeaders.java b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/functions/ParseImageDetailsFromHeaders.java index 7c8ecbe890..b2c374e5ec 100644 --- a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/functions/ParseImageDetailsFromHeaders.java +++ b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/functions/ParseImageDetailsFromHeaders.java @@ -18,7 +18,21 @@ */ package org.jclouds.openstack.glance.v1_0.functions; -import static org.jclouds.openstack.glance.v1_0.options.ImageField.*; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.CHECKSUM; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.CONTAINER_FORMAT; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.CREATED_AT; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.DELETED_AT; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.DISK_FORMAT; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.ID; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.IS_PUBLIC; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.LOCATION; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.MIN_DISK; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.MIN_RAM; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.NAME; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.OWNER; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.SIZE; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.STATUS; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.UPDATED_AT; import javax.inject.Inject; diff --git a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/ImageField.java b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/ImageField.java index fd67d2c355..5efd3a8fb8 100644 --- a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/ImageField.java +++ b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/ImageField.java @@ -18,13 +18,6 @@ */ package org.jclouds.openstack.glance.v1_0.options; -import static com.google.common.base.CaseFormat.LOWER_UNDERSCORE; -import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE; - -import org.jclouds.util.Strings2; - -import com.google.common.base.CaseFormat; -import com.google.common.base.Strings; /** * Fields used in Glance options diff --git a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/ListImageOptions.java b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/ListImageOptions.java index b81c07c9bc..34bae7e019 100644 --- a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/ListImageOptions.java +++ b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/ListImageOptions.java @@ -20,7 +20,16 @@ package org.jclouds.openstack.glance.v1_0.options; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static org.jclouds.openstack.glance.v1_0.options.ImageField.*; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.CONTAINER_FORMAT; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.DISK_FORMAT; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.IS_PUBLIC; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.MIN_DISK; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.MIN_RAM; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.NAME; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.PROTECTED; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.SIZE_MAX; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.SIZE_MIN; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.STATUS; import org.jclouds.http.options.BaseHttpRequestOptions; import org.jclouds.openstack.glance.v1_0.domain.ContainerFormat; diff --git a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/UpdateImageOptions.java b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/UpdateImageOptions.java index da0e4e9fb8..dc02986ac8 100644 --- a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/UpdateImageOptions.java +++ b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/options/UpdateImageOptions.java @@ -18,7 +18,19 @@ */ package org.jclouds.openstack.glance.v1_0.options; -import static org.jclouds.openstack.glance.v1_0.options.ImageField.*; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.CHECKSUM; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.CONTAINER_FORMAT; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.DISK_FORMAT; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.IS_PUBLIC; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.LOCATION; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.MIN_DISK; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.MIN_RAM; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.NAME; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.OWNER; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.PROPERTY; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.PROTECTED; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.SIZE; +import static org.jclouds.openstack.glance.v1_0.options.ImageField.STORE; import org.jclouds.http.options.BaseHttpRequestOptions; import org.jclouds.openstack.glance.v1_0.domain.ContainerFormat; diff --git a/labs/openstack-glance/src/test/java/org/jclouds/openstack/glance/v1_0/features/ImageClientExpectTest.java b/labs/openstack-glance/src/test/java/org/jclouds/openstack/glance/v1_0/features/ImageClientExpectTest.java index 415803bd5c..9ed94a1b2a 100644 --- a/labs/openstack-glance/src/test/java/org/jclouds/openstack/glance/v1_0/features/ImageClientExpectTest.java +++ b/labs/openstack-glance/src/test/java/org/jclouds/openstack/glance/v1_0/features/ImageClientExpectTest.java @@ -20,7 +20,6 @@ package org.jclouds.openstack.glance.v1_0.features; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; diff --git a/labs/openstack-quantum/pom.xml b/labs/openstack-quantum/pom.xml index 9c3511b67f..951c56517e 100644 --- a/labs/openstack-quantum/pom.xml +++ b/labs/openstack-quantum/pom.xml @@ -52,8 +52,8 @@ - org.jclouds.common - openstack-common + org.jclouds.api + openstack-keystone ${project.version} @@ -69,8 +69,8 @@ test - org.jclouds.common - openstack-common + org.jclouds.api + openstack-keystone ${project.version} test-jar test diff --git a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/QuantumApiMetadata.java b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/QuantumApiMetadata.java index 6511ee029e..4ca0706e4f 100644 --- a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/QuantumApiMetadata.java +++ b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/QuantumApiMetadata.java @@ -26,7 +26,7 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; import org.jclouds.openstack.quantum.v1_0.config.QuantumRestClientModule; -import org.jclouds.openstack.services.ServiceType; +import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.BaseRestApiMetadata; diff --git a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/domain/Network.java b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/domain/Network.java index fd3e3cf850..6ad19f7879 100644 --- a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/domain/Network.java +++ b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/domain/Network.java @@ -18,11 +18,11 @@ */ package org.jclouds.openstack.quantum.v1_0.domain; +import static com.google.common.base.Preconditions.checkNotNull; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; - /** * A Quantum network * diff --git a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/NetworkAsyncClient.java b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/NetworkAsyncClient.java index b0d114e0c8..060af7b59c 100644 --- a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/NetworkAsyncClient.java +++ b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/NetworkAsyncClient.java @@ -30,7 +30,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.quantum.v1_0.domain.Network; import org.jclouds.openstack.quantum.v1_0.domain.NetworkDetails; import org.jclouds.openstack.quantum.v1_0.domain.Reference; diff --git a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/PortAsyncClient.java b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/PortAsyncClient.java index 9535bc6bf5..562270eb70 100644 --- a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/PortAsyncClient.java +++ b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/features/PortAsyncClient.java @@ -29,7 +29,7 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.quantum.v1_0.domain.Attachment; import org.jclouds.openstack.quantum.v1_0.domain.Port; import org.jclouds.openstack.quantum.v1_0.domain.PortDetails; diff --git a/labs/openstack-swift/pom.xml b/labs/openstack-swift/pom.xml index f4a546af8d..1412f5bc6f 100644 --- a/labs/openstack-swift/pom.xml +++ b/labs/openstack-swift/pom.xml @@ -56,8 +56,8 @@ - org.jclouds.common - openstack-common + org.jclouds.api + openstack-keystone ${project.version} @@ -73,8 +73,8 @@ test - org.jclouds.common - openstack-common + org.jclouds.api + openstack-keystone ${project.version} test-jar test diff --git a/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/SwiftApiMetadata.java b/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/SwiftApiMetadata.java index 60a20eea8b..7c0188069f 100644 --- a/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/SwiftApiMetadata.java +++ b/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/SwiftApiMetadata.java @@ -25,8 +25,8 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; -import org.jclouds.openstack.services.ServiceType; import org.jclouds.openstack.swift.v1.config.SwiftRestClientModule; +import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.BaseRestApiMetadata; diff --git a/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/AccountAsyncClient.java b/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/AccountAsyncClient.java index c159b221cd..d4b5169a7a 100644 --- a/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/AccountAsyncClient.java +++ b/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/AccountAsyncClient.java @@ -26,7 +26,7 @@ import javax.ws.rs.HEAD; import javax.ws.rs.Path; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.swift.v1.domain.AccountMetadata; import org.jclouds.openstack.swift.v1.domain.ContainerMetadata; import org.jclouds.openstack.swift.v1.functions.ParseAccountMetadataResponseFromHeaders; diff --git a/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ContainerAsyncClient.java b/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ContainerAsyncClient.java index 68fda93deb..3ac2a996a9 100644 --- a/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ContainerAsyncClient.java +++ b/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ContainerAsyncClient.java @@ -18,7 +18,7 @@ */ package org.jclouds.openstack.swift.v1.features; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SkipEncoding; diff --git a/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectAsyncClient.java b/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectAsyncClient.java index 597a5e2e17..0067c9edfd 100644 --- a/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectAsyncClient.java +++ b/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/features/ObjectAsyncClient.java @@ -18,7 +18,7 @@ */ package org.jclouds.openstack.swift.v1.features; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SkipEncoding; diff --git a/labs/pom.xml b/labs/pom.xml index a976fc93d1..bde7affc9e 100644 --- a/labs/pom.xml +++ b/labs/pom.xml @@ -46,7 +46,6 @@ cdmi openstack-glance joyent-sdc - openstack-keystone openstack-quantum diff --git a/providers/hpcloud-objectstorage/pom.xml b/providers/hpcloud-objectstorage/pom.xml index e2c664f951..4b6534de2f 100644 --- a/providers/hpcloud-objectstorage/pom.xml +++ b/providers/hpcloud-objectstorage/pom.xml @@ -50,6 +50,11 @@ swift ${project.version} + + org.jclouds.api + openstack-keystone + ${project.version} + org.jclouds jclouds-core @@ -58,8 +63,8 @@ test - org.jclouds.common - openstack-common + org.jclouds.api + openstack-keystone ${project.version} test-jar test diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageAsyncClient.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageAsyncClient.java index 24087f6e56..49309e677a 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageAsyncClient.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageAsyncClient.java @@ -33,7 +33,7 @@ import org.jclouds.blobstore.functions.ReturnNullOnContainerNotFound; import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNAsyncClient; import org.jclouds.hpcloud.objectstorage.functions.ParseContainerMetadataFromHeaders; import org.jclouds.hpcloud.objectstorage.options.CreateContainerOptions; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.swift.CommonSwiftAsyncClient; import org.jclouds.openstack.swift.Storage; import org.jclouds.openstack.swift.domain.ContainerMetadata; diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/extensions/HPCloudCDNAsyncClient.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/extensions/HPCloudCDNAsyncClient.java index 9d231dbe5c..c61019d5b0 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/extensions/HPCloudCDNAsyncClient.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/extensions/HPCloudCDNAsyncClient.java @@ -39,7 +39,7 @@ import org.jclouds.hpcloud.objectstorage.functions.ParseContainerCDNMetadataFrom import org.jclouds.hpcloud.objectstorage.options.ListCDNContainerOptions; import org.jclouds.hpcloud.objectstorage.reference.HPCloudObjectStorageHeaders; import org.jclouds.hpcloud.services.HPExtensionCDN; -import org.jclouds.openstack.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.rest.annotations.Endpoint; import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.Headers; From 8684e5902570260d6d03a6fd1c036138d5753ed2 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 6 Jun 2012 16:04:06 -0700 Subject: [PATCH 2/9] fixed hpcloud-objectstorage blob signing --- ...HPCloudObjectStorageBlobRequestSigner.java | 67 +++++++++++++++ ...udObjectStorageBlobStoreContextModule.java | 16 ++-- ...oudObjectStorageBlobRequestSignerTest.java | 86 +++++++++++++++++++ ...CloudObjectStorageBlobStoreExpectTest.java | 52 +++++++++++ ...loudObjectStorageBlobStoreExpectTest.java} | 43 +++++----- 5 files changed, 236 insertions(+), 28 deletions(-) create mode 100644 providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobRequestSigner.java create mode 100644 providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobRequestSignerTest.java create mode 100644 providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStoreExpectTest.java rename providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/{HPCloudObjectStorageExpectTest.java => BaseHPCloudObjectStorageBlobStoreExpectTest.java} (62%) diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobRequestSigner.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobRequestSigner.java new file mode 100644 index 0000000000..90829b5418 --- /dev/null +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobRequestSigner.java @@ -0,0 +1,67 @@ +package org.jclouds.hpcloud.objectstorage.blobstore; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.blobstore.util.BlobStoreUtils.cleanRequest; + +import java.lang.reflect.Method; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.blobstore.BlobRequestSigner; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.blobstore.functions.BlobToHttpGetOptions; +import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageAsyncClient; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.options.GetOptions; +import org.jclouds.openstack.swift.blobstore.functions.BlobToObject; +import org.jclouds.openstack.swift.domain.SwiftObject; +import org.jclouds.rest.internal.RestAnnotationProcessor; + +/** + * + * @author Adrian Cole + */ +@Singleton +public class HPCloudObjectStorageBlobRequestSigner implements BlobRequestSigner { + private final RestAnnotationProcessor processor; + private final BlobToObject blobToObject; + private final BlobToHttpGetOptions blob2HttpGetOptions; + + private final Method getMethod; + private final Method deleteMethod; + private final Method createMethod; + + @Inject + public HPCloudObjectStorageBlobRequestSigner(RestAnnotationProcessor processor, BlobToObject blobToObject, + BlobToHttpGetOptions blob2HttpGetOptions) throws SecurityException, NoSuchMethodException { + this.processor = checkNotNull(processor, "processor"); + this.blobToObject = checkNotNull(blobToObject, "blobToObject"); + this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions"); + this.getMethod = HPCloudObjectStorageAsyncClient.class.getMethod("getObject", String.class, String.class, + GetOptions[].class); + this.deleteMethod = HPCloudObjectStorageAsyncClient.class.getMethod("removeObject", String.class, String.class); + this.createMethod = HPCloudObjectStorageAsyncClient.class.getMethod("putObject", String.class, SwiftObject.class); + + } + + @Override + public HttpRequest signGetBlob(String container, String name) { + return cleanRequest(processor.createRequest(getMethod, container, name)); + } + + @Override + public HttpRequest signPutBlob(String container, Blob blob) { + return cleanRequest(processor.createRequest(createMethod, container, blobToObject.apply(blob))); + } + + @Override + public HttpRequest signRemoveBlob(String container, String name) { + return cleanRequest(processor.createRequest(deleteMethod, container, name)); + } + + @Override + public HttpRequest signGetBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) { + return cleanRequest(processor.createRequest(getMethod, container, name, blob2HttpGetOptions.apply(options))); + } +} diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/config/HPCloudObjectStorageBlobStoreContextModule.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/config/HPCloudObjectStorageBlobStoreContextModule.java index 28cbcdfd5d..a2086305c6 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/config/HPCloudObjectStorageBlobStoreContextModule.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/blobstore/config/HPCloudObjectStorageBlobStoreContextModule.java @@ -28,16 +28,20 @@ import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.blobstore.AsyncBlobStore; +import org.jclouds.blobstore.BlobRequestSigner; +import org.jclouds.blobstore.BlobStore; +import org.jclouds.blobstore.attr.ConsistencyModel; +import org.jclouds.blobstore.config.BlobStoreMapModule; import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageClient; import org.jclouds.hpcloud.objectstorage.blobstore.HPCloudObjectStorageAsyncBlobStore; +import org.jclouds.hpcloud.objectstorage.blobstore.HPCloudObjectStorageBlobRequestSigner; import org.jclouds.hpcloud.objectstorage.blobstore.HPCloudObjectStorageBlobStore; import org.jclouds.hpcloud.objectstorage.blobstore.functions.HPCloudObjectStorageObjectToBlobMetadata; import org.jclouds.hpcloud.objectstorage.domain.ContainerCDNMetadata; import org.jclouds.hpcloud.objectstorage.extensions.HPCloudCDNClient; import org.jclouds.http.HttpResponseException; import org.jclouds.logging.Logger; -import org.jclouds.openstack.swift.blobstore.SwiftAsyncBlobStore; -import org.jclouds.openstack.swift.blobstore.SwiftBlobStore; import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule; import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata; @@ -98,9 +102,11 @@ public class HPCloudObjectStorageBlobStoreContextModule extends SwiftBlobStoreCo @Override protected void configure() { - super.configure(); - bind(SwiftBlobStore.class).to(HPCloudObjectStorageBlobStore.class); - bind(SwiftAsyncBlobStore.class).to(HPCloudObjectStorageAsyncBlobStore.class); + install(new BlobStoreMapModule()); + bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT); + bind(AsyncBlobStore.class).to(HPCloudObjectStorageAsyncBlobStore.class); + bind(BlobStore.class).to(HPCloudObjectStorageBlobStore.class); bind(ObjectToBlobMetadata.class).to(HPCloudObjectStorageObjectToBlobMetadata.class); + bind(BlobRequestSigner.class).to(HPCloudObjectStorageBlobRequestSigner.class); } } diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobRequestSignerTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobRequestSignerTest.java new file mode 100644 index 0000000000..da1c2699ec --- /dev/null +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobRequestSignerTest.java @@ -0,0 +1,86 @@ +/** + * 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.hpcloud.objectstorage.blobstore; + +import static org.testng.Assert.assertEquals; + +import java.util.Date; +import java.util.Map; + +import org.jclouds.blobstore.BlobRequestSigner; +import org.jclouds.blobstore.BlobStore; +import org.jclouds.blobstore.domain.Blob; +import org.jclouds.hpcloud.objectstorage.internal.BaseHPCloudObjectStorageBlobStoreExpectTest; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMultimap; + +/** + * Tests behavior of {@code HPCloudObjectStorageBlobRequestSigner} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire +@Test(groups = "unit", testName = "HPCloudObjectStorageBlobRequestSignerTest") +public class HPCloudObjectStorageBlobRequestSignerTest extends BaseHPCloudObjectStorageBlobStoreExpectTest { + + Map requestResponseMap = ImmutableMap. builder().put( + keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess).build(); + + public void testSignGetBlob() { + + BlobRequestSigner signGetBlob = requestsSendResponses(requestResponseMap).getContext().getSigner(); + + HttpRequest request = signGetBlob.signGetBlob("container", "name"); + + assertEquals(request.getRequestLine(), + "GET https://objects.jclouds.org/v1.0/40806637803162/container/name HTTP/1.1"); + assertEquals(request.getHeaders(), ImmutableMultimap.of("X-Auth-Token", "Auth_4f173437e4b013bee56d1007")); + } + + public void testSignRemoveBlob() { + BlobRequestSigner signRemoveBlob = requestsSendResponses(requestResponseMap).getContext().getSigner(); + + HttpRequest request = signRemoveBlob.signRemoveBlob("container", "name"); + assertEquals(request.getRequestLine(), + "DELETE https://objects.jclouds.org/v1.0/40806637803162/container/name HTTP/1.1"); + assertEquals(request.getHeaders(), ImmutableMultimap.of("X-Auth-Token", "Auth_4f173437e4b013bee56d1007")); + + } + + public void testSignPutBlob() { + BlobStore blobStore = requestsSendResponses(requestResponseMap); + BlobRequestSigner signPutBlob = blobStore.getContext().getSigner(); + Blob blob = blobStore.blobBuilder("name").forSigning().contentLength(2l).contentMD5(new byte[] { 0, 2, 4, 8 }) + .contentType("text/plain").expires(new Date(1000)).build(); + + HttpRequest request = signPutBlob.signPutBlob("container", blob); + + assertEquals(request.getRequestLine(), + "PUT https://objects.jclouds.org/v1.0/40806637803162/container/name HTTP/1.1"); + assertEquals(request.getHeaders(), ImmutableMultimap.of("X-Auth-Token", "Auth_4f173437e4b013bee56d1007")); + // TODO: + // assertEquals(request.getPayload(), blob); + + } + +} diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStoreExpectTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStoreExpectTest.java new file mode 100644 index 0000000000..e1ed9d89a9 --- /dev/null +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/HPCloudObjectStorageBlobStoreExpectTest.java @@ -0,0 +1,52 @@ +/** + * 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.hpcloud.objectstorage.blobstore; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.util.Map; +import java.util.Set; + +import org.jclouds.blobstore.BlobStore; +import org.jclouds.domain.Location; +import org.jclouds.hpcloud.objectstorage.internal.BaseHPCloudObjectStorageBlobStoreExpectTest; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; + +@Test(groups = "unit", testName = "HPCloudObjectStorageBlobStoreExpectTest") +public class HPCloudObjectStorageBlobStoreExpectTest extends BaseHPCloudObjectStorageBlobStoreExpectTest { + + + public void testListObjectsWhenResponseIs2xx() throws Exception { + Map requestResponseMap = ImmutableMap. builder().put( + keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess).build(); + + BlobStore clientWhenLocationsExist = requestsSendResponses(requestResponseMap); + + Set locations = clientWhenLocationsExist.listAssignableLocations(); + assertNotNull(locations); + assertEquals(locations.size(), 1); + // TODO: does this location make sense? + assertEquals(locations.iterator().next().getId(), "hpcloud-objectstorage"); + } +} diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/BaseHPCloudObjectStorageBlobStoreExpectTest.java similarity index 62% rename from providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java rename to providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/BaseHPCloudObjectStorageBlobStoreExpectTest.java index 87c9e4b926..969b589b31 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/BaseHPCloudObjectStorageBlobStoreExpectTest.java @@ -1,14 +1,26 @@ +/** + * 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.hpcloud.objectstorage.internal; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import java.util.Map; import java.util.Properties; -import java.util.Set; import org.jclouds.blobstore.BlobStore; -import org.jclouds.domain.Location; import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageProviderMetadata; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; @@ -17,11 +29,10 @@ import org.jclouds.rest.internal.BaseRestClientExpectTest; import org.testng.annotations.Test; import com.google.common.base.Function; -import com.google.common.collect.ImmutableMap; import com.google.inject.Module; @Test(groups = "unit", testName = "HPCloudObjectStorageExpectTest") -public class HPCloudObjectStorageExpectTest extends BaseRestClientExpectTest { +public class BaseHPCloudObjectStorageBlobStoreExpectTest extends BaseRestClientExpectTest { protected HttpRequest keystoneAuthWithUsernameAndPassword; @@ -29,7 +40,7 @@ public class HPCloudObjectStorageExpectTest extends BaseRestClientExpectTest requestResponseMap = ImmutableMap. builder().put( - keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess).build(); - - BlobStore clientWhenServersExist = requestsSendResponses(requestResponseMap); - - Set locations = clientWhenServersExist.listAssignableLocations(); - assertNotNull(locations); - assertEquals(locations.size(), 1); - // TODO: does this location make sense? - assertEquals(locations.iterator().next().getId(), "hpcloud-objectstorage"); - } @Override public BlobStore createClient(Function fn, Module module, Properties props) { From 6cfa5877f3eb55600e0dacc72b461ce2c5b5d30a Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 6 Jun 2012 16:35:34 -0700 Subject: [PATCH 3/9] incorrectly added file --- apis/openstack-keystone/.pom.xml.swp | Bin 16384 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 apis/openstack-keystone/.pom.xml.swp diff --git a/apis/openstack-keystone/.pom.xml.swp b/apis/openstack-keystone/.pom.xml.swp deleted file mode 100644 index 2e445a32b1607b1a6362553fd4b61348037193d3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeHOO^h5z8LgNQLP$(-6e5IBDnpQxXuEsXb^tl;F~fST4A~#!Sv#?0X;a%>GgG@g z-JPzUogE@#2`Pvx5|JWt3>?BCNN^0f5OPBz5I~9q7Y+~(h@YI`0i7t7~`aS6b`z3-&33=Uzg7_Tyh{ik}=D`*eC6VSXZ5=tTink@KHs zW@oLyP+DT0d3F$aESO2~!q}lRjFLSWGmkr6kvh9x5Dk3k1Z+n-QOrY`GH=h?<0F|y zA$Q`aZy)q$JCYLr$GsuB+(J)*hnwowz*L(nJ^qi~>dhqkvJsC}0#Y z3K#{90{?por13Fw9mP7Pi?*$Q-!}F8-}<>3D?#BuFHSiAbUBCyHfWICm zPXhM?cL0C-C?Vehc7X?gH}52554aon{znM;9`IG*PT((hfD7;v-~-oyCa?_Dfd_%( zz@I-%$Q!`7f$KmBw1Ce5f4`lO-vF-zuL3Uv0dNku5BTSYzzO&*@EUL(cow(-oCa#Z zgTM*kcHnO~VEF^^Ht+`UBJdSp8F&Er2lW3bpz7gORTnc4oqF7E!~)qMQ^C}Ydrb0% z2vgooSSq5>O1Vs3Cl8;s7k<^)b?`oAsL0io9`3F*a<%inHAQ!y zCsN6`Y}f6&>lCj=bVZCH>h7q!FJ8c;6y9M%l@fV9`?*NswoR5~N*K2!tqI;D<%ge# zG`rkOZO!`Y3;FA-JeCYPr*{{!R~4+SZQLM&_y2MU(vhwWYnQ=y_F5=j)W9v4&WjQ> zo=UY9ev7tQDcmiU>I1`X+>Elek8)xpNzl&G!^fSWsK-clg)RDVl%z$kcuY%EQRJ~F zbn(vCX7#Tv%_guDj9|7J(vpw`M@a3?CFB;D&FqXTKd5r8aJ0*7Xm)W8&E7w`U0=+d zX51%p*I69y`^GMpFqz_U)v!|bmy(i~aEwc-V1bpj?--*7?$-G$WjF@Rqb03mQc&>9xz^S>EKar9y~s+Djd;Nhr)_n|lRl;Ic&gcH>`~3sDu5k^$atLdHMf^8_z)^r=o*Iar52A!OXo9j;Ipq5*nIgp~X9u9~0@RY6WPS)$o z&NJ(4ZLHk-%o6G@Z|HHPlH!ca0@rXoST&q7`TWf2JUaQZa{u&peYE^X(Dz8Dfed!MunU( zh(hp3>dPT+VoRFv=LT4E`*df7-Vz7GV>n~BSVb0PSuRER4JtEsP^a+ zbfi;-QA!6=X^QfxMLA^mc$_MtYKRHct#l6sFc6sZ9^~Kt`2JZM1au@dAUjx+szxclYJM8t}1YQA# zz`wA+Pl5NauipdS!(RRx-~h*g_mTcx;4R=sz$?IafNugX0?PjgFpp8dC}0#Y3K#{9 z0!9I&fKlN8Q-SOlRc*YpO>6e1_B!SF1#HWU4-yoQ>r8yXPyzabNO91bTTOom$wSKz zIOPWs6|NrFDdVb+ib(8SI-)zsKP1f>sPq#5q|5sk^Yf$86^4Hr#x`>%Bkl2MXORy- zev?@_2JTfx=`#_Jzq!W Date: Wed, 6 Jun 2012 16:35:48 -0700 Subject: [PATCH 4/9] Issue 962:slf4j initializing loggers to null --- .../main/java/org/jclouds/logging/slf4j/SLF4JLogger.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/slf4j/src/main/java/org/jclouds/logging/slf4j/SLF4JLogger.java b/drivers/slf4j/src/main/java/org/jclouds/logging/slf4j/SLF4JLogger.java index 250f959cca..7054a70fe3 100644 --- a/drivers/slf4j/src/main/java/org/jclouds/logging/slf4j/SLF4JLogger.java +++ b/drivers/slf4j/src/main/java/org/jclouds/logging/slf4j/SLF4JLogger.java @@ -22,12 +22,17 @@ import org.jclouds.logging.BaseLogger; import org.jclouds.logging.Logger; /** - * {@link org.apache.slf4j.Logger} implementation of {@link Logger}. + * {@link org.slf4j.LoggerFactory} implementation of {@link Logger}. * * @author Adrian Cole * */ public class SLF4JLogger extends BaseLogger { + static { + // force initialization to avoid http://www.slf4j.org/codes.html#substituteLogger messages + org.slf4j.LoggerFactory.getILoggerFactory(); + } + private final org.slf4j.Logger logger; private final String category; From d00e360d6571b4077fd0ee8f49f299ad9f129926 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 6 Jun 2012 23:14:23 -0700 Subject: [PATCH 5/9] Issue 815: refactored the 3 major features of keystone into separate clients. removed cyclic dependency needed to support keystone controlling keystones in other regions --- .../v2_0/AuthenticationAsyncClient.java | 9 +- .../keystone/v2_0/AuthenticationClient.java | 9 +- .../keystone/v2_0/KeystoneApiMetadata.java | 18 +- .../keystone/v2_0/KeystoneAsyncClient.java | 53 ++- .../keystone/v2_0/KeystoneClient.java | 42 +- .../v2_0/binders/BindAuthToJsonPayload.java | 13 +- .../keystone/v2_0/config/CredentialType.java | 38 +- .../keystone/v2_0/config/CredentialTypes.java | 56 +++ .../config/KeystoneAuthenticationModule.java | 96 ++--- .../v2_0/config/KeystoneProperties.java | 2 +- .../v2_0/config/KeystoneRestClientModule.java | 36 +- .../v2_0/domain/ApiAccessKeyCredentials.java | 4 + .../keystone/v2_0/domain/ApiMetadata.java | 30 +- .../keystone/v2_0/domain/Endpoint.java | 64 ++- .../v2_0/domain/PasswordCredentials.java | 4 + .../openstack/keystone/v2_0/domain/Role.java | 29 +- .../v2_0/features/AdminAsyncClient.java | 177 -------- .../keystone/v2_0/features/AdminClient.java | 145 ------- ...syncClient.java => TenantAsyncClient.java} | 48 ++- .../{ServiceClient.java => TenantClient.java} | 37 +- .../v2_0/features/TokenAsyncClient.java | 94 +++++ .../keystone/v2_0/features/TokenClient.java | 77 ++++ .../v2_0/features/UserAsyncClient.java | 101 +++++ .../keystone/v2_0/features/UserClient.java | 85 ++++ .../AuthenticateApiAccessKeyCredentials.java | 39 +- .../AuthenticatePasswordCredentials.java | 41 +- .../v2_0/functions/EndpointToRegion.java | 2 +- ...egion.java => ReturnRegionOrProvider.java} | 12 +- .../functions/internal/BaseAuthenticator.java | 62 +++ ...onIdToURIFromAccessForTypeAndVersion.java} | 8 +- ...oAdminURIFromAccessForTypeAndVersion.java} | 11 +- .../suppliers/RegionIdToAdminURISupplier.java | 8 +- ...onIdToURIFromAccessForTypeAndVersion.java} | 9 +- ...neIdToURIFromAccessForTypeAndVersion.java} | 9 +- .../v2_0/KeystoneClientExpectTest.java | 64 +++ .../keystone/v2_0/KeystoneClientLiveTest.java | 43 ++ .../v2_0/config/CredentialTypesTest.java | 54 +++ .../v2_0/features/AdminClientExpectTest.java | 381 ------------------ .../v2_0/features/AdminClientLiveTest.java | 192 --------- .../v2_0/features/TenantClientExpectTest.java | 112 +++++ .../v2_0/features/TenantClientLiveTest.java | 67 +++ .../v2_0/features/TokenClientExpectTest.java | 153 +++++++ .../v2_0/features/TokenClientLiveTest.java | 98 +++++ .../v2_0/features/UserClientExpectTest.java | 175 +++++--- .../v2_0/features/UserClientLiveTest.java | 68 +++- ...t.java => ReturnRegionOrProviderTest.java} | 20 +- .../internal/BaseKeystoneClientLiveTest.java | 6 +- .../BaseKeystoneRestClientExpectTest.java | 24 +- .../keystone/v2_0/parse/ParseAccessTest.java | 12 +- .../v2_0/parse/ParseRackspaceAccessTest.java | 113 ++++++ ...ava => ParseRackspaceApiMetadataTest.java} | 23 +- ...inURIFromAccessForTypeAndVersionTest.java} | 53 ++- ...omAccessForTypeAndVersionSupplierTest.java | 71 ---- ...dToURIFromAccessForTypeAndVersionTest.java | 120 ++++++ ...ToURIFromAccessForTypeAndVersionTest.java} | 47 ++- .../test/resources/apiMetadataResponse.json | 1 - .../src/test/resources/api_metadata.json | 1 - .../src/test/resources/raxAuth.json | 98 +++++ .../src/test/resources/raxVersion.json | 28 ++ .../openstack/nova/v1_1/NovaApiMetadata.java | 7 +- .../v1_1/config/NovaRestClientModule.java | 7 - .../suppliers/RegionIdToURISupplier.java | 5 +- .../suppliers/ZoneIdToURISupplier.java | 5 +- .../glance/v1_0/GlanceApiMetadata.java | 7 +- .../v1_0/config/GlanceRestClientModule.java | 12 - .../quantum/v1_0/QuantumApiMetadata.java | 7 +- .../v1_0/config/QuantumRestClientModule.java | 12 - .../openstack/swift/v1/SwiftApiMetadata.java | 7 +- .../v1/config/SwiftRestClientModule.java | 12 - .../HPCloudComputeProviderMetadata.java | 3 +- .../HPCloudObjectStorageApiMetadata.java | 6 +- .../HPCloudObjectStorageRestClientModule.java | 8 - 72 files changed, 2183 insertions(+), 1407 deletions(-) create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialTypes.java delete mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/AdminAsyncClient.java delete mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/AdminClient.java rename apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/{ServiceAsyncClient.java => TenantAsyncClient.java} (64%) rename apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/{ServiceClient.java => TenantClient.java} (64%) create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenAsyncClient.java create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenClient.java create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserAsyncClient.java create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserClient.java rename apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/{ReturnRegion.java => ReturnRegionOrProvider.java} (75%) create mode 100644 apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/internal/BaseAuthenticator.java rename apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/{LocationIdToURIFromAccessForTypeAndVersionSupplier.java => LocationIdToURIFromAccessForTypeAndVersion.java} (92%) rename apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/{RegionIdToAdminURIFromAccessForTypeAndVersionSupplier.java => RegionIdToAdminURIFromAccessForTypeAndVersion.java} (72%) rename apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/{RegionIdToURIFromAccessForTypeAndVersionSupplier.java => RegionIdToURIFromAccessForTypeAndVersion.java} (81%) rename apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/{ZoneIdToURIFromAccessForTypeAndVersionSupplier.java => ZoneIdToURIFromAccessForTypeAndVersion.java} (83%) create mode 100644 apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/KeystoneClientExpectTest.java create mode 100644 apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/KeystoneClientLiveTest.java create mode 100644 apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/config/CredentialTypesTest.java delete mode 100644 apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/AdminClientExpectTest.java delete mode 100644 apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/AdminClientLiveTest.java create mode 100644 apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TenantClientExpectTest.java create mode 100644 apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TenantClientLiveTest.java create mode 100644 apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TokenClientExpectTest.java create mode 100644 apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TokenClientLiveTest.java rename apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/{ReturnRegionTest.java => ReturnRegionOrProviderTest.java} (72%) create mode 100644 apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseRackspaceAccessTest.java rename apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/{ParseApiMetadataTest.java => ParseRackspaceApiMetadataTest.java} (72%) rename apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/{RegionIdToAdminURIFromAccessForTypeAndVersionSupplierTest.java => RegionIdToAdminURIFromAccessForTypeAndVersionTest.java} (51%) delete mode 100644 apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionSupplierTest.java create mode 100644 apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionTest.java rename apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/{ZoneIdToURIFromAccessForTypeAndVersionSupplierTest.java => ZoneIdToURIFromAccessForTypeAndVersionTest.java} (52%) delete mode 100644 apis/openstack-keystone/src/test/resources/apiMetadataResponse.json delete mode 100644 apis/openstack-keystone/src/test/resources/api_metadata.json create mode 100644 apis/openstack-keystone/src/test/resources/raxAuth.json create mode 100644 apis/openstack-keystone/src/test/resources/raxVersion.json diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationAsyncClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationAsyncClient.java index c8b515235b..170f4c19c3 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationAsyncClient.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationAsyncClient.java @@ -23,6 +23,7 @@ import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.core.MediaType; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.keystone.v2_0.binders.BindAuthToJsonPayload; import org.jclouds.openstack.keystone.v2_0.domain.Access; import org.jclouds.openstack.keystone.v2_0.domain.ApiAccessKeyCredentials; @@ -53,7 +54,7 @@ public interface AuthenticationAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @Path("/tokens") @MapBinder(BindAuthToJsonPayload.class) - ListenableFuture authenticateWithTenantNameAndCredentials(@PayloadParam("tenantName") String tenantName, + ListenableFuture authenticateWithTenantNameAndCredentials(@Nullable @PayloadParam("tenantName") String tenantName, PasswordCredentials passwordCredentials); /** @@ -64,7 +65,7 @@ public interface AuthenticationAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @Path("/tokens") @MapBinder(BindAuthToJsonPayload.class) - ListenableFuture authenticateWithTenantIdAndCredentials(@PayloadParam("tenantId") String tenantId, + ListenableFuture authenticateWithTenantIdAndCredentials(@Nullable @PayloadParam("tenantId") String tenantId, PasswordCredentials passwordCredentials); /** @@ -77,7 +78,7 @@ public interface AuthenticationAsyncClient { @MapBinder(BindAuthToJsonPayload.class) // TODO: is tenantName permanent? or should we switch to tenantId at some point. seems most tools // still use tenantName - ListenableFuture authenticateWithTenantNameAndCredentials(@PayloadParam("tenantName") String tenantName, + ListenableFuture authenticateWithTenantNameAndCredentials(@Nullable @PayloadParam("tenantName") String tenantName, ApiAccessKeyCredentials apiAccessKeyCredentials); /** @@ -88,6 +89,6 @@ public interface AuthenticationAsyncClient { @Consumes(MediaType.APPLICATION_JSON) @Path("/tokens") @MapBinder(BindAuthToJsonPayload.class) - ListenableFuture authenticateWithTenantIdAndCredentials(@PayloadParam("tenantId") String tenantId, + ListenableFuture authenticateWithTenantIdAndCredentials(@Nullable @PayloadParam("tenantId") String tenantId, ApiAccessKeyCredentials apiAccessKeyCredentials); } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationClient.java index 167f6bb99f..fc701f50b1 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationClient.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/AuthenticationClient.java @@ -21,6 +21,7 @@ package org.jclouds.openstack.keystone.v2_0; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.keystone.v2_0.domain.Access; import org.jclouds.openstack.keystone.v2_0.domain.ApiAccessKeyCredentials; import org.jclouds.openstack.keystone.v2_0.domain.PasswordCredentials; @@ -42,26 +43,26 @@ public interface AuthenticationClient { * * @return access with token */ - Access authenticateWithTenantNameAndCredentials(String tenantId, PasswordCredentials passwordCredentials); + Access authenticateWithTenantNameAndCredentials(@Nullable String tenantId, PasswordCredentials passwordCredentials); /** * Authenticate to generate a token. * * @return access with token */ - Access authenticateWithTenantIdAndCredentials(String tenantId, PasswordCredentials passwordCredentials); + Access authenticateWithTenantIdAndCredentials(@Nullable String tenantId, PasswordCredentials passwordCredentials); /** * Authenticate to generate a token. * * @return access with token */ - Access authenticateWithTenantNameAndCredentials(String tenantId, ApiAccessKeyCredentials passwordCredentials); + Access authenticateWithTenantNameAndCredentials(@Nullable String tenantId, ApiAccessKeyCredentials passwordCredentials); /** * Authenticate to generate a token. * * @return access with token */ - Access authenticateWithTenantIdAndCredentials(String tenantId, ApiAccessKeyCredentials passwordCredentials); + Access authenticateWithTenantIdAndCredentials(@Nullable String tenantId, ApiAccessKeyCredentials passwordCredentials); } \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java index a9c8f69310..c15f193b99 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneApiMetadata.java @@ -18,12 +18,14 @@ */ package org.jclouds.openstack.keystone.v2_0; +import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; import java.net.URI; import java.util.Properties; import org.jclouds.apis.ApiMetadata; +import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule; import org.jclouds.openstack.v2_0.ServiceType; @@ -44,19 +46,18 @@ public class KeystoneApiMetadata extends BaseRestApiMetadata { /** The serialVersionUID */ private static final long serialVersionUID = 6725672099385580694L; - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - - /** The serialVersionUID */ - private static final long serialVersionUID = 3030344682235783904L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; }; @Override public Builder toBuilder() { - return new Builder().fromApiMetadata(this); + return (Builder) new Builder(getApi(), getAsyncApi()).fromApiMetadata(this); } public KeystoneApiMetadata() { - this(new Builder()); + this(new Builder(KeystoneClient.class, KeystoneAsyncClient.class)); } protected KeystoneApiMetadata(Builder builder) { @@ -67,14 +68,15 @@ public class KeystoneApiMetadata extends BaseRestApiMetadata { Properties properties = BaseRestApiMetadata.defaultProperties(); // TODO: this doesn't actually do anything yet. properties.setProperty(KeystoneProperties.VERSION, "2.0"); + properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS); properties.put(SERVICE_TYPE, ServiceType.IDENTITY); return properties; } public static class Builder extends BaseRestApiMetadata.Builder { - protected Builder() { - super(KeystoneClient.class, KeystoneAsyncClient.class); + protected Builder(Class api, Class asyncApi) { + super(api, asyncApi); id("openstack-keystone") .name("OpenStack Keystone Essex+ API") .identityName("tenantId:user") diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncClient.java index 1d23d251f4..c05af31d49 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncClient.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneAsyncClient.java @@ -18,21 +18,22 @@ */ package org.jclouds.openstack.keystone.v2_0; -import java.util.Set; - +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; import javax.ws.rs.Path; +import javax.ws.rs.core.MediaType; import org.jclouds.Constants; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.Region; -import org.jclouds.location.functions.RegionToEndpoint; -import org.jclouds.openstack.keystone.v2_0.features.AdminAsyncClient; -import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncClient; -import org.jclouds.openstack.keystone.v2_0.functions.RegionToAdminEndpointURI; +import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; +import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncClient; +import org.jclouds.openstack.keystone.v2_0.features.TokenAsyncClient; +import org.jclouds.openstack.keystone.v2_0.features.UserAsyncClient; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.EndpointParam; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; -import com.google.inject.Provides; +import com.google.common.util.concurrent.ListenableFuture; /** * Provides access to Openstack keystone resources via their REST API. @@ -42,20 +43,34 @@ import com.google.inject.Provides; * @see * @see KeystoneClient */ -@Path("/v{" + Constants.PROPERTY_API_VERSION + "}") public interface KeystoneAsyncClient { + /** - * @return the Region codes configured + * @see KeystoneClient#getApiMetadata() */ - @Provides - @Region - Set getConfiguredRegions(); + @GET + @SelectJson("version") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/v{" + Constants.PROPERTY_API_VERSION + "}/") + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getApiMetadata(); - /** Provides asynchronous access to Identity user-accessible features */ + /** + * @see KeystoneClient#getTokenClient() + */ @Delegate - ServiceAsyncClient getServiceClientForRegion(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region); + TokenAsyncClient getTokenClient(); - /** Provides asynchronous access to the KeyStone Admin API */ + /** + * @see KeystoneClient#getUserClient() + */ @Delegate - AdminAsyncClient getAdminClientForRegion(@EndpointParam(parser = RegionToAdminEndpointURI.class) @Nullable String region); + UserAsyncClient getUserClient(); + + + /** + * @see KeystoneClient#getTenantClient() + */ + @Delegate + TenantAsyncClient getTenantClient(); } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneClient.java index ae23238227..a73f75859b 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneClient.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/KeystoneClient.java @@ -18,20 +18,14 @@ */ package org.jclouds.openstack.keystone.v2_0; -import java.util.Set; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.Region; -import org.jclouds.location.functions.RegionToEndpoint; -import org.jclouds.openstack.keystone.v2_0.features.AdminClient; -import org.jclouds.openstack.keystone.v2_0.features.ServiceClient; -import org.jclouds.openstack.keystone.v2_0.functions.RegionToAdminEndpointURI; +import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; +import org.jclouds.openstack.keystone.v2_0.features.TenantClient; +import org.jclouds.openstack.keystone.v2_0.features.TokenClient; +import org.jclouds.openstack.keystone.v2_0.features.UserClient; import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.EndpointParam; - -import com.google.inject.Provides; /** * Provides access to Openstack keystone resources via their REST API. @@ -39,22 +33,34 @@ import com.google.inject.Provides; * * @author Adam Lowe * @see + * @see KeystoneAsyncClient */ @Timeout(duration = 10, timeUnit = TimeUnit.SECONDS) public interface KeystoneClient { + /** - * @return the Region codes configured + * Discover API version information, links to documentation (PDF, HTML, WADL), and supported media types + * + * @return the requested information */ - @Provides - @Region - Set getConfiguredRegions(); + ApiMetadata getApiMetadata(); - /** Provides synchronous access to Identity user-accessible features */ + /** + * Provides synchronous access to Token features + */ @Delegate - ServiceClient getServiceClientForRegion(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region); + TokenClient getTokenClient(); - /** Provides synchronous access to the KeyStone Admin API */ + /** + * Provides synchronous access to User features + */ @Delegate - AdminClient getAdminClientForRegion(@EndpointParam(parser = RegionToAdminEndpointURI.class) @Nullable String region); + UserClient getUserClient(); + + /** + * Provides synchronous access to Tenant features + */ + @Delegate + TenantClient getTenantClient(); } \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java index 87f583db2c..77f37fb4dd 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/binders/BindAuthToJsonPayload.java @@ -29,14 +29,15 @@ import javax.inject.Singleton; import org.jclouds.http.HttpRequest; import org.jclouds.json.Json; -import org.jclouds.openstack.keystone.v2_0.domain.ApiAccessKeyCredentials; -import org.jclouds.openstack.keystone.v2_0.domain.PasswordCredentials; +import org.jclouds.openstack.keystone.v2_0.config.CredentialType; import org.jclouds.rest.MapBinder; import org.jclouds.rest.binders.BindToJsonPayload; import org.jclouds.rest.internal.GeneratedHttpRequest; +import com.google.common.base.Predicates; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; import com.google.common.collect.ImmutableMap.Builder; /** @@ -57,11 +58,9 @@ public class BindAuthToJsonPayload extends BindToJsonPayload implements MapBinde } protected void addCredentialsInArgsOrNull(GeneratedHttpRequest gRequest, Builder builder) { - for (Object arg : gRequest.getArgs()) { - if (arg instanceof PasswordCredentials) { - builder.put("passwordCredentials", PasswordCredentials.class.cast(arg)); - } else if (arg instanceof ApiAccessKeyCredentials) { - builder.put("apiAccessKeyCredentials", ApiAccessKeyCredentials.class.cast(arg)); + for (Object arg : Iterables.filter(gRequest.getArgs(), Predicates.notNull())) { + if (arg.getClass().isAnnotationPresent(CredentialType.class)) { + builder.put(arg.getClass().getAnnotation(CredentialType.class).value(), arg); } } } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialType.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialType.java index c168ccc666..4509b40198 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialType.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialType.java @@ -18,29 +18,25 @@ */ package org.jclouds.openstack.keystone.v2_0.config; -import static com.google.common.base.Preconditions.checkNotNull; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; -import com.google.common.base.CaseFormat; +import javax.inject.Qualifier; /** - * Configuration properties and constants used in Keystone connections. - * + * @see CredentialTypes * @author Adrian Cole + * */ -public enum CredentialType { - - API_ACCESS_KEY_CREDENTIALS, - - PASSWORD_CREDENTIALS; - - @Override - public String toString() { - return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()); - } - - public static CredentialType fromValue(String credentialType) { - return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(credentialType, - "credentialType"))); - } - -} +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) +@Qualifier +public @interface CredentialType { + /** + * @see CredentialTypes + * + */ + String value(); +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialTypes.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialTypes.java new file mode 100644 index 0000000000..42035496f2 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/CredentialTypes.java @@ -0,0 +1,56 @@ +/** + * 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.openstack.keystone.v2_0.config; + +import static com.google.common.base.Preconditions.checkArgument; + +import java.util.Map; + +import com.google.common.base.Function; +import com.google.common.collect.Maps; + +/** + * Configuration properties and constants used in Keystone connections. + * + * @author Adrian Cole + */ +public class CredentialTypes { + + public static final String API_ACCESS_KEY_CREDENTIALS = "apiAccessKeyCredentials"; + + public static final String PASSWORD_CREDENTIALS = "passwordCredentials"; + + public static String credentialTypeOf(T input) { + Class authenticationType = input.getClass(); + checkArgument(authenticationType.isAnnotationPresent(CredentialType.class), + "programming error: %s should have annotation %s", authenticationType, CredentialType.class.getName()); + return authenticationType.getAnnotation(CredentialType.class).value(); + } + + public static Map indexByCredentialType(Iterable iterable) { + return Maps.uniqueIndex(iterable, new Function() { + + @Override + public String apply(T input) { + return credentialTypeOf(input); + } + + }); + } +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java index 5379e3f4f1..c556487086 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneAuthenticationModule.java @@ -18,9 +18,11 @@ */ package org.jclouds.openstack.keystone.v2_0.config; +import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Throwables.propagate; import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient; +import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -45,10 +47,10 @@ import org.jclouds.openstack.keystone.v2_0.domain.Access; import org.jclouds.openstack.keystone.v2_0.functions.AuthenticateApiAccessKeyCredentials; import org.jclouds.openstack.keystone.v2_0.functions.AuthenticatePasswordCredentials; import org.jclouds.openstack.keystone.v2_0.handlers.RetryOnRenew; -import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURIFromAccessForTypeAndVersionSupplier; +import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURIFromAccessForTypeAndVersion; import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToAdminURISupplier; -import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToURIFromAccessForTypeAndVersionSupplier; -import org.jclouds.openstack.keystone.v2_0.suppliers.ZoneIdToURIFromAccessForTypeAndVersionSupplier; +import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToURIFromAccessForTypeAndVersion; +import org.jclouds.openstack.keystone.v2_0.suppliers.ZoneIdToURIFromAccessForTypeAndVersion; import org.jclouds.rest.annotations.ApiVersion; import com.google.common.base.Function; @@ -56,8 +58,10 @@ import com.google.common.base.Supplier; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet.Builder; import com.google.inject.AbstractModule; -import com.google.inject.Inject; +import com.google.inject.Injector; import com.google.inject.Module; import com.google.inject.Provides; import com.google.inject.assistedinject.FactoryModuleBuilder; @@ -76,18 +80,24 @@ public class KeystoneAuthenticationModule extends AbstractModule { protected KeystoneAuthenticationModule(Module locationModule) { this.locationModule = locationModule; } - - public static Module forRegions() { - return new KeystoneAuthenticationModule(new RegionModule()); + + public static class KeystoneAuthenticationModuleForRegions extends KeystoneAuthenticationModule { + public KeystoneAuthenticationModuleForRegions() { + super(new RegionModule()); + } } + public static Module forRegions() { + return new KeystoneAuthenticationModuleForRegions(); + } + public static class RegionModule extends AbstractModule { @Override protected void configure() { install(new FactoryModuleBuilder().implement(RegionIdToURISupplier.class, - RegionIdToURIFromAccessForTypeAndVersionSupplier.class).build(RegionIdToURISupplier.Factory.class)); + RegionIdToURIFromAccessForTypeAndVersion.class).build(RegionIdToURISupplier.Factory.class)); install(new FactoryModuleBuilder().implement(RegionIdToAdminURISupplier.class, - RegionIdToAdminURIFromAccessForTypeAndVersionSupplier.class).build(RegionIdToAdminURISupplier.Factory.class)); + RegionIdToAdminURIFromAccessForTypeAndVersion.class).build(RegionIdToAdminURISupplier.Factory.class)); // dynamically build the region list as opposed to from properties bind(RegionIdsSupplier.class).to(RegionIdsFromRegionIdToURIKeySet.class); } @@ -101,14 +111,15 @@ public class KeystoneAuthenticationModule extends AbstractModule { RegionIdToURISupplier.Factory factory) { return factory.createForApiTypeAndVersion(serviceType, apiVersion); } - - // supply the region to id to AdminURL map from keystone, based on the servicetype and api version in + + // supply the region to id to AdminURL map from keystone, based on the servicetype and api + // version in // config @Provides @Singleton protected RegionIdToAdminURISupplier provideRegionIdToAdminURISupplierForApiVersion( - @Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion, - RegionIdToAdminURISupplier.Factory factory) { + @Named(KeystoneProperties.SERVICE_TYPE) String serviceType, @ApiVersion String apiVersion, + RegionIdToAdminURISupplier.Factory factory) { return factory.createForApiTypeAndVersion(serviceType, apiVersion); } @@ -118,7 +129,7 @@ public class KeystoneAuthenticationModule extends AbstractModule { @Override protected void configure() { install(new FactoryModuleBuilder().implement(ZoneIdToURISupplier.class, - ZoneIdToURIFromAccessForTypeAndVersionSupplier.class).build(ZoneIdToURISupplier.Factory.class)); + ZoneIdToURIFromAccessForTypeAndVersion.class).build(ZoneIdToURISupplier.Factory.class)); // dynamically build the zone list as opposed to from properties bind(ZoneIdsSupplier.class).to(ZoneIdsFromZoneIdToURIKeySet.class); } @@ -135,18 +146,27 @@ public class KeystoneAuthenticationModule extends AbstractModule { } + public static class KeystoneAuthenticationModuleForZones extends KeystoneAuthenticationModule { + public KeystoneAuthenticationModuleForZones() { + super(new ZoneModule()); + } + } + public static Module forZones() { - return new KeystoneAuthenticationModule(new ZoneModule()); + return new KeystoneAuthenticationModuleForZones(); } @Override protected void configure() { bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(RetryOnRenew.class); - bind(CredentialType.class).toProvider(CredentialTypeFromPropertyOrDefault.class); - // ServiceClient is used directly for filters and retry handlers, so let's bind it + bindAuthenticationClient(); + install(locationModule); + } + + protected void bindAuthenticationClient() { + // AuthenticationClient is used directly for filters and retry handlers, so let's bind it // explicitly bindClientAndAsyncClient(binder(), AuthenticationClient.class, AuthenticationAsyncClient.class); - install(locationModule); } /** @@ -164,41 +184,25 @@ public class KeystoneAuthenticationModule extends AbstractModule { }; } + @Provides @Singleton - static class CredentialTypeFromPropertyOrDefault implements javax.inject.Provider { - /** - * use optional injection to supply a default value for credential type. so that we don't have - * to set a default property. - */ - @Inject(optional = true) - @Named(KeystoneProperties.CREDENTIAL_TYPE) - String credentialType = CredentialType.PASSWORD_CREDENTIALS.toString(); - - @Override - public CredentialType get() { - return CredentialType.fromValue(credentialType); - } + protected Map> authenticationMethods(Injector i) { + Builder> fns = ImmutableSet.> builder(); + fns.add(i.getInstance(AuthenticatePasswordCredentials.class)); + fns.add(i.getInstance(AuthenticateApiAccessKeyCredentials.class)); + return CredentialTypes.indexByCredentialType(fns.build()); } @Provides @Singleton - protected Function authenticationMethodForCredentialType(CredentialType credentialType, - AuthenticatePasswordCredentials authenticatePasswordCredentials, - AuthenticateApiAccessKeyCredentials authenticateApiAccessKeyCredentials) { - Function authMethod; - switch (credentialType) { - case PASSWORD_CREDENTIALS: - authMethod = authenticatePasswordCredentials; - break; - case API_ACCESS_KEY_CREDENTIALS: - authMethod = authenticateApiAccessKeyCredentials; - break; - default: - throw new IllegalArgumentException("credential type not supported: " + credentialType); - } + protected Function authenticationMethodForCredentialType( + @Named(KeystoneProperties.CREDENTIAL_TYPE) String credentialType, + Map> authenticationMethods) { + checkArgument(authenticationMethods.containsKey(credentialType), "credential type %s not in supported list: %s", + credentialType, authenticationMethods.keySet()); // regardless of how we authenticate, we should retry if there is a timeout exception logging // in. - return new RetryOnTimeOutExceptionFunction(authMethod); + return new RetryOnTimeOutExceptionFunction(authenticationMethods.get(credentialType)); } // TODO: what is the timeout of the session token? modify default accordingly diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java index a180e101d6..1865c23373 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneProperties.java @@ -36,7 +36,7 @@ public interface KeystoneProperties { *
  • passwordCredentials
  • * * - * @see CredentialType + * @see CredentialTypes * @see
    */ diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java index 7a07dd6444..4e6c9c10e3 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/config/KeystoneRestClientModule.java @@ -26,15 +26,19 @@ import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncClient; import org.jclouds.openstack.keystone.v2_0.KeystoneClient; -import org.jclouds.openstack.keystone.v2_0.features.AdminAsyncClient; -import org.jclouds.openstack.keystone.v2_0.features.AdminClient; -import org.jclouds.openstack.keystone.v2_0.features.ServiceAsyncClient; -import org.jclouds.openstack.keystone.v2_0.features.ServiceClient; +import org.jclouds.openstack.keystone.v2_0.features.TenantAsyncClient; +import org.jclouds.openstack.keystone.v2_0.features.TenantClient; +import org.jclouds.openstack.keystone.v2_0.features.TokenAsyncClient; +import org.jclouds.openstack.keystone.v2_0.features.TokenClient; +import org.jclouds.openstack.keystone.v2_0.features.UserAsyncClient; +import org.jclouds.openstack.keystone.v2_0.features.UserClient; import org.jclouds.openstack.keystone.v2_0.handlers.KeystoneErrorHandler; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.config.RestClientModule; import com.google.common.collect.ImmutableMap; +import com.google.common.reflect.TypeToken; +import com.google.inject.util.Modules; /** * Configures the Keystone connection. @@ -42,15 +46,22 @@ import com.google.common.collect.ImmutableMap; * @author Adam Lowe */ @ConfiguresRestClient -public class KeystoneRestClientModule extends RestClientModule { +public class KeystoneRestClientModule extends RestClientModule { public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder() - .put(ServiceClient.class, ServiceAsyncClient.class) - .put(AdminClient.class, AdminAsyncClient.class) + .put(TokenClient.class, TokenAsyncClient.class) + .put(UserClient.class, UserAsyncClient.class) + .put(TenantClient.class, TenantAsyncClient.class) .build(); - + + @SuppressWarnings("unchecked") public KeystoneRestClientModule() { - super(DELEGATE_MAP); + super((TypeToken) TypeToken.of(KeystoneClient.class), (TypeToken) TypeToken.of(KeystoneAsyncClient.class), DELEGATE_MAP); + } + + protected KeystoneRestClientModule(TypeToken syncClientType, TypeToken asyncClientType, + Map, Class> sync2Async) { + super(syncClientType, asyncClientType, sync2Async); } @Override @@ -61,13 +72,10 @@ public class KeystoneRestClientModule extends RestClientModule * @author Adrian Cole */ +@CredentialType(CredentialTypes.API_ACCESS_KEY_CREDENTIALS) public class ApiAccessKeyCredentials { public static Builder builder() { return new Builder(); diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiMetadata.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiMetadata.java index 5b78d101c3..14e5552c67 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiMetadata.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/ApiMetadata.java @@ -105,15 +105,31 @@ public class ApiMetadata extends Resource { private String status; @Nullable private Date updated; + + + // dealing with the goofy structure with "values" holder noted here + // http://docs.openstack.org/api/openstack-identity-service/2.0/content/Versions-d1e472.html + // if they change this to not be a value holder, we'll probably need to write a custom + // deserializer. + private static class MediaTypesHolder { + private Set values = ImmutableSet.of(); + + private MediaTypesHolder() { + } + + private MediaTypesHolder(Set mediaTypes) { + this.values = ImmutableSet.copyOf(checkNotNull(mediaTypes, "mediaTypes")); + } + } + @SerializedName(value="media-types") - @Nullable - private Set mediaTypes = ImmutableSet.of(); + private MediaTypesHolder mediaTypes = new MediaTypesHolder(); protected ApiMetadata(Builder builder) { super(builder); this.status = checkNotNull(builder.status, "status"); this.updated = checkNotNull(builder.updated, "updated"); - this.mediaTypes = ImmutableSet.copyOf(checkNotNull(builder.mediaTypes, "mediaTypes")); + this.mediaTypes = new MediaTypesHolder(builder.mediaTypes); } /** @@ -131,12 +147,12 @@ public class ApiMetadata extends Resource { /** */ public Set getMediaTypes() { - return Collections.unmodifiableSet(this.mediaTypes); + return Collections.unmodifiableSet(this.mediaTypes.values); } @Override public int hashCode() { - return Objects.hashCode(status, updated, mediaTypes); + return Objects.hashCode(status, updated, mediaTypes.values); } @Override @@ -146,14 +162,14 @@ public class ApiMetadata extends Resource { ApiMetadata that = ApiMetadata.class.cast(obj); return super.equals(that) && Objects.equal(this.status, that.status) && Objects.equal(this.updated, that.updated) - && Objects.equal(this.mediaTypes, that.mediaTypes); + && Objects.equal(this.mediaTypes.values, that.mediaTypes.values); } protected ToStringHelper string() { return super.string() .add("status", status) .add("updated", updated) - .add("mediaTypes", mediaTypes); + .add("mediaTypes", mediaTypes.values); } } \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Endpoint.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Endpoint.java index fc3c58e440..5574ed5ef3 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Endpoint.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Endpoint.java @@ -57,6 +57,8 @@ public class Endpoint implements Comparable { protected URI internalURL; protected URI adminURL; protected String tenantId; + protected URI versionInfo; + protected URI versionList; /** * @see Endpoint#getVersionId() @@ -105,14 +107,31 @@ public class Endpoint implements Comparable { this.tenantId = tenantId; return this; } - + + /** + * @see Endpoint#getVersionInfo() + */ + public Builder versionInfo(URI versionInfo) { + this.versionInfo = checkNotNull(versionInfo, "versionInfo"); + return this; + } + + /** + * @see Endpoint#getVersionList() + */ + public Builder versionList(URI versionList) { + this.versionList = checkNotNull(versionList, "versionList"); + return this; + } + public Endpoint build() { - return new Endpoint(versionId, region, publicURL, internalURL, adminURL, tenantId); + return new Endpoint(versionId, region, publicURL, internalURL, adminURL, tenantId, versionInfo, versionList); } public Builder fromEndpoint(Endpoint from) { return versionId(from.getVersionId()).region(from.getRegion()).publicURL(from.getPublicURL()).internalURL( - from.getInternalURL()).tenantId(from.getTenantId()); + from.getInternalURL()).tenantId(from.getTenantId()).versionInfo(from.getVersionInfo()).versionList( + from.getVersionList()); } } @@ -130,35 +149,41 @@ public class Endpoint implements Comparable { protected URI publicURL; protected URI internalURL; protected URI adminURL; + protected URI versionInfo; + protected URI versionList; // renamed half-way through @Deprecated protected String tenantName; protected String tenantId; - protected Endpoint(String versionId, String region, @Nullable URI publicURL, @Nullable URI internalURL, - @Nullable URI adminURL, @Nullable String tenantId) { - this.versionId = checkNotNull(versionId, "versionId"); - this.region = checkNotNull(region, "region"); + protected Endpoint(@Nullable String versionId, @Nullable String region, @Nullable URI publicURL, @Nullable URI internalURL, + @Nullable URI adminURL, @Nullable String tenantId, @Nullable URI versionInfo, @Nullable URI versionList) { + this.versionId = versionId; + this.region = region; this.publicURL = publicURL; this.internalURL = internalURL; this.adminURL = adminURL; this.tenantId = tenantId; + this.versionInfo = versionInfo; + this.versionList = versionList; } /** - * When provversionIding an ID, it is assumed that the endpoint exists in the current OpenStack + * When providing an ID, it is assumed that the endpoint exists in the current OpenStack * deployment * - * @return the versionId of the endpoint in the current OpenStack deployment + * @return the versionId of the endpoint in the current OpenStack deployment, or null if not specified */ + @Nullable public String getVersionId() { return versionId != null ? versionId : id; } /** - * @return the region of the endpoint + * @return the region of the endpoint, or null if not specified */ + @Nullable public String getRegion() { return region; } @@ -195,6 +220,20 @@ public class Endpoint implements Comparable { return tenantId != null ? tenantId : tenantName; } + /** + */ + @Nullable + public URI getVersionInfo() { + return versionInfo; + } + + /** + */ + @Nullable + public URI getVersionList() { + return versionList; + } + @Override public boolean equals(Object object) { if (this == object) { @@ -216,8 +255,9 @@ public class Endpoint implements Comparable { @Override public String toString() { - return toStringHelper("").add("versionId", getVersionId()).add("region", region).add("publicURL", publicURL).add("internalURL", - internalURL).add("adminURL", adminURL).add("tenantId", getTenantId()).toString(); + return toStringHelper("").add("versionId", getVersionId()).add("region", region).add("publicURL", publicURL).add( + "internalURL", internalURL).add("adminURL", adminURL).add("tenantId", getTenantId()).add("versionInfo", + versionInfo).add("versionList", versionList).toString(); } @Override diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/PasswordCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/PasswordCredentials.java index 8fef3d18b2..72fec16ea2 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/PasswordCredentials.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/PasswordCredentials.java @@ -23,6 +23,9 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.toStringHelper; import static com.google.common.base.Preconditions.checkNotNull; +import org.jclouds.openstack.keystone.v2_0.config.CredentialType; +import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; + import com.google.common.base.Objects; /** @@ -32,6 +35,7 @@ import com.google.common.base.Objects; * /> * @author Adrian Cole */ +@CredentialType(CredentialTypes.PASSWORD_CREDENTIALS) public class PasswordCredentials { public static Builder builder() { return new Builder(); diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Role.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Role.java index 3e7342ee31..51e8ec4eb5 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Role.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/domain/Role.java @@ -53,6 +53,7 @@ public class Role implements Comparable { public static class Builder { protected String id; protected String name; + protected String description; protected String serviceId; protected String tenantId; @@ -71,7 +72,15 @@ public class Role implements Comparable { this.name = checkNotNull(name, "name"); return this; } - + + /** + * @see Role#getDescription() + */ + public Builder description(String description) { + this.description = checkNotNull(description, "description"); + return this; + } + /** * @see Role#getServiceId() */ @@ -89,11 +98,11 @@ public class Role implements Comparable { } public Role build() { - return new Role(id, name, serviceId, tenantId); + return new Role(id, name, description, serviceId, tenantId); } public Builder fromRole(Role from) { - return id(from.getId()).name(from.getName()).serviceId(from.getServiceId()).tenantId(from.getTenantId()); + return id(from.getId()).name(from.getName()).description(from.getName()).serviceId(from.getServiceId()).tenantId(from.getTenantId()); } } @@ -105,15 +114,17 @@ public class Role implements Comparable { protected String id; protected String name; + protected String description; protected String serviceId; // renamed half-way through @Deprecated protected String tenantName; protected String tenantId; - protected Role(String id, String name, @Nullable String serviceId, @Nullable String tenantId) { + protected Role(String id, String name, @Nullable String description, @Nullable String serviceId, @Nullable String tenantId) { this.id = checkNotNull(id, "id"); this.name = checkNotNull(name, "name"); + this.description = description; this.serviceId = serviceId; this.tenantId = tenantId; } @@ -133,6 +144,14 @@ public class Role implements Comparable { public String getName() { return name; } + + /** + * @return the description of the role + */ + @Nullable + public String getDescription() { + return description; + } /** * @return the service id of the role or null, if not present @@ -171,7 +190,7 @@ public class Role implements Comparable { @Override public String toString() { - return toStringHelper("").add("id", id).add("name", name).add("serviceId", serviceId).add("tenantId", getTenantId()) + return toStringHelper("").add("id", id).add("name", name).add("description", description).add("serviceId", serviceId).add("tenantId", getTenantId()) .toString(); } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/AdminAsyncClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/AdminAsyncClient.java deleted file mode 100644 index 2c259af154..0000000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/AdminAsyncClient.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * 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.openstack.keystone.v2_0.features; - -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.HEAD; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; -import org.jclouds.openstack.keystone.v2_0.domain.Role; -import org.jclouds.openstack.keystone.v2_0.domain.Tenant; -import org.jclouds.openstack.keystone.v2_0.domain.Token; -import org.jclouds.openstack.keystone.v2_0.domain.User; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.rest.annotations.ExceptionParser; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.annotations.SkipEncoding; -import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; -import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Admin via their REST API. - *

    - * - * @see AdminClient - * @see - * @author Adam Lowe - */ -@SkipEncoding({ '/', '=' }) -public interface AdminAsyncClient { - /** - * @see AdminClient#getApiMetadata() - */ - @GET - @SelectJson("version") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/") - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getApiMetadata(); - - /** - * @see AdminClient#listTenants() - */ - @GET - @SelectJson("tenants") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tenants") - @RequestFilters(AuthenticateRequest.class) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) - ListenableFuture> listTenants(); - - /** @see AdminClient#getToken(String) */ - @GET - @SelectJson("token") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tokens/{token}") - @RequestFilters(AuthenticateRequest.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getToken(@PathParam("token") String token); - - /** @see AdminClient#getUserOfToken(String) */ - @GET - @SelectJson("user") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tokens/{token}") - @RequestFilters(AuthenticateRequest.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getUserOfToken(@PathParam("token") String token); - - /** @see AdminClient#checkTokenIsValid(String) */ - @HEAD - @Path("/tokens/{token}") - @RequestFilters(AuthenticateRequest.class) - @ExceptionParser(ReturnFalseOnNotFoundOr404.class) - ListenableFuture checkTokenIsValid(@PathParam("token") String token); - - /** @see AdminClient#getEndpointsForToken(String) */ - @GET - @SelectJson("endpoints") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tokens/{token}/endpoints") - @RequestFilters(AuthenticateRequest.class) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) - ListenableFuture> getEndpointsForToken(@PathParam("token") String token); - - /** @see AdminClient#getTenant(String) */ - @GET - @SelectJson("tenant") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tenants/{tenantId}") - @RequestFilters(AuthenticateRequest.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getTenant(@PathParam("tenantId") String tenantId); - - /** @see AdminClient#getTenantByName(String) */ - @GET - @SelectJson("tenant") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tenants") - @RequestFilters(AuthenticateRequest.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getTenantByName(@QueryParam("name") String tenantName); - - /** @see AdminClient#listUsers() */ - @GET - @SelectJson("users") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/users") - @RequestFilters(AuthenticateRequest.class) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) - ListenableFuture> listUsers(); - - /** @see AdminClient#getUser(String) */ - @GET - @SelectJson("user") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/users/{userId}") - @RequestFilters(AuthenticateRequest.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getUser(@PathParam("userId") String userId); - - /** @see AdminClient#getUserByName(String) */ - @GET - @SelectJson("user") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/users") - @RequestFilters(AuthenticateRequest.class) - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getUserByName(@QueryParam("name") String userName); - - /** @see AdminClient#listRolesOfUser(String) */ - @GET - @SelectJson("roles") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/users/{userId}/roles") - @RequestFilters(AuthenticateRequest.class) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) - ListenableFuture> listRolesOfUser(@PathParam("userId") String userId); - - /** @see AdminClient#listRolesOfUserOnTenant(String, String) */ - @GET - @SelectJson("roles") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/tenants/{tenantId}/users/{userId}/roles") - @RequestFilters(AuthenticateRequest.class) - @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) - ListenableFuture> listRolesOfUserOnTenant(@PathParam("userId") String userId, @PathParam("tenantId") String tenantId); -} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/AdminClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/AdminClient.java deleted file mode 100644 index bbaa922aba..0000000000 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/AdminClient.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * 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.openstack.keystone.v2_0.features; - -import java.util.Set; -import java.util.concurrent.TimeUnit; - -import org.jclouds.concurrent.Timeout; -import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; -import org.jclouds.openstack.keystone.v2_0.domain.Role; -import org.jclouds.openstack.keystone.v2_0.domain.Tenant; -import org.jclouds.openstack.keystone.v2_0.domain.Token; -import org.jclouds.openstack.keystone.v2_0.domain.User; - -/** - * Provides synchronous access to the KeyStone Admin API. - *

    - * - * @author Adam Lowe - * @see AdminAsyncClient - * @see - */ -@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) -public interface AdminClient { - - /** - * Discover API version information, links to documentation (PDF, HTML, WADL), and supported media types - * - * @return the requested information - */ - ApiMetadata getApiMetadata(); - - /** - * The operation returns a list of tenants which the current token provides access to. - */ - Set listTenants(); - - /** - * Retrieve information about a tenant, by tenant ID - * - * @return the information about the tenant - */ - Tenant getTenant(String tenantId); - - /** - * Retrieve information about a tenant, by tenant name - *

    - * NOTE: currently not working in openstack ( https://bugs.launchpad.net/keystone/+bug/956687 ) - * - * @return the information about the tenant - */ - Tenant getTenantByName(String tenantName); - - /** - * Validate a token and, if it is valid, return access information regarding the tenant (though not the service catalog)/ - * - * @return the requested information - */ - Token getToken(String token); - - /** - * Validate a token and, if it is valid, return access information regarding the tenant (though not the service catalog)/ - * - * @return the requested information - */ - User getUserOfToken(String token); - - /** - * Validate a token. This is a high-performance variant of the #getToken() call that does not return any further - * information. - * - * @return true if the token is valid - */ - Boolean checkTokenIsValid(String token); - - /** - * List all endpoints for a token - *

    - * NOTE: currently not working in openstack ( https://bugs.launchpad.net/keystone/+bug/988672 ) - * - * @return the set of endpoints - */ - Set getEndpointsForToken(String token); - - /** - * Retrieve the list of users - *

    - * NOTE: this method is not in API documentation for keystone, but does work - * - * @return the list of users - */ - Set listUsers(); - - /** - * Retrieve information about a user, by user ID - * - * @return the information about the user - */ - User getUser(String userId); - - /** - * Retrieve information about a user, by user name - *

    - * NOTE: currently not working in openstack ( https://bugs.launchpad.net/keystone/+bug/956687 ) - * - * @return the information about the user - */ - User getUserByName(String userName); - - /** - * Retrieves the list of global roles associated with a specific user (excludes tenant roles). - *

    - * NOTE: Broken in openstack ( https://bugs.launchpad.net/keystone/+bug/933565 ) - * - * @return the set of Roles granted to the user - */ - Set listRolesOfUser(String userId); - - /** - * List the roles a user has been granted on a specific tenant - * - * @return the set of roles - */ - Set listRolesOfUserOnTenant(String userId, String tenantId); - -} \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceAsyncClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TenantAsyncClient.java similarity index 64% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceAsyncClient.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TenantAsyncClient.java index 7a7f10d209..20955ecb66 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceAsyncClient.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TenantAsyncClient.java @@ -23,9 +23,11 @@ import java.util.Set; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; -import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; +import org.jclouds.Constants; import org.jclouds.openstack.keystone.v2_0.domain.Tenant; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.rest.annotations.ExceptionParser; @@ -38,28 +40,21 @@ import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import com.google.common.util.concurrent.ListenableFuture; /** - * Provides asynchronous access to Service via their REST API. + * Provides asynchronous access to Tenant via their REST API. *

    * - * @see ServiceClient - * @see * @author Adam Lowe */ -@SkipEncoding({ '/', '=' }) -public interface ServiceAsyncClient { - /** - * @see ServiceClient#getApiMetadata() - */ - @GET - @SelectJson("version") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/") - @ExceptionParser(ReturnNullOnNotFoundOr404.class) - ListenableFuture getApiMetadata(); +@Path("/v{" + Constants.PROPERTY_API_VERSION + "}") +@SkipEncoding( { '/', '=' }) +public interface TenantAsyncClient { /** - * @see ServiceClient#listTenants() + * @see TenantClient#list() */ @GET @SelectJson("tenants") @@ -67,5 +62,24 @@ public interface ServiceAsyncClient { @Path("/tenants") @RequestFilters(AuthenticateRequest.class) @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) - ListenableFuture> listTenants(); + ListenableFuture> list(); + + /** @see TenantClient#get(String) */ + @GET + @SelectJson("tenant") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/tenants/{tenantId}") + @RequestFilters(AuthenticateRequest.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture get(@PathParam("tenantId") String tenantId); + + /** @see TenantClient#getByName(String) */ + @GET + @SelectJson("tenant") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/tenants") + @RequestFilters(AuthenticateRequest.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getByName(@QueryParam("name") String tenantName); + } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TenantClient.java similarity index 64% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceClient.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TenantClient.java index 604f8d3705..8253b912a4 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/ServiceClient.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TenantClient.java @@ -22,30 +22,39 @@ import java.util.Set; import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; -import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; import org.jclouds.openstack.keystone.v2_0.domain.Tenant; /** - * Provides synchronous access to the KeyStone Service API. + * Provides synchronous access to the KeyStone Tenant API. *

    - * + * * @author Adam Lowe - * @see ServiceAsyncClient - * @see */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) -public interface ServiceClient { - - /** - * Discover API version information, links to documentation (PDF, HTML, WADL), and supported media types - * - * @return the requested information - */ - ApiMetadata getApiMetadata(); +public interface TenantClient { /** * The operation returns a list of tenants which the current token provides access to. */ - Set listTenants(); + Set list(); + + /** + * Retrieve information about a tenant, by tenant ID + * + * @return the information about the tenant + */ + Tenant get(String tenantId); + + /** + * Retrieve information about a tenant, by tenant name + *

    + * NOTE: currently not working in openstack ( https://bugs.launchpad.net/keystone/+bug/956687 ) + * + * @return the information about the tenant + */ + Tenant getByName(String tenantName); } \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenAsyncClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenAsyncClient.java new file mode 100644 index 0000000000..7975954954 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenAsyncClient.java @@ -0,0 +1,94 @@ +/** + * 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.openstack.keystone.v2_0.features; + +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Constants; +import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; +import org.jclouds.openstack.keystone.v2_0.domain.Token; +import org.jclouds.openstack.keystone.v2_0.domain.User; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides asynchronous access to Token via their REST API. + *

    + * + * @see TokenClient + * @see + * @author Adam Lowe + */ +@Path("/v{" + Constants.PROPERTY_API_VERSION + "}") +@SkipEncoding({ '/', '=' }) +public interface TokenAsyncClient { + + + /** @see TokenClient#get(String) */ + @GET + @SelectJson("token") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/tokens/{token}") + @RequestFilters(AuthenticateRequest.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture get(@PathParam("token") String token); + + /** @see TokenClient#getUserOfToken(String) */ + @GET + @SelectJson("user") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/tokens/{token}") + @RequestFilters(AuthenticateRequest.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getUserOfToken(@PathParam("token") String token); + + /** @see TokenClient#isValid(String) */ + @HEAD + @Path("/tokens/{token}") + @RequestFilters(AuthenticateRequest.class) + @ExceptionParser(ReturnFalseOnNotFoundOr404.class) + ListenableFuture isValid(@PathParam("token") String token); + + /** @see TokenClient#listEndpointsForToken(String) */ + @GET + @SelectJson("endpoints") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/tokens/{token}/endpoints") + @RequestFilters(AuthenticateRequest.class) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listEndpointsForToken(@PathParam("token") String token); + +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenClient.java new file mode 100644 index 0000000000..3a1078370d --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/TokenClient.java @@ -0,0 +1,77 @@ +/** + * 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.openstack.keystone.v2_0.features; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; +import org.jclouds.openstack.keystone.v2_0.domain.Token; +import org.jclouds.openstack.keystone.v2_0.domain.User; + +import com.google.common.annotations.Beta; + +/** + * Provides synchronous access to the KeyStone Admin API. + *

    + * + * @author Adam Lowe + * @see TokenAsyncClient + * @see + */ +@Beta +@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) +public interface TokenClient { + + + /** + * Validate a token and, if it is valid, return access information regarding the tenant (though not the service catalog)/ + * + * @return the requested information + */ + Token get(String token); + + /** + * Validate a token and, if it is valid, return access information regarding the tenant (though not the service catalog)/ + * + * @return the requested information + */ + User getUserOfToken(String token); + + /** + * Validate a token. This is a high-performance variant of the #getToken() call that does not return any further + * information. + * + * @return true if the token is valid + */ + boolean isValid(String token); + + /** + * List all endpoints for a token + *

    + * NOTE: currently not working in openstack ( https://bugs.launchpad.net/keystone/+bug/988672 ) + * + * @return the set of endpoints + */ + Set listEndpointsForToken(String token); + +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserAsyncClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserAsyncClient.java new file mode 100644 index 0000000000..d56f0d1b02 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserAsyncClient.java @@ -0,0 +1,101 @@ +/** + * 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.openstack.keystone.v2_0.features; + +import java.util.Set; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Constants; +import org.jclouds.openstack.keystone.v2_0.domain.Role; +import org.jclouds.openstack.keystone.v2_0.domain.User; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.rest.annotations.ExceptionParser; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.SkipEncoding; +import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; +import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides asynchronous access to User via their REST API. + *

    + * + * @see UserClient + * @see + * @author Adam Lowe + */ +@Path("/v{" + Constants.PROPERTY_API_VERSION + "}") +@SkipEncoding({ '/', '=' }) +public interface UserAsyncClient { + + /** @see UserClient#list() */ + @GET + @SelectJson("users") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/users") + @RequestFilters(AuthenticateRequest.class) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> list(); + + /** @see UserClient#get(String) */ + @GET + @SelectJson("user") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/users/{userId}") + @RequestFilters(AuthenticateRequest.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture get(@PathParam("userId") String userId); + + /** @see UserClient#getByName(String) */ + @GET + @SelectJson("user") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/users") + @RequestFilters(AuthenticateRequest.class) + @ExceptionParser(ReturnNullOnNotFoundOr404.class) + ListenableFuture getByName(@QueryParam("name") String userName); + + /** @see UserClient#listRolesOfUser(String) */ + @GET + @SelectJson("roles") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/users/{userId}/roles") + @RequestFilters(AuthenticateRequest.class) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listRolesOfUser(@PathParam("userId") String userId); + + /** @see UserClient#listRolesOfUserOnTenant(String, String) */ + @GET + @SelectJson("roles") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/tenants/{tenantId}/users/{userId}/roles") + @RequestFilters(AuthenticateRequest.class) + @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class) + ListenableFuture> listRolesOfUserOnTenant(@PathParam("userId") String userId, @PathParam("tenantId") String tenantId); +} diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserClient.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserClient.java new file mode 100644 index 0000000000..8a811ba242 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/features/UserClient.java @@ -0,0 +1,85 @@ +/** + * 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.openstack.keystone.v2_0.features; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.jclouds.concurrent.Timeout; +import org.jclouds.openstack.keystone.v2_0.domain.Role; +import org.jclouds.openstack.keystone.v2_0.domain.User; + +import com.google.common.annotations.Beta; + +/** + * Provides synchronous access to the KeyStone User API. + *

    + * + * @author Adam Lowe + * @see UserAsyncClient + * @see + */ +@Beta +@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) +public interface UserClient { + + /** + * Retrieve the list of users + *

    + * NOTE: this method is not in API documentation for keystone, but does work + * + * @return the list of users + */ + Set list(); + + /** + * Retrieve information about a user, by user ID + * + * @return the information about the user + */ + User get(String userId); + + /** + * Retrieve information about a user, by user name + *

    + * NOTE: currently not working in openstack ( https://bugs.launchpad.net/keystone/+bug/956687 ) + * + * @return the information about the user + */ + User getByName(String userName); + + /** + * Retrieves the list of global roles associated with a specific user (excludes tenant roles). + *

    + * NOTE: Broken in openstack ( https://bugs.launchpad.net/keystone/+bug/933565 ) + * + * @return the set of Roles granted to the user + */ + Set listRolesOfUser(String userId); + + /** + * List the roles a user has been granted on a specific tenant + * + * @return the set of roles + */ + Set listRolesOfUserOnTenant(String userId, String tenantId); + +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticateApiAccessKeyCredentials.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticateApiAccessKeyCredentials.java index d1aa97f24e..b6915e8e1d 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticateApiAccessKeyCredentials.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/AuthenticateApiAccessKeyCredentials.java @@ -21,17 +21,17 @@ package org.jclouds.openstack.keystone.v2_0.functions; import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.domain.Credentials; import org.jclouds.openstack.keystone.v2_0.AuthenticationClient; +import org.jclouds.openstack.keystone.v2_0.config.CredentialType; +import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; import org.jclouds.openstack.keystone.v2_0.domain.Access; import org.jclouds.openstack.keystone.v2_0.domain.ApiAccessKeyCredentials; -import org.jclouds.rest.AuthorizationException; - -import com.google.common.base.Function; +import org.jclouds.openstack.keystone.v2_0.functions.internal.BaseAuthenticator; +@CredentialType(CredentialTypes.API_ACCESS_KEY_CREDENTIALS) @Singleton -public class AuthenticateApiAccessKeyCredentials implements Function { - private final AuthenticationClient client; +public class AuthenticateApiAccessKeyCredentials extends BaseAuthenticator { + protected final AuthenticationClient client; @Inject public AuthenticateApiAccessKeyCredentials(AuthenticationClient client) { @@ -39,25 +39,18 @@ public class AuthenticateApiAccessKeyCredentials implements Function { - private final AuthenticationClient client; +@CredentialType(CredentialTypes.PASSWORD_CREDENTIALS) +@Singleton +public class AuthenticatePasswordCredentials extends BaseAuthenticator { + protected final AuthenticationClient client; @Inject public AuthenticatePasswordCredentials(AuthenticationClient client) { @@ -37,25 +39,18 @@ public class AuthenticatePasswordCredentials implements Function { } \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegion.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionOrProvider.java similarity index 75% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegion.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionOrProvider.java index 37ec7d8ce0..2a2a3dff46 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegion.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionOrProvider.java @@ -20,15 +20,23 @@ package org.jclouds.openstack.keystone.v2_0.functions; import static com.google.common.base.Preconditions.checkNotNull; +import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.location.Provider; import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; @Singleton -public class ReturnRegion implements EndpointToRegion { +public class ReturnRegionOrProvider implements EndpointToRegion { + private String provider; + + @Inject + ReturnRegionOrProvider(@Provider String provider) { + this.provider = checkNotNull(provider, "provider"); + } @Override public String apply(Endpoint input) { - return checkNotNull(input.getRegion(), "no region for endpoint %s", input); + return input.getRegion() != null ? input.getRegion() : provider; } } \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/internal/BaseAuthenticator.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/internal/BaseAuthenticator.java new file mode 100644 index 0000000000..35704b4225 --- /dev/null +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/functions/internal/BaseAuthenticator.java @@ -0,0 +1,62 @@ +/** + * 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.openstack.keystone.v2_0.functions.internal; + +import javax.annotation.Resource; + +import org.jclouds.domain.Credentials; +import org.jclouds.logging.Logger; +import org.jclouds.openstack.keystone.v2_0.domain.Access; + +import com.google.common.base.Function; + +public abstract class BaseAuthenticator implements Function { + + @Resource + protected Logger logger = Logger.NULL; + + @Override + public Access apply(Credentials input) { + String tenantId = null; + String usernameOrAccessKey = input.identity; + if (input.identity.indexOf(':') == -1) { + logger.debug("Identity %s does not match format tenantName:accessKey", input.identity); + } else { + tenantId = input.identity.substring(0, input.identity.indexOf(':')); + usernameOrAccessKey = input.identity.substring(input.identity.indexOf(':') + 1); + } + String passwordOrSecretKey = input.credential; + + C creds = createCredentials(usernameOrAccessKey, passwordOrSecretKey); + Access access; + if (tenantId != null && tenantId.matches("^[0-9]+$")) { + access = authenticateWithTenantId(tenantId, creds); + } else { + access = authenticateWithTenantNameOrNull(tenantId, creds); + } + return access; + } + + public abstract C createCredentials(String identity, String credential); + + protected abstract Access authenticateWithTenantId(String tenantId, C apiAccessKeyCredentials); + + protected abstract Access authenticateWithTenantNameOrNull(String tenantId, C apiAccessKeyCredentials); + +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersionSupplier.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersion.java similarity index 92% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersionSupplier.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersion.java index 0b73cb8c46..4206cf673c 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersionSupplier.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/LocationIdToURIFromAccessForTypeAndVersion.java @@ -38,7 +38,7 @@ import com.google.common.collect.Maps; import com.google.inject.assistedinject.Assisted; @Singleton -public class LocationIdToURIFromAccessForTypeAndVersionSupplier implements Supplier>> { +public class LocationIdToURIFromAccessForTypeAndVersion implements Supplier>> { protected final Supplier access; protected final EndpointToSupplierURI endpointToSupplierURI; protected final Function endpointToLocationId; @@ -46,7 +46,7 @@ public class LocationIdToURIFromAccessForTypeAndVersionSupplier implements Suppl protected final String apiVersion; @Inject - public LocationIdToURIFromAccessForTypeAndVersionSupplier(Supplier access, + public LocationIdToURIFromAccessForTypeAndVersion(Supplier access, EndpointToSupplierURI endpointToSupplierURI, Function endpointToLocationId, @Assisted("apiType") String apiType, @Assisted("apiVersion") String apiVersion) { this.access = access; @@ -70,8 +70,8 @@ public class LocationIdToURIFromAccessForTypeAndVersionSupplier implements Suppl }); } catch (NoSuchElementException e) { - throw new NoSuchElementException(String.format("apiType %s not found in catalog %s", apiType, - accessResponse.getServiceCatalog())); + throw new NoSuchElementException(String.format("apiType %s not found in catalog %s", apiType, accessResponse + .getServiceCatalog())); } Map locationIdToEndpoint = Maps.uniqueIndex(Iterables.filter(service.getEndpoints(), new Predicate() { diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplier.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersion.java similarity index 72% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplier.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersion.java index 74d15f5be0..36496586e7 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplier.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersion.java @@ -21,6 +21,7 @@ package org.jclouds.openstack.keystone.v2_0.suppliers; import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.keystone.v2_0.domain.Access; import org.jclouds.openstack.keystone.v2_0.functions.EndpointToRegion; import org.jclouds.openstack.keystone.v2_0.functions.EndpointToSupplierAdminURI; @@ -29,12 +30,12 @@ import com.google.common.base.Supplier; import com.google.inject.assistedinject.Assisted; @Singleton -public class RegionIdToAdminURIFromAccessForTypeAndVersionSupplier extends - LocationIdToURIFromAccessForTypeAndVersionSupplier implements RegionIdToAdminURISupplier { +public class RegionIdToAdminURIFromAccessForTypeAndVersion extends LocationIdToURIFromAccessForTypeAndVersion implements + RegionIdToAdminURISupplier { @Inject - public RegionIdToAdminURIFromAccessForTypeAndVersionSupplier(Supplier access, - EndpointToSupplierAdminURI endpointToSupplierURI, EndpointToRegion endpointToRegion, - @Assisted("apiType") String apiType, @Assisted("apiVersion") String apiVersion) { + public RegionIdToAdminURIFromAccessForTypeAndVersion(Supplier access, + EndpointToSupplierAdminURI endpointToSupplierURI, EndpointToRegion endpointToRegion, + @Assisted("apiType") String apiType, @Nullable @Assisted("apiVersion") String apiVersion) { super(access, endpointToSupplierURI, endpointToRegion, apiType, apiVersion); } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURISupplier.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURISupplier.java index 9f2b1c15b7..d39e101da2 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURISupplier.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURISupplier.java @@ -3,6 +3,8 @@ package org.jclouds.openstack.keystone.v2_0.suppliers; import java.net.URI; import java.util.Map; +import org.jclouds.javax.annotation.Nullable; + import com.google.common.base.Supplier; import com.google.inject.ImplementedBy; import com.google.inject.assistedinject.Assisted; @@ -10,7 +12,7 @@ import com.google.inject.assistedinject.Assisted; /** * @author Adam Lowe */ -@ImplementedBy(RegionIdToAdminURIFromAccessForTypeAndVersionSupplier.class) +@ImplementedBy(RegionIdToAdminURIFromAccessForTypeAndVersion.class) public interface RegionIdToAdminURISupplier extends Supplier>> { static interface Factory { /** @@ -19,10 +21,10 @@ public interface RegionIdToAdminURISupplier extends Supplier access, + public RegionIdToURIFromAccessForTypeAndVersion(Supplier access, EndpointToSupplierURI endpointToSupplierURI, EndpointToRegion endpointToRegion, - @Assisted("apiType") String apiType, @Assisted("apiVersion") String apiVersion) { + @Assisted("apiType") String apiType, @Nullable @Assisted("apiVersion") String apiVersion) { super(access, endpointToSupplierURI, endpointToRegion, apiType, apiVersion); } diff --git a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplier.java b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersion.java similarity index 83% rename from apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplier.java rename to apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersion.java index 36ceb3c82d..350a9f8b8f 100644 --- a/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplier.java +++ b/apis/openstack-keystone/src/main/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersion.java @@ -21,6 +21,7 @@ package org.jclouds.openstack.keystone.v2_0.suppliers; import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.suppliers.ZoneIdToURISupplier; import org.jclouds.openstack.keystone.v2_0.domain.Access; import org.jclouds.openstack.keystone.v2_0.functions.EndpointToRegion; @@ -30,16 +31,16 @@ import com.google.common.base.Supplier; import com.google.inject.assistedinject.Assisted; @Singleton -public class ZoneIdToURIFromAccessForTypeAndVersionSupplier extends LocationIdToURIFromAccessForTypeAndVersionSupplier - implements ZoneIdToURISupplier { +public class ZoneIdToURIFromAccessForTypeAndVersion extends LocationIdToURIFromAccessForTypeAndVersion implements + ZoneIdToURISupplier { @Inject - public ZoneIdToURIFromAccessForTypeAndVersionSupplier( + public ZoneIdToURIFromAccessForTypeAndVersion( Supplier access, // NOTE that in some services, the region is in fact the zone. temporarily, we need // to use the region field, in this case. EndpointToSupplierURI endpointToSupplierURI, EndpointToRegion endpointToZone, - @Assisted("apiType") String apiType, @Assisted("apiVersion") String apiVersion) { + @Assisted("apiType") String apiType, @Nullable @Assisted("apiVersion") String apiVersion) { super(access, endpointToSupplierURI, endpointToZone, apiType, apiVersion); } diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/KeystoneClientExpectTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/KeystoneClientExpectTest.java new file mode 100644 index 0000000000..eddcb33090 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/KeystoneClientExpectTest.java @@ -0,0 +1,64 @@ +/** + * 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 1.1 (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-1.1 + * + * 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.openstack.keystone.v2_0; + +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; + +import java.net.URI; + +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; +import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest; +import org.jclouds.openstack.keystone.v2_0.parse.ParseRackspaceApiMetadataTest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMultimap; + +/** + * + * @author Adrian Cole + */ +@Test(testName = "KeystoneClientExpectTest") +public class KeystoneClientExpectTest extends BaseKeystoneRestClientExpectTest { + + public void testGetApiMetaData() { + KeystoneClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + HttpRequest.builder().method("GET").endpoint(URI.create(endpoint + "/v2.0/")). + headers(ImmutableMultimap.of("Accept", APPLICATION_JSON)).build(), + HttpResponse.builder().statusCode(200). + payload(payloadFromResourceWithContentType("/raxVersion.json", APPLICATION_JSON)).build()); + ApiMetadata metadata = client.getApiMetadata(); + + assertEquals(metadata, new ParseRackspaceApiMetadataTest().expected()); + } + + public void testGetApiMetaDataFailNotFound() { + KeystoneClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/").headers(ImmutableMultimap.of("Accept", APPLICATION_JSON)).build(), + standardResponseBuilder(404).build()); + assertNull(client.getApiMetadata()); + } + +} + diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/KeystoneClientLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/KeystoneClientLiveTest.java new file mode 100644 index 0000000000..3d0cddb328 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/KeystoneClientLiveTest.java @@ -0,0 +1,43 @@ +/** + * 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 1.1 (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-1.1 + * + * 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.openstack.keystone.v2_0; + +import static org.testng.Assert.assertNotNull; + +import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; +import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneClientLiveTest; +import org.testng.annotations.Test; + +/** + * Tests KeystoneClient + * + * @author Adam Lowe + */ +@Test(groups = "live", testName = "KeystoneClientLiveTest") +public class KeystoneClientLiveTest extends BaseKeystoneClientLiveTest { + + public void testGetApiMetaData() { + ApiMetadata result = keystoneContext.getApi().getApiMetadata(); + assertNotNull(result); + assertNotNull(result.getId()); + assertNotNull(result.getStatus()); + assertNotNull(result.getUpdated()); + } + +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/config/CredentialTypesTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/config/CredentialTypesTest.java new file mode 100644 index 0000000000..d8d8b2b786 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/config/CredentialTypesTest.java @@ -0,0 +1,54 @@ +/** + * 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.openstack.keystone.v2_0.config; + +import static org.testng.Assert.assertEquals; + +import org.jclouds.openstack.keystone.v2_0.domain.PasswordCredentials; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; + +/** + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "CredentialTypesTest") +public class CredentialTypesTest { + + public void testCredentialTypeOfWhenValid() { + assertEquals(CredentialTypes.credentialTypeOf(PasswordCredentials.createWithUsernameAndPassword("username", + "password")), CredentialTypes.PASSWORD_CREDENTIALS); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testCredentialTypeOfWithoutAnnotation() { + CredentialTypes.credentialTypeOf(""); + } + + public void testIndexByCredentialTypeWhenValid() { + assertEquals(CredentialTypes.indexByCredentialType( + ImmutableSet.of(PasswordCredentials.createWithUsernameAndPassword("username", "password"))).keySet(), + ImmutableSet.of(CredentialTypes.PASSWORD_CREDENTIALS)); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testIndexByCredentialTypeWithoutAnnotation() { + CredentialTypes.indexByCredentialType(ImmutableSet.of("")); + } +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/AdminClientExpectTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/AdminClientExpectTest.java deleted file mode 100644 index 9ca48068c4..0000000000 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/AdminClientExpectTest.java +++ /dev/null @@ -1,381 +0,0 @@ -/** - * 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 1.1 (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-1.1 - * - * 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.openstack.keystone.v2_0.features; - -import static javax.ws.rs.core.MediaType.APPLICATION_JSON; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.net.URI; -import java.util.Set; - -import org.jclouds.date.DateService; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.HttpResponseException; -import org.jclouds.openstack.keystone.v2_0.KeystoneClient; -import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; -import org.jclouds.openstack.keystone.v2_0.domain.MediaType; -import org.jclouds.openstack.keystone.v2_0.domain.Role; -import org.jclouds.openstack.keystone.v2_0.domain.Tenant; -import org.jclouds.openstack.keystone.v2_0.domain.Token; -import org.jclouds.openstack.keystone.v2_0.domain.User; -import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest; -import org.jclouds.openstack.v2_0.domain.Link; -import org.jclouds.rest.AuthorizationException; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; - -/** - * Tests parsing and Guice wiring of UserClient - * - * @author Adam Lowe - */ -@Test(testName = "AdminClientExpectTest") -public class AdminClientExpectTest extends BaseKeystoneRestClientExpectTest { - private DateService dateService = new SimpleDateFormatDateService(); - - public AdminClientExpectTest() { - endpoint = "https://csnode.jclouds.org:35357"; - } - - public void testGetApiMetaData() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/"). - headers(ImmutableMultimap.of("Accept", APPLICATION_JSON)).build(), - standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/api_metadata.json", APPLICATION_JSON)).build()) - .getAdminClientForRegion("region-a.geo-1"); - ApiMetadata metadata = client.getApiMetadata(); - assertNotNull(metadata); - assertEquals(metadata.getId(), "v2.0"); - - ApiMetadata expected = ApiMetadata.builder().id("v2.0") - .links(ImmutableSet.of(Link.builder().relation(Link.Relation.SELF).href(URI.create("http://172.16.89.140:5000/v2.0/")).build(), - Link.builder().relation(Link.Relation.DESCRIBEDBY).type("text/html").href(URI.create("http://docs.openstack.org/api/openstack-identity-service/2.0/content/")).build(), - Link.builder().relation(Link.Relation.DESCRIBEDBY).type("application/pdf").href(URI.create("http://docs.openstack.org/api/openstack-identity-service/2.0/identity-dev-guide-2.0.pdf")).build() - )) - .status("beta") - .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-11-19T00:00:00Z")) - .mediaTypes(ImmutableSet.of( - MediaType.builder().base("application/json").type("application/vnd.openstack.identity-v2.0+json").build(), - MediaType.builder().base("application/xml").type("application/vnd.openstack.identity-v2.0+xml").build() - )) - .build(); - - assertEquals(metadata, expected); - } - - public void testGetApiMetaDataFailNotFound() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/").headers(ImmutableMultimap.of("Accept", APPLICATION_JSON)).build(), - standardResponseBuilder(404).build()).getAdminClientForRegion("region-a.geo-1"); - assertNull(client.getApiMetadata()); - } - - public void testListTenants() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tenants").build(), - standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build()) - .getAdminClientForRegion("region-a.geo-1"); - Set tenants = client.listTenants(); - assertNotNull(tenants); - assertFalse(tenants.isEmpty()); - - Set expected = ImmutableSet.of( - Tenant.builder().name("demo").id("05d1dc7af71646deba64cfc17b81bec0").build(), - Tenant.builder().name("admin").id("7aa2e17ec29f44d193c48feaba0852cc").build() - ); - - assertEquals(tenants, expected); - } - - public void testListTenantsFailNotFound() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tenants").build(), - standardResponseBuilder(404).build()).getAdminClientForRegion("region-a.geo-1"); - assertTrue(client.listTenants().isEmpty()); - } - - public void testGetTenant() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tenants/013ba41150a14830bec85ffe93353bcc").build(), - standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build()) - .getAdminClientForRegion("region-a.geo-1"); - Tenant tenant = client.getTenant("013ba41150a14830bec85ffe93353bcc"); - assertNotNull(tenant); - assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").build()); - } - - @Test(expectedExceptions = AuthorizationException.class) - public void testListTenantsFailNotAuthorized() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tenants/013ba41150a14830bec85ffe93353bcc").build(), - standardResponseBuilder(401).build()).getAdminClientForRegion("region-a.geo-1"); - client.getTenant("013ba41150a14830bec85ffe93353bcc"); - } - - public void testGetTenantByName() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tenants?name=admin").build(), - standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build()) - .getAdminClientForRegion("region-a.geo-1"); - Tenant tenant = client.getTenantByName("admin"); - assertNotNull(tenant); - assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").build()); - } - - public void testGetTenantByNameFailNotFound() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tenants?name=admin").build(), - standardResponseBuilder(404).build()).getAdminClientForRegion("region-a.geo-1"); - assertNull(client.getTenantByName("admin")); - } - - public void testGetToken() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(), - standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build()) - .getAdminClientForRegion("region-a.geo-1"); - Token token = client.getToken("sometokenorother"); - assertNotNull(token); - assertEquals(token, - Token.builder().id("167eccdc790946969ced473732e8109b").expires(dateService.iso8601SecondsDateParse("2012-04-28T12:42:50Z")) - .tenant(Tenant.builder().id("4cea93f5464b4f1c921fb3e0461d72b5").name("demo").build()).build()); - } - - public void testGetTokenFailNotFound() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(), - standardResponseBuilder(404).build()) - .getAdminClientForRegion("region-a.geo-1"); - assertNull(client.getToken("sometokenorother")); - } - - @Test(expectedExceptions = HttpResponseException.class) - public void testGetTokenFail500() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(), - standardResponseBuilder(500).build()).getAdminClientForRegion("region-a.geo-1"); - client.getToken("sometokenorother"); - } - - public void testGetUserOfToken() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(), - standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build()) - .getAdminClientForRegion("region-a.geo-1"); - User user = client.getUserOfToken("sometokenorother"); - assertNotNull(user); - assertEquals(user, User.builder().id("2b9b606181634ae9ac86fd95a8bc2cde").name("admin") - .roles(ImmutableSet.of(Role.builder().id("79cada5c02814b57a52e0eed4dd388cb").name("admin").build())) - .build()); - } - - public void testGetUserOfTokenFailNotFound() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(), - standardResponseBuilder(404).build()).getAdminClientForRegion("region-a.geo-1"); - assertNull(client.getUserOfToken("sometokenorother")); - } - - public void testCheckTokenIsValid() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").method("HEAD") - .headers(ImmutableMultimap.of("X-Auth-Token", authToken)).build(), - standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build()) - .getAdminClientForRegion("region-a.geo-1"); - assertTrue(client.checkTokenIsValid("sometokenorother")); - } - - public void testCheckTokenIsValidFailNotValid() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").method("HEAD") - .headers(ImmutableMultimap.of("X-Auth-Token", authToken)).build(), - standardResponseBuilder(404).build()).getAdminClientForRegion("region-a.geo-1"); - assertFalse(client.checkTokenIsValid("sometokenorother")); - } - - @Test - public void testGetEndpointsForToken() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tokens/XXXXXX/endpoints").build(), - standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_endpoints.json", APPLICATION_JSON)).build()) - .getAdminClientForRegion("region-a.geo-1"); - Set endpoints = client.getEndpointsForToken("XXXXXX"); - - assertEquals(endpoints, ImmutableSet.of( - Endpoint.builder().publicURL(URI.create("https://csnode.jclouds.org/v2.0/")) - .adminURL(URI.create("https://csnode.jclouds.org:35357/v2.0/")) - .region("region-a.geo-1").versionId("2.0").build() - )); - } - - @Test - public void testGetEndpointsForTokenFailNotFound() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/tokens/XXXXXX/endpoints").build(), - standardResponseBuilder(404).build()) - .getAdminClientForRegion("region-a.geo-1"); - assertTrue(client.getEndpointsForToken("XXXXXX").isEmpty()); - } - - public void testListUsers() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/users").build(), - standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_list.json", APPLICATION_JSON)).build()) - .getAdminClientForRegion("region-a.geo-1"); - Set users = client.listUsers(); - assertNotNull(users); - assertFalse(users.isEmpty()); - - Set expected = ImmutableSet.of( - User.builder().name("nova").id("e021dfd758eb44a89f1c57c8ef3be8e2").build(), - User.builder().name("glance").id("3f6c1c9ba993495ead7d2eb2192e284f").build(), - User.builder().name("demo").id("667b2e1420604df8b67cd8ea57d4ee64").build(), - User.builder().name("admin").id("2b9b606181634ae9ac86fd95a8bc2cde").build() - ); - - assertEquals(users, expected); - } - - @Test(expectedExceptions = AuthorizationException.class) - public void testListUsersFailNotAuth() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/users").build(), - standardResponseBuilder(401).build()).getAdminClientForRegion("region-a.geo-1"); - client.listUsers(); - } - - public void testGetUser() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/users/e021dfd758eb44a89f1c57c8ef3be8e2").build(), - standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_details.json", APPLICATION_JSON)).build()) - .getAdminClientForRegion("region-a.geo-1"); - User user = client.getUser("e021dfd758eb44a89f1c57c8ef3be8e2"); - assertNotNull(user); - assertEquals(user, User.builder().name("nova").id("e021dfd758eb44a89f1c57c8ef3be8e2").build()); - } - - public void testGetUserFailNotFound() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/users/f021dfd758eb44a89f1c57c8ef3be8e2").build(), - standardResponseBuilder(404).build()).getAdminClientForRegion("region-a.geo-1"); - assertNull(client.getUser("f021dfd758eb44a89f1c57c8ef3be8e2")); - } - - public void testGetUserByName() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/users?name=nova").build(), - standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_details.json", APPLICATION_JSON)).build()) - .getAdminClientForRegion("region-a.geo-1"); - User user = client.getUserByName("nova"); - assertNotNull(user); - assertEquals(user, User.builder().name("nova").id("e021dfd758eb44a89f1c57c8ef3be8e2").build()); - } - - public void testGetUserByNameFailNotFound() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/users?name=fred").build(), - standardResponseBuilder(404).build()).getAdminClientForRegion("region-a.geo-1"); - assertNull(client.getUserByName("fred")); - } - - public void testListRolesOfUser() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(), - standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_role_list.json", APPLICATION_JSON)).build()) - .getAdminClientForRegion("region-a.geo-1"); - Set roles = client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f"); - assertNotNull(roles); - assertFalse(roles.isEmpty()); - assertEquals(roles, ImmutableSet.of( - Role.builder().id("79cada5c02814b57a52e0eed4dd388cb").name("admin").build() - )); - } - - public void testListRolesOfUserFailNotFound() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/users/4f6c1c9ba993495ead7d2eb2192e284f/roles").build(), - standardResponseBuilder(404).build()).getAdminClientForRegion("region-a.geo-1"); - assertTrue(client.listRolesOfUser("4f6c1c9ba993495ead7d2eb2192e284f").isEmpty()); - } - - @Test(expectedExceptions = HttpResponseException.class) - public void testListRolesOfUserFailNotImplemented() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/users/5f6c1c9ba993495ead7d2eb2192e284f/roles").build(), - standardResponseBuilder(501).build()).getAdminClientForRegion("region-a.geo-1"); - assertTrue(client.listRolesOfUser("5f6c1c9ba993495ead7d2eb2192e284f").isEmpty()); - } - - public void testListRolesOfUserInTenant() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(), - standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_tenant_role_list.json", APPLICATION_JSON)).build()) - .getAdminClientForRegion("region-a.geo-1"); - Set roles = client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f"); - assertNotNull(roles); - assertFalse(roles.isEmpty()); - assertEquals(roles, ImmutableSet.of( - Role.builder().id("31c451195aac49b386039341e2c92a16").name("KeystoneServiceAdmin").build(), - Role.builder().id("79cada5c02814b57a52e0eed4dd388cb").name("admin").build(), - Role.builder().id("6ea17ddd37a6447794cb0e164d4db894").name("KeystoneAdmin").build())); - } - - public void testListRolesOfUserInTenantFailNotFound() { - AdminClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - standardRequestBuilder(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(), - standardResponseBuilder(404).build()).getAdminClientForRegion("region-a.geo-1"); - assertTrue(client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f").isEmpty()); - } - -} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/AdminClientLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/AdminClientLiveTest.java deleted file mode 100644 index 62db6cd514..0000000000 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/AdminClientLiveTest.java +++ /dev/null @@ -1,192 +0,0 @@ -/** - * 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 1.1 (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-1.1 - * - * 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.openstack.keystone.v2_0.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.AssertJUnit.assertTrue; - -import java.net.URI; -import java.util.Set; - -import org.jclouds.http.HttpRequest; -import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; -import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; -import org.jclouds.openstack.keystone.v2_0.domain.Role; -import org.jclouds.openstack.keystone.v2_0.domain.Tenant; -import org.jclouds.openstack.keystone.v2_0.domain.Token; -import org.jclouds.openstack.keystone.v2_0.domain.User; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneClientLiveTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; - -/** - * Tests AdminClient - * - * @author Adam Lowe - */ -@Test(groups = "live", testName = "AdminClientLiveTest", singleThreaded = true) -public class AdminClientLiveTest extends BaseKeystoneClientLiveTest { - - protected String token; - - // Get the token currently in use (there's currently no listTokens()) - @BeforeMethod - public void grabToken() { - AuthenticateRequest ar = keystoneContext.getUtils().getInjector().getInstance(AuthenticateRequest.class); - HttpRequest test = ar.filter(HttpRequest.builder().method("GET").endpoint(URI.create(endpoint)).build()); - token = Iterables.getOnlyElement(test.getHeaders().get("X-Auth-Token")); - } - - public void testGetApiMetaData() { - for (String regionId : keystoneContext.getApi().getConfiguredRegions()) { - ApiMetadata result = keystoneContext.getApi().getAdminClientForRegion(regionId).getApiMetadata(); - assertNotNull(result); - assertNotNull(result.getId()); - assertNotNull(result.getStatus()); - assertNotNull(result.getUpdated()); - } - } - - public void testTenants() { - for (String regionId : keystoneContext.getApi().getConfiguredRegions()) { - AdminClient client = keystoneContext.getApi().getAdminClientForRegion(regionId); - Set result = client.listTenants(); - assertNotNull(result); - assertFalse(result.isEmpty()); - - for (Tenant tenant : result) { - assertNotNull(tenant.getId()); - - Tenant aTenant = client.getTenant(tenant.getId()); - assertEquals(aTenant, tenant); - } - } - } - - public void testToken() { - for (String regionId : keystoneContext.getApi().getConfiguredRegions()) { - AdminClient client = keystoneContext.getApi().getAdminClientForRegion(regionId); - assertTrue(client.checkTokenIsValid(token)); - Token result = client.getToken(token); - assertNotNull(result); - assertEquals(result.getId(), token); - assertNotNull(result.getTenant()); - - User user = client.getUserOfToken(token); - assertNotNull(user); - assertNotNull(user.getId()); - assertNotNull(user.getName()); - } - } - - public void testInvalidToken() { - for (String regionId : keystoneContext.getApi().getConfiguredRegions()) { - AdminClient client = keystoneContext.getApi().getAdminClientForRegion(regionId); - assertFalse(client.checkTokenIsValid("thisisnotarealtoken!")); - assertNull(client.getToken("thisisnotarealtoken!")); - } - } - - // TODO this threw 501 not implemented - @Test(enabled = false) - public void testTokenEndpoints() { - for (String regionId : keystoneContext.getApi().getConfiguredRegions()) { - AdminClient client = keystoneContext.getApi().getAdminClientForRegion(regionId); - Set endpoints = client.getEndpointsForToken(token); - assertNotNull(endpoints); - assertFalse(endpoints.isEmpty()); - } - } - - // TODO this threw 501 not implemented - @Test(enabled = false) - public void testInvalidTokenEndpoints() { - for (String regionId : keystoneContext.getApi().getConfiguredRegions()) { - AdminClient client = keystoneContext.getApi().getAdminClientForRegion(regionId); - assertTrue(client.getEndpointsForToken("thisisnotarealtoken!").isEmpty()); - } - } - - public void testUsers() { - for (String regionId : keystoneContext.getApi().getConfiguredRegions()) { - AdminClient client = keystoneContext.getApi().getAdminClientForRegion(regionId); - Set users = client.listUsers(); - assertNotNull(users); - assertFalse(users.isEmpty()); - for (User user : users) { - User aUser = client.getUser(user.getId()); - assertEquals(aUser, user); - } - } - } - - @Test(dependsOnMethods = {"testUsers", "testTenants"}) - public void testUserRolesOnTenant() { - for (String regionId : keystoneContext.getApi().getConfiguredRegions()) { - AdminClient client = keystoneContext.getApi().getAdminClientForRegion(regionId); - Set users = client.listUsers(); - Set tenants = client.listTenants(); - - for (User user : users) { - for (Tenant tenant : tenants) { - Set roles = client.listRolesOfUserOnTenant(user.getId(), tenant.getId()); - for (Role role : roles) { - assertNotNull(role.getId()); - } - } - } - } - } - - // TODO this functionality is currently broken in openstack - @Test(enabled = false, dependsOnMethods = "testUsers") - public void testListRolesOfUser() { - for (String regionId : keystoneContext.getApi().getConfiguredRegions()) { - AdminClient client = keystoneContext.getApi().getAdminClientForRegion(regionId); - for (User user : client.listUsers()) { - Set roles = client.listRolesOfUser(user.getId()); - for (Role role : roles) { - assertNotNull(role.getId()); - } - } - } - } - - // TODO this functionality is currently broken in openstack (possibly deprecated?) - @Test(enabled=false, dependsOnMethods = {"testUsers", "testTenants"}) - public void testUsersAndTenantsByName() { - for (String regionId : keystoneContext.getApi().getConfiguredRegions()) { - AdminClient client = keystoneContext.getApi().getAdminClientForRegion(regionId); - for (User user : client.listUsers()) { - User aUser = client.getUserByName(user.getName()); - assertEquals(aUser, user); - } - for (Tenant tenant : client.listTenants()) { - Tenant aTenant = client.getTenantByName(tenant.getName()); - assertEquals(aTenant, tenant); - } - } - } -} \ No newline at end of file diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TenantClientExpectTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TenantClientExpectTest.java new file mode 100644 index 0000000000..afe2bcb2cd --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TenantClientExpectTest.java @@ -0,0 +1,112 @@ +/** + * 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 1.1 (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-1.1 + * + * 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.openstack.keystone.v2_0.features; + +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import java.util.Set; + +import org.jclouds.openstack.keystone.v2_0.KeystoneClient; +import org.jclouds.openstack.keystone.v2_0.domain.Tenant; +import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest; +import org.jclouds.rest.AuthorizationException; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; + +/** + * Tests parsing and Guice wiring of TenantClient + * + * @author Adam Lowe + */ +@Test(testName = "TenantClientExpectTest") +public class TenantClientExpectTest extends BaseKeystoneRestClientExpectTest { + + public void testListTenants() { + TenantClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, + responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tenants").build(), + standardResponseBuilder(200).payload( + payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build()) + .getTenantClient(); + Set tenants = client.list(); + assertNotNull(tenants); + assertFalse(tenants.isEmpty()); + + Set expected = ImmutableSet.of(Tenant.builder().name("demo").id("05d1dc7af71646deba64cfc17b81bec0") + .build(), Tenant.builder().name("admin").id("7aa2e17ec29f44d193c48feaba0852cc").build()); + + assertEquals(tenants, expected); + } + + public void testListTenantsFailNotFound() { + TenantClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tenants").build(), standardResponseBuilder(404).build()) + .getTenantClient(); + assertTrue(client.list().isEmpty()); + } + + public void testGetTenant() { + TenantClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, + responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tenants/013ba41150a14830bec85ffe93353bcc").build(), + standardResponseBuilder(200).payload( + payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build()) + .getTenantClient(); + Tenant tenant = client.get("013ba41150a14830bec85ffe93353bcc"); + assertNotNull(tenant); + assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").build()); + } + + @Test(expectedExceptions = AuthorizationException.class) + public void testListTenantsFailNotAuthorized() { + TenantClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tenants/013ba41150a14830bec85ffe93353bcc").build(), + standardResponseBuilder(401).build()).getTenantClient(); + client.get("013ba41150a14830bec85ffe93353bcc"); + } + + public void testGetTenantByName() { + TenantClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, + responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tenants?name=admin").build(), + standardResponseBuilder(200).payload( + payloadFromResourceWithContentType("/tenant_details.json", APPLICATION_JSON)).build()) + .getTenantClient(); + Tenant tenant = client.getByName("admin"); + assertNotNull(tenant); + assertEquals(tenant, Tenant.builder().id("013ba41150a14830bec85ffe93353bcc").name("admin").build()); + } + + public void testGetTenantByNameFailNotFound() { + TenantClient client = requestsSendResponses(keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tenants?name=admin").build(), + standardResponseBuilder(404).build()).getTenantClient(); + assertNull(client.getByName("admin")); + } + +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TenantClientLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TenantClientLiveTest.java new file mode 100644 index 0000000000..09f9f2069b --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TenantClientLiveTest.java @@ -0,0 +1,67 @@ +/** + * 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 1.1 (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-1.1 + * + * 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.openstack.keystone.v2_0.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; + +import java.util.Set; + +import org.jclouds.openstack.keystone.v2_0.domain.Tenant; +import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneClientLiveTest; +import org.testng.annotations.Test; + +/** + * Tests TenantClient + * + * @author Adam Lowe + */ +@Test(groups = "live", testName = "TenantClientLiveTest") +public class TenantClientLiveTest extends BaseKeystoneClientLiveTest { + + public void testTenants() { + TenantClient client = keystoneContext.getApi().getTenantClient(); + Set result = client.list(); + assertNotNull(result); + assertFalse(result.isEmpty()); + + for (Tenant tenant : result) { + assertNotNull(tenant.getId()); + + Tenant aTenant = client.get(tenant.getId()); + assertNotNull(aTenant, "get returned null for tenant: " + tenant); + + assertEquals(aTenant, tenant); + } + } + + public void testTenantsByName() { + + TenantClient client = keystoneContext.getApi().getTenantClient(); + + for (Tenant tenant : client.list()) { + Tenant aTenant = client.getByName(tenant.getName()); + assertNotNull(aTenant, "get returned null for tenant: " + tenant); + + assertEquals(aTenant, tenant); + } + + } +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TokenClientExpectTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TokenClientExpectTest.java new file mode 100644 index 0000000000..bb77b3a4e9 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TokenClientExpectTest.java @@ -0,0 +1,153 @@ +/** + * 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 1.1 (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-1.1 + * + * 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.openstack.keystone.v2_0.features; + +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.date.DateService; +import org.jclouds.date.internal.SimpleDateFormatDateService; +import org.jclouds.http.HttpResponseException; +import org.jclouds.openstack.keystone.v2_0.KeystoneClient; +import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; +import org.jclouds.openstack.keystone.v2_0.domain.Role; +import org.jclouds.openstack.keystone.v2_0.domain.Tenant; +import org.jclouds.openstack.keystone.v2_0.domain.Token; +import org.jclouds.openstack.keystone.v2_0.domain.User; +import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; + +/** + * Tests parsing and Guice wiring of TokenClient + * + * @author Adam Lowe + */ +@Test(testName = "TokenClientExpectTest") +public class TokenClientExpectTest extends BaseKeystoneRestClientExpectTest { + private DateService dateService = new SimpleDateFormatDateService(); + + public void testGetToken() { + TokenClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(), + standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build()) + .getTokenClient(); + Token token = client.get("sometokenorother"); + assertNotNull(token); + assertEquals(token, + Token.builder().id("167eccdc790946969ced473732e8109b").expires(dateService.iso8601SecondsDateParse("2012-04-28T12:42:50Z")) + .tenant(Tenant.builder().id("4cea93f5464b4f1c921fb3e0461d72b5").name("demo").build()).build()); + } + + public void testGetTokenFailNotFound() { + TokenClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(), + standardResponseBuilder(404).build()) + .getTokenClient(); + assertNull(client.get("sometokenorother")); + } + + @Test(expectedExceptions = HttpResponseException.class) + public void testGetTokenFail500() { + TokenClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(), + standardResponseBuilder(500).build()).getTokenClient(); + client.get("sometokenorother"); + } + + public void testGetUserOfToken() { + TokenClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(), + standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build()) + .getTokenClient(); + User user = client.getUserOfToken("sometokenorother"); + assertNotNull(user); + assertEquals(user, User.builder().id("2b9b606181634ae9ac86fd95a8bc2cde").name("admin") + .roles(ImmutableSet.of(Role.builder().id("79cada5c02814b57a52e0eed4dd388cb").name("admin").build())) + .build()); + } + + public void testGetUserOfTokenFailNotFound() { + TokenClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").build(), + standardResponseBuilder(404).build()).getTokenClient(); + assertNull(client.getUserOfToken("sometokenorother")); + } + + public void testCheckTokenIsValid() { + TokenClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").method("HEAD") + .headers(ImmutableMultimap.of("X-Auth-Token", authToken)).build(), + standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/token_details.json", APPLICATION_JSON)).build()) + .getTokenClient(); + assertTrue(client.isValid("sometokenorother")); + } + + public void testCheckTokenIsValidFailNotValid() { + TokenClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tokens/sometokenorother").method("HEAD") + .headers(ImmutableMultimap.of("X-Auth-Token", authToken)).build(), + standardResponseBuilder(404).build()).getTokenClient(); + assertFalse(client.isValid("sometokenorother")); + } + + @Test + public void testGetEndpointsForToken() { + TokenClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tokens/XXXXXX/endpoints").build(), + standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_endpoints.json", APPLICATION_JSON)).build()) + .getTokenClient(); + Set endpoints = client.listEndpointsForToken("XXXXXX"); + + assertEquals(endpoints, ImmutableSet.of( + Endpoint.builder().publicURL(URI.create("https://csnode.jclouds.org/v2.0/")) + .adminURL(URI.create("https://csnode.jclouds.org:35357/v2.0/")) + .region("region-a.geo-1").versionId("2.0").build() + )); + } + + @Test + public void testGetEndpointsForTokenFailNotFound() { + TokenClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/tokens/XXXXXX/endpoints").build(), + standardResponseBuilder(404).build()) + .getTokenClient(); + assertTrue(client.listEndpointsForToken("XXXXXX").isEmpty()); + } + + +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TokenClientLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TokenClientLiveTest.java new file mode 100644 index 0000000000..6dfbb92624 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/TokenClientLiveTest.java @@ -0,0 +1,98 @@ +/** + * 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 1.1 (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-1.1 + * + * 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.openstack.keystone.v2_0.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.AssertJUnit.assertTrue; + +import java.net.URI; +import java.util.Set; + +import org.jclouds.http.HttpRequest; +import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; +import org.jclouds.openstack.keystone.v2_0.domain.Token; +import org.jclouds.openstack.keystone.v2_0.domain.User; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneClientLiveTest; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import com.google.common.collect.Iterables; + +/** + * Tests TokenClient + * + * @author Adam Lowe + */ +@Test(groups = "live", testName = "TokenClientLiveTest", singleThreaded = true) +public class TokenClientLiveTest extends BaseKeystoneClientLiveTest { + + protected String token; + + // Get the token currently in use (there's currently no listTokens()) + @BeforeMethod + public void grabToken() { + AuthenticateRequest ar = keystoneContext.getUtils().getInjector().getInstance(AuthenticateRequest.class); + HttpRequest test = ar.filter(HttpRequest.builder().method("GET").endpoint(URI.create(endpoint)).build()); + token = Iterables.getOnlyElement(test.getHeaders().get("X-Auth-Token")); + } + + public void testToken() { + + TokenClient client = keystoneContext.getApi().getTokenClient(); + assertTrue(client.isValid(token)); + Token result = client.get(token); + assertNotNull(result); + assertEquals(result.getId(), token); + assertNotNull(result.getTenant()); + + User user = client.getUserOfToken(token); + assertNotNull(user); + assertNotNull(user.getId()); + assertNotNull(user.getName()); + + } + + public void testInvalidToken() { + + TokenClient client = keystoneContext.getApi().getTokenClient(); + assertFalse(client.isValid("thisisnotarealtoken!")); + assertNull(client.get("thisisnotarealtoken!")); + + } + + public void testTokenEndpoints() { + + TokenClient client = keystoneContext.getApi().getTokenClient(); + Set endpoints = client.listEndpointsForToken(token); + assertNotNull(endpoints); + assertFalse(endpoints.isEmpty()); + + } + + public void testInvalidTokenEndpoints() { + + TokenClient client = keystoneContext.getApi().getTokenClient(); + assertTrue(client.listEndpointsForToken("thisisnotarealtoken!").isEmpty()); + + } +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/UserClientExpectTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/UserClientExpectTest.java index d6e8504ecc..71b83dca17 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/UserClientExpectTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/UserClientExpectTest.java @@ -22,21 +22,19 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; -import java.net.URI; import java.util.Set; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; +import org.jclouds.http.HttpResponseException; import org.jclouds.openstack.keystone.v2_0.KeystoneClient; -import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; -import org.jclouds.openstack.keystone.v2_0.domain.MediaType; -import org.jclouds.openstack.keystone.v2_0.domain.Tenant; +import org.jclouds.openstack.keystone.v2_0.domain.Role; +import org.jclouds.openstack.keystone.v2_0.domain.User; import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneRestClientExpectTest; -import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.rest.AuthorizationException; +import org.testng.annotations.Test; -import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; /** @@ -44,53 +42,128 @@ import com.google.common.collect.ImmutableSet; * * @author Adam Lowe */ +@Test(testName = "UserClientExpectTest") public class UserClientExpectTest extends BaseKeystoneRestClientExpectTest { - public void testGetApiMetaData() { - ServiceClient client = requestsSendResponses( + public void testListUsers() { + UserClient client = requestsSendResponses( keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - HttpRequest.builder().method("GET").endpoint(URI.create(endpoint + "/v2.0/")). - headers(ImmutableMultimap.of("Accept", APPLICATION_JSON)).build(), - HttpResponse.builder().statusCode(200). - payload(payloadFromResourceWithContentType("/api_metadata.json", APPLICATION_JSON)).build()) - .getServiceClientForRegion("region-a.geo-1"); - ApiMetadata metadata = client.getApiMetadata(); - assertNotNull(metadata); - assertEquals(metadata.getId(), "v2.0"); + standardRequestBuilder(endpoint + "/v2.0/users").build(), + standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_list.json", APPLICATION_JSON)).build()) + .getUserClient(); + Set users = client.list(); + assertNotNull(users); + assertFalse(users.isEmpty()); - ApiMetadata expected = ApiMetadata.builder().id("v2.0") - .links(ImmutableSet.of(Link.builder().relation(Link.Relation.SELF).href(URI.create("http://172.16.89.140:5000/v2.0/")).build(), - Link.builder().relation(Link.Relation.DESCRIBEDBY).type("text/html").href(URI.create("http://docs.openstack.org/api/openstack-identity-service/2.0/content/")).build(), - Link.builder().relation(Link.Relation.DESCRIBEDBY).type("application/pdf").href(URI.create("http://docs.openstack.org/api/openstack-identity-service/2.0/identity-dev-guide-2.0.pdf")).build() - )) - .status("beta") - .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-11-19T00:00:00Z")) - .mediaTypes(ImmutableSet.of( - MediaType.builder().base("application/json").type("application/vnd.openstack.identity-v2.0+json").build(), - MediaType.builder().base("application/xml").type("application/vnd.openstack.identity-v2.0+xml").build() - )) - .build(); - - assertEquals(metadata, expected); - } - - public void testListTenants() { - ServiceClient client = requestsSendResponses( - keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, - HttpRequest.builder().method("GET").endpoint(URI.create(endpoint + "/v2.0/tenants")). - headers(ImmutableMultimap.of("Accept", APPLICATION_JSON, "X-Auth-Token", authToken)).build(), - HttpResponse.builder().statusCode(200). - payload(payloadFromResourceWithContentType("/tenant_list.json", APPLICATION_JSON)).build()) - .getServiceClientForRegion("region-a.geo-1"); - Set tenants = client.listTenants(); - assertNotNull(tenants); - assertFalse(tenants.isEmpty()); - - Set expected = ImmutableSet.of( - Tenant.builder().name("demo").id("05d1dc7af71646deba64cfc17b81bec0").build(), - Tenant.builder().name("admin").id("7aa2e17ec29f44d193c48feaba0852cc").build() + Set expected = ImmutableSet.of( + User.builder().name("nova").id("e021dfd758eb44a89f1c57c8ef3be8e2").build(), + User.builder().name("glance").id("3f6c1c9ba993495ead7d2eb2192e284f").build(), + User.builder().name("demo").id("667b2e1420604df8b67cd8ea57d4ee64").build(), + User.builder().name("admin").id("2b9b606181634ae9ac86fd95a8bc2cde").build() ); - assertEquals(tenants, expected); + assertEquals(users, expected); } + + @Test(expectedExceptions = AuthorizationException.class) + public void testListUsersFailNotAuth() { + UserClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/users").build(), + standardResponseBuilder(401).build()).getUserClient(); + client.list(); + } + + public void testGetUser() { + UserClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/users/e021dfd758eb44a89f1c57c8ef3be8e2").build(), + standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_details.json", APPLICATION_JSON)).build()) + .getUserClient(); + User user = client.get("e021dfd758eb44a89f1c57c8ef3be8e2"); + assertNotNull(user); + assertEquals(user, User.builder().name("nova").id("e021dfd758eb44a89f1c57c8ef3be8e2").build()); + } + + public void testGetUserFailNotFound() { + UserClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/users/f021dfd758eb44a89f1c57c8ef3be8e2").build(), + standardResponseBuilder(404).build()).getUserClient(); + assertNull(client.get("f021dfd758eb44a89f1c57c8ef3be8e2")); + } + + public void testGetUserByName() { + UserClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/users?name=nova").build(), + standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_details.json", APPLICATION_JSON)).build()) + .getUserClient(); + User user = client.getByName("nova"); + assertNotNull(user); + assertEquals(user, User.builder().name("nova").id("e021dfd758eb44a89f1c57c8ef3be8e2").build()); + } + + public void testGetUserByNameFailNotFound() { + UserClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/users?name=fred").build(), + standardResponseBuilder(404).build()).getUserClient(); + assertNull(client.getByName("fred")); + } + + public void testListRolesOfUser() { + UserClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(), + standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_role_list.json", APPLICATION_JSON)).build()) + .getUserClient(); + Set roles = client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f"); + assertNotNull(roles); + assertFalse(roles.isEmpty()); + assertEquals(roles, ImmutableSet.of( + Role.builder().id("79cada5c02814b57a52e0eed4dd388cb").name("admin").build() + )); + } + + public void testListRolesOfUserFailNotFound() { + UserClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/users/4f6c1c9ba993495ead7d2eb2192e284f/roles").build(), + standardResponseBuilder(404).build()).getUserClient(); + assertTrue(client.listRolesOfUser("4f6c1c9ba993495ead7d2eb2192e284f").isEmpty()); + } + + @Test(expectedExceptions = HttpResponseException.class) + public void testListRolesOfUserFailNotImplemented() { + UserClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/users/5f6c1c9ba993495ead7d2eb2192e284f/roles").build(), + standardResponseBuilder(501).build()).getUserClient(); + assertTrue(client.listRolesOfUser("5f6c1c9ba993495ead7d2eb2192e284f").isEmpty()); + } + + public void testListRolesOfUserInTenant() { + UserClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(), + standardResponseBuilder(200).payload(payloadFromResourceWithContentType("/user_tenant_role_list.json", APPLICATION_JSON)).build()) + .getUserClient(); + Set roles = client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f"); + assertNotNull(roles); + assertFalse(roles.isEmpty()); + assertEquals(roles, ImmutableSet.of( + Role.builder().id("31c451195aac49b386039341e2c92a16").name("KeystoneServiceAdmin").build(), + Role.builder().id("79cada5c02814b57a52e0eed4dd388cb").name("admin").build(), + Role.builder().id("6ea17ddd37a6447794cb0e164d4db894").name("KeystoneAdmin").build())); + } + + public void testListRolesOfUserInTenantFailNotFound() { + UserClient client = requestsSendResponses( + keystoneAuthWithUsernameAndPassword, responseWithKeystoneAccess, + standardRequestBuilder(endpoint + "/v2.0/users/3f6c1c9ba993495ead7d2eb2192e284f/roles").build(), + standardResponseBuilder(404).build()).getUserClient(); + assertTrue(client.listRolesOfUser("3f6c1c9ba993495ead7d2eb2192e284f").isEmpty()); + } + } diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/UserClientLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/UserClientLiveTest.java index c1cf75acee..3e1aaacefc 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/UserClientLiveTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/features/UserClientLiveTest.java @@ -18,43 +18,75 @@ */ package org.jclouds.openstack.keystone.v2_0.features; +import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import java.util.Set; -import org.jclouds.openstack.keystone.v2_0.domain.ApiMetadata; +import org.jclouds.openstack.keystone.v2_0.domain.Role; import org.jclouds.openstack.keystone.v2_0.domain.Tenant; +import org.jclouds.openstack.keystone.v2_0.domain.User; import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneClientLiveTest; import org.testng.annotations.Test; /** * Tests UserClient - * + * * @author Adam Lowe */ -@Test(groups = "live", testName = "UserClientLiveTest") +@Test(groups = "live", testName = "UserClientLiveTest", singleThreaded = true) public class UserClientLiveTest extends BaseKeystoneClientLiveTest { - public void testGetApiMetaData() { - for (String regionId : keystoneContext.getApi().getConfiguredRegions()) { - ApiMetadata result = keystoneContext.getApi().getServiceClientForRegion(regionId).getApiMetadata(); - assertNotNull(result); - assertNotNull(result.getId()); - assertNotNull(result.getStatus()); - assertNotNull(result.getUpdated()); + public void testUsers() { + + UserClient client = keystoneContext.getApi().getUserClient(); + Set users = client.list(); + assertNotNull(users); + assertFalse(users.isEmpty()); + for (User user : users) { + User aUser = client.get(user.getId()); + assertEquals(aUser, user); } + } - public void testListTenants() { - for (String regionId : keystoneContext.getApi().getConfiguredRegions()) { - Set result = keystoneContext.getApi().getServiceClientForRegion(regionId).listTenants(); - assertNotNull(result); - assertFalse(result.isEmpty()); + public void testUserRolesOnTenant() { - for (Tenant tenant : result) { - assertNotNull(tenant.getId()); + UserClient client = keystoneContext.getApi().getUserClient(); + Set users = client.list(); + Set tenants = keystoneContext.getApi().getTenantClient().list(); + + for (User user : users) { + for (Tenant tenant : tenants) { + Set roles = client.listRolesOfUserOnTenant(user.getId(), tenant.getId()); + for (Role role : roles) { + assertNotNull(role.getId()); + } } } + } -} + + public void testListRolesOfUser() { + + UserClient client = keystoneContext.getApi().getUserClient(); + for (User user : client.list()) { + Set roles = client.listRolesOfUser(user.getId()); + for (Role role : roles) { + assertNotNull(role.getId()); + } + } + + } + + public void testUsersByName() { + + UserClient client = keystoneContext.getApi().getUserClient(); + for (User user : client.list()) { + User aUser = client.getByName(user.getName()); + assertEquals(aUser, user); + } + + } +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionOrProviderTest.java similarity index 72% rename from apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionOrProviderTest.java index 4a8cfe5976..595ed260a1 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/functions/ReturnRegionOrProviderTest.java @@ -28,9 +28,9 @@ import org.testng.annotations.Test; /** * @author Adrian Cole */ -@Test(groups = "unit", testName = "ReturnRegionTest") -public class ReturnRegionTest { - private final ReturnRegion fn = new ReturnRegion(); +@Test(groups = "unit", testName = "ReturnRegionOrProviderTest") +public class ReturnRegionOrProviderTest { + private final ReturnRegionOrProvider fn = new ReturnRegionOrProvider("openstack-keystone"); public void testRegionNotNullReturnsRegion() { assertEquals( @@ -39,15 +39,11 @@ public class ReturnRegionTest { .build()), "LON"); } - public void testRegionNullNiceNPE() { - try { - fn.apply(Endpoint.builder().versionId("1.0").publicURL( - URI.create("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953")) - .build()); - assert false; - } catch (NullPointerException e) { - assertEquals(e.getMessage(), "region"); - } + public void testRegionNullReturnsProvider() { + assertEquals( + fn.apply(Endpoint.builder().versionId("1.0").publicURL( + URI.create("https://cdn3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953")) + .build()), "openstack-keystone"); } } diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneClientLiveTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneClientLiveTest.java index 3f7be6f320..217108c702 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneClientLiveTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneClientLiveTest.java @@ -38,13 +38,13 @@ import com.google.common.reflect.TypeToken; * @author Adam Lowe */ @Test(groups = "live") -public class BaseKeystoneClientLiveTest extends BaseContextLiveTest> { +public class BaseKeystoneClientLiveTest extends BaseContextLiveTest> { public BaseKeystoneClientLiveTest() { provider = "openstack-keystone"; } - protected RestContext keystoneContext; + protected RestContext keystoneContext; @BeforeGroups(groups = { "integration", "live" }) @Override @@ -67,7 +67,7 @@ public class BaseKeystoneClientLiveTest extends BaseContextLiveTest> contextType() { + protected TypeToken> contextType() { return KeystoneApiMetadata.CONTEXT_TOKEN; } diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestClientExpectTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestClientExpectTest.java index 102090a500..e48a7f43c9 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestClientExpectTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/internal/BaseKeystoneRestClientExpectTest.java @@ -25,8 +25,10 @@ import java.util.Properties; import javax.ws.rs.core.MediaType; +import org.jclouds.apis.ApiMetadata; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; +import org.jclouds.openstack.keystone.v2_0.KeystoneApiMetadata; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.rest.internal.BaseRestClientExpectTest; @@ -43,14 +45,14 @@ public class BaseKeystoneRestClientExpectTest extends BaseRestClientExpectTes protected HttpRequest keystoneAuthWithAccessKeyAndSecretKey; protected String authToken; protected HttpResponse responseWithKeystoneAccess; - protected String endpoint = "https://csnode.jclouds.org"; + protected String endpoint = "http://localhost:5000"; public BaseKeystoneRestClientExpectTest() { provider = "openstack-keystone"; keystoneAuthWithUsernameAndPassword = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPassword(identity, - credential); + credential); keystoneAuthWithAccessKeyAndSecretKey = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKey(identity, - credential); + credential); authToken = KeystoneFixture.INSTANCE.getAuthToken(); responseWithKeystoneAccess = KeystoneFixture.INSTANCE.responseWithAccess(); @@ -59,15 +61,15 @@ public class BaseKeystoneRestClientExpectTest extends BaseRestClientExpectTes } protected HttpRequest.Builder standardRequestBuilder(String endpoint) { - return HttpRequest.builder().method("GET") - .headers(ImmutableMultimap.of("Accept", MediaType.APPLICATION_JSON, "X-Auth-Token", authToken)) - .endpoint(URI.create(endpoint)); + return HttpRequest.builder().method("GET").headers( + ImmutableMultimap.of("Accept", MediaType.APPLICATION_JSON, "X-Auth-Token", authToken)).endpoint( + URI.create(endpoint)); } protected HttpResponse.Builder standardResponseBuilder(int status) { return HttpResponse.builder().statusCode(status); } - + @Override protected Properties setupProperties() { Properties props = super.setupProperties(); @@ -77,7 +79,13 @@ public class BaseKeystoneRestClientExpectTest extends BaseRestClientExpectTes @Override protected HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) { - return Objects.equal("HEAD", input.getMethod()) ? HttpRequestComparisonType.DEFAULT : HttpRequestComparisonType.JSON; + return Objects.equal("HEAD", input.getMethod()) ? HttpRequestComparisonType.DEFAULT + : HttpRequestComparisonType.JSON; + } + + @Override + protected ApiMetadata createApiMetadata() { + return new KeystoneApiMetadata(); } } diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseAccessTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseAccessTest.java index b4dd8e8277..ba381dd055 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseAccessTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseAccessTest.java @@ -85,17 +85,23 @@ public class ParseAccessTest extends BaseItemParserTest { .tenantId("3456") .publicURL(URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456")) .region("az-1.region-a.geo-1") - .versionId("1.1").build(), + .versionId("1.1") + .versionInfo(URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/")) + .versionList(URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com")).build(), Endpoint.builder() .tenantId("3456") .publicURL(URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456")) .region("az-2.region-a.geo-1") - .versionId("1.1").build(), + .versionId("1.1") + .versionInfo(URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/")) + .versionList(URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com")).build(), Endpoint.builder() .tenantId("3456") .publicURL(URI.create("https://az-3.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456")) .region("az-3.region-a.geo-1") - .versionId("1.1").build()).build(), + .versionId("1.1") + .versionInfo(URI.create("https://az-3.region-a.geo-1.compute.hpcloudsvc.com/v1.1/")) + .versionList(URI.create("https://az-3.region-a.geo-1.compute.hpcloudsvc.com")).build()).build(), Service.builder().name("Quantum Service").type("network").endpoints( Endpoint.builder() diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseRackspaceAccessTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseRackspaceAccessTest.java new file mode 100644 index 0000000000..670b1c5ab7 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseRackspaceAccessTest.java @@ -0,0 +1,113 @@ +/** + * 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.openstack.keystone.v2_0.parse; + +import java.net.URI; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; + +import org.jclouds.date.internal.SimpleDateFormatDateService; +import org.jclouds.json.BaseItemParserTest; +import org.jclouds.openstack.keystone.v2_0.domain.Access; +import org.jclouds.openstack.keystone.v2_0.domain.Endpoint; +import org.jclouds.openstack.keystone.v2_0.domain.Role; +import org.jclouds.openstack.keystone.v2_0.domain.Service; +import org.jclouds.openstack.keystone.v2_0.domain.Tenant; +import org.jclouds.openstack.keystone.v2_0.domain.Token; +import org.jclouds.openstack.keystone.v2_0.domain.User; +import org.jclouds.rest.annotations.SelectJson; +import org.testng.annotations.Test; + +/** + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "ParseAccessTest") +public class ParseRackspaceAccessTest extends BaseItemParserTest { + + @Override + public String resource() { + return "/raxAuth.json"; + } + + @Override + @SelectJson("access") + @Consumes(MediaType.APPLICATION_JSON) + public Access expected() { + return Access.builder().token( + Token.builder().expires(new SimpleDateFormatDateService().iso8601DateParse("2012-06-06T20:56:47.000-05:00")) + .id("Auth_4f173437e4b013bee56d1007").tenant( + Tenant.builder().id("40806637803162").name("40806637803162").build()) + .build()).user( + User.builder().id("54321").name("joe").roles( + Role.builder().id("3").name("identity:user-admin").description("User Admin Role.") + .build()).build()).serviceCatalog( + + Service.builder().name("cloudDatabases").type("rax:database").endpoints( + Endpoint.builder().tenantId("40806637803162").publicURL( + URI.create("https://dfw.databases.api.rackspacecloud.com/v1.0/40806637803162")) + .region("DFW").build(), + Endpoint.builder().tenantId("40806637803162").publicURL( + URI.create("https://ord.databases.api.rackspacecloud.com/v1.0/40806637803162")) + .region("ORD").build()).build(), + + Service.builder().name("cloudServers").type("compute").endpoints( + Endpoint.builder().tenantId("40806637803162").publicURL( + URI.create("https://servers.api.rackspacecloud.com/v1.0/40806637803162")) + .versionId("1.0").versionInfo(URI.create("https://servers.api.rackspacecloud.com/v1.0")) + .versionList(URI.create("https://servers.api.rackspacecloud.com/")).build()).build(), + + Service.builder().name("cloudFiles").type("object-store").endpoints( + Endpoint.builder().tenantId("MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22").publicURL( + URI.create("https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22")) + .internalURL( + URI.create("https://snet-storage101.dfw1.clouddrive.com/v1/MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22")) + .region("DFW").build()).build(), + + Service.builder().name("cloudServersOpenStack").type("compute").endpoints( + Endpoint.builder().tenantId("40806637803162").publicURL( + URI.create("https://dfw.servers.api.rackspacecloud.com/v2/40806637803162")) + .versionInfo(URI.create("https://dfw.servers.api.rackspacecloud.com/v2")) + .versionList(URI.create("https://dfw.servers.api.rackspacecloud.com/")) + .versionId("2") + .region("DFW").build()).build(), + + Service.builder().name("cloudLoadBalancers").type("rax:load-balancer").endpoints( + Endpoint.builder().tenantId("40806637803162").publicURL( + URI.create("https://ord.loadbalancers.api.rackspacecloud.com/v1.0/40806637803162")) + .region("ORD").build(), + Endpoint.builder().tenantId("40806637803162").publicURL( + URI.create("https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/40806637803162")) + .region("DFW").build()).build(), + + Service.builder().name("cloudMonitoring").type("rax:monitor").endpoints( + Endpoint.builder().tenantId("40806637803162").publicURL( + URI.create("https://monitoring.api.rackspacecloud.com/v1.0/40806637803162")).build()).build(), + + Service.builder().name("cloudDNS").type("dnsextension:dns").endpoints( + Endpoint.builder().tenantId("40806637803162").publicURL( + URI.create("https://dns.api.rackspacecloud.com/v1.0/40806637803162")).build()).build(), + + Service.builder().name("cloudFilesCDN").type("rax:object-cdn").endpoints( + Endpoint.builder().tenantId("MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22").publicURL( + URI.create("https://cdn1.clouddrive.com/v1/MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22")) + .region("DFW").build()).build() + ).build(); + } +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseApiMetadataTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseRackspaceApiMetadataTest.java similarity index 72% rename from apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseApiMetadataTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseRackspaceApiMetadataTest.java index df44b6d504..23647aee2b 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseApiMetadataTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/parse/ParseRackspaceApiMetadataTest.java @@ -7,7 +7,7 @@ * "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 + * https://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 @@ -33,30 +33,31 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; /** - * @author Adam Lowe + * @author Adrian Cole */ @Test(groups = "unit", testName = "ParseApiMetadataTest") -public class ParseApiMetadataTest extends BaseItemParserTest { +public class ParseRackspaceApiMetadataTest extends BaseItemParserTest { @Override public String resource() { - return "/apiMetadataResponse.json"; + return "/raxVersion.json"; } + // http://docs.openstack.org/api/openstack-identity-service/2.0/content/Versions-d1e472.html @Override @SelectJson("version") @Consumes(MediaType.APPLICATION_JSON) public ApiMetadata expected() { return ApiMetadata.builder().id("v2.0") - .links(ImmutableSet.of(Link.builder().relation(Link.Relation.SELF).href(URI.create("http://172.16.89.140:5000/v2.0/")).build(), - Link.builder().relation(Link.Relation.DESCRIBEDBY).type("text/html").href(URI.create("http://docs.openstack.org/api/openstack-identity-service/2.0/content/")).build(), - Link.builder().relation(Link.Relation.DESCRIBEDBY).type("application/pdf").href(URI.create("http://docs.openstack.org/api/openstack-identity-service/2.0/identity-dev-guide-2.0.pdf")).build() + .links(ImmutableSet.of(Link.builder().relation(Link.Relation.SELF).href(URI.create("https://identity.api.rackspacecloud.com/v2.0")).build(), + Link.builder().relation(Link.Relation.DESCRIBEDBY).type("application/pdf").href(URI.create("http://docs.rackspacecloud.com/auth/api/v2.0/auth-client-devguide-latest.pdf")).build(), + Link.builder().relation(Link.Relation.DESCRIBEDBY).type("application/vnd.sun.wadl+xml").href(URI.create("http://docs.rackspacecloud.com/auth/api/v2.0/auth.wadl")).build() )) - .status("beta") - .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-11-19T00:00:00Z")) + .status("BETA") + .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-01-21T11:33:21-06:00")) .mediaTypes(ImmutableSet.of( - org.jclouds.openstack.keystone.v2_0.domain.MediaType.builder().base("application/json").type("application/vnd.openstack.identity-v2.0+json").build(), - org.jclouds.openstack.keystone.v2_0.domain.MediaType.builder().base("application/xml").type("application/vnd.openstack.identity-v2.0+xml").build() + org.jclouds.openstack.keystone.v2_0.domain.MediaType.builder().base("application/xml").type("application/vnd.openstack.identity+xml;version=2.0").build(), + org.jclouds.openstack.keystone.v2_0.domain.MediaType.builder().base("application/json").type("application/vnd.openstack.identity+json;version=2.0").build() )) .build(); } diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplierTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionTest.java similarity index 51% rename from apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplierTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionTest.java index fffde689c6..09f266708e 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionSupplierTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToAdminURIFromAccessForTypeAndVersionTest.java @@ -22,11 +22,14 @@ import static org.testng.Assert.assertEquals; import java.net.URI; import java.util.Map; +import java.util.NoSuchElementException; import javax.inject.Singleton; +import org.jclouds.location.Provider; import org.jclouds.openstack.keystone.v2_0.domain.Access; import org.jclouds.openstack.keystone.v2_0.parse.ParseAccessTest; +import org.jclouds.openstack.keystone.v2_0.parse.ParseRackspaceAccessTest; import org.testng.annotations.Test; import com.google.common.base.Supplier; @@ -36,19 +39,23 @@ import com.google.common.collect.Maps; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Provides; +import com.google.inject.TypeLiteral; import com.google.inject.assistedinject.FactoryModuleBuilder; /** * @author Adam Lowe */ -@Test(groups = "unit", testName = "RegionIdToAdminURIFromAccessForTypeAndVersionSupplierTest") -public class RegionIdToAdminURIFromAccessForTypeAndVersionSupplierTest { +@Test(groups = "unit", testName = "RegionIdToAdminURIFromAccessForTypeAndVersionTest") +public class RegionIdToAdminURIFromAccessForTypeAndVersionTest { private final RegionIdToAdminURISupplier.Factory factory = Guice.createInjector(new AbstractModule() { @Override protected void configure() { + bindConstant().annotatedWith(Provider.class).to("openstack-keystone"); + bind(new TypeLiteral>() { + }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); install(new FactoryModuleBuilder().implement(RegionIdToAdminURISupplier.class, - RegionIdToAdminURIFromAccessForTypeAndVersionSupplier.class).build(RegionIdToAdminURISupplier.Factory.class)); + RegionIdToAdminURIFromAccessForTypeAndVersion.class).build(RegionIdToAdminURISupplier.Factory.class)); } @SuppressWarnings("unused") @@ -69,5 +76,45 @@ public class RegionIdToAdminURIFromAccessForTypeAndVersionSupplierTest { assertEquals(Maps.transformValues(factory.createForApiTypeAndVersion("compute", "1.1").get(), Suppliers . supplierFunction()), map); } + + private final RegionIdToAdminURISupplier.Factory raxFactory = Guice.createInjector(new AbstractModule() { + @Override + protected void configure() { + bindConstant().annotatedWith(Provider.class).to("rackspace"); + bind(new TypeLiteral>() { + }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); + install(new FactoryModuleBuilder().implement(RegionIdToAdminURISupplier.class, + RegionIdToAdminURIFromAccessForTypeAndVersion.class).build(RegionIdToAdminURISupplier.Factory.class)); + } + + @SuppressWarnings("unused") + @Provides + @Singleton + public Supplier provide() { + return Suppliers.ofInstance(new ParseRackspaceAccessTest().expected()); + } + }).getInstance(RegionIdToAdminURISupplier.Factory.class); + + @Test(expectedExceptions = NoSuchElementException.class) + public void testWhenNotInList() { + assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("goo", "1.0").get(), Suppliers + . supplierFunction()), ImmutableMap.of("rackspace", URI + .create("https://servers.api.rackspacecloud.com/v1.0/40806637803162"))); + } + + public void testProviderWhenNoRegions() { + Map map = Maps.newLinkedHashMap(); + map.put("rackspace", null); + assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("compute", "1.0").get(), Suppliers + . supplierFunction()), map); + } + + public void testOkWithNoVersions() { + Map map = Maps.newLinkedHashMap(); + map.put("DFW", null); + map.put("ORD", null); + assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("rax:database", null).get(), Suppliers + . supplierFunction()), map); + } } diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionSupplierTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionSupplierTest.java deleted file mode 100644 index ef993f1211..0000000000 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionSupplierTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * 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.openstack.keystone.v2_0.suppliers; - -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import javax.inject.Singleton; - -import org.jclouds.location.suppliers.RegionIdToURISupplier; -import org.jclouds.openstack.keystone.v2_0.domain.Access; -import org.jclouds.openstack.keystone.v2_0.parse.ParseAccessTest; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Maps; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Provides; -import com.google.inject.assistedinject.FactoryModuleBuilder; - -/** - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "RegionIdToURIFromAccessForTypeAndVersionSupplierTest") -public class RegionIdToURIFromAccessForTypeAndVersionSupplierTest { - private final RegionIdToURISupplier.Factory factory = Guice.createInjector(new AbstractModule() { - - @Override - protected void configure() { - install(new FactoryModuleBuilder().implement(RegionIdToURISupplier.class, - RegionIdToURIFromAccessForTypeAndVersionSupplier.class).build(RegionIdToURISupplier.Factory.class)); - } - - @SuppressWarnings("unused") - @Provides - @Singleton - public Supplier provide() { - return Suppliers.ofInstance(new ParseAccessTest().expected()); - } - }).getInstance(RegionIdToURISupplier.Factory.class); - - public void testRegionMatches() { - assertEquals(Maps.transformValues(factory.createForApiTypeAndVersion("compute", "1.0").get(), Suppliers - . supplierFunction()), ImmutableMap.of()); - assertEquals(Maps.transformValues(factory.createForApiTypeAndVersion("compute", "1.1").get(), Suppliers - . supplierFunction()), ImmutableMap.of("az-1.region-a.geo-1", URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456"), - "az-2.region-a.geo-1", URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456"), - "az-3.region-a.geo-1", URI.create("https://az-3.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456"))); - } - -} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionTest.java new file mode 100644 index 0000000000..650fcd5c82 --- /dev/null +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/RegionIdToURIFromAccessForTypeAndVersionTest.java @@ -0,0 +1,120 @@ +/** + * 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.openstack.keystone.v2_0.suppliers; + +import static org.testng.Assert.assertEquals; + +import java.net.URI; +import java.util.NoSuchElementException; + +import javax.inject.Singleton; + +import org.jclouds.location.Provider; +import org.jclouds.location.suppliers.RegionIdToURISupplier; +import org.jclouds.openstack.keystone.v2_0.domain.Access; +import org.jclouds.openstack.keystone.v2_0.parse.ParseAccessTest; +import org.jclouds.openstack.keystone.v2_0.parse.ParseRackspaceAccessTest; +import org.testng.annotations.Test; + +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Provides; +import com.google.inject.TypeLiteral; +import com.google.inject.assistedinject.FactoryModuleBuilder; + +/** + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "RegionIdToURIFromAccessForTypeAndVersionTest") +public class RegionIdToURIFromAccessForTypeAndVersionTest { + private final RegionIdToURISupplier.Factory factory = Guice.createInjector(new AbstractModule() { + + @Override + protected void configure() { + bindConstant().annotatedWith(Provider.class).to("openstack-keystone"); + bind(new TypeLiteral>(){ + }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); + install(new FactoryModuleBuilder().implement(RegionIdToURISupplier.class, + RegionIdToURIFromAccessForTypeAndVersion.class).build( + RegionIdToURISupplier.Factory.class)); + } + + @SuppressWarnings("unused") + @Provides + @Singleton + public Supplier provide() { + return Suppliers.ofInstance(new ParseAccessTest().expected()); + } + }).getInstance(RegionIdToURISupplier.Factory.class); + + public void testRegionMatches() { + assertEquals(Maps.transformValues(factory.createForApiTypeAndVersion("compute", "1.0").get(), Suppliers + . supplierFunction()), ImmutableMap.of()); + assertEquals(Maps.transformValues(factory.createForApiTypeAndVersion("compute", "1.1").get(), Suppliers + . supplierFunction()), ImmutableMap.of("az-1.region-a.geo-1", URI + .create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456"), "az-2.region-a.geo-1", URI + .create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456"), "az-3.region-a.geo-1", URI + .create("https://az-3.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456"))); + } + + private final RegionIdToURISupplier.Factory raxFactory = Guice.createInjector(new AbstractModule() { + + @Override + protected void configure() { + bindConstant().annotatedWith(Provider.class).to("rackspace"); + bind(new TypeLiteral>() { + }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); + install(new FactoryModuleBuilder().implement(RegionIdToURISupplier.class, + RegionIdToURIFromAccessForTypeAndVersion.class).build( + RegionIdToURISupplier.Factory.class)); + } + + @SuppressWarnings("unused") + @Provides + @Singleton + public Supplier provide() { + return Suppliers.ofInstance(new ParseRackspaceAccessTest().expected()); + } + }).getInstance(RegionIdToURISupplier.Factory.class); + + @Test(expectedExceptions = NoSuchElementException.class) + public void testWhenNotInList() { + assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("goo", "1.0").get(), Suppliers + . supplierFunction()), ImmutableMap.of("rackspace", URI + .create("https://servers.api.rackspacecloud.com/v1.0/40806637803162"))); + } + + public void testProviderWhenNoRegions() { + assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("compute", "1.0").get(), Suppliers + . supplierFunction()), ImmutableMap.of("rackspace", URI + .create("https://servers.api.rackspacecloud.com/v1.0/40806637803162"))); + } + + public void testOkWithNoVersions() { + assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("rax:database", null).get(), Suppliers + . supplierFunction()), ImmutableMap.of("DFW", URI + .create("https://dfw.databases.api.rackspacecloud.com/v1.0/40806637803162"), "ORD", URI + .create("https://ord.databases.api.rackspacecloud.com/v1.0/40806637803162"))); + } + +} diff --git a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplierTest.java b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionTest.java similarity index 52% rename from apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplierTest.java rename to apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionTest.java index b8c72edd78..3805196400 100644 --- a/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionSupplierTest.java +++ b/apis/openstack-keystone/src/test/java/org/jclouds/openstack/keystone/v2_0/suppliers/ZoneIdToURIFromAccessForTypeAndVersionTest.java @@ -21,12 +21,15 @@ package org.jclouds.openstack.keystone.v2_0.suppliers; import static org.testng.Assert.assertEquals; import java.net.URI; +import java.util.NoSuchElementException; import javax.inject.Singleton; +import org.jclouds.location.Provider; import org.jclouds.location.suppliers.ZoneIdToURISupplier; import org.jclouds.openstack.keystone.v2_0.domain.Access; import org.jclouds.openstack.keystone.v2_0.parse.ParseAccessTest; +import org.jclouds.openstack.keystone.v2_0.parse.ParseRackspaceAccessTest; import org.testng.annotations.Test; import com.google.common.base.Supplier; @@ -36,19 +39,23 @@ import com.google.common.collect.Maps; import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Provides; +import com.google.inject.TypeLiteral; import com.google.inject.assistedinject.FactoryModuleBuilder; /** * @author Adrian Cole */ @Test(groups = "unit", testName = "ZoneIdToURIFromAccessForTypeAndVersionSupplierTest") -public class ZoneIdToURIFromAccessForTypeAndVersionSupplierTest { +public class ZoneIdToURIFromAccessForTypeAndVersionTest { private final ZoneIdToURISupplier.Factory factory = Guice.createInjector(new AbstractModule() { @Override protected void configure() { + bindConstant().annotatedWith(Provider.class).to("rackspace"); + bind(new TypeLiteral>() { + }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); install(new FactoryModuleBuilder().implement(ZoneIdToURISupplier.class, - ZoneIdToURIFromAccessForTypeAndVersionSupplier.class).build(ZoneIdToURISupplier.Factory.class)); + ZoneIdToURIFromAccessForTypeAndVersion.class).build(ZoneIdToURISupplier.Factory.class)); } @SuppressWarnings("unused") @@ -67,5 +74,41 @@ public class ZoneIdToURIFromAccessForTypeAndVersionSupplierTest { "az-2.region-a.geo-1", URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456"), "az-3.region-a.geo-1", URI.create("https://az-3.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456"))); } + + private final ZoneIdToURISupplier.Factory raxFactory = Guice.createInjector(new AbstractModule() { + @Override + protected void configure() { + bindConstant().annotatedWith(Provider.class).to("rackspace"); + bind(new TypeLiteral>() { + }).annotatedWith(Provider.class).toInstance(Suppliers.ofInstance(URI.create("https://identity"))); + install(new FactoryModuleBuilder().implement(ZoneIdToURISupplier.class, + ZoneIdToURIFromAccessForTypeAndVersion.class).build(ZoneIdToURISupplier.Factory.class)); + } + + @SuppressWarnings("unused") + @Provides + @Singleton + public Supplier provide() { + return Suppliers.ofInstance(new ParseRackspaceAccessTest().expected()); + } + }).getInstance(ZoneIdToURISupplier.Factory.class); + + @Test(expectedExceptions = NoSuchElementException.class) + public void testWhenNotInList() { + assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("goo", "1.0").get(), Suppliers + . supplierFunction()), ImmutableMap.of("rackspace", URI + .create("https://servers.api.rackspacecloud.com/v1.0/40806637803162"))); + } + + public void testProviderWhenNoZones() { + assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("compute", "1.0").get(), Suppliers + . supplierFunction()), ImmutableMap.of("rackspace", URI.create("https://servers.api.rackspacecloud.com/v1.0/40806637803162"))); + } + + public void testOkWithNoVersions() { + assertEquals(Maps.transformValues(raxFactory.createForApiTypeAndVersion("rax:database", null).get(), Suppliers + . supplierFunction()), ImmutableMap.of("DFW", URI.create("https://dfw.databases.api.rackspacecloud.com/v1.0/40806637803162"), + "ORD", URI.create("https://ord.databases.api.rackspacecloud.com/v1.0/40806637803162"))); + } } diff --git a/apis/openstack-keystone/src/test/resources/apiMetadataResponse.json b/apis/openstack-keystone/src/test/resources/apiMetadataResponse.json deleted file mode 100644 index 09934299c9..0000000000 --- a/apis/openstack-keystone/src/test/resources/apiMetadataResponse.json +++ /dev/null @@ -1 +0,0 @@ -{"version": {"status": "beta", "updated": "2011-11-19T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v2.0+json"}, {"base": "application/xml", "type": "application/vnd.openstack.identity-v2.0+xml"}], "id": "v2.0", "links": [{"href": "http://172.16.89.140:5000/v2.0/", "rel": "self"}, {"href": "http://docs.openstack.org/api/openstack-identity-service/2.0/content/", "type": "text/html", "rel": "describedby"}, {"href": "http://docs.openstack.org/api/openstack-identity-service/2.0/identity-dev-guide-2.0.pdf", "type": "application/pdf", "rel": "describedby"}]}} \ No newline at end of file diff --git a/apis/openstack-keystone/src/test/resources/api_metadata.json b/apis/openstack-keystone/src/test/resources/api_metadata.json deleted file mode 100644 index 09934299c9..0000000000 --- a/apis/openstack-keystone/src/test/resources/api_metadata.json +++ /dev/null @@ -1 +0,0 @@ -{"version": {"status": "beta", "updated": "2011-11-19T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v2.0+json"}, {"base": "application/xml", "type": "application/vnd.openstack.identity-v2.0+xml"}], "id": "v2.0", "links": [{"href": "http://172.16.89.140:5000/v2.0/", "rel": "self"}, {"href": "http://docs.openstack.org/api/openstack-identity-service/2.0/content/", "type": "text/html", "rel": "describedby"}, {"href": "http://docs.openstack.org/api/openstack-identity-service/2.0/identity-dev-guide-2.0.pdf", "type": "application/pdf", "rel": "describedby"}]}} \ No newline at end of file diff --git a/apis/openstack-keystone/src/test/resources/raxAuth.json b/apis/openstack-keystone/src/test/resources/raxAuth.json new file mode 100644 index 0000000000..fbf29eff1f --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/raxAuth.json @@ -0,0 +1,98 @@ +{ + "access": { + "token": { + "id": "Auth_4f173437e4b013bee56d1007", + "expires": "2012-06-06T20:56:47.000-05:00", + "tenant": { + "id": "40806637803162", + "name": "40806637803162" + } + }, + "serviceCatalog": [{ + "endpoints": [{ + "region": "DFW", + "tenantId": "40806637803162", + "publicURL": "https:\/\/dfw.databases.api.rackspacecloud.com\/v1.0\/40806637803162" + }, { + "region": "ORD", + "tenantId": "40806637803162", + "publicURL": "https:\/\/ord.databases.api.rackspacecloud.com\/v1.0\/40806637803162" + }], + "name": "cloudDatabases", + "type": "rax:database" + }, { + "endpoints": [{ + "tenantId": "40806637803162", + "publicURL": "https:\/\/servers.api.rackspacecloud.com\/v1.0\/40806637803162", + "versionInfo": "https:\/\/servers.api.rackspacecloud.com\/v1.0", + "versionList": "https:\/\/servers.api.rackspacecloud.com\/", + "versionId": "1.0" + }], + "name": "cloudServers", + "type": "compute" + }, { + "endpoints": [{ + "region": "DFW", + "tenantId": "MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22", + "publicURL": "https:\/\/storage101.dfw1.clouddrive.com\/v1\/MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22", + "internalURL": "https:\/\/snet-storage101.dfw1.clouddrive.com\/v1\/MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22" + }], + "name": "cloudFiles", + "type": "object-store" + }, { + "endpoints": [{ + "region": "DFW", + "tenantId": "40806637803162", + "publicURL": "https:\/\/dfw.servers.api.rackspacecloud.com\/v2\/40806637803162", + "versionInfo": "https:\/\/dfw.servers.api.rackspacecloud.com\/v2", + "versionList": "https:\/\/dfw.servers.api.rackspacecloud.com\/", + "versionId": "2" + }], + "name": "cloudServersOpenStack", + "type": "compute" + }, { + "endpoints": [{ + "region": "ORD", + "tenantId": "40806637803162", + "publicURL": "https:\/\/ord.loadbalancers.api.rackspacecloud.com\/v1.0\/40806637803162" + }, { + "region": "DFW", + "tenantId": "40806637803162", + "publicURL": "https:\/\/dfw.loadbalancers.api.rackspacecloud.com\/v1.0\/40806637803162" + }], + "name": "cloudLoadBalancers", + "type": "rax:load-balancer" + }, { + "endpoints": [{ + "tenantId": "40806637803162", + "publicURL": "https:\/\/monitoring.api.rackspacecloud.com\/v1.0\/40806637803162" + }], + "name": "cloudMonitoring", + "type": "rax:monitor" + }, { + "endpoints": [{ + "tenantId": "40806637803162", + "publicURL": "https:\/\/dns.api.rackspacecloud.com\/v1.0\/40806637803162" + }], + "name": "cloudDNS", + "type": "dnsextension:dns" + }, { + "endpoints": [{ + "region": "DFW", + "tenantId": "MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22", + "publicURL": "https:\/\/cdn1.clouddrive.com\/v1\/MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22" + }], + "name": "cloudFilesCDN", + "type": "rax:object-cdn" + }], + "user": { + "id": "54321", + "roles": [{ + "id": "3", + "description": "User Admin Role.", + "name": "identity:user-admin" + }], + "name": "joe" + } + } +} \ No newline at end of file diff --git a/apis/openstack-keystone/src/test/resources/raxVersion.json b/apis/openstack-keystone/src/test/resources/raxVersion.json new file mode 100644 index 0000000000..13d99de05a --- /dev/null +++ b/apis/openstack-keystone/src/test/resources/raxVersion.json @@ -0,0 +1,28 @@ +{ + "version": { + "id": "v2.0", + "updated": "2012-01-21T11:33:21-06:00", + "status": "BETA", + "links": [{ + "rel": "self", + "href": "https:\/\/identity.api.rackspacecloud.com\/v2.0" + }, { + "rel": "describedby", + "type": "application\/pdf", + "href": "http:\/\/docs.rackspacecloud.com\/auth\/api\/v2.0\/auth-client-devguide-latest.pdf" + }, { + "rel": "describedby", + "type": "application\/vnd.sun.wadl+xml", + "href": "http:\/\/docs.rackspacecloud.com\/auth\/api\/v2.0\/auth.wadl" + }], + "media-types": { + "values": [{ + "base": "application\/xml", + "type": "application\/vnd.openstack.identity+xml;version=2.0" + }, { + "base": "application\/json", + "type": "application\/vnd.openstack.identity+json;version=2.0" + }] + } + } +} \ No newline at end of file diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java index 870db664d8..a48920a8db 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/NovaApiMetadata.java @@ -18,6 +18,7 @@ */ package org.jclouds.openstack.nova.v1_1; +import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.VERSION; import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS; @@ -29,6 +30,8 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; +import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.KeystoneAuthenticationModuleForZones; import org.jclouds.openstack.nova.v1_1.compute.config.NovaComputeServiceContextModule; import org.jclouds.openstack.nova.v1_1.config.NovaRestClientModule; import org.jclouds.openstack.v2_0.ServiceType; @@ -73,6 +76,8 @@ public class NovaApiMetadata extends BaseRestApiMetadata { properties.setProperty("jclouds.ssh.retry-auth", "true"); properties.setProperty(SERVICE_TYPE, ServiceType.COMPUTE); + properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS); + // TODO: this doesn't actually do anything yet. properties.setProperty(VERSION, "2.0"); @@ -95,7 +100,7 @@ public class NovaApiMetadata extends BaseRestApiMetadata { .defaultEndpoint("http://localhost:5000") .defaultProperties(NovaApiMetadata.defaultProperties()) .view(TypeToken.of(ComputeServiceContext.class)) - .defaultModules(ImmutableSet.>of(NovaRestClientModule.class, NovaComputeServiceContextModule.class)); + .defaultModules(ImmutableSet.>of(KeystoneAuthenticationModuleForZones.class, NovaRestClientModule.class, NovaComputeServiceContextModule.class)); } @Override diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java index b9bfa0ac86..5eccc0759f 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v1_1/config/NovaRestClientModule.java @@ -31,7 +31,6 @@ import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; import org.jclouds.location.suppliers.ImplicitLocationSupplier; import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; import org.jclouds.openstack.nova.v1_1.NovaAsyncClient; import org.jclouds.openstack.nova.v1_1.NovaClient; import org.jclouds.openstack.nova.v1_1.domain.Extension; @@ -126,12 +125,6 @@ public class NovaRestClientModule extends RestClientModule> * type of the api, according to the provider. ex. {@code compute} {@code * object-store} * @param apiVersion - * version of the api + * version of the api, or null if not present * @return regions mapped to default uri */ ZoneIdToURISupplier createForApiTypeAndVersion(@Assisted("apiType") String apiType, - @Assisted("apiVersion") String apiVersion); + @Nullable @Assisted("apiVersion") String apiVersion); } } \ No newline at end of file diff --git a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/GlanceApiMetadata.java b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/GlanceApiMetadata.java index 5d52819197..a3c1adbbfe 100644 --- a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/GlanceApiMetadata.java +++ b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/GlanceApiMetadata.java @@ -18,6 +18,7 @@ */ package org.jclouds.openstack.glance.v1_0; +import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE; import java.net.URI; @@ -25,7 +26,9 @@ import java.util.Properties; import org.jclouds.apis.ApiMetadata; import org.jclouds.openstack.glance.v1_0.config.GlanceRestClientModule; +import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; +import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.KeystoneAuthenticationModuleForRegions; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.rest.RestContext; import org.jclouds.rest.internal.BaseRestApiMetadata; @@ -64,6 +67,8 @@ public class GlanceApiMetadata extends BaseRestApiMetadata { public static Properties defaultProperties() { Properties properties = BaseRestApiMetadata.defaultProperties(); properties.setProperty(SERVICE_TYPE, ServiceType.IMAGE); + properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS); + // TODO: this doesn't actually do anything yet. properties.setProperty(KeystoneProperties.VERSION, "2.0"); return properties; @@ -81,7 +86,7 @@ public class GlanceApiMetadata extends BaseRestApiMetadata { .version("1.0") .defaultEndpoint("http://localhost:5000") .defaultProperties(GlanceApiMetadata.defaultProperties()) - .defaultModules(ImmutableSet.>of(GlanceRestClientModule.class)); + .defaultModules(ImmutableSet.>of(KeystoneAuthenticationModuleForRegions.class, GlanceRestClientModule.class)); } @Override diff --git a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/config/GlanceRestClientModule.java b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/config/GlanceRestClientModule.java index 2e6c7b2918..9dbe6f5234 100644 --- a/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/config/GlanceRestClientModule.java +++ b/labs/openstack-glance/src/main/java/org/jclouds/openstack/glance/v1_0/config/GlanceRestClientModule.java @@ -31,7 +31,6 @@ import org.jclouds.openstack.glance.v1_0.GlanceClient; import org.jclouds.openstack.glance.v1_0.features.ImageAsyncClient; import org.jclouds.openstack.glance.v1_0.features.ImageClient; import org.jclouds.openstack.glance.v1_0.handlers.GlanceErrorHandler; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.config.RestClientModule; @@ -59,17 +58,6 @@ public class GlanceRestClientModule extends RestClientModule>of(QuantumRestClientModule.class)); + .defaultModules(ImmutableSet.>of(KeystoneAuthenticationModuleForRegions.class, QuantumRestClientModule.class)); } @Override diff --git a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/config/QuantumRestClientModule.java b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/config/QuantumRestClientModule.java index 4017df5257..8850d989f9 100644 --- a/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/config/QuantumRestClientModule.java +++ b/labs/openstack-quantum/src/main/java/org/jclouds/openstack/quantum/v1_0/config/QuantumRestClientModule.java @@ -26,7 +26,6 @@ import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; import org.jclouds.json.config.GsonModule.DateAdapter; import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; import org.jclouds.openstack.quantum.v1_0.QuantumAsyncClient; import org.jclouds.openstack.quantum.v1_0.QuantumClient; import org.jclouds.openstack.quantum.v1_0.features.NetworkAsyncClient; @@ -62,17 +61,6 @@ public class QuantumRestClientModule extends RestClientModule>of(SwiftRestClientModule.class)); + .defaultModules(ImmutableSet.>of(KeystoneAuthenticationModuleForRegions.class, SwiftRestClientModule.class)); } @Override diff --git a/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/config/SwiftRestClientModule.java b/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/config/SwiftRestClientModule.java index 54dfd01498..daa5c2eb10 100644 --- a/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/config/SwiftRestClientModule.java +++ b/labs/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/config/SwiftRestClientModule.java @@ -26,7 +26,6 @@ import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; import org.jclouds.json.config.GsonModule.DateAdapter; import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; import org.jclouds.openstack.swift.v1.SwiftAsyncClient; import org.jclouds.openstack.swift.v1.SwiftClient; import org.jclouds.openstack.swift.v1.features.AccountAsyncClient; @@ -65,17 +64,6 @@ public class SwiftRestClientModule extends RestClientModule>of(HPCloudObjectStorageRestClientModule.class, HPCloudObjectStorageBlobStoreContextModule.class)); + .defaultModules(ImmutableSet.>of(KeystoneAuthenticationModuleForRegions.class, HPCloudObjectStorageRestClientModule.class, HPCloudObjectStorageBlobStoreContextModule.class)); } @Override diff --git a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java index a165856a0b..a2ec6948e2 100644 --- a/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java +++ b/providers/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java @@ -38,7 +38,6 @@ import org.jclouds.http.annotation.ServerError; import org.jclouds.json.config.GsonModule.DateAdapter; import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; import org.jclouds.location.suppliers.RegionIdToURISupplier; -import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; import org.jclouds.openstack.services.ServiceType; import org.jclouds.openstack.swift.CommonSwiftAsyncClient; import org.jclouds.openstack.swift.CommonSwiftClient; @@ -73,13 +72,6 @@ public class HPCloudObjectStorageRestClientModule extends super.configure(); } - @Override - protected void installLocations() { - super.installLocations(); - // TODO: select this from KeystoneProperties.VERSION; - install(KeystoneAuthenticationModule.forRegions()); - } - @Override protected void bindErrorHandlers() { bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseSwiftErrorFromHttpResponse.class); From 8f84608fe7838cb841a3b5661ec515c4196f9886 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 6 Jun 2012 23:33:38 -0700 Subject: [PATCH 6/9] regression --- .../hpcloud/compute/HPCloudComputeProviderMetadata.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java index d2e7746ece..00c1ac1348 100644 --- a/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java +++ b/providers/hpcloud-compute/src/main/java/org/jclouds/hpcloud/compute/HPCloudComputeProviderMetadata.java @@ -29,6 +29,7 @@ import java.util.Properties; import org.jclouds.hpcloud.compute.config.HPCloudComputeServiceContextModule; import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; +import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.KeystoneAuthenticationModuleForZones; import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; import org.jclouds.openstack.nova.v1_1.config.NovaRestClientModule; import org.jclouds.providers.ProviderMetadata; @@ -84,7 +85,7 @@ public class HPCloudComputeProviderMetadata extends BaseProviderMetadata { .apiMetadata(new NovaApiMetadata().toBuilder() .identityName("tenantName:accessKey") .credentialName("secretKey") - .defaultModules(ImmutableSet.>of(NovaRestClientModule.class, HPCloudComputeServiceContextModule.class)) + .defaultModules(ImmutableSet.>of(KeystoneAuthenticationModuleForZones.class,NovaRestClientModule.class, HPCloudComputeServiceContextModule.class)) .build()) .homepage(URI.create("http://hpcloud.com")) .console(URI.create("https://manage.hpcloud.com/compute")) From 5c56e0b9c869e0eac75ccb5b366f4d783a33d2ff Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 6 Jun 2012 23:39:09 -0700 Subject: [PATCH 7/9] Issue 961:add cloudservers-nova-us --- labs/cloudidentity/pom.xml | 121 ++++++++++++++ .../v2_0/CloudIdentityApiMetadata.java | 103 ++++++++++++ ...loudIdentityAuthenticationAsyncClient.java | 71 +++++++++ .../CloudIdentityAuthenticationClient.java | 56 +++++++ .../CloudIdentityAuthenticationModule.java | 95 +++++++++++ .../config/CloudIdentityCredentialTypes.java | 32 ++++ .../config/CloudIdentityRestClientModule.java | 25 +++ .../v2_0/domain/ApiKeyCredentials.java | 125 +++++++++++++++ .../AuthenticateApiKeyCredentials.java | 66 ++++++++ .../services/org.jclouds.apis.ApiMetadata | 1 + .../v2_0/CloudIdentityApiMetadataTest.java | 39 +++++ .../v2_0/CloudIdentityClientLiveTest.java | 33 ++++ .../CloudIdentityTenantClientLiveTest.java | 33 ++++ .../CloudIdentityTokenClientLiveTest.java | 33 ++++ .../CloudIdentityUserClientLiveTest.java | 33 ++++ labs/cloudservers-nova-us/pom.xml | 150 ++++++++++++++++++ .../us/CloudServersUSProviderMetadata.java | 109 +++++++++++++ .../org.jclouds.providers.ProviderMetadata | 1 + .../us/CloudServersUSProviderTest.java | 52 ++++++ .../CloudServersUSComputeServiceLiveTest.java | 34 ++++ ...CloudServersUSTemplateBuilderLiveTest.java | 89 +++++++++++ .../CloudServersUSImageExtensionLivetest.java | 44 +++++ .../CloudServersUSFlavorClientLiveTest.java | 34 ++++ ...loudServersUSFloatingIPClientLiveTest.java | 34 ++++ .../CloudServersUSImageClientLiveTest.java | 33 ++++ .../CloudServersUSKeyPairClientLiveTest.java | 34 ++++ ...dServersUSSecurityGroupClientLiveTest.java | 33 ++++ .../CloudServersUSServerClientLiveTest.java | 34 ++++ .../CloudServersUSVolumeClientLiveTest.java | 34 ++++ labs/pom.xml | 2 + 30 files changed, 1583 insertions(+) create mode 100644 labs/cloudidentity/pom.xml create mode 100644 labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/CloudIdentityApiMetadata.java create mode 100644 labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/CloudIdentityAuthenticationAsyncClient.java create mode 100644 labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/CloudIdentityAuthenticationClient.java create mode 100644 labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/config/CloudIdentityAuthenticationModule.java create mode 100644 labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/config/CloudIdentityCredentialTypes.java create mode 100644 labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/config/CloudIdentityRestClientModule.java create mode 100644 labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/domain/ApiKeyCredentials.java create mode 100644 labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/functions/AuthenticateApiKeyCredentials.java create mode 100644 labs/cloudidentity/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata create mode 100644 labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/CloudIdentityApiMetadataTest.java create mode 100644 labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/CloudIdentityClientLiveTest.java create mode 100644 labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/features/CloudIdentityTenantClientLiveTest.java create mode 100644 labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/features/CloudIdentityTokenClientLiveTest.java create mode 100644 labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/features/CloudIdentityUserClientLiveTest.java create mode 100644 labs/cloudservers-nova-us/pom.xml create mode 100644 labs/cloudservers-nova-us/src/main/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderMetadata.java create mode 100644 labs/cloudservers-nova-us/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata create mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderTest.java create mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSComputeServiceLiveTest.java create mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSTemplateBuilderLiveTest.java create mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/extensions/CloudServersUSImageExtensionLivetest.java create mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSFlavorClientLiveTest.java create mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSFloatingIPClientLiveTest.java create mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSImageClientLiveTest.java create mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSKeyPairClientLiveTest.java create mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSSecurityGroupClientLiveTest.java create mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSServerClientLiveTest.java create mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSVolumeClientLiveTest.java diff --git a/labs/cloudidentity/pom.xml b/labs/cloudidentity/pom.xml new file mode 100644 index 0000000000..ec218143c2 --- /dev/null +++ b/labs/cloudidentity/pom.xml @@ -0,0 +1,121 @@ + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.5.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.labs + cloudidentity + jcloud cloudidentity api + jclouds components to access an implementation of Rackspace Cloud Identity + bundle + + + + https://identity.api.rackspacecloud.com + + 2.0 + + 413274:${test.rackspace-us.identity} + ${test.rackspace-us.credential} + RAX-KSKEY:apiKeyCredentials + + org.jclouds.cloudidentity.v2_0*;version="${project.version}" + + org.jclouds.rest.internal;version="${project.version}", + org.jclouds*;version="${project.version}", + * + + + + + + org.jclouds.api + openstack-keystone + ${project.version} + + + org.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.jclouds.api + openstack-keystone + ${project.version} + test-jar + test + + + org.jclouds.driver + jclouds-slf4j + ${project.version} + test + + + ch.qos.logback + logback-classic + 1.0.0 + test + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + + ${test.cloudidentity.endpoint} + ${test.cloudidentity.api-version} + ${test.cloudidentity.build-version} + ${test.cloudidentity.identity} + ${test.cloudidentity.credential} + ${test.jclouds.keystone.credential-type} + + + + + + + + + + + diff --git a/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/CloudIdentityApiMetadata.java b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/CloudIdentityApiMetadata.java new file mode 100644 index 0000000000..4a22b27a55 --- /dev/null +++ b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/CloudIdentityApiMetadata.java @@ -0,0 +1,103 @@ +package org.jclouds.cloudidentity.v2_0; +/** + * 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. + */ + + +import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; +import org.jclouds.cloudidentity.v2_0.config.CloudIdentityRestClientModule; +import org.jclouds.openstack.keystone.v2_0.KeystoneApiMetadata; +import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncClient; +import org.jclouds.openstack.keystone.v2_0.KeystoneClient; +import org.jclouds.rest.RestContext; + +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; +import com.google.inject.Module; + +/** + * Implementation of {@link ApiMetadata} for the Rackspace Cloud Identity Service + * + * @author Adrian Cole + */ +public class CloudIdentityApiMetadata extends KeystoneApiMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -1572520638079261710L; + + public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { + private static final long serialVersionUID = -5070937833892503232L; + }; + + private static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return builder().fromApiMetadata(this); + } + + public CloudIdentityApiMetadata() { + this(builder()); + } + + protected CloudIdentityApiMetadata(Builder builder) { + super(builder); + } + + public static Properties defaultProperties() { + Properties properties = KeystoneApiMetadata.defaultProperties(); + properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS); + + return properties; + } + + public static class Builder extends KeystoneApiMetadata.Builder { + protected Builder(){ + super(KeystoneClient.class, KeystoneAsyncClient.class); + id("cloudidentity") + .name("Rackspace Cloud Identity Service") + .defaultEndpoint("https://identity.api.rackspacecloud.com") + .identityName("username") + .credentialName("API Key") + .defaultProperties(CloudIdentityApiMetadata.defaultProperties()) + .context(CONTEXT_TOKEN) + .documentation(URI.create("http://docs.rackspace.com/auth/api/v2.0/auth-client-devguide/")) + .defaultModules(ImmutableSet.>of(CloudIdentityRestClientModule.class)); + } + + @Override + public CloudIdentityApiMetadata build() { + return new CloudIdentityApiMetadata(this); + } + + @Override + public Builder fromApiMetadata(ApiMetadata in) { + super.fromApiMetadata(in); + return this; + } + } + +} \ No newline at end of file diff --git a/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/CloudIdentityAuthenticationAsyncClient.java b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/CloudIdentityAuthenticationAsyncClient.java new file mode 100644 index 0000000000..4215daa977 --- /dev/null +++ b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/CloudIdentityAuthenticationAsyncClient.java @@ -0,0 +1,71 @@ +/** + * 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.cloudidentity.v2_0; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.MediaType; + +import org.jclouds.cloudidentity.v2_0.domain.ApiKeyCredentials; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.v2_0.AuthenticationAsyncClient; +import org.jclouds.openstack.keystone.v2_0.binders.BindAuthToJsonPayload; +import org.jclouds.openstack.keystone.v2_0.domain.Access; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.SelectJson; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * Provides asynchronous access to Service via their REST API. + *

    + * + * @see AuthenticationClient + * @see + * @author Adrian Cole + */ +@Path("/v2.0") +public interface CloudIdentityAuthenticationAsyncClient extends AuthenticationAsyncClient { + + /** + * @see CloudIdentityAuthenticationAsyncClient#authenticateWithTenantNameAndCredentials(String,ApiKeyCredentials) + */ + @POST + @SelectJson("access") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/tokens") + @MapBinder(BindAuthToJsonPayload.class) + ListenableFuture authenticateWithTenantNameAndCredentials(@Nullable @PayloadParam("tenantName") String tenantName, + ApiKeyCredentials apiKeyCredentials); + + /** + * @see CloudIdentityAuthenticationAsyncClient#authenticateWithTenantIdAndCredentials(String,ApiKeyCredentials) + */ + @POST + @SelectJson("access") + @Consumes(MediaType.APPLICATION_JSON) + @Path("/tokens") + @MapBinder(BindAuthToJsonPayload.class) + ListenableFuture authenticateWithTenantIdAndCredentials(@Nullable @PayloadParam("tenantId") String tenantId, + ApiKeyCredentials apiKeyCredentials); + +} diff --git a/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/CloudIdentityAuthenticationClient.java b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/CloudIdentityAuthenticationClient.java new file mode 100644 index 0000000000..c9533d86b8 --- /dev/null +++ b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/CloudIdentityAuthenticationClient.java @@ -0,0 +1,56 @@ +/** + * 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.cloudidentity.v2_0; + +import java.util.concurrent.TimeUnit; + +import org.jclouds.cloudidentity.v2_0.domain.ApiKeyCredentials; +import org.jclouds.concurrent.Timeout; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.v2_0.AuthenticationAsyncClient; +import org.jclouds.openstack.keystone.v2_0.AuthenticationClient; +import org.jclouds.openstack.keystone.v2_0.domain.Access; + +/** + * Provides synchronous access to the KeyStone Service API. + *

    + * + * @see AuthenticationAsyncClient + * @see + * @author Adrian Cole + */ +@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) +public interface CloudIdentityAuthenticationClient extends AuthenticationClient { + + /** + * Authenticate to generate a token. + * + * @return access with token + */ + Access authenticateWithTenantNameAndCredentials(@Nullable String tenantId, ApiKeyCredentials apiKeyCredentials); + + /** + * Authenticate to generate a token. + * + * @return access with token + */ + Access authenticateWithTenantIdAndCredentials(@Nullable String tenantId, ApiKeyCredentials apiKeyCredentials); + +} \ No newline at end of file diff --git a/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/config/CloudIdentityAuthenticationModule.java b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/config/CloudIdentityAuthenticationModule.java new file mode 100644 index 0000000000..a4fa64a0da --- /dev/null +++ b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/config/CloudIdentityAuthenticationModule.java @@ -0,0 +1,95 @@ +/** + * 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.cloudidentity.v2_0.config; + +import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient; + +import java.util.Map; + +import org.jclouds.cloudidentity.v2_0.CloudIdentityAuthenticationAsyncClient; +import org.jclouds.cloudidentity.v2_0.CloudIdentityAuthenticationClient; +import org.jclouds.cloudidentity.v2_0.functions.AuthenticateApiKeyCredentials; +import org.jclouds.domain.Credentials; +import org.jclouds.openstack.keystone.v2_0.AuthenticationAsyncClient; +import org.jclouds.openstack.keystone.v2_0.AuthenticationClient; +import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; +import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; +import org.jclouds.openstack.keystone.v2_0.domain.Access; +import org.jclouds.openstack.keystone.v2_0.functions.AuthenticatePasswordCredentials; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet.Builder; +import com.google.inject.Injector; +import com.google.inject.Module; +import com.google.inject.Scopes; + +/** + * + * @author Adrian Cole + */ +public class CloudIdentityAuthenticationModule extends KeystoneAuthenticationModule { + + public CloudIdentityAuthenticationModule() { + this(new RegionModule()); + } + + protected CloudIdentityAuthenticationModule(Module locationModule) { + super(locationModule); + } + + public static class CloudIdentityAuthenticationModuleForRegions extends CloudIdentityAuthenticationModule { + public CloudIdentityAuthenticationModuleForRegions() { + super(new RegionModule()); + } + } + + public static Module forRegions() { + return new CloudIdentityAuthenticationModuleForRegions(); + } + + public static class CloudIdentityAuthenticationModuleForZones extends CloudIdentityAuthenticationModule { + public CloudIdentityAuthenticationModuleForZones() { + super(new ZoneModule()); + } + } + + public static Module forZones() { + return new CloudIdentityAuthenticationModuleForZones(); + } + + @Override + protected void bindAuthenticationClient() { + // AuthenticationClient is used directly for filters and retry handlers, so let's bind it + // explicitly + bindClientAndAsyncClient(binder(), CloudIdentityAuthenticationClient.class, + CloudIdentityAuthenticationAsyncClient.class); + bind(AuthenticationClient.class).to(CloudIdentityAuthenticationClient.class).in(Scopes.SINGLETON); + bind(AuthenticationAsyncClient.class).to(CloudIdentityAuthenticationAsyncClient.class).in(Scopes.SINGLETON); + } + + @Override + protected Map> authenticationMethods(Injector i) { + Builder> fns = ImmutableSet.> builder(); + fns.add(i.getInstance(AuthenticatePasswordCredentials.class)); + fns.add(i.getInstance(AuthenticateApiKeyCredentials.class)); + return CredentialTypes.indexByCredentialType(fns.build()); + } + +} \ No newline at end of file diff --git a/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/config/CloudIdentityCredentialTypes.java b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/config/CloudIdentityCredentialTypes.java new file mode 100644 index 0000000000..84dcd7c49e --- /dev/null +++ b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/config/CloudIdentityCredentialTypes.java @@ -0,0 +1,32 @@ +/** + * 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.cloudidentity.v2_0.config; + +import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; + + +/** + * + * @author Adrian Cole + */ +public class CloudIdentityCredentialTypes extends CredentialTypes { + + public static final String API_KEY_CREDENTIALS = "RAX-KSKEY:apiKeyCredentials"; + +} diff --git a/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/config/CloudIdentityRestClientModule.java b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/config/CloudIdentityRestClientModule.java new file mode 100644 index 0000000000..7f2065f91a --- /dev/null +++ b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/config/CloudIdentityRestClientModule.java @@ -0,0 +1,25 @@ +package org.jclouds.cloudidentity.v2_0.config; + +import org.jclouds.location.config.LocationModule; +import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncClient; +import org.jclouds.openstack.keystone.v2_0.KeystoneClient; +import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule; +import org.jclouds.rest.ConfiguresRestClient; + +/** + * Configures the Keystone connection. + * + * @author Adam Lowe + */ +@ConfiguresRestClient +public class CloudIdentityRestClientModule extends KeystoneRestClientModule { + + @Override + protected void installLocations() { + // TODO: select this from KeystoneProperties.VERSION; note you select from + // a guice provided property, so it will have to come from somewhere else, maybe we move + // this to the the ContextBuilder + install(CloudIdentityAuthenticationModule.forRegions()); + install(new LocationModule()); + } +} diff --git a/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/domain/ApiKeyCredentials.java b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/domain/ApiKeyCredentials.java new file mode 100644 index 0000000000..b44ae50538 --- /dev/null +++ b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/domain/ApiKeyCredentials.java @@ -0,0 +1,125 @@ +/** + * 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.cloudidentity.v2_0.domain; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Objects.toStringHelper; +import static com.google.common.base.Preconditions.checkNotNull; + +import org.jclouds.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; +import org.jclouds.openstack.keystone.v2_0.config.CredentialType; + +import com.google.common.base.Objects; + +/** + * ApiKey Credentials + * + * @see docs + + * @author Adrian Cole + */ +@CredentialType(CloudIdentityCredentialTypes.API_KEY_CREDENTIALS) +public class ApiKeyCredentials { + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromApiKeyCredentials(this); + } + + public static ApiKeyCredentials createWithUsernameAndApiKey(String username, String apiKey) { + return builder().apiKey(apiKey).username(username).build(); + } + + public static class Builder { + protected String username; + protected String apiKey; + + /** + * @see ApiKeyCredentials#getUsername() + */ + protected Builder apiKey(String apiKey) { + this.apiKey = apiKey; + return this; + } + + /** + * @see ApiKeyCredentials#getApiKey() + */ + public Builder username(String username) { + this.username = username; + return this; + } + + public ApiKeyCredentials build() { + return new ApiKeyCredentials(username, apiKey); + } + + public Builder fromApiKeyCredentials(ApiKeyCredentials from) { + return username(from.getUsername()).apiKey(from.getApiKey()); + } + } + + protected final String username; + protected final String apiKey; + + protected ApiKeyCredentials(String username, String apiKey) { + this.username = checkNotNull(username, "username"); + this.apiKey = checkNotNull(apiKey, "apiKey"); + } + + /** + * @return the username + */ + public String getUsername() { + return username; + } + + /** + * @return the apiKey + */ + public String getApiKey() { + return apiKey; + } + + @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } + if (object instanceof ApiKeyCredentials) { + final ApiKeyCredentials other = ApiKeyCredentials.class.cast(object); + return equal(username, other.username) && equal(apiKey, other.apiKey); + } else { + return false; + } + } + + @Override + public int hashCode() { + return Objects.hashCode(username, apiKey); + } + + @Override + public String toString() { + return toStringHelper("").add("username", username).add("apiKey", apiKey).toString(); + } + +} diff --git a/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/functions/AuthenticateApiKeyCredentials.java b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/functions/AuthenticateApiKeyCredentials.java new file mode 100644 index 0000000000..58d8ec8867 --- /dev/null +++ b/labs/cloudidentity/src/main/java/org/jclouds/cloudidentity/v2_0/functions/AuthenticateApiKeyCredentials.java @@ -0,0 +1,66 @@ +/** + * 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.cloudidentity.v2_0.functions; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.cloudidentity.v2_0.CloudIdentityAuthenticationClient; +import org.jclouds.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; +import org.jclouds.cloudidentity.v2_0.domain.ApiKeyCredentials; +import org.jclouds.openstack.keystone.v2_0.config.CredentialType; +import org.jclouds.openstack.keystone.v2_0.domain.Access; +import org.jclouds.openstack.keystone.v2_0.functions.internal.BaseAuthenticator; + +/** + * + * @author Adrian Cole + * @see docs + */ +@CredentialType(CloudIdentityCredentialTypes.API_KEY_CREDENTIALS) +@Singleton +public class AuthenticateApiKeyCredentials extends BaseAuthenticator { + protected final CloudIdentityAuthenticationClient client; + + @Inject + public AuthenticateApiKeyCredentials(CloudIdentityAuthenticationClient client) { + this.client = client; + } + + @Override + protected Access authenticateWithTenantNameOrNull(String tenantId, ApiKeyCredentials apiKeyCredentials) { + return client.authenticateWithTenantNameAndCredentials(tenantId, apiKeyCredentials); + } + + @Override + protected Access authenticateWithTenantId(String tenantId, ApiKeyCredentials apiKeyCredentials) { + return client.authenticateWithTenantIdAndCredentials(tenantId, apiKeyCredentials); + } + + @Override + public ApiKeyCredentials createCredentials(String identity, String credential) { + return ApiKeyCredentials.createWithUsernameAndApiKey(identity, credential); + } + + @Override + public String toString() { + return "authenticateApiKeyCredentials()"; + } +} \ No newline at end of file diff --git a/labs/cloudidentity/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/labs/cloudidentity/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata new file mode 100644 index 0000000000..82996dbf10 --- /dev/null +++ b/labs/cloudidentity/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata @@ -0,0 +1 @@ +org.jclouds.cloudidentity.v2_0.CloudIdentityApiMetadata diff --git a/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/CloudIdentityApiMetadataTest.java b/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/CloudIdentityApiMetadataTest.java new file mode 100644 index 0000000000..b87885a2b3 --- /dev/null +++ b/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/CloudIdentityApiMetadataTest.java @@ -0,0 +1,39 @@ +/** + * 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.cloudidentity.v2_0; + +import org.jclouds.View; +import org.jclouds.rest.internal.BaseRestApiMetadataTest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; +import com.google.common.reflect.TypeToken; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "CloudIdentityApiMetadataTest") +public class CloudIdentityApiMetadataTest extends BaseRestApiMetadataTest { + + // no identity abstraction, yet + public CloudIdentityApiMetadataTest() { + super(new CloudIdentityApiMetadata(), ImmutableSet.> of()); + } +} diff --git a/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/CloudIdentityClientLiveTest.java b/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/CloudIdentityClientLiveTest.java new file mode 100644 index 0000000000..7d4f69cd24 --- /dev/null +++ b/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/CloudIdentityClientLiveTest.java @@ -0,0 +1,33 @@ +/** + * 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 1.1 (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-1.1 + * + * 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.cloudidentity.v2_0; + +import org.jclouds.openstack.keystone.v2_0.KeystoneClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "CloudIdentityClientLiveTest", singleThreaded = true) +public class CloudIdentityClientLiveTest extends KeystoneClientLiveTest { + public CloudIdentityClientLiveTest() { + provider = "cloudidentity"; + } +} \ No newline at end of file diff --git a/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/features/CloudIdentityTenantClientLiveTest.java b/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/features/CloudIdentityTenantClientLiveTest.java new file mode 100644 index 0000000000..394eff99a6 --- /dev/null +++ b/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/features/CloudIdentityTenantClientLiveTest.java @@ -0,0 +1,33 @@ +/** + * 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 1.1 (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-1.1 + * + * 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.cloudidentity.v2_0.features; + +import org.jclouds.openstack.keystone.v2_0.features.TenantClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "CloudIdentityTenantClientLiveTest", singleThreaded = true) +public class CloudIdentityTenantClientLiveTest extends TenantClientLiveTest { + public CloudIdentityTenantClientLiveTest() { + provider = "cloudidentity"; + } +} \ No newline at end of file diff --git a/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/features/CloudIdentityTokenClientLiveTest.java b/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/features/CloudIdentityTokenClientLiveTest.java new file mode 100644 index 0000000000..d219ddfe49 --- /dev/null +++ b/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/features/CloudIdentityTokenClientLiveTest.java @@ -0,0 +1,33 @@ +/** + * 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 1.1 (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-1.1 + * + * 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.cloudidentity.v2_0.features; + +import org.jclouds.openstack.keystone.v2_0.features.TokenClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "CloudIdentityTokenClientLiveTest", singleThreaded = true) +public class CloudIdentityTokenClientLiveTest extends TokenClientLiveTest { + public CloudIdentityTokenClientLiveTest() { + provider = "cloudidentity"; + } +} \ No newline at end of file diff --git a/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/features/CloudIdentityUserClientLiveTest.java b/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/features/CloudIdentityUserClientLiveTest.java new file mode 100644 index 0000000000..e2b477f12f --- /dev/null +++ b/labs/cloudidentity/src/test/java/org/jclouds/cloudidentity/v2_0/features/CloudIdentityUserClientLiveTest.java @@ -0,0 +1,33 @@ +/** + * 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 1.1 (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-1.1 + * + * 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.cloudidentity.v2_0.features; + +import org.jclouds.openstack.keystone.v2_0.features.UserClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "CloudIdentityUserClientLiveTest", singleThreaded = true) +public class CloudIdentityUserClientLiveTest extends UserClientLiveTest { + public CloudIdentityUserClientLiveTest() { + provider = "cloudidentity"; + } +} \ No newline at end of file diff --git a/labs/cloudservers-nova-us/pom.xml b/labs/cloudservers-nova-us/pom.xml new file mode 100644 index 0000000000..bc872a211e --- /dev/null +++ b/labs/cloudservers-nova-us/pom.xml @@ -0,0 +1,150 @@ + + + + 4.0.0 + + org.jclouds + jclouds-project + 1.5.0-SNAPSHOT + ../../project/pom.xml + + org.jclouds.labs + cloudservers-nova-us + jclouds Rackspace Next Generation Cloud Servers provider + OpenStack Nova implementation targeted to Rackspace Next Generation Cloud Servers + bundle + + + https://identity.api.rackspacecloud.com + 2 + + ${test.rackspace-us.identity} + ${test.rackspace-us.credential} + + + + + org.jclouds.cloudservers_nova.us*;version="${project.version}" + + org.jclouds.compute.internal;version="${project.version}", + org.jclouds.rest.internal;version="${project.version}", + org.jclouds*;version="${project.version}", + * + + + + + + org.jclouds.labs + cloudidentity + ${project.version} + + + org.jclouds.api + openstack-nova + ${project.version} + + + org.jclouds + jclouds-core + ${project.version} + test-jar + test + + + org.jclouds + jclouds-compute + ${project.version} + test-jar + test + + + org.jclouds.labs + cloudidentity + ${project.version} + test-jar + test + + + org.jclouds.api + openstack-nova + ${project.version} + test-jar + test + + + org.jclouds.driver + jclouds-slf4j + ${project.version} + test + + + org.jclouds.driver + jclouds-sshj + ${project.version} + test + + + ch.qos.logback + logback-classic + 1.0.0 + test + + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration + integration-test + + test + + + 1 + + ${test.cloudservers-nova-us.endpoint} + ${test.cloudservers-nova-us.api-version} + ${test.cloudservers-nova-us.build-version} + ${test.cloudservers-nova-us.identity} + ${test.cloudservers-nova-us.credential} + ${test.cloudservers-nova-us.image-id} + ${test.cloudservers-nova-us.image.login-user} + ${test.cloudservers-nova-us.image.authenticate-sudo} + + + + + + + + + + + diff --git a/labs/cloudservers-nova-us/src/main/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderMetadata.java b/labs/cloudservers-nova-us/src/main/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderMetadata.java new file mode 100644 index 0000000000..a704cf79dd --- /dev/null +++ b/labs/cloudservers-nova-us/src/main/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderMetadata.java @@ -0,0 +1,109 @@ +/** + * 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.cloudservers_nova.us; + +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED; +import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; +import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS; +import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_GENERATE_KEYPAIRS; + +import java.net.URI; +import java.util.Properties; + +import org.jclouds.cloudidentity.v2_0.config.CloudIdentityCredentialTypes; +import org.jclouds.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule.CloudIdentityAuthenticationModuleForZones; +import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; +import org.jclouds.openstack.nova.v1_1.compute.config.NovaComputeServiceContextModule; +import org.jclouds.openstack.nova.v1_1.config.NovaRestClientModule; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.internal.BaseProviderMetadata; + +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; + +/** + * Implementation of {@link org.jclouds.types.ProviderMetadata} for Rackspace Next Generation Cloud Servers. + * + * @author Adrian Cole + */ +public class CloudServersUSProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -300987074165012648L; + + public static Builder builder() { + return new Builder(); + } + + @Override + public Builder toBuilder() { + return builder().fromProviderMetadata(this); + } + + public CloudServersUSProviderMetadata() { + super(builder()); + } + + public CloudServersUSProviderMetadata(Builder builder) { + super(builder); + } + + public static Properties defaultProperties() { + Properties properties = new Properties(); + properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS); + + // deallocating ip addresses can take a while + properties.setProperty(TIMEOUT_NODE_TERMINATED, 60 * 1000 + ""); + properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "true"); + properties.setProperty(AUTO_GENERATE_KEYPAIRS, "true"); + return properties; + } + + public static class Builder extends BaseProviderMetadata.Builder { + + protected Builder(){ + id("cloudservers-nova-us") + .name("Rackspace Next Generation Cloud Servers") + .apiMetadata(new NovaApiMetadata().toBuilder() + .identityName("username") + .credentialName("API Key") + .version("2") + .documentation(URI.create("http://docs.rackspace.com/servers/api/v2/cs-devguide/content/ch_preface.html#webhelp-currentid")) + .defaultModules(ImmutableSet.>of(CloudIdentityAuthenticationModuleForZones.class, NovaRestClientModule.class, NovaComputeServiceContextModule.class)) + .build()) + .homepage(URI.create("http://www.rackspace.com/cloud/nextgen")) + .console(URI.create("https://mycloud.rackspace.com")) + .linkedServices("cloudservers-nova-us", "cloudfiles-swift-us") + .iso3166Codes("US-IL", "US-TX") + .endpoint("https://identity.api.rackspacecloud.com") + .defaultProperties(CloudServersUSProviderMetadata.defaultProperties()); + } + + @Override + public CloudServersUSProviderMetadata build() { + return new CloudServersUSProviderMetadata(this); + } + + @Override + public Builder fromProviderMetadata(ProviderMetadata in) { + super.fromProviderMetadata(in); + return this; + } + } +} diff --git a/labs/cloudservers-nova-us/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/labs/cloudservers-nova-us/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata new file mode 100644 index 0000000000..720076428f --- /dev/null +++ b/labs/cloudservers-nova-us/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata @@ -0,0 +1 @@ +org.jclouds.cloudservers_nova.us.CloudServersUSProviderMetadata diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderTest.java new file mode 100644 index 0000000000..be17d28fee --- /dev/null +++ b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderTest.java @@ -0,0 +1,52 @@ +/** + * 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 computee 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. + */ +/** + * + * + * ==================================================================== + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not computee 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.cloudservers_nova.us; + +import org.jclouds.openstack.nova.v1_1.NovaApiMetadata; +import org.jclouds.providers.internal.BaseProviderMetadataTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "CloudServersUSProviderTest") +public class CloudServersUSProviderTest extends BaseProviderMetadataTest { + + public CloudServersUSProviderTest() { + super(new CloudServersUSProviderMetadata(), new NovaApiMetadata()); + } +} diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSComputeServiceLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSComputeServiceLiveTest.java new file mode 100644 index 0000000000..18506ec2c9 --- /dev/null +++ b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSComputeServiceLiveTest.java @@ -0,0 +1,34 @@ +/** + * 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 computee 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.cloudservers_nova.us.compute; + +import org.jclouds.openstack.nova.v1_1.compute.NovaComputeServiceLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", singleThreaded = true, testName = "CloudServersUSComputeServiceLiveTest") +public class CloudServersUSComputeServiceLiveTest extends NovaComputeServiceLiveTest { + + public CloudServersUSComputeServiceLiveTest() { + provider = "cloudservers-nova-us"; + } +} diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSTemplateBuilderLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSTemplateBuilderLiveTest.java new file mode 100644 index 0000000000..c77f62f2ba --- /dev/null +++ b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSTemplateBuilderLiveTest.java @@ -0,0 +1,89 @@ +/** + * 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 computee 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.cloudservers_nova.us.compute; + +import static org.jclouds.compute.util.ComputeServiceUtils.getCores; +import static org.testng.Assert.assertEquals; + +import java.util.Set; + +import org.jclouds.compute.domain.OsFamily; +import org.jclouds.compute.domain.OsFamilyVersion64Bit; +import org.jclouds.compute.domain.Template; +import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; +import org.jclouds.openstack.nova.v1_1.compute.options.NovaTemplateOptions; +import org.testng.annotations.Test; + +import com.google.common.base.Predicate; +import com.google.common.base.Predicates; +import com.google.common.collect.ImmutableSet; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", singleThreaded = true, testName = "CloudServersUSTemplateBuilderLiveTest") +public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { + + public CloudServersUSTemplateBuilderLiveTest() { + provider = "cloudservers-nova-us"; + } + + @Override + protected Predicate defineUnsupportedOperatingSystems() { + return Predicates.not(new Predicate() { + + @Override + public boolean apply(OsFamilyVersion64Bit input) { + switch (input.family) { + case UBUNTU: + return (input.version.equals("") || input.version.equals("12.04") || input.version.matches("^1[01].*")) && input.is64Bit; + case DEBIAN: + return input.is64Bit && !input.version.equals("5.0"); + case CENTOS: + return (input.version.equals("") || input.version.equals("5.6") || input.version.equals("6.0")) + && input.is64Bit; + default: + return false; + } + } + + }); + } + + @Test + public void testTemplateBuilder() { + Template defaultTemplate = this.view.getComputeService().templateBuilder().build(); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "12.04"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); + assertEquals(defaultTemplate.getImage().getName(), "Ubuntu Precise 12.04 LTS Server 64-bit 20120424"); + assertEquals(defaultTemplate.getImage().getDefaultCredentials().getUser(), "ubuntu"); + assertEquals(defaultTemplate.getLocation().getId(), "az-2.region-a.geo-1"); + assertEquals(defaultTemplate.getImage().getLocation().getId(), "az-2.region-a.geo-1"); + assertEquals(defaultTemplate.getHardware().getLocation().getId(), "az-2.region-a.geo-1"); + assertEquals(defaultTemplate.getOptions().as(NovaTemplateOptions.class).shouldAutoAssignFloatingIp(), true); + assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + } + + @Override + protected Set getIso3166Codes() { + return ImmutableSet. of("US-NV"); + } +} diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/extensions/CloudServersUSImageExtensionLivetest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/extensions/CloudServersUSImageExtensionLivetest.java new file mode 100644 index 0000000000..0c4d3af76b --- /dev/null +++ b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/extensions/CloudServersUSImageExtensionLivetest.java @@ -0,0 +1,44 @@ +/** + * 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.cloudservers_nova.us.compute.extensions; + +import org.jclouds.compute.extensions.internal.BaseImageExtensionLiveTest; +import org.jclouds.sshj.config.SshjSshClientModule; +import org.testng.annotations.Test; + +import com.google.inject.Module; + +/** + * + * @author Adrian Cole + * + */ +@Test(groups = "live", singleThreaded = true, testName = "CloudServersUSImageExtensionLivetest") +public class CloudServersUSImageExtensionLivetest extends BaseImageExtensionLiveTest { + + public CloudServersUSImageExtensionLivetest() { + provider = "cloudservers-nova-us"; + } + + @Override + protected Module getSshModule() { + return new SshjSshClientModule(); + } +} diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSFlavorClientLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSFlavorClientLiveTest.java new file mode 100644 index 0000000000..068211c21e --- /dev/null +++ b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSFlavorClientLiveTest.java @@ -0,0 +1,34 @@ +/** + * 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.cloudservers_nova.us.features; + +import org.jclouds.openstack.nova.v1_1.features.FlavorClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "CloudServersUSFlavorClientLiveTest") +public class CloudServersUSFlavorClientLiveTest extends FlavorClientLiveTest { + public CloudServersUSFlavorClientLiveTest() { + provider = "cloudservers-nova-us"; + } + +} diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSFloatingIPClientLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSFloatingIPClientLiveTest.java new file mode 100644 index 0000000000..3ff3d1b18e --- /dev/null +++ b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSFloatingIPClientLiveTest.java @@ -0,0 +1,34 @@ +/** + * 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.cloudservers_nova.us.features; + +import org.jclouds.openstack.nova.v1_1.extensions.FloatingIPClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "CloudServersUSFloatingIPClientLiveTest") +public class CloudServersUSFloatingIPClientLiveTest extends FloatingIPClientLiveTest { + public CloudServersUSFloatingIPClientLiveTest() { + provider = "cloudservers-nova-us"; + } + +} diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSImageClientLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSImageClientLiveTest.java new file mode 100644 index 0000000000..b6643d2153 --- /dev/null +++ b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSImageClientLiveTest.java @@ -0,0 +1,33 @@ +/** + * 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.cloudservers_nova.us.features; + +import org.jclouds.openstack.nova.v1_1.features.ImageClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "CloudServersUSImageClientLiveTest") +public class CloudServersUSImageClientLiveTest extends ImageClientLiveTest { + public CloudServersUSImageClientLiveTest() { + provider = "cloudservers-nova-us"; + } +} diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSKeyPairClientLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSKeyPairClientLiveTest.java new file mode 100644 index 0000000000..6c56ca73a1 --- /dev/null +++ b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSKeyPairClientLiveTest.java @@ -0,0 +1,34 @@ +/** + * 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.cloudservers_nova.us.features; + +import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "CloudServersUSKeyPairClientLiveTest") +public class CloudServersUSKeyPairClientLiveTest extends KeyPairClientLiveTest { + public CloudServersUSKeyPairClientLiveTest() { + provider = "cloudservers-nova-us"; + } + +} diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSSecurityGroupClientLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSSecurityGroupClientLiveTest.java new file mode 100644 index 0000000000..c9fbe4b626 --- /dev/null +++ b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSSecurityGroupClientLiveTest.java @@ -0,0 +1,33 @@ +/** + * 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.cloudservers_nova.us.features; + +import org.jclouds.openstack.nova.v1_1.extensions.SecurityGroupClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "CloudServersUSSecurityGroupClientLiveTest") +public class CloudServersUSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest { + public CloudServersUSSecurityGroupClientLiveTest() { + provider = "cloudservers-nova-us"; + } +} diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSServerClientLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSServerClientLiveTest.java new file mode 100644 index 0000000000..73168b44f7 --- /dev/null +++ b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSServerClientLiveTest.java @@ -0,0 +1,34 @@ +/** + * 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.cloudservers_nova.us.features; + +import org.jclouds.openstack.nova.v1_1.features.ServerClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "CloudServersUSServerClientLiveTest") +public class CloudServersUSServerClientLiveTest extends ServerClientLiveTest { + public CloudServersUSServerClientLiveTest() { + provider = "cloudservers-nova-us"; + } + +} diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSVolumeClientLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSVolumeClientLiveTest.java new file mode 100644 index 0000000000..90c89c686a --- /dev/null +++ b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSVolumeClientLiveTest.java @@ -0,0 +1,34 @@ +/** + * 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.cloudservers_nova.us.features; + +import org.jclouds.openstack.nova.v1_1.extensions.VolumeClientLiveTest; +import org.testng.annotations.Test; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "live", testName = "CloudServersUSVolumeClientLiveTest") +public class CloudServersUSVolumeClientLiveTest extends VolumeClientLiveTest { + public CloudServersUSVolumeClientLiveTest() { + provider = "cloudservers-nova-us"; + } + +} diff --git a/labs/pom.xml b/labs/pom.xml index bde7affc9e..fae08004c5 100644 --- a/labs/pom.xml +++ b/labs/pom.xml @@ -47,5 +47,7 @@ openstack-glance joyent-sdc openstack-quantum + cloudidentity + cloudservers-nova-us From d7cbb2da8d086089b3c4974886eea27d83994536 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 7 Jun 2012 00:14:48 -0700 Subject: [PATCH 8/9] attempt to clear fuzz from cloudservers --- .../us/CloudServersUSProviderMetadata.java | 11 ++---- ...CloudServersUSTemplateBuilderLiveTest.java | 18 +++++----- ...loudServersUSFloatingIPClientLiveTest.java | 34 ------------------- .../CloudServersUSKeyPairClientLiveTest.java | 34 ------------------- ...dServersUSSecurityGroupClientLiveTest.java | 33 ------------------ .../CloudServersUSVolumeClientLiveTest.java | 34 ------------------- .../src/test/resources/raxImages.json | 1 + 7 files changed, 14 insertions(+), 151 deletions(-) delete mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSFloatingIPClientLiveTest.java delete mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSKeyPairClientLiveTest.java delete mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSSecurityGroupClientLiveTest.java delete mode 100644 labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSVolumeClientLiveTest.java create mode 100644 labs/cloudservers-nova-us/src/test/resources/raxImages.json diff --git a/labs/cloudservers-nova-us/src/main/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderMetadata.java b/labs/cloudservers-nova-us/src/main/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderMetadata.java index a704cf79dd..8814febfd9 100644 --- a/labs/cloudservers-nova-us/src/main/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderMetadata.java +++ b/labs/cloudservers-nova-us/src/main/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderMetadata.java @@ -18,10 +18,8 @@ */ package org.jclouds.cloudservers_nova.us; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED; +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE; -import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS; -import static org.jclouds.openstack.nova.v1_1.config.NovaProperties.AUTO_GENERATE_KEYPAIRS; import java.net.URI; import java.util.Properties; @@ -67,11 +65,8 @@ public class CloudServersUSProviderMetadata extends BaseProviderMetadata { public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS); + properties.setProperty(TEMPLATE, "imageId=DFW/3afe97b2-26dc-49c5-a2cc-a2fc8d80c001"); - // deallocating ip addresses can take a while - properties.setProperty(TIMEOUT_NODE_TERMINATED, 60 * 1000 + ""); - properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "true"); - properties.setProperty(AUTO_GENERATE_KEYPAIRS, "true"); return properties; } @@ -90,7 +85,7 @@ public class CloudServersUSProviderMetadata extends BaseProviderMetadata { .homepage(URI.create("http://www.rackspace.com/cloud/nextgen")) .console(URI.create("https://mycloud.rackspace.com")) .linkedServices("cloudservers-nova-us", "cloudfiles-swift-us") - .iso3166Codes("US-IL", "US-TX") + .iso3166Codes("US-TX") .endpoint("https://identity.api.rackspacecloud.com") .defaultProperties(CloudServersUSProviderMetadata.defaultProperties()); } diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSTemplateBuilderLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSTemplateBuilderLiveTest.java index c77f62f2ba..b5644e87dc 100644 --- a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSTemplateBuilderLiveTest.java +++ b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSTemplateBuilderLiveTest.java @@ -53,7 +53,9 @@ public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLi public boolean apply(OsFamilyVersion64Bit input) { switch (input.family) { case UBUNTU: - return (input.version.equals("") || input.version.equals("12.04") || input.version.matches("^1[01].*")) && input.is64Bit; + return (input.version.equals("") || (input.version.matches("^1[01].*") && !input.version + .equals("10.10"))) + && input.is64Bit; case DEBIAN: return input.is64Bit && !input.version.equals("5.0"); case CENTOS: @@ -71,19 +73,19 @@ public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLi public void testTemplateBuilder() { Template defaultTemplate = this.view.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "12.04"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(defaultTemplate.getImage().getName(), "Ubuntu Precise 12.04 LTS Server 64-bit 20120424"); + assertEquals(defaultTemplate.getImage().getName(), "Ubuntu 11.10"); assertEquals(defaultTemplate.getImage().getDefaultCredentials().getUser(), "ubuntu"); - assertEquals(defaultTemplate.getLocation().getId(), "az-2.region-a.geo-1"); - assertEquals(defaultTemplate.getImage().getLocation().getId(), "az-2.region-a.geo-1"); - assertEquals(defaultTemplate.getHardware().getLocation().getId(), "az-2.region-a.geo-1"); + assertEquals(defaultTemplate.getLocation().getId(), "DFW"); + assertEquals(defaultTemplate.getImage().getLocation().getId(), "DFW"); + assertEquals(defaultTemplate.getHardware().getLocation().getId(), "DFW"); assertEquals(defaultTemplate.getOptions().as(NovaTemplateOptions.class).shouldAutoAssignFloatingIp(), true); - assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); + assertEquals(getCores(defaultTemplate.getHardware()), 4.0d); } @Override protected Set getIso3166Codes() { - return ImmutableSet. of("US-NV"); + return ImmutableSet. of("US-TX"); } } diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSFloatingIPClientLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSFloatingIPClientLiveTest.java deleted file mode 100644 index 3ff3d1b18e..0000000000 --- a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSFloatingIPClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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.cloudservers_nova.us.features; - -import org.jclouds.openstack.nova.v1_1.extensions.FloatingIPClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "CloudServersUSFloatingIPClientLiveTest") -public class CloudServersUSFloatingIPClientLiveTest extends FloatingIPClientLiveTest { - public CloudServersUSFloatingIPClientLiveTest() { - provider = "cloudservers-nova-us"; - } - -} diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSKeyPairClientLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSKeyPairClientLiveTest.java deleted file mode 100644 index 6c56ca73a1..0000000000 --- a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSKeyPairClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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.cloudservers_nova.us.features; - -import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "CloudServersUSKeyPairClientLiveTest") -public class CloudServersUSKeyPairClientLiveTest extends KeyPairClientLiveTest { - public CloudServersUSKeyPairClientLiveTest() { - provider = "cloudservers-nova-us"; - } - -} diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSSecurityGroupClientLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSSecurityGroupClientLiveTest.java deleted file mode 100644 index c9fbe4b626..0000000000 --- a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSSecurityGroupClientLiveTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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.cloudservers_nova.us.features; - -import org.jclouds.openstack.nova.v1_1.extensions.SecurityGroupClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "CloudServersUSSecurityGroupClientLiveTest") -public class CloudServersUSSecurityGroupClientLiveTest extends SecurityGroupClientLiveTest { - public CloudServersUSSecurityGroupClientLiveTest() { - provider = "cloudservers-nova-us"; - } -} diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSVolumeClientLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSVolumeClientLiveTest.java deleted file mode 100644 index 90c89c686a..0000000000 --- a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/features/CloudServersUSVolumeClientLiveTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * 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.cloudservers_nova.us.features; - -import org.jclouds.openstack.nova.v1_1.extensions.VolumeClientLiveTest; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName = "CloudServersUSVolumeClientLiveTest") -public class CloudServersUSVolumeClientLiveTest extends VolumeClientLiveTest { - public CloudServersUSVolumeClientLiveTest() { - provider = "cloudservers-nova-us"; - } - -} diff --git a/labs/cloudservers-nova-us/src/test/resources/raxImages.json b/labs/cloudservers-nova-us/src/test/resources/raxImages.json new file mode 100644 index 0000000000..ba10f7609a --- /dev/null +++ b/labs/cloudservers-nova-us/src/test/resources/raxImages.json @@ -0,0 +1 @@ +{"images": [{"status": "ACTIVE", "updated": "2012-05-17T17:13:17Z", "links": [{"href": "https://dfw.servers.api.rackspacecloud.com/v2/413274/images/d6dd6c70-a122-4391-91a8-decb1a356549", "rel": "self"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/d6dd6c70-a122-4391-91a8-decb1a356549", "rel": "bookmark"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/d6dd6c70-a122-4391-91a8-decb1a356549", "type": "application/vnd.openstack.image", "rel": "alternate"}], "minDisk": 0, "id": "d6dd6c70-a122-4391-91a8-decb1a356549", "name": "Red Hat Enterprise Linux 6.1", "created": "2012-04-06T22:12:02Z", "OS-DCF:diskConfig": "AUTO", "progress": 100, "minRam": 256, "metadata": {"os_distro": "rhel", "org.openstack__1__os_distro": "com.redhat", "arch": "x86-64", "org.openstack__1__os_version": "6.1", "rax_managed": "false", "os_version": "6.1", "auto_disk_config": "True", "rax_options": "1", "os_type": "linux", "rax_activation_profile": "redhat", "org.openstack__1__architecture": "x64"}}, {"status": "ACTIVE", "updated": "2012-05-17T17:14:17Z", "links": [{"href": "https://dfw.servers.api.rackspacecloud.com/v2/413274/images/644be485-411d-4bac-aba5-5f60641d92b5", "rel": "self"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/644be485-411d-4bac-aba5-5f60641d92b5", "rel": "bookmark"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/644be485-411d-4bac-aba5-5f60641d92b5", "type": "application/vnd.openstack.image", "rel": "alternate"}], "minDisk": 0, "id": "644be485-411d-4bac-aba5-5f60641d92b5", "name": "Red Hat Enterprise Linux 5.5", "created": "2012-04-06T22:11:47Z", "OS-DCF:diskConfig": "AUTO", "progress": 100, "minRam": 256, "metadata": {"os_distro": "rhel", "org.openstack__1__os_distro": "com.redhat", "arch": "x86-64", "org.openstack__1__os_version": "5.5", "rax_managed": "false", "os_version": "5.5", "auto_disk_config": "True", "rax_options": "1", "os_type": "linux", "rax_activation_profile": "redhat", "org.openstack__1__architecture": "x64"}}, {"status": "ACTIVE", "updated": "2012-05-17T17:14:18Z", "links": [{"href": "https://dfw.servers.api.rackspacecloud.com/v2/413274/images/8bf22129-8483-462b-a020-1754ec822770", "rel": "self"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/8bf22129-8483-462b-a020-1754ec822770", "rel": "bookmark"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/8bf22129-8483-462b-a020-1754ec822770", "type": "application/vnd.openstack.image", "rel": "alternate"}], "minDisk": 10, "id": "8bf22129-8483-462b-a020-1754ec822770", "name": "Ubuntu 11.04", "created": "2012-02-28T21:24:42Z", "OS-DCF:diskConfig": "AUTO", "progress": 100, "minRam": 256, "metadata": {"os_distro": "ubuntu", "org.openstack__1__os_distro": "com.ubuntu", "org.openstack__1__os_version": "11.10", "rax_managed": "false", "os_version": "11.10", "auto_disk_config": "True", "rax_options": "0", "os_type": "linux", "arch": "x86-64", "org.openstack__1__architecture": "x64"}}, {"status": "ACTIVE", "updated": "2012-05-17T17:13:50Z", "links": [{"href": "https://dfw.servers.api.rackspacecloud.com/v2/413274/images/0d589460-f177-4b0f-81c1-8ab8903ac7d8", "rel": "self"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/0d589460-f177-4b0f-81c1-8ab8903ac7d8", "rel": "bookmark"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/0d589460-f177-4b0f-81c1-8ab8903ac7d8", "type": "application/vnd.openstack.image", "rel": "alternate"}], "minDisk": 10, "id": "0d589460-f177-4b0f-81c1-8ab8903ac7d8", "name": "Arch 2011.10", "created": "2012-02-28T19:42:22Z", "OS-DCF:diskConfig": "AUTO", "progress": 100, "minRam": 256, "metadata": {"os_distro": "arch", "org.openstack__1__os_distro": "org.archlinux", "org.openstack__1__os_version": "2011.10", "rax_managed": "false", "os_version": "2011.10", "auto_disk_config": "True", "rax_options": "0", "os_type": "linux", "arch": "x86-64", "org.openstack__1__architecture": "x64"}}, {"status": "ACTIVE", "updated": "2012-05-17T17:12:59Z", "links": [{"href": "https://dfw.servers.api.rackspacecloud.com/v2/413274/images/096c55e5-39f3-48cf-a413-68d9377a3ab6", "rel": "self"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/096c55e5-39f3-48cf-a413-68d9377a3ab6", "rel": "bookmark"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/096c55e5-39f3-48cf-a413-68d9377a3ab6", "type": "application/vnd.openstack.image", "rel": "alternate"}], "minDisk": 10, "id": "096c55e5-39f3-48cf-a413-68d9377a3ab6", "name": "openSUSE 12", "created": "2012-02-28T19:42:04Z", "OS-DCF:diskConfig": "AUTO", "progress": 100, "minRam": 256, "metadata": {"os_distro": "opensuse", "org.openstack__1__os_distro": "org.opensuse", "org.openstack__1__os_version": "12.0", "rax_managed": "false", "os_version": "12", "auto_disk_config": "True", "rax_options": "0", "os_type": "linux", "arch": "x86-64", "org.openstack__1__architecture": "x64"}}, {"status": "ACTIVE", "updated": "2012-05-17T17:13:17Z", "links": [{"href": "https://dfw.servers.api.rackspacecloud.com/v2/413274/images/040e6c82-6618-4f53-9f27-44db2c4ce9ee", "rel": "self"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/040e6c82-6618-4f53-9f27-44db2c4ce9ee", "rel": "bookmark"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/040e6c82-6618-4f53-9f27-44db2c4ce9ee", "type": "application/vnd.openstack.image", "rel": "alternate"}], "minDisk": 10, "id": "040e6c82-6618-4f53-9f27-44db2c4ce9ee", "name": "Gentoo 11.0", "created": "2012-02-28T19:41:50Z", "OS-DCF:diskConfig": "AUTO", "progress": 100, "minRam": 256, "metadata": {"os_distro": "gentoo", "org.openstack__1__os_distro": "org.gentoo", "org.openstack__1__os_version": "11.0", "rax_managed": "false", "os_version": "11.0", "auto_disk_config": "True", "rax_options": "0", "os_type": "linux", "arch": "x86-64", "org.openstack__1__architecture": "x64"}}, {"status": "ACTIVE", "updated": "2012-05-17T17:13:50Z", "links": [{"href": "https://dfw.servers.api.rackspacecloud.com/v2/413274/images/a10eacf7-ac15-4225-b533-5744f1fe47c1", "rel": "self"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/a10eacf7-ac15-4225-b533-5744f1fe47c1", "rel": "bookmark"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/a10eacf7-ac15-4225-b533-5744f1fe47c1", "type": "application/vnd.openstack.image", "rel": "alternate"}], "minDisk": 10, "id": "a10eacf7-ac15-4225-b533-5744f1fe47c1", "name": "Debian 6 (Squeeze)", "created": "2012-02-28T19:41:44Z", "OS-DCF:diskConfig": "AUTO", "progress": 100, "minRam": 256, "metadata": {"os_distro": "debian", "org.openstack__1__os_distro": "org.debian", "org.openstack__1__os_version": "6.0", "rax_managed": "false", "os_version": "6", "auto_disk_config": "True", "rax_options": "0", "os_type": "linux", "arch": "x86-64", "org.openstack__1__architecture": "x64"}}, {"status": "ACTIVE", "updated": "2012-05-17T17:14:18Z", "links": [{"href": "https://dfw.servers.api.rackspacecloud.com/v2/413274/images/25a025a8-b126-409c-ab02-0ca70af61d8d", "rel": "self"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/25a025a8-b126-409c-ab02-0ca70af61d8d", "rel": "bookmark"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/25a025a8-b126-409c-ab02-0ca70af61d8d", "type": "application/vnd.openstack.image", "rel": "alternate"}], "minDisk": 10, "id": "25a025a8-b126-409c-ab02-0ca70af61d8d", "name": "Debian 5 (Lenny)", "created": "2012-02-28T19:41:37Z", "OS-DCF:diskConfig": "AUTO", "progress": 100, "minRam": 256, "metadata": {"os_distro": "debian", "org.openstack__1__os_distro": "org.debian", "org.openstack__1__os_version": "5.0", "rax_managed": "false", "os_version": "5", "auto_disk_config": "True", "rax_options": "0", "os_type": "linux", "arch": "x86-64", "org.openstack__1__architecture": "x64"}}, {"status": "ACTIVE", "updated": "2012-05-17T17:12:26Z", "links": [{"href": "https://dfw.servers.api.rackspacecloud.com/v2/413274/images/bca91446-e60e-42e7-9e39-0582e7e20fb9", "rel": "self"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/bca91446-e60e-42e7-9e39-0582e7e20fb9", "rel": "bookmark"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/bca91446-e60e-42e7-9e39-0582e7e20fb9", "type": "application/vnd.openstack.image", "rel": "alternate"}], "minDisk": 10, "id": "bca91446-e60e-42e7-9e39-0582e7e20fb9", "name": "Fedora 16", "created": "2012-02-28T19:41:07Z", "OS-DCF:diskConfig": "AUTO", "progress": 100, "minRam": 256, "metadata": {"os_distro": "fedora", "org.openstack__1__os_distro": "org.fedoraproject", "org.openstack__1__os_version": "16.0", "rax_managed": "false", "os_version": "16", "auto_disk_config": "True", "rax_options": "0", "os_type": "linux", "arch": "x86-64", "org.openstack__1__architecture": "x64"}}, {"status": "ACTIVE", "updated": "2012-05-17T17:13:50Z", "links": [{"href": "https://dfw.servers.api.rackspacecloud.com/v2/413274/images/7c151d6f-d87b-420d-9f8e-b6ed7a160fbb", "rel": "self"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/7c151d6f-d87b-420d-9f8e-b6ed7a160fbb", "rel": "bookmark"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/7c151d6f-d87b-420d-9f8e-b6ed7a160fbb", "type": "application/vnd.openstack.image", "rel": "alternate"}], "minDisk": 10, "id": "7c151d6f-d87b-420d-9f8e-b6ed7a160fbb", "name": "Fedora 15", "created": "2012-02-28T19:40:57Z", "OS-DCF:diskConfig": "AUTO", "progress": 100, "minRam": 256, "metadata": {"os_distro": "fedora", "org.openstack__1__os_distro": "org.fedoraproject", "org.openstack__1__os_version": "15.0", "rax_managed": "false", "os_version": "15", "auto_disk_config": "True", "rax_options": "0", "os_type": "linux", "arch": "x86-64", "org.openstack__1__architecture": "x64"}}, {"status": "ACTIVE", "updated": "2012-05-17T17:14:17Z", "links": [{"href": "https://dfw.servers.api.rackspacecloud.com/v2/413274/images/03318d19-b6e6-4092-9b5c-4758ee0ada60", "rel": "self"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/03318d19-b6e6-4092-9b5c-4758ee0ada60", "rel": "bookmark"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/03318d19-b6e6-4092-9b5c-4758ee0ada60", "type": "application/vnd.openstack.image", "rel": "alternate"}], "minDisk": 10, "id": "03318d19-b6e6-4092-9b5c-4758ee0ada60", "name": "CentOS 5.6", "created": "2012-02-28T19:40:46Z", "OS-DCF:diskConfig": "AUTO", "progress": 100, "minRam": 256, "metadata": {"os_distro": "centos", "org.openstack__1__os_distro": "org.centos", "org.openstack__1__os_version": "5.6", "rax_managed": "false", "os_version": "5.6", "auto_disk_config": "True", "rax_options": "0", "os_type": "linux", "arch": "x86-64", "org.openstack__1__architecture": "x64"}}, {"status": "ACTIVE", "updated": "2012-05-17T17:14:18Z", "links": [{"href": "https://dfw.servers.api.rackspacecloud.com/v2/413274/images/a3a2c42f-575f-4381-9c6d-fcd3b7d07d17", "rel": "self"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/a3a2c42f-575f-4381-9c6d-fcd3b7d07d17", "rel": "bookmark"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/a3a2c42f-575f-4381-9c6d-fcd3b7d07d17", "type": "application/vnd.openstack.image", "rel": "alternate"}], "minDisk": 10, "id": "a3a2c42f-575f-4381-9c6d-fcd3b7d07d17", "name": "CentOS 6.0", "created": "2012-02-28T19:40:32Z", "OS-DCF:diskConfig": "AUTO", "progress": 100, "minRam": 256, "metadata": {"os_distro": "centos", "org.openstack__1__os_distro": "org.centos", "org.openstack__1__os_version": "6.0", "rax_managed": "false", "os_version": "6.0", "auto_disk_config": "True", "rax_options": "0", "os_type": "linux", "arch": "x86-64", "org.openstack__1__architecture": "x64"}}, {"status": "ACTIVE", "updated": "2012-05-17T17:14:18Z", "links": [{"href": "https://dfw.servers.api.rackspacecloud.com/v2/413274/images/5f68715f-201f-4600-b5a1-0b97e2b1cb31", "rel": "self"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/5f68715f-201f-4600-b5a1-0b97e2b1cb31", "rel": "bookmark"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/5f68715f-201f-4600-b5a1-0b97e2b1cb31", "type": "application/vnd.openstack.image", "rel": "alternate"}], "minDisk": 10, "id": "5f68715f-201f-4600-b5a1-0b97e2b1cb31", "name": "Ubuntu 10.04 LTS", "created": "2012-02-28T19:40:25Z", "OS-DCF:diskConfig": "AUTO", "progress": 100, "minRam": 256, "metadata": {"os_distro": "ubuntu", "org.openstack__1__os_distro": "com.ubuntu", "org.openstack__1__os_version": "10.04", "rax_managed": "false", "os_version": "10.04LTS", "auto_disk_config": "True", "rax_options": "0", "os_type": "linux", "arch": "x86-64", "org.openstack__1__architecture": "x64"}}, {"status": "ACTIVE", "updated": "2012-02-28T19:39:05Z", "links": [{"href": "https://dfw.servers.api.rackspacecloud.com/v2/413274/images/3afe97b2-26dc-49c5-a2cc-a2fc8d80c001", "rel": "self"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/3afe97b2-26dc-49c5-a2cc-a2fc8d80c001", "rel": "bookmark"}, {"href": "https://dfw.servers.api.rackspacecloud.com/413274/images/3afe97b2-26dc-49c5-a2cc-a2fc8d80c001", "type": "application/vnd.openstack.image", "rel": "alternate"}], "minDisk": 10, "id": "3afe97b2-26dc-49c5-a2cc-a2fc8d80c001", "name": "Ubuntu 11.10", "created": "2012-02-28T19:38:57Z", "OS-DCF:diskConfig": "AUTO", "progress": 100, "minRam": 256, "metadata": {"os_distro": "ubuntu", "rax_managed": "false", "os_version": "11.10", "auto_disk_config": "True", "rax_options": "0", "os_type": "linux", "arch": "x86-64"}}]} \ No newline at end of file From ee64660f45f42d144456f87b56b9ba9e1a4cbaad Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 7 Jun 2012 00:36:00 -0700 Subject: [PATCH 9/9] changed default login to root --- .../cloudservers_nova/us/CloudServersUSProviderMetadata.java | 2 +- .../us/compute/CloudServersUSTemplateBuilderLiveTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/labs/cloudservers-nova-us/src/main/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderMetadata.java b/labs/cloudservers-nova-us/src/main/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderMetadata.java index 8814febfd9..599040b843 100644 --- a/labs/cloudservers-nova-us/src/main/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderMetadata.java +++ b/labs/cloudservers-nova-us/src/main/java/org/jclouds/cloudservers_nova/us/CloudServersUSProviderMetadata.java @@ -65,7 +65,7 @@ public class CloudServersUSProviderMetadata extends BaseProviderMetadata { public static Properties defaultProperties() { Properties properties = new Properties(); properties.setProperty(CREDENTIAL_TYPE, CloudIdentityCredentialTypes.API_KEY_CREDENTIALS); - properties.setProperty(TEMPLATE, "imageId=DFW/3afe97b2-26dc-49c5-a2cc-a2fc8d80c001"); + properties.setProperty(TEMPLATE, "imageId=DFW/3afe97b2-26dc-49c5-a2cc-a2fc8d80c001,loginUser=root"); return properties; } diff --git a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSTemplateBuilderLiveTest.java b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSTemplateBuilderLiveTest.java index b5644e87dc..9e616cac61 100644 --- a/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSTemplateBuilderLiveTest.java +++ b/labs/cloudservers-nova-us/src/test/java/org/jclouds/cloudservers_nova/us/compute/CloudServersUSTemplateBuilderLiveTest.java @@ -76,7 +76,7 @@ public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLi assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(defaultTemplate.getImage().getName(), "Ubuntu 11.10"); - assertEquals(defaultTemplate.getImage().getDefaultCredentials().getUser(), "ubuntu"); + assertEquals(defaultTemplate.getImage().getDefaultCredentials().getUser(), "root"); assertEquals(defaultTemplate.getLocation().getId(), "DFW"); assertEquals(defaultTemplate.getImage().getLocation().getId(), "DFW"); assertEquals(defaultTemplate.getHardware().getLocation().getId(), "DFW");