mirror of https://github.com/apache/jclouds.git
openstack-nova: allowing extension of the standard extensions by providers
This commit is contained in:
parent
9981eee038
commit
4fad770eaf
|
@ -100,98 +100,98 @@ public interface NovaApi {
|
||||||
* Provides synchronous access to Floating IP features.
|
* Provides synchronous access to Floating IP features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<FloatingIPApi> getFloatingIPExtensionForZone(
|
Optional<? extends FloatingIPApi> getFloatingIPExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Security Group features.
|
* Provides synchronous access to Security Group features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<SecurityGroupApi> getSecurityGroupExtensionForZone(
|
Optional<? extends SecurityGroupApi> getSecurityGroupExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Key Pair features.
|
* Provides synchronous access to Key Pair features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<KeyPairApi> getKeyPairExtensionForZone(
|
Optional<? extends KeyPairApi> getKeyPairExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Host Administration features.
|
* Provides synchronous access to Host Administration features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<HostAdministrationApi> getHostAdministrationExtensionForZone(
|
Optional<? extends HostAdministrationApi> getHostAdministrationExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Simple Tenant Usage features.
|
* Provides synchronous access to Simple Tenant Usage features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<SimpleTenantUsageApi> getSimpleTenantUsageExtensionForZone(
|
Optional<? extends SimpleTenantUsageApi> getSimpleTenantUsageExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Volume features.
|
* Provides synchronous access to Volume features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<VolumeApi> getVolumeExtensionForZone(
|
Optional<? extends VolumeApi> getVolumeExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Virtual Interface features.
|
* Provides synchronous access to Virtual Interface features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<VirtualInterfaceApi> getVirtualInterfaceExtensionForZone(
|
Optional<? extends VirtualInterfaceApi> getVirtualInterfaceExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Server Extra Data features.
|
* Provides synchronous access to Server Extra Data features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<ServerWithSecurityGroupsApi> getServerWithSecurityGroupsExtensionForZone(
|
Optional<? extends ServerWithSecurityGroupsApi> getServerWithSecurityGroupsExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Server Admin Actions features.
|
* Provides synchronous access to Server Admin Actions features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<AdminActionsApi> getAdminActionsExtensionForZone(
|
Optional<? extends AdminActionsApi> getAdminActionsExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Aggregate features.
|
* Provides synchronous access to Aggregate features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<HostAggregateApi> getHostAggregateExtensionForZone(
|
Optional<? extends HostAggregateApi> getHostAggregateExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Flavor extra specs features.
|
* Provides synchronous access to Flavor extra specs features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<FlavorExtraSpecsApi> getFlavorExtraSpecsExtensionForZone(
|
Optional<? extends FlavorExtraSpecsApi> getFlavorExtraSpecsExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Quota features.
|
* Provides synchronous access to Quota features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<QuotaApi> getQuotaExtensionForZone(
|
Optional<? extends QuotaApi> getQuotaExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Quota Classes features.
|
* Provides synchronous access to Quota Classes features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<QuotaClassApi> getQuotaClassExtensionForZone(
|
Optional<? extends QuotaClassApi> getQuotaClassExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides synchronous access to Volume Type features.
|
* Provides synchronous access to Volume Type features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<VolumeTypeApi> getVolumeTypeExtensionForZone(
|
Optional<? extends VolumeTypeApi> getVolumeTypeExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,49 +98,49 @@ public interface NovaAsyncApi {
|
||||||
* Provides asynchronous access to Floating IP features.
|
* Provides asynchronous access to Floating IP features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<FloatingIPAsyncApi> getFloatingIPExtensionForZone(
|
Optional<? extends FloatingIPAsyncApi> getFloatingIPExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Security Group features.
|
* Provides asynchronous access to Security Group features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<SecurityGroupAsyncApi> getSecurityGroupExtensionForZone(
|
Optional<? extends SecurityGroupAsyncApi> getSecurityGroupExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Key Pair features.
|
* Provides asynchronous access to Key Pair features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<KeyPairAsyncApi> getKeyPairExtensionForZone(
|
Optional<? extends KeyPairAsyncApi> getKeyPairExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Host Administration features.
|
* Provides asynchronous access to Host Administration features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<HostAdministrationAsyncApi> getHostAdministrationExtensionForZone(
|
Optional<? extends HostAdministrationAsyncApi> getHostAdministrationExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Simple Tenant Usage features.
|
* Provides asynchronous access to Simple Tenant Usage features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<SimpleTenantUsageAsyncApi> getSimpleTenantUsageExtensionForZone(
|
Optional<? extends SimpleTenantUsageAsyncApi> getSimpleTenantUsageExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Volume features.
|
* Provides asynchronous access to Volume features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<VolumeAsyncApi> getVolumeExtensionForZone(
|
Optional<? extends VolumeAsyncApi> getVolumeExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Virtual Interface features.
|
* Provides asynchronous access to Virtual Interface features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<VirtualInterfaceAsyncApi> getVirtualInterfaceExtensionForZone(
|
Optional<? extends VirtualInterfaceAsyncApi> getVirtualInterfaceExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,49 +148,49 @@ public interface NovaAsyncApi {
|
||||||
* Provides asynchronous access to Server Extra Data features.
|
* Provides asynchronous access to Server Extra Data features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<ServerWithSecurityGroupsAsyncApi> getServerWithSecurityGroupsExtensionForZone(
|
Optional<? extends ServerWithSecurityGroupsAsyncApi> getServerWithSecurityGroupsExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Server Admin Actions features.
|
* Provides asynchronous access to Server Admin Actions features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<AdminActionsAsyncApi> getAdminActionsExtensionForZone(
|
Optional<? extends AdminActionsAsyncApi> getAdminActionsExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to HostAggregate features.
|
* Provides asynchronous access to HostAggregate features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<HostAggregateAsyncApi> getHostAggregateExtensionForZone(
|
Optional<? extends HostAggregateAsyncApi> getHostAggregateExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Flavor extra specs features.
|
* Provides asynchronous access to Flavor extra specs features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<FlavorExtraSpecsAsyncApi> getFlavorExtraSpecsExtensionForZone(
|
Optional<? extends FlavorExtraSpecsAsyncApi> getFlavorExtraSpecsExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Quota features.
|
* Provides asynchronous access to Quota features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<QuotaAsyncApi> getQuotaExtensionForZone(
|
Optional<? extends QuotaAsyncApi> getQuotaExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Quota Classes features.
|
* Provides asynchronous access to Quota Classes features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<QuotaClassAsyncApi> getQuotaClassExtensionForZone(
|
Optional<? extends QuotaClassAsyncApi> getQuotaClassExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides asynchronous access to Volume Type features.
|
* Provides asynchronous access to Volume Type features.
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
Optional<VolumeTypeAsyncApi> getVolumeTypeExtensionForZone(
|
Optional<? extends VolumeTypeAsyncApi> getVolumeTypeExtensionForZone(
|
||||||
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
@EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class NovaComputeService extends BaseComputeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanupOrphanedSecurityGroupsInZone(Set<String> groups, String zoneId) {
|
private void cleanupOrphanedSecurityGroupsInZone(Set<String> groups, String zoneId) {
|
||||||
Optional<SecurityGroupApi> securityGroupApi = novaApi.getSecurityGroupExtensionForZone(zoneId);
|
Optional<? extends SecurityGroupApi> securityGroupApi = novaApi.getSecurityGroupExtensionForZone(zoneId);
|
||||||
if (securityGroupApi.isPresent()) {
|
if (securityGroupApi.isPresent()) {
|
||||||
for (String group : groups) {
|
for (String group : groups) {
|
||||||
for (SecurityGroup securityGroup : Iterables.filter(securityGroupApi.get().listSecurityGroups(),
|
for (SecurityGroup securityGroup : Iterables.filter(securityGroupApi.get().listSecurityGroups(),
|
||||||
|
@ -152,7 +152,7 @@ public class NovaComputeService extends BaseComputeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanupOrphanedKeyPairsInZone(Set<String> groups, String zoneId) {
|
private void cleanupOrphanedKeyPairsInZone(Set<String> groups, String zoneId) {
|
||||||
Optional<KeyPairApi> keyPairApi = novaApi.getKeyPairExtensionForZone(zoneId);
|
Optional<? extends KeyPairApi> keyPairApi = novaApi.getKeyPairExtensionForZone(zoneId);
|
||||||
if (keyPairApi.isPresent()) {
|
if (keyPairApi.isPresent()) {
|
||||||
for (String group : groups) {
|
for (String group : groups) {
|
||||||
for (Map<String, KeyPair> view : keyPairApi.get().listKeyPairs()) {
|
for (Map<String, KeyPair> view : keyPairApi.get().listKeyPairs()) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class CreateSecurityGroupIfNeeded implements Function<ZoneSecurityGroupNa
|
||||||
checkNotNull(zoneSecurityGroupNameAndPorts, "zoneSecurityGroupNameAndPorts");
|
checkNotNull(zoneSecurityGroupNameAndPorts, "zoneSecurityGroupNameAndPorts");
|
||||||
|
|
||||||
String zoneId = zoneSecurityGroupNameAndPorts.getZone();
|
String zoneId = zoneSecurityGroupNameAndPorts.getZone();
|
||||||
Optional<SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(zoneId);
|
Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(zoneId);
|
||||||
checkArgument(api.isPresent(), "Security groups are required, but the extension is not availablein zone %s!", zoneId);
|
checkArgument(api.isPresent(), "Security groups are required, but the extension is not availablein zone %s!", zoneId);
|
||||||
logger.debug(">> creating securityGroup %s", zoneSecurityGroupNameAndPorts);
|
logger.debug(">> creating securityGroup %s", zoneSecurityGroupNameAndPorts);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class CreateUniqueKeyPair extends CacheLoader<ZoneAndName, KeyPair> {
|
||||||
String zoneId = checkNotNull(zoneAndName, "zoneAndName").getZone();
|
String zoneId = checkNotNull(zoneAndName, "zoneAndName").getZone();
|
||||||
String prefix = zoneAndName.getName();
|
String prefix = zoneAndName.getName();
|
||||||
|
|
||||||
Optional<KeyPairApi> api = novaApi.getKeyPairExtensionForZone(zoneId);
|
Optional<? extends KeyPairApi> api = novaApi.getKeyPairExtensionForZone(zoneId);
|
||||||
checkArgument(api.isPresent(), "Key pairs are required, but the extension is not available in zone %s!",
|
checkArgument(api.isPresent(), "Key pairs are required, but the extension is not available in zone %s!",
|
||||||
zoneId);
|
zoneId);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class LoadFloatingIpsForInstance extends CacheLoader<ZoneAndId, Iterable<
|
||||||
@Override
|
@Override
|
||||||
public Iterable<FloatingIP> load(final ZoneAndId key) throws Exception {
|
public Iterable<FloatingIP> load(final ZoneAndId key) throws Exception {
|
||||||
String zone = key.getZone();
|
String zone = key.getZone();
|
||||||
Optional<FloatingIPApi> ipApiOptional = api.getFloatingIPExtensionForZone(zone);
|
Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPExtensionForZone(zone);
|
||||||
if (ipApiOptional.isPresent()) {
|
if (ipApiOptional.isPresent()) {
|
||||||
return Iterables.filter(ipApiOptional.get().listFloatingIPs(),
|
return Iterables.filter(ipApiOptional.get().listFloatingIPs(),
|
||||||
new Predicate<FloatingIP>() {
|
new Predicate<FloatingIP>() {
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class FindSecurityGroupWithNameAndReturnTrue implements Predicate<AtomicR
|
||||||
checkNotNull(securityGroupInZoneRef, "securityGroupRef");
|
checkNotNull(securityGroupInZoneRef, "securityGroupRef");
|
||||||
final ZoneAndName securityGroupInZone = checkNotNull(securityGroupInZoneRef.get(), "securityGroupInZone");
|
final ZoneAndName securityGroupInZone = checkNotNull(securityGroupInZoneRef.get(), "securityGroupInZone");
|
||||||
|
|
||||||
Optional<SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(securityGroupInZone.getZone());
|
Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(securityGroupInZone.getZone());
|
||||||
checkArgument(api.isPresent(), "Security groups are required, but the extension is not available!");
|
checkArgument(api.isPresent(), "Security groups are required, but the extension is not available!");
|
||||||
|
|
||||||
logger.trace("looking for security group %s", securityGroupInZone.slashEncode());
|
logger.trace("looking for security group %s", securityGroupInZone.slashEncode());
|
||||||
|
|
|
@ -52,7 +52,9 @@ public class CreateUniqueKeyPairTest {
|
||||||
|
|
||||||
KeyPair pair = createMock(KeyPair.class);
|
KeyPair pair = createMock(KeyPair.class);
|
||||||
|
|
||||||
expect(api.getKeyPairExtensionForZone("zone")).andReturn(Optional.of(keyApi)).atLeastOnce();
|
Optional optKeyApi = Optional.of(keyApi);
|
||||||
|
|
||||||
|
expect(api.getKeyPairExtensionForZone("zone")).andReturn(optKeyApi).atLeastOnce();
|
||||||
|
|
||||||
expect(keyApi.createKeyPair("group-1")).andReturn(pair);
|
expect(keyApi.createKeyPair("group-1")).andReturn(pair);
|
||||||
|
|
||||||
|
@ -83,7 +85,7 @@ public class CreateUniqueKeyPairTest {
|
||||||
|
|
||||||
KeyPair pair = createMock(KeyPair.class);
|
KeyPair pair = createMock(KeyPair.class);
|
||||||
|
|
||||||
expect(api.getKeyPairExtensionForZone("zone")).andReturn(Optional.of(keyApi)).atLeastOnce();
|
expect(api.getKeyPairExtensionForZone("zone")).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();
|
||||||
|
|
||||||
expect(uniqueIdSupplier.get()).andReturn("1");
|
expect(uniqueIdSupplier.get()).andReturn("1");
|
||||||
expect(keyApi.createKeyPair("group-1")).andThrow(new IllegalStateException());
|
expect(keyApi.createKeyPair("group-1")).andThrow(new IllegalStateException());
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class LoadFloatingIpsForInstanceTest {
|
||||||
FloatingIPApi ipApi = createMock(FloatingIPApi.class);
|
FloatingIPApi ipApi = createMock(FloatingIPApi.class);
|
||||||
FloatingIP testIp = FloatingIP.builder().id("1").ip("1.1.1.1").fixedIp("10.1.1.1").instanceId("i-blah").build();
|
FloatingIP testIp = FloatingIP.builder().id("1").ip("1.1.1.1").fixedIp("10.1.1.1").instanceId("i-blah").build();
|
||||||
|
|
||||||
expect(api.getFloatingIPExtensionForZone("Zone")).andReturn(Optional.of(ipApi)).atLeastOnce();
|
expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
|
||||||
expect(ipApi.listFloatingIPs()).andReturn(ImmutableSet.<FloatingIP>of(testIp)).atLeastOnce();
|
expect(ipApi.listFloatingIPs()).andReturn(ImmutableSet.<FloatingIP>of(testIp)).atLeastOnce();
|
||||||
|
|
||||||
replay(api);
|
replay(api);
|
||||||
|
@ -65,7 +65,7 @@ public class LoadFloatingIpsForInstanceTest {
|
||||||
NovaApi api = createMock(NovaApi.class);
|
NovaApi api = createMock(NovaApi.class);
|
||||||
FloatingIPApi ipApi = createMock(FloatingIPApi.class);
|
FloatingIPApi ipApi = createMock(FloatingIPApi.class);
|
||||||
|
|
||||||
expect(api.getFloatingIPExtensionForZone("Zone")).andReturn(Optional.of(ipApi)).atLeastOnce();
|
expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
|
||||||
|
|
||||||
expect(ipApi.listFloatingIPs()).andReturn(ImmutableSet.<FloatingIP>of()).atLeastOnce();
|
expect(ipApi.listFloatingIPs()).andReturn(ImmutableSet.<FloatingIP>of()).atLeastOnce();
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public class LoadFloatingIpsForInstanceTest {
|
||||||
NovaApi api = createMock(NovaApi.class);
|
NovaApi api = createMock(NovaApi.class);
|
||||||
FloatingIPApi ipApi = createMock(FloatingIPApi.class);
|
FloatingIPApi ipApi = createMock(FloatingIPApi.class);
|
||||||
|
|
||||||
expect(api.getFloatingIPExtensionForZone("Zone")).andReturn(Optional.of(ipApi)).atLeastOnce();
|
expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
|
||||||
|
|
||||||
expect(ipApi.listFloatingIPs()).andReturn(
|
expect(ipApi.listFloatingIPs()).andReturn(
|
||||||
ImmutableSet.<FloatingIP>of(FloatingIP.builder().id("1").ip("1.1.1.1").build()))
|
ImmutableSet.<FloatingIP>of(FloatingIP.builder().id("1").ip("1.1.1.1").build()))
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
private ImageApi imageApi;
|
private ImageApi imageApi;
|
||||||
private ServerApi serverApi;
|
private ServerApi serverApi;
|
||||||
private ExtensionApi extensionApi;
|
private ExtensionApi extensionApi;
|
||||||
private Optional<AdminActionsApi> apiOption;
|
private Optional<? extends AdminActionsApi> apiOption;
|
||||||
private String zone;
|
private String zone;
|
||||||
|
|
||||||
private String testServerId;
|
private String testServerId;
|
||||||
|
|
|
@ -44,7 +44,7 @@ import com.google.common.collect.Maps;
|
||||||
@Test(groups = "live", testName = "FlavorExtraSpecsApiLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "FlavorExtraSpecsApiLiveTest", singleThreaded = true)
|
||||||
public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest {
|
public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
private FlavorApi flavorApi;
|
private FlavorApi flavorApi;
|
||||||
private Optional<FlavorExtraSpecsApi> apiOption;
|
private Optional<? extends FlavorExtraSpecsApi> apiOption;
|
||||||
private String zone;
|
private String zone;
|
||||||
|
|
||||||
private Resource testFlavor;
|
private Resource testFlavor;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Test
|
@Test
|
||||||
public void testListFloatingIPs() throws Exception {
|
public void testListFloatingIPs() throws Exception {
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
||||||
Optional<FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId);
|
Optional<? extends FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId);
|
||||||
if (!apiOption.isPresent())
|
if (!apiOption.isPresent())
|
||||||
continue;
|
continue;
|
||||||
FloatingIPApi api = apiOption.get();
|
FloatingIPApi api = apiOption.get();
|
||||||
|
@ -70,7 +70,7 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAllocateAndDeallocateFloatingIPs() throws Exception {
|
public void testAllocateAndDeallocateFloatingIPs() throws Exception {
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
||||||
Optional<FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId);
|
Optional<? extends FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId);
|
||||||
if (!apiOption.isPresent())
|
if (!apiOption.isPresent())
|
||||||
continue;
|
continue;
|
||||||
FloatingIPApi api = apiOption.get();
|
FloatingIPApi api = apiOption.get();
|
||||||
|
@ -101,7 +101,7 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
@Test
|
@Test
|
||||||
public void testAddAndRemoveFloatingIp() throws Exception {
|
public void testAddAndRemoveFloatingIp() throws Exception {
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
||||||
Optional<FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId);
|
Optional<? extends FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId);
|
||||||
if (!apiOption.isPresent())
|
if (!apiOption.isPresent())
|
||||||
continue;
|
continue;
|
||||||
FloatingIPApi api = apiOption.get();
|
FloatingIPApi api = apiOption.get();
|
||||||
|
|
|
@ -42,7 +42,7 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "HostAdministrationApiLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "HostAdministrationApiLiveTest", singleThreaded = true)
|
||||||
public class HostAdministrationApiLiveTest extends BaseNovaApiLiveTest {
|
public class HostAdministrationApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
private Optional<HostAdministrationApi> optApi = Optional.absent();
|
private Optional<? extends HostAdministrationApi> optApi = Optional.absent();
|
||||||
|
|
||||||
Predicate<Host> isComputeHost = new Predicate<Host>() {
|
Predicate<Host> isComputeHost = new Predicate<Host>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,8 +44,8 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "AggregateApiLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "AggregateApiLiveTest", singleThreaded = true)
|
||||||
public class HostAggregateApiLiveTest extends BaseNovaApiLiveTest {
|
public class HostAggregateApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
private Optional<HostAggregateApi> apiOption;
|
private Optional<? extends HostAggregateApi> apiOption;
|
||||||
private Optional<HostAdministrationApi> hostAdminOption;
|
private Optional<? extends HostAdministrationApi> hostAdminOption;
|
||||||
|
|
||||||
private HostAggregate testAggregate;
|
private HostAggregate testAggregate;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "QuotaApiLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "QuotaApiLiveTest", singleThreaded = true)
|
||||||
public class QuotaApiLiveTest extends BaseNovaApiLiveTest {
|
public class QuotaApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
private Optional<QuotaApi> apiOption;
|
private Optional<? extends QuotaApi> apiOption;
|
||||||
private String tenant;
|
private String tenant;
|
||||||
|
|
||||||
@BeforeClass(groups = {"integration", "live"})
|
@BeforeClass(groups = {"integration", "live"})
|
||||||
|
|
|
@ -36,7 +36,7 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "QuotaClassApiLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "QuotaClassApiLiveTest", singleThreaded = true)
|
||||||
public class QuotaClassApiLiveTest extends BaseNovaApiLiveTest {
|
public class QuotaClassApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
private Optional<QuotaClassApi> apiOption;
|
private Optional<? extends QuotaClassApi> apiOption;
|
||||||
private String zone;
|
private String zone;
|
||||||
|
|
||||||
@BeforeClass(groups = {"integration", "live"})
|
@BeforeClass(groups = {"integration", "live"})
|
||||||
|
|
|
@ -41,7 +41,7 @@ import com.google.common.collect.Iterables;
|
||||||
@Test(groups = "live", testName = "ServerWithSecurityGroupsApiLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "ServerWithSecurityGroupsApiLiveTest", singleThreaded = true)
|
||||||
public class ServerWithSecurityGroupsApiLiveTest extends BaseNovaApiLiveTest {
|
public class ServerWithSecurityGroupsApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
private ServerApi serverApi;
|
private ServerApi serverApi;
|
||||||
private Optional<ServerWithSecurityGroupsApi> apiOption;
|
private Optional<? extends ServerWithSecurityGroupsApi> apiOption;
|
||||||
private String zone;
|
private String zone;
|
||||||
|
|
||||||
@BeforeGroups(groups = {"integration", "live"})
|
@BeforeGroups(groups = {"integration", "live"})
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class SimpleTenantUsageApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
public void testList() throws Exception {
|
public void testList() throws Exception {
|
||||||
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
|
||||||
Optional<SimpleTenantUsageApi> optApi = novaContext.getApi().getSimpleTenantUsageExtensionForZone(zoneId);
|
Optional<? extends SimpleTenantUsageApi> optApi = novaContext.getApi().getSimpleTenantUsageExtensionForZone(zoneId);
|
||||||
if (optApi.isPresent() && identity.endsWith(":admin")) {
|
if (optApi.isPresent() && identity.endsWith(":admin")) {
|
||||||
SimpleTenantUsageApi api = optApi.get();
|
SimpleTenantUsageApi api = optApi.get();
|
||||||
Set<SimpleTenantUsage> usages = api.listTenantUsages();
|
Set<SimpleTenantUsage> usages = api.listTenantUsages();
|
||||||
|
|
|
@ -38,7 +38,7 @@ import com.google.common.collect.Iterables;
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "VirtualInterfaceApiLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "VirtualInterfaceApiLiveTest", singleThreaded = true)
|
||||||
public class VirtualInterfaceApiLiveTest extends BaseNovaApiLiveTest {
|
public class VirtualInterfaceApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
private Optional<VirtualInterfaceApi> apiOption;
|
private Optional<? extends VirtualInterfaceApi> apiOption;
|
||||||
private String zone;
|
private String zone;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ import com.google.common.collect.Iterables;
|
||||||
@Test(groups = "live", testName = "VolumeApiLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "VolumeApiLiveTest", singleThreaded = true)
|
||||||
public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
|
public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
private Optional<VolumeApi> volumeOption;
|
private Optional<? extends VolumeApi> volumeOption;
|
||||||
private String zone;
|
private String zone;
|
||||||
|
|
||||||
private Volume testVolume;
|
private Volume testVolume;
|
||||||
|
|
|
@ -46,7 +46,7 @@ import com.google.common.collect.Iterables;
|
||||||
@Test(groups = "live", testName = "VolumeTypeApiLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "VolumeTypeApiLiveTest", singleThreaded = true)
|
||||||
public class VolumeTypeApiLiveTest extends BaseNovaApiLiveTest {
|
public class VolumeTypeApiLiveTest extends BaseNovaApiLiveTest {
|
||||||
|
|
||||||
private Optional<VolumeTypeApi> volumeTypeOption;
|
private Optional<? extends VolumeTypeApi> volumeTypeOption;
|
||||||
private String zone;
|
private String zone;
|
||||||
|
|
||||||
private VolumeType testVolumeType;
|
private VolumeType testVolumeType;
|
||||||
|
|
|
@ -20,6 +20,8 @@ package org.jclouds.util;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.lang.reflect.WildcardType;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
|
@ -35,7 +37,11 @@ public class Optionals2 {
|
||||||
if (optional) {
|
if (optional) {
|
||||||
ParameterizedType futureType = ParameterizedType.class.cast(method.getGenericReturnType());
|
ParameterizedType futureType = ParameterizedType.class.cast(method.getGenericReturnType());
|
||||||
// TODO: error checking in case this is a type, not a class.
|
// TODO: error checking in case this is a type, not a class.
|
||||||
syncClass = Class.class.cast(futureType.getActualTypeArguments()[0]);
|
Type t = futureType.getActualTypeArguments()[0];
|
||||||
|
if (t instanceof WildcardType) {
|
||||||
|
t = ((WildcardType) t).getUpperBounds()[0];
|
||||||
|
}
|
||||||
|
syncClass = Class.class.cast(t);
|
||||||
} else {
|
} else {
|
||||||
syncClass = method.getReturnType();
|
syncClass = method.getReturnType();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue