mirror of https://github.com/apache/jclouds.git
format and imports
This commit is contained in:
parent
318c31c054
commit
1bef09ab91
|
@ -41,7 +41,8 @@ import com.google.inject.Provides;
|
|||
* <p/>
|
||||
*
|
||||
* @see NovaClient
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-compute/1.1/content/" />
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-compute/1.1/content/"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public interface NovaAsyncClient {
|
||||
|
@ -59,47 +60,47 @@ public interface NovaAsyncClient {
|
|||
*/
|
||||
@Delegate
|
||||
ServerAsyncClient getServerClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Flavor features.
|
||||
*/
|
||||
@Delegate
|
||||
FlavorAsyncClient getFlavorClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Extension features.
|
||||
*/
|
||||
@Delegate
|
||||
ExtensionAsyncClient getExtensionClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Image features.
|
||||
*/
|
||||
@Delegate
|
||||
ImageAsyncClient getImageClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Floating IP features.
|
||||
*/
|
||||
@Delegate
|
||||
Optional<FloatingIPAsyncClient> getFloatingIPExtensionForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Security Group features.
|
||||
*/
|
||||
@Delegate
|
||||
Optional<SecurityGroupAsyncClient> getSecurityGroupClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides asynchronous access to Key Pair features.
|
||||
*/
|
||||
@Delegate
|
||||
Optional<KeyPairAsyncClient> getKeyPairClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,8 @@ import com.google.inject.Provides;
|
|||
* <p/>
|
||||
*
|
||||
* @see NovaAsyncClient
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-compute/1.1/content/" />
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-compute/1.1/content/"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
|
||||
|
@ -61,48 +62,48 @@ public interface NovaClient {
|
|||
*/
|
||||
@Delegate
|
||||
ServerClient getServerClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Flavor features.
|
||||
*/
|
||||
@Delegate
|
||||
FlavorClient getFlavorClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Extension features.
|
||||
*/
|
||||
@Delegate
|
||||
ExtensionClient getExtensionClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Image features.
|
||||
*/
|
||||
@Delegate
|
||||
ImageClient getImageClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Floating IP features.
|
||||
*/
|
||||
@Delegate
|
||||
Optional<FloatingIPClient> getFloatingIPExtensionForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Security Group features.
|
||||
*/
|
||||
@Delegate
|
||||
SecurityGroupClient getSecurityGroupClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
/**
|
||||
* Provides synchronous access to Key Pair features.
|
||||
*/
|
||||
@Delegate
|
||||
KeyPairClient getKeyPairClientForRegion(
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
@EndpointParam(parser = RegionToEndpointOrProviderIfNull.class) @Nullable String region);
|
||||
|
||||
}
|
||||
|
|
|
@ -32,8 +32,7 @@ import com.google.inject.Module;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class NovaContextBuilder extends ComputeServiceContextBuilder<NovaClient, NovaAsyncClient>
|
||||
{
|
||||
public class NovaContextBuilder extends ComputeServiceContextBuilder<NovaClient, NovaAsyncClient> {
|
||||
|
||||
public NovaContextBuilder(Properties props) {
|
||||
super(NovaClient.class, NovaAsyncClient.class, props);
|
||||
|
|
|
@ -42,12 +42,12 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* The adapter used by the NovaComputeServiceContextModule to interface the nova-specific domain model to the computeService generic domain model.
|
||||
* The adapter used by the NovaComputeServiceContextModule to interface the
|
||||
* nova-specific domain model to the computeService generic domain model.
|
||||
*
|
||||
* @author Matt Stephenson
|
||||
*/
|
||||
public class NovaComputeServiceAdapter implements ComputeServiceAdapter<Server, Flavor, Image, Location>
|
||||
{
|
||||
public class NovaComputeServiceAdapter implements ComputeServiceAdapter<Server, Flavor, Image, Location> {
|
||||
|
||||
private final NovaClient novaClient;
|
||||
private final ServerClient defaultLocationServerClient;
|
||||
|
@ -55,15 +55,13 @@ public class NovaComputeServiceAdapter implements ComputeServiceAdapter<Server,
|
|||
private final ImageClient defaultImageClient;
|
||||
private final Set<String> regions;
|
||||
|
||||
|
||||
@Inject
|
||||
public NovaComputeServiceAdapter(NovaClient novaClient)
|
||||
{
|
||||
public NovaComputeServiceAdapter(NovaClient novaClient) {
|
||||
this.novaClient = novaClient;
|
||||
regions = novaClient.getConfiguredRegions();
|
||||
if (regions.isEmpty())
|
||||
{
|
||||
throw new IllegalStateException("No regions exist for this compute service. The Nova compute service requires at least 1 region.");
|
||||
if (regions.isEmpty()) {
|
||||
throw new IllegalStateException(
|
||||
"No regions exist for this compute service. The Nova compute service requires at least 1 region.");
|
||||
}
|
||||
String region = regions.iterator().next();
|
||||
this.defaultLocationServerClient = novaClient.getServerClientForRegion(region);
|
||||
|
@ -72,78 +70,68 @@ public class NovaComputeServiceAdapter implements ComputeServiceAdapter<Server,
|
|||
}
|
||||
|
||||
@Override
|
||||
public NodeAndInitialCredentials<Server> createNodeWithGroupEncodedIntoName(String tag, String name, Template template)
|
||||
{
|
||||
ServerClient serverClient = template.getLocation() != null ? novaClient.getServerClientForRegion(template.getLocation().getId()) : defaultLocationServerClient;
|
||||
public NodeAndInitialCredentials<Server> createNodeWithGroupEncodedIntoName(String tag, String name,
|
||||
Template template) {
|
||||
ServerClient serverClient = template.getLocation() != null ? novaClient.getServerClientForRegion(template
|
||||
.getLocation().getId()) : defaultLocationServerClient;
|
||||
// TODO: make NovaTemplateOptions with the following:
|
||||
// security group, key pair, floating ip (attach post server-create?)
|
||||
Server server = serverClient.createServer(name, template.getImage().getId(), template.getHardware().getId());
|
||||
return new NodeAndInitialCredentials<Server>(server, server.getId() + "", LoginCredentials.builder().password(server.getAdminPass()).build());
|
||||
return new NodeAndInitialCredentials<Server>(server, server.getId() + "", LoginCredentials.builder()
|
||||
.password(server.getAdminPass()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Flavor> listHardwareProfiles()
|
||||
{
|
||||
public Iterable<Flavor> listHardwareProfiles() {
|
||||
return defaultFlavorClient.listFlavorsInDetail();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Image> listImages()
|
||||
{
|
||||
public Iterable<Image> listImages() {
|
||||
return defaultImageClient.listImagesInDetail();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Location> listLocations()
|
||||
{
|
||||
return Iterables.transform(novaClient.getConfiguredRegions(), new Function<String, Location>()
|
||||
{
|
||||
public Iterable<Location> listLocations() {
|
||||
return Iterables.transform(novaClient.getConfiguredRegions(), new Function<String, Location>() {
|
||||
|
||||
@Override
|
||||
public Location apply(@Nullable String region)
|
||||
{
|
||||
public Location apply(@Nullable String region) {
|
||||
return new LocationBuilder().id(region).description(region).build();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server getNode(String id)
|
||||
{
|
||||
public Server getNode(String id) {
|
||||
return defaultLocationServerClient.getServer(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyNode(String id)
|
||||
{
|
||||
public void destroyNode(String id) {
|
||||
defaultLocationServerClient.deleteServer(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebootNode(String id)
|
||||
{
|
||||
public void rebootNode(String id) {
|
||||
defaultLocationServerClient.rebootServer(id, RebootType.SOFT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resumeNode(String id)
|
||||
{
|
||||
public void resumeNode(String id) {
|
||||
throw new UnsupportedOperationException("suspend not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void suspendNode(String id)
|
||||
{
|
||||
public void suspendNode(String id) {
|
||||
throw new UnsupportedOperationException("suspend not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Server> listNodes()
|
||||
{
|
||||
public Iterable<Server> listNodes() {
|
||||
ImmutableSet.Builder<Server> servers = new ImmutableSet.Builder<Server>();
|
||||
|
||||
for (String region : regions)
|
||||
{
|
||||
for (String region : regions) {
|
||||
servers.addAll(novaClient.getServerClientForRegion(region).listServersInDetail());
|
||||
}
|
||||
|
||||
|
|
|
@ -44,29 +44,34 @@ import com.google.inject.TypeLiteral;
|
|||
*
|
||||
* @author Matt Stephenson
|
||||
*/
|
||||
public class NovaComputeServiceContextModule extends
|
||||
ComputeServiceAdapterContextModule<NovaClient, NovaAsyncClient, Server, Flavor, org.jclouds.openstack.nova.v1_1.domain.Image, Location>
|
||||
{
|
||||
public NovaComputeServiceContextModule()
|
||||
{
|
||||
public class NovaComputeServiceContextModule
|
||||
extends
|
||||
ComputeServiceAdapterContextModule<NovaClient, NovaAsyncClient, Server, Flavor, org.jclouds.openstack.nova.v1_1.domain.Image, Location> {
|
||||
public NovaComputeServiceContextModule() {
|
||||
super(NovaClient.class, NovaAsyncClient.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
bind(new TypeLiteral<ComputeServiceAdapter<Server, Flavor, org.jclouds.openstack.nova.v1_1.domain.Image, Location>>(){}).to(NovaComputeServiceAdapter.class);
|
||||
bind(
|
||||
new TypeLiteral<ComputeServiceAdapter<Server, Flavor, org.jclouds.openstack.nova.v1_1.domain.Image, Location>>() {
|
||||
}).to(NovaComputeServiceAdapter.class);
|
||||
|
||||
bind(new TypeLiteral<Function<Server, NodeMetadata>>(){}).to(ServerToNodeMetadata.class);
|
||||
bind(new TypeLiteral<Function<Server, NodeMetadata>>() {
|
||||
}).to(ServerToNodeMetadata.class);
|
||||
|
||||
bind(new TypeLiteral<Function<org.jclouds.openstack.nova.v1_1.domain.Image, Image>>(){}).to(NovaImageToImage.class);
|
||||
bind(new TypeLiteral<Function<org.jclouds.openstack.nova.v1_1.domain.Image, OperatingSystem>>(){}).to(NovaImageToOperatingSystem.class);
|
||||
bind(new TypeLiteral<Function<org.jclouds.openstack.nova.v1_1.domain.Image, Image>>() {
|
||||
}).to(NovaImageToImage.class);
|
||||
bind(new TypeLiteral<Function<org.jclouds.openstack.nova.v1_1.domain.Image, OperatingSystem>>() {
|
||||
}).to(NovaImageToOperatingSystem.class);
|
||||
|
||||
bind(new TypeLiteral<Function<Flavor, Hardware>>(){}).to(FlavorToHardware.class);
|
||||
bind(new TypeLiteral<Function<Flavor, Hardware>>() {
|
||||
}).to(FlavorToHardware.class);
|
||||
|
||||
// we aren't converting location from a provider-specific type
|
||||
bind(new TypeLiteral<Function<Location, Location>>(){}).to((Class)IdentityFunction.class);
|
||||
bind(new TypeLiteral<Function<Location, Location>>() {
|
||||
}).to((Class) IdentityFunction.class);
|
||||
}
|
||||
}
|
|
@ -31,33 +31,27 @@ import com.google.common.base.Function;
|
|||
import com.google.common.base.Supplier;
|
||||
|
||||
/**
|
||||
* A function for transforming the nova specific Flavor object to the generic Hardware object.
|
||||
* A function for transforming the nova specific Flavor object to the generic
|
||||
* Hardware object.
|
||||
*
|
||||
* @author Matt Stephenson
|
||||
*/
|
||||
public class FlavorToHardware implements Function<Flavor, Hardware>
|
||||
{
|
||||
public class FlavorToHardware implements Function<Flavor, Hardware> {
|
||||
|
||||
private final Supplier<Location> defaultLocation;
|
||||
|
||||
@Inject
|
||||
public FlavorToHardware(Supplier<Location> defaultLocation)
|
||||
{
|
||||
public FlavorToHardware(Supplier<Location> defaultLocation) {
|
||||
this.defaultLocation = defaultLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Hardware apply(Flavor flavor)
|
||||
{
|
||||
public Hardware apply(Flavor flavor) {
|
||||
return new HardwareBuilder()
|
||||
// TODO: scope id to region, if there's a chance for conflict
|
||||
.id(flavor.getId())
|
||||
.providerId(flavor.getId())
|
||||
.name(flavor.getName())
|
||||
.ram(flavor.getRam())
|
||||
.processor(new Processor(flavor.getVcpus(), 1.0))
|
||||
.volume(new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true))
|
||||
.location(defaultLocation.get())
|
||||
.build();
|
||||
// TODO: scope id to region, if there's a chance for conflict
|
||||
.id(flavor.getId()).providerId(flavor.getId()).name(flavor.getName()).ram(flavor.getRam())
|
||||
.processor(new Processor(flavor.getVcpus(), 1.0))
|
||||
.volume(new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(defaultLocation.get())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,33 +29,27 @@ import com.google.common.base.Function;
|
|||
import com.google.common.base.Supplier;
|
||||
|
||||
/**
|
||||
* A function for transforming a nova-specific Image into a generic Image object.
|
||||
* A function for transforming a nova-specific Image into a generic Image
|
||||
* object.
|
||||
*
|
||||
* @author Matt Stephenson
|
||||
*/
|
||||
public class NovaImageToImage implements Function<org.jclouds.openstack.nova.v1_1.domain.Image, Image>
|
||||
{
|
||||
public class NovaImageToImage implements Function<org.jclouds.openstack.nova.v1_1.domain.Image, Image> {
|
||||
private final Function<org.jclouds.openstack.nova.v1_1.domain.Image, OperatingSystem> imageToOs;
|
||||
private final Supplier<Location> defaultLocation;
|
||||
|
||||
@Inject
|
||||
public NovaImageToImage(Function<org.jclouds.openstack.nova.v1_1.domain.Image, OperatingSystem> imageToOs, Supplier<Location> defaultLocation)
|
||||
{
|
||||
public NovaImageToImage(Function<org.jclouds.openstack.nova.v1_1.domain.Image, OperatingSystem> imageToOs,
|
||||
Supplier<Location> defaultLocation) {
|
||||
this.imageToOs = imageToOs;
|
||||
this.defaultLocation = defaultLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image apply(org.jclouds.openstack.nova.v1_1.domain.Image image)
|
||||
{
|
||||
public Image apply(org.jclouds.openstack.nova.v1_1.domain.Image image) {
|
||||
return new ImageBuilder()
|
||||
// TODO: scope id to region, if there's a chance for conflict
|
||||
.id(image.getId())
|
||||
.providerId(image.getId())
|
||||
.name(image.getName())
|
||||
.operatingSystem(imageToOs.apply(image))
|
||||
.description(image.getName())
|
||||
.location(defaultLocation.get())
|
||||
.build();
|
||||
// TODO: scope id to region, if there's a chance for conflict
|
||||
.id(image.getId()).providerId(image.getId()).name(image.getName()).operatingSystem(imageToOs.apply(image))
|
||||
.description(image.getName()).location(defaultLocation.get()).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,12 +43,12 @@ import com.google.common.base.Splitter;
|
|||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* A function for transforming a nova specific Image into a generic OperatingSystem object.
|
||||
* A function for transforming a nova specific Image into a generic
|
||||
* OperatingSystem object.
|
||||
*
|
||||
* @author Matt Stephenson
|
||||
*/
|
||||
public class NovaImageToOperatingSystem implements Function<Image, OperatingSystem>
|
||||
{
|
||||
public class NovaImageToOperatingSystem implements Function<Image, OperatingSystem> {
|
||||
public static final Pattern DEFAULT_PATTERN = Pattern.compile("(([^ ]*) ([0-9.]+) ?.*)");
|
||||
// Windows Server 2008 R2 x64
|
||||
public static final Pattern WINDOWS_PATTERN = Pattern.compile("Windows (.*) (x[86][64])");
|
||||
|
@ -60,13 +60,11 @@ public class NovaImageToOperatingSystem implements Function<Image, OperatingSyst
|
|||
private final Map<OsFamily, Map<String, String>> osVersionMap;
|
||||
|
||||
@Inject
|
||||
public NovaImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap)
|
||||
{
|
||||
public NovaImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap) {
|
||||
this.osVersionMap = osVersionMap;
|
||||
}
|
||||
|
||||
public OperatingSystem apply(final Image from)
|
||||
{
|
||||
public OperatingSystem apply(final Image from) {
|
||||
OsFamily osFamily = null;
|
||||
String osVersion = null;
|
||||
|
||||
|
@ -74,42 +72,31 @@ public class NovaImageToOperatingSystem implements Function<Image, OperatingSyst
|
|||
|
||||
boolean is64Bit = true;
|
||||
|
||||
if (imageName.indexOf("Windows") != -1)
|
||||
{
|
||||
if (imageName.indexOf("Windows") != -1) {
|
||||
osFamily = OsFamily.WINDOWS;
|
||||
Matcher matcher = WINDOWS_PATTERN.matcher(from.getName());
|
||||
if (matcher.find())
|
||||
{
|
||||
if (matcher.find()) {
|
||||
osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap);
|
||||
is64Bit = matcher.group(2).equals("x64");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (imageName.contains("Red Hat EL"))
|
||||
{
|
||||
} else {
|
||||
if (imageName.contains("Red Hat EL")) {
|
||||
osFamily = OsFamily.RHEL;
|
||||
}
|
||||
else if (imageName.contains("Oracle EL"))
|
||||
{
|
||||
} else if (imageName.contains("Oracle EL")) {
|
||||
osFamily = OsFamily.OEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split(imageName.toLowerCase());
|
||||
} else {
|
||||
final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults()
|
||||
.split(imageName.toLowerCase());
|
||||
|
||||
osFamily = Iterables.find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>()
|
||||
{
|
||||
osFamily = Iterables.find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable OsFamily osFamily)
|
||||
{
|
||||
public boolean apply(@Nullable OsFamily osFamily) {
|
||||
return Iterables.any(imageNameParts, Predicates.equalTo(osFamily.name().toLowerCase()));
|
||||
}
|
||||
});
|
||||
}
|
||||
Matcher matcher = DEFAULT_PATTERN.matcher(imageName);
|
||||
if (matcher.find() && matcher.groupCount() >= 3)
|
||||
{
|
||||
if (matcher.find() && matcher.groupCount() >= 3) {
|
||||
osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.compute.functions;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||
import org.jclouds.openstack.nova.v1_1.domain.Address;
|
||||
|
@ -30,33 +28,30 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* A function for transforming a nova-specific Server into a generic NodeMetadata object.
|
||||
* A function for transforming a nova-specific Server into a generic
|
||||
* NodeMetadata object.
|
||||
*
|
||||
* @author Matt Stephenson
|
||||
*/
|
||||
public class ServerToNodeMetadata implements Function<Server, NodeMetadata>
|
||||
{
|
||||
public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
|
||||
|
||||
@Override
|
||||
public NodeMetadata apply(Server server)
|
||||
{
|
||||
public NodeMetadata apply(Server server) {
|
||||
return new NodeMetadataBuilder()
|
||||
// TODO: scope id to region, if there's a chance for conflict
|
||||
.id(server.getId())
|
||||
.providerId(server.getId())
|
||||
.name(server.getName())
|
||||
.publicAddresses(Iterables.transform(server.getPublicAddresses(), new AddressToStringTransformationFunction()))
|
||||
.privateAddresses(Iterables.transform(server.getPrivateAddresses(), new AddressToStringTransformationFunction()))
|
||||
.state(server.getStatus().getNodeState())
|
||||
.userMetadata(ImmutableMap.copyOf(server.getMetadata()))
|
||||
.build();
|
||||
// TODO: scope id to region, if there's a chance for conflict
|
||||
.id(server.getId())
|
||||
.providerId(server.getId())
|
||||
.name(server.getName())
|
||||
.publicAddresses(
|
||||
Iterables.transform(server.getPublicAddresses(), new AddressToStringTransformationFunction()))
|
||||
.privateAddresses(
|
||||
Iterables.transform(server.getPrivateAddresses(), new AddressToStringTransformationFunction()))
|
||||
.state(server.getStatus().getNodeState()).userMetadata(ImmutableMap.copyOf(server.getMetadata())).build();
|
||||
}
|
||||
|
||||
private class AddressToStringTransformationFunction implements Function<Address, String>
|
||||
{
|
||||
private class AddressToStringTransformationFunction implements Function<Address, String> {
|
||||
@Override
|
||||
public String apply(Address address)
|
||||
{
|
||||
public String apply(Address address) {
|
||||
return address.getAddr();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,8 +38,7 @@ public class NovaParserModule extends AbstractModule {
|
|||
@Provides
|
||||
@Singleton
|
||||
public Map<Type, Object> provideCustomAdapterBindings() {
|
||||
return ImmutableMap.<Type, Object>of(
|
||||
);
|
||||
return ImmutableMap.<Type, Object> of();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -57,15 +57,16 @@ import com.google.common.collect.ImmutableMap;
|
|||
@ConfiguresRestClient
|
||||
public class NovaRestClientModule extends RestClientModule<NovaClient, NovaAsyncClient> {
|
||||
|
||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
|
||||
.put(ServerClient.class, ServerAsyncClient.class)//
|
||||
.put(FlavorClient.class, FlavorAsyncClient.class)
|
||||
.put(ImageClient.class, ImageAsyncClient.class)
|
||||
.put(ExtensionClient.class, ExtensionAsyncClient.class)
|
||||
.put(FloatingIPClient.class, FloatingIPAsyncClient.class)
|
||||
.put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)
|
||||
.put(KeyPairClient.class, KeyPairAsyncClient.class)
|
||||
.build();
|
||||
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap
|
||||
.<Class<?>, Class<?>> builder()
|
||||
//
|
||||
.put(ServerClient.class, ServerAsyncClient.class)
|
||||
//
|
||||
.put(FlavorClient.class, FlavorAsyncClient.class).put(ImageClient.class, ImageAsyncClient.class)
|
||||
.put(ExtensionClient.class, ExtensionAsyncClient.class)
|
||||
.put(FloatingIPClient.class, FloatingIPAsyncClient.class)
|
||||
.put(SecurityGroupClient.class, SecurityGroupAsyncClient.class)
|
||||
.put(KeyPairClient.class, KeyPairAsyncClient.class).build();
|
||||
|
||||
public NovaRestClientModule() {
|
||||
super(NovaClient.class, NovaAsyncClient.class, DELEGATE_MAP);
|
||||
|
@ -80,8 +81,10 @@ public class NovaRestClientModule extends RestClientModule<NovaClient, NovaAsync
|
|||
@Override
|
||||
protected void installLocations() {
|
||||
super.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
|
||||
// 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(new KeystoneAuthenticationModule());
|
||||
}
|
||||
|
|
|
@ -28,12 +28,14 @@ import org.jclouds.openstack.domain.Link;
|
|||
import org.jclouds.openstack.domain.Resource;
|
||||
|
||||
/**
|
||||
* The OpenStack Compute API is extensible. Extensions serve two purposes: They allow the
|
||||
* introduction of new features in the API without requiring a version change and they allow the
|
||||
* introduction of vendor specific niche functionality.
|
||||
* The OpenStack Compute API is extensible. Extensions serve two purposes: They
|
||||
* allow the introduction of new features in the API without requiring a version
|
||||
* change and they allow the introduction of vendor specific niche
|
||||
* functionality.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a href= "http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
|
||||
* @see <a href=
|
||||
* "http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
|
||||
* />
|
||||
*/
|
||||
public class Extension extends Resource {
|
||||
|
@ -78,7 +80,7 @@ public class Extension extends Resource {
|
|||
|
||||
public Builder fromExtension(Extension in) {
|
||||
return fromResource(in).namespace(in.getNamespace()).alias(in.getAlias()).updated(in.getUpdated())
|
||||
.description(in.getDescription());
|
||||
.description(in.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,8 +121,7 @@ public class Extension extends Resource {
|
|||
private Date updated;
|
||||
private String description;
|
||||
|
||||
protected Extension(String name, Set<Link> links, URI namespace, String alias, Date updated,
|
||||
String description) {
|
||||
protected Extension(String name, Set<Link> links, URI namespace, String alias, Date updated, String description) {
|
||||
super(alias, name, links);
|
||||
this.namespace = namespace;
|
||||
this.alias = alias;
|
||||
|
@ -151,8 +152,8 @@ public class Extension extends Resource {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("id", getId()).add("name", name).add("links", links).add("namespace", namespace).add(
|
||||
"alias", alias).add("updated", updated).add("description", description).toString();
|
||||
return toStringHelper("").add("id", getId()).add("name", name).add("links", links).add("namespace", namespace)
|
||||
.add("alias", alias).add("updated", updated).add("description", description).toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -109,8 +109,7 @@ public class Flavor extends Resource {
|
|||
private int disk;
|
||||
private int vcpus;
|
||||
|
||||
protected Flavor(String id, String name, Set<Link> links, int ram, int disk,
|
||||
int vcpus) {
|
||||
protected Flavor(String id, String name, Set<Link> links, int ram, int disk, int vcpus) {
|
||||
super(id, name, links);
|
||||
this.ram = ram;
|
||||
this.disk = disk;
|
||||
|
@ -131,8 +130,7 @@ public class Flavor extends Resource {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("id", id).add("name", name)
|
||||
.add("links", links).add("ram", ram).add("disk", disk)
|
||||
return toStringHelper("").add("id", id).add("name", name).add("links", links).add("ram", ram).add("disk", disk)
|
||||
.add("vcpus", vcpus).toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,9 @@ import org.jclouds.javax.annotation.Nullable;
|
|||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* A Floating IP is an IP address that can be created and associated with a Server instance.
|
||||
* Floating IPs can also be disassociated and deleted from a Server instance.
|
||||
* A Floating IP is an IP address that can be created and associated with a
|
||||
* Server instance. Floating IPs can also be disassociated and deleted from a
|
||||
* Server instance.
|
||||
*
|
||||
* @author Jeremy Daggett
|
||||
* @author chamerling
|
||||
|
@ -71,8 +72,7 @@ public class FloatingIP implements Comparable<FloatingIP> {
|
|||
}
|
||||
|
||||
public Builder fromFloatingIp(FloatingIP in) {
|
||||
return id(in.getId()).ip(in.getIp()).fixedIp(in.getFixedIp())
|
||||
.instanceId(in.getInstanceId());
|
||||
return id(in.getId()).ip(in.getIp()).fixedIp(in.getFixedIp()).instanceId(in.getInstanceId());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -84,8 +84,7 @@ public class FloatingIP implements Comparable<FloatingIP> {
|
|||
@SerializedName("instance_id")
|
||||
private String instanceId;
|
||||
|
||||
protected FloatingIP(String id, String ip, @Nullable String fixedIp,
|
||||
@Nullable String instanceId) {
|
||||
protected FloatingIP(String id, String ip, @Nullable String fixedIp, @Nullable String instanceId) {
|
||||
this.id = id;
|
||||
this.ip = ip;
|
||||
this.fixedIp = fixedIp;
|
||||
|
@ -119,8 +118,7 @@ public class FloatingIP implements Comparable<FloatingIP> {
|
|||
int result = 1;
|
||||
result = prime * result + ((fixedIp == null) ? 0 : fixedIp.hashCode());
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
result = prime * result
|
||||
+ ((instanceId == null) ? 0 : instanceId.hashCode());
|
||||
result = prime * result + ((instanceId == null) ? 0 : instanceId.hashCode());
|
||||
result = prime * result + ((ip == null) ? 0 : ip.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
@ -159,8 +157,8 @@ public class FloatingIP implements Comparable<FloatingIP> {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("id", id).add("ip", ip)
|
||||
.add("fixedIp", fixedIp).add("instanceId", instanceId).toString();
|
||||
return toStringHelper("").add("id", id).add("ip", ip).add("fixedIp", fixedIp).add("instanceId", instanceId)
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -113,15 +113,13 @@ public class Image extends Resource {
|
|||
}
|
||||
|
||||
public Image build() {
|
||||
return new Image(id, name, links, updated, created, tenantId, userId,
|
||||
status, progress, minDisk, minRam, server, metadata);
|
||||
return new Image(id, name, links, updated, created, tenantId, userId, status, progress, minDisk, minRam,
|
||||
server, metadata);
|
||||
}
|
||||
|
||||
public Builder fromImage(Image in) {
|
||||
return fromResource(in).status(in.getStatus())
|
||||
.updated(in.getUpdated()).created(in.getCreated())
|
||||
.progress(in.getProgress()).server(in.getServer())
|
||||
.metadata(in.getMetadata());
|
||||
return fromResource(in).status(in.getStatus()).updated(in.getUpdated()).created(in.getCreated())
|
||||
.progress(in.getProgress()).server(in.getServer()).metadata(in.getMetadata());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,10 +168,8 @@ public class Image extends Resource {
|
|||
private Resource server;
|
||||
private Map<String, String> metadata = Maps.newHashMap();
|
||||
|
||||
protected Image(String id, String name, Set<Link> links, Date updated,
|
||||
Date created, String tenantId, String userId, ImageStatus status,
|
||||
int progress, int minDisk, int minRam, Resource server,
|
||||
Map<String, String> metadata) {
|
||||
protected Image(String id, String name, Set<Link> links, Date updated, Date created, String tenantId, String userId,
|
||||
ImageStatus status, int progress, int minDisk, int minRam, Resource server, Map<String, String> metadata) {
|
||||
super(id, name, links);
|
||||
this.updated = updated;
|
||||
this.created = created;
|
||||
|
@ -229,12 +225,9 @@ public class Image extends Resource {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("id", id).add("name", name)
|
||||
.add("links", links).add("updated", updated)
|
||||
.add("created", created).add("tenantId", tenantId)
|
||||
.add("userId", userId).add("status", status)
|
||||
.add("progress", progress).add("minDisk", minDisk)
|
||||
.add("minRam", minRam).add("server", server)
|
||||
return toStringHelper("").add("id", id).add("name", name).add("links", links).add("updated", updated)
|
||||
.add("created", created).add("tenantId", tenantId).add("userId", userId).add("status", status)
|
||||
.add("progress", progress).add("minDisk", minDisk).add("minRam", minRam).add("server", server)
|
||||
.add("metadata", metadata).toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.jclouds.javax.annotation.Nullable;
|
|||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class KeyPair implements Comparable<KeyPair>{
|
||||
public class KeyPair implements Comparable<KeyPair> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
@ -71,8 +71,7 @@ public class KeyPair implements Comparable<KeyPair>{
|
|||
}
|
||||
|
||||
public Builder fromKeyPair(KeyPair in) {
|
||||
return publicKey(in.getPublicKey()).privateKey(in.getPrivateKey())
|
||||
.userId(in.getUserId()).name(in.getName())
|
||||
return publicKey(in.getPublicKey()).privateKey(in.getPrivateKey()).userId(in.getUserId()).name(in.getName())
|
||||
.fingerprint(in.getFingerprint());
|
||||
}
|
||||
|
||||
|
@ -87,8 +86,7 @@ public class KeyPair implements Comparable<KeyPair>{
|
|||
String name;
|
||||
String fingerprint;
|
||||
|
||||
protected KeyPair(String publicKey, String privateKey,
|
||||
@Nullable String userId, String name, String fingerprint) {
|
||||
protected KeyPair(String publicKey, String privateKey, @Nullable String userId, String name, String fingerprint) {
|
||||
this.publicKey = publicKey;
|
||||
this.privateKey = privateKey;
|
||||
this.userId = userId;
|
||||
|
@ -116,59 +114,57 @@ public class KeyPair implements Comparable<KeyPair>{
|
|||
return this.fingerprint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(KeyPair o) {
|
||||
return this.fingerprint.compareTo(o.getFingerprint());
|
||||
}
|
||||
@Override
|
||||
public int compareTo(KeyPair o) {
|
||||
return this.fingerprint.compareTo(o.getFingerprint());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((publicKey == null) ? 0 : publicKey.hashCode());
|
||||
result = prime * result + ((privateKey == null) ? 0 : privateKey.hashCode());
|
||||
result = prime * result
|
||||
+ ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((fingerprint == null) ? 0 : fingerprint.hashCode());
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((publicKey == null) ? 0 : publicKey.hashCode());
|
||||
result = prime * result + ((privateKey == null) ? 0 : privateKey.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((fingerprint == null) ? 0 : fingerprint.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
KeyPair other = (KeyPair) obj;
|
||||
if (publicKey == null) {
|
||||
if (other.publicKey != null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
} else if (!publicKey.equals(other.publicKey))
|
||||
return false;
|
||||
if (privateKey == null) {
|
||||
if (other.privateKey != null)
|
||||
return false;
|
||||
KeyPair other = (KeyPair) obj;
|
||||
if (publicKey == null) {
|
||||
if (other.publicKey != null)
|
||||
return false;
|
||||
} else if (!publicKey.equals(other.publicKey))
|
||||
} else if (!privateKey.equals(other.privateKey))
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
if (privateKey == null) {
|
||||
if (other.privateKey != null)
|
||||
return false;
|
||||
} else if (!privateKey.equals(other.privateKey))
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (fingerprint == null) {
|
||||
if (other.fingerprint != null)
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (fingerprint == null) {
|
||||
if (other.fingerprint != null)
|
||||
return false;
|
||||
} else if (!fingerprint.equals(other.fingerprint))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
} else if (!fingerprint.equals(other.fingerprint))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("publicKey", publicKey)
|
||||
.add("privateKey", privateKey).add("userId", userId)
|
||||
return toStringHelper("").add("publicKey", publicKey).add("privateKey", privateKey).add("userId", userId)
|
||||
.add("name", name).add("fingerprint", fingerprint).toString();
|
||||
}
|
||||
}
|
|
@ -23,12 +23,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
|
||||
/**
|
||||
* Defines a security group
|
||||
*
|
||||
|
@ -79,10 +78,9 @@ public class SecurityGroup {
|
|||
return new SecurityGroup(id, tenantId, name, description, rules);
|
||||
}
|
||||
|
||||
|
||||
public Builder fromSecurityGroup(SecurityGroup in) {
|
||||
return id(in.getId()).tenantId(in.getTenantId()).name(in.getName())
|
||||
.description(in.getDescription()).rules(in.getRules());
|
||||
return id(in.getId()).tenantId(in.getTenantId()).name(in.getName()).description(in.getDescription())
|
||||
.rules(in.getRules());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -94,8 +92,8 @@ public class SecurityGroup {
|
|||
protected String description;
|
||||
protected Set<SecurityGroupRule> rules;
|
||||
|
||||
protected SecurityGroup(String id, String tenantId, @Nullable String name,
|
||||
@Nullable String description, Set<SecurityGroupRule> rules) {
|
||||
protected SecurityGroup(String id, String tenantId, @Nullable String name, @Nullable String description,
|
||||
Set<SecurityGroupRule> rules) {
|
||||
this.id = id;
|
||||
this.tenantId = tenantId;
|
||||
this.name = name;
|
||||
|
@ -123,13 +121,11 @@ public class SecurityGroup {
|
|||
return this.rules;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result
|
||||
+ ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((rules == null) ? 0 : rules.hashCode());
|
||||
|
@ -176,9 +172,8 @@ public class SecurityGroup {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("id", id).add("name", name)
|
||||
.add("tenantId", tenantId).add("description", description).add("rules", rules)
|
||||
.toString();
|
||||
return toStringHelper("").add("id", id).add("name", name).add("tenantId", tenantId)
|
||||
.add("description", description).add("rules", rules).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -51,7 +51,6 @@ public class SecurityGroupRule implements Comparable<SecurityGroupRule> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
@ -108,18 +107,15 @@ public class SecurityGroupRule implements Comparable<SecurityGroupRule> {
|
|||
}
|
||||
|
||||
public SecurityGroupRule build() {
|
||||
return new SecurityGroupRule(id, fromPort, group, ipProtocol, toPort,
|
||||
parentGroupId, ipRange);
|
||||
return new SecurityGroupRule(id, fromPort, group, ipProtocol, toPort, parentGroupId, ipRange);
|
||||
}
|
||||
|
||||
public Builder fromSecurityGroupRule(SecurityGroupRule in) {
|
||||
return id(in.getId()).fromPort(in.getFromPort()).group(in.getGroup())
|
||||
.ipProtocol(in.getIpProtocol()).toPort(in.getToPort()).parentGroupId(in.getParentGroupId())
|
||||
.ipRange(in.getIpRange());
|
||||
return id(in.getId()).fromPort(in.getFromPort()).group(in.getGroup()).ipProtocol(in.getIpProtocol())
|
||||
.toPort(in.getToPort()).parentGroupId(in.getParentGroupId()).ipRange(in.getIpRange());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected String id;
|
||||
|
||||
@SerializedName(value = "from_port")
|
||||
|
@ -140,9 +136,8 @@ public class SecurityGroupRule implements Comparable<SecurityGroupRule> {
|
|||
@SerializedName(value = "ip_range")
|
||||
protected Map<String, String> ipRange;
|
||||
|
||||
|
||||
protected SecurityGroupRule(String id, int fromPort, Map<String, String> group,
|
||||
IpProtocol ipProtocol, int toPort, String parentGroupId, Map<String, String> ipRange) {
|
||||
protected SecurityGroupRule(String id, int fromPort, Map<String, String> group, IpProtocol ipProtocol, int toPort,
|
||||
String parentGroupId, Map<String, String> ipRange) {
|
||||
this.id = id;
|
||||
this.fromPort = fromPort;
|
||||
this.group = group;
|
||||
|
@ -182,7 +177,7 @@ public class SecurityGroupRule implements Comparable<SecurityGroupRule> {
|
|||
|
||||
@Override
|
||||
public int compareTo(SecurityGroupRule o) {
|
||||
return this.id.compareTo(o.getId());
|
||||
return this.id.compareTo(o.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -192,11 +187,9 @@ public class SecurityGroupRule implements Comparable<SecurityGroupRule> {
|
|||
result = prime * result + fromPort;
|
||||
result = prime * result + ((group == null) ? 0 : group.hashCode());
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
result = prime * result
|
||||
+ ((ipProtocol == null) ? 0 : ipProtocol.hashCode());
|
||||
result = prime * result + ((ipProtocol == null) ? 0 : ipProtocol.hashCode());
|
||||
result = prime * result + ((ipRange == null) ? 0 : ipRange.hashCode());
|
||||
result = prime * result
|
||||
+ ((parentGroupId == null) ? 0 : parentGroupId.hashCode());
|
||||
result = prime * result + ((parentGroupId == null) ? 0 : parentGroupId.hashCode());
|
||||
result = prime * result + toPort;
|
||||
return result;
|
||||
}
|
||||
|
@ -241,11 +234,9 @@ public class SecurityGroupRule implements Comparable<SecurityGroupRule> {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("id", id).add("fromPort", fromPort)
|
||||
.add("group", group).add("ipProtocol", ipProtocol)
|
||||
.add("toPort", toPort).add("parentGroupId", parentGroupId)
|
||||
return toStringHelper("").add("id", id).add("fromPort", fromPort).add("group", group)
|
||||
.add("ipProtocol", ipProtocol).add("toPort", toPort).add("parentGroupId", parentGroupId)
|
||||
.add("ipRange", ipRange).toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -45,8 +45,8 @@ import com.google.common.collect.Multimap;
|
|||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* A server is a virtual machine instance in the compute system. Flavor and image are requisite
|
||||
* elements when creating a server.
|
||||
* A server is a virtual machine instance in the compute system. Flavor and
|
||||
* image are requisite elements when creating a server.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @see <a href=
|
||||
|
@ -194,8 +194,8 @@ public class Server extends Resource {
|
|||
* @see Server#getPrivateAddresses()
|
||||
*/
|
||||
public Builder privateAddresses(Set<Address> privateAddresses) {
|
||||
this.addresses.replaceValues(Address.Type.PRIVATE, ImmutableSet.copyOf(checkNotNull(privateAddresses,
|
||||
"privateAddresses")));
|
||||
this.addresses.replaceValues(Address.Type.PRIVATE,
|
||||
ImmutableSet.copyOf(checkNotNull(privateAddresses, "privateAddresses")));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -210,8 +210,8 @@ public class Server extends Resource {
|
|||
* @see Server#getPublicAddresses()
|
||||
*/
|
||||
public Builder publicAddresses(Set<Address> publicAddresses) {
|
||||
this.addresses.replaceValues(Address.Type.PUBLIC, ImmutableSet.copyOf(checkNotNull(publicAddresses,
|
||||
"publicAddresses")));
|
||||
this.addresses.replaceValues(Address.Type.PUBLIC,
|
||||
ImmutableSet.copyOf(checkNotNull(publicAddresses, "publicAddresses")));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ public class Server extends Resource {
|
|||
public Server build() {
|
||||
// return new Server(id, name, links, addresses);
|
||||
return new Server(id, name, links, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6, status,
|
||||
progress, image, flavor, adminPass, addresses, metadata);
|
||||
progress, image, flavor, adminPass, addresses, metadata);
|
||||
}
|
||||
|
||||
public Builder fromServer(Server in) {
|
||||
|
@ -285,9 +285,9 @@ public class Server extends Resource {
|
|||
protected Map<String, String> metadata;
|
||||
|
||||
protected Server(String id, String name, Set<Link> links, String tenantId, String userId, Date updated,
|
||||
Date created, String hostId, String accessIPv4, String accessIPv6, ServerStatus status, int progress,
|
||||
Resource image, Resource flavor, String adminPass, Multimap<Address.Type, Address> addresses,
|
||||
Map<String, String> metadata) {
|
||||
Date created, String hostId, String accessIPv4, String accessIPv6, ServerStatus status, int progress,
|
||||
Resource image, Resource flavor, String adminPass, Multimap<Address.Type, Address> addresses,
|
||||
Map<String, String> metadata) {
|
||||
super(id, name, links);
|
||||
this.tenantId = tenantId;
|
||||
this.userId = userId;
|
||||
|
@ -386,13 +386,13 @@ public class Server extends Resource {
|
|||
Set<Address> publicAddresses = addresses.get(Address.Type.PUBLIC);
|
||||
Set<Address> privateAddresses = addresses.get(Address.Type.PRIVATE);
|
||||
if (publicAddresses != null) {
|
||||
returnMapBuilder.putAll(Address.Type.PUBLIC, Iterables.filter(publicAddresses, Predicates
|
||||
.not(IsPrivateAddress.INSTANCE)));
|
||||
returnMapBuilder.putAll(Address.Type.PUBLIC,
|
||||
Iterables.filter(publicAddresses, Predicates.not(IsPrivateAddress.INSTANCE)));
|
||||
}
|
||||
if (privateAddresses != null) {
|
||||
returnMapBuilder.putAll(Address.Type.PRIVATE, Iterables.filter(privateAddresses, IsPrivateAddress.INSTANCE));
|
||||
returnMapBuilder.putAll(Address.Type.PUBLIC, Iterables.filter(privateAddresses, Predicates
|
||||
.not(IsPrivateAddress.INSTANCE)));
|
||||
returnMapBuilder.putAll(Address.Type.PUBLIC,
|
||||
Iterables.filter(privateAddresses, Predicates.not(IsPrivateAddress.INSTANCE)));
|
||||
}
|
||||
ImmutableSetMultimap<Type, Address> returnMap = returnMapBuilder.build();
|
||||
|
||||
|
@ -415,10 +415,10 @@ public class Server extends Resource {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("id", id).add("name", name).add("tenantId", tenantId).add("userId", userId).add(
|
||||
"hostId", hostId).add("updated", updated).add("created", created).add("accessIPv4", accessIPv4).add(
|
||||
"accessIPv6", accessIPv6).add("status", status).add("progress", progress).add("image", image).add(
|
||||
"flavor", flavor).add("metadata", metadata).add("links", links).add("addresses", addresses).add(
|
||||
"adminPass", adminPass).toString();
|
||||
return toStringHelper("").add("id", id).add("name", name).add("tenantId", tenantId).add("userId", userId)
|
||||
.add("hostId", hostId).add("updated", updated).add("created", created).add("accessIPv4", accessIPv4)
|
||||
.add("accessIPv6", accessIPv6).add("status", status).add("progress", progress).add("image", image)
|
||||
.add("flavor", flavor).add("metadata", metadata).add("links", links).add("addresses", addresses)
|
||||
.add("adminPass", adminPass).toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,25 +32,15 @@ import org.jclouds.compute.domain.NodeState;
|
|||
*/
|
||||
public enum ServerStatus {
|
||||
|
||||
ACTIVE (NodeState.RUNNING),
|
||||
BUILD (NodeState.PENDING),
|
||||
REBUILD (NodeState.PENDING),
|
||||
SUSPENDED (NodeState.SUSPENDED),
|
||||
RESIZE (NodeState.PENDING),
|
||||
VERIFY_RESIZE(NodeState.PENDING),
|
||||
REVERT_RESIZE(NodeState.PENDING),
|
||||
PASSWORD (NodeState.PENDING),
|
||||
REBOOT (NodeState.PENDING),
|
||||
HARD_REBOOT (NodeState.PENDING),
|
||||
DELETED (NodeState.TERMINATED),
|
||||
UNKNOWN (NodeState.UNRECOGNIZED),
|
||||
ERROR (NodeState.ERROR),
|
||||
UNRECOGNIZED (NodeState.UNRECOGNIZED);
|
||||
ACTIVE(NodeState.RUNNING), BUILD(NodeState.PENDING), REBUILD(NodeState.PENDING), SUSPENDED(NodeState.SUSPENDED), RESIZE(
|
||||
NodeState.PENDING), VERIFY_RESIZE(NodeState.PENDING), REVERT_RESIZE(NodeState.PENDING), PASSWORD(
|
||||
NodeState.PENDING), REBOOT(NodeState.PENDING), HARD_REBOOT(NodeState.PENDING), DELETED(NodeState.TERMINATED), UNKNOWN(
|
||||
NodeState.UNRECOGNIZED), ERROR(NodeState.ERROR), UNRECOGNIZED(NodeState.UNRECOGNIZED);
|
||||
|
||||
private final NodeState nodeState;
|
||||
|
||||
ServerStatus(NodeState nodeState) {
|
||||
this.nodeState = nodeState;
|
||||
this.nodeState = nodeState;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
|
@ -65,8 +55,7 @@ public enum ServerStatus {
|
|||
}
|
||||
}
|
||||
|
||||
public NodeState getNodeState()
|
||||
{
|
||||
return nodeState;
|
||||
}
|
||||
public NodeState getNodeState() {
|
||||
return nodeState;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.extensions;
|
||||
|
||||
|
||||
/**
|
||||
* Extension namespaces
|
||||
*
|
||||
|
|
|
@ -74,7 +74,7 @@ public interface FloatingIPClient {
|
|||
* @param address
|
||||
* the IP address to add
|
||||
*
|
||||
* NOTE: Possibly move this to ServerClient?
|
||||
* NOTE: Possibly move this to ServerClient?
|
||||
*/
|
||||
void addFloatingIP(String serverId, String address);
|
||||
|
||||
|
@ -86,7 +86,7 @@ public interface FloatingIPClient {
|
|||
* @param address
|
||||
* the IP address to remove
|
||||
*
|
||||
* NOTE: Possibly move this to ServerClient?
|
||||
* NOTE: Possibly move this to ServerClient?
|
||||
*/
|
||||
void removeFloatingIP(String serverId, String address);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,9 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @see KeyPairClient
|
||||
* @author Jeremy Daggett
|
||||
* @see ExtensionAsyncClient
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html" />
|
||||
* @see <a href=
|
||||
* "http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
|
||||
* />
|
||||
* @see <a href="http://nova.openstack.org/api_ext" />
|
||||
* @see <a href="http://nova.openstack.org/api_ext/ext_keypairs.html" />
|
||||
*/
|
||||
|
@ -69,7 +71,6 @@ public interface KeyPairAsyncClient {
|
|||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<Map<String, KeyPair>>> listKeyPairs();
|
||||
|
||||
|
||||
@POST
|
||||
@Path("/os-keypairs")
|
||||
@SelectJson("keypair")
|
||||
|
@ -85,7 +86,7 @@ public interface KeyPairAsyncClient {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("%7B\"keypair\":%7B\"name\":\"{name}\",\"public_key\":\"{publicKey}\"%7D%7D")
|
||||
ListenableFuture<KeyPair> createKeyPairWithPublicKey(@PayloadParam("name") String name,
|
||||
@PayloadParam("publicKey") String publicKey);
|
||||
@PayloadParam("publicKey") String publicKey);
|
||||
|
||||
@DELETE
|
||||
@Path("/os-keypairs/{name}")
|
||||
|
|
|
@ -43,7 +43,7 @@ public interface KeyPairClient {
|
|||
*
|
||||
* @return all Key Pairs
|
||||
*/
|
||||
Set<Map<String,KeyPair>> listKeyPairs();
|
||||
Set<Map<String, KeyPair>> listKeyPairs();
|
||||
|
||||
/**
|
||||
* Create a Key Pair.
|
||||
|
|
|
@ -52,7 +52,9 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
*
|
||||
* @see SecurityGroupClient
|
||||
* @author Jeremy Daggett
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html" />
|
||||
* @see <a href=
|
||||
* "http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
|
||||
* />
|
||||
* @see <a href="http://nova.openstack.org/api_ext" />
|
||||
* @see <a href="http://wiki.openstack.org/os-security-groups" />
|
||||
*/
|
||||
|
@ -81,7 +83,6 @@ public interface SecurityGroupAsyncClient {
|
|||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<SecurityGroup> getSecurityGroup(@PathParam("id") String id);
|
||||
|
||||
|
||||
/**
|
||||
* @see SecurityGroupClient#createSecurityGroup
|
||||
*/
|
||||
|
@ -93,8 +94,7 @@ public interface SecurityGroupAsyncClient {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("%7B\"security_group\":%7B\"name\":\"{name}\",\"description\":\"{description}\"%7D%7D")
|
||||
ListenableFuture<SecurityGroup> createSecurityGroup(@PayloadParam("name") String name,
|
||||
@PayloadParam("description") String description);
|
||||
|
||||
@PayloadParam("description") String description);
|
||||
|
||||
/**
|
||||
* @see SecurityGroupClient#deleteSecurityGroup
|
||||
|
@ -105,7 +105,6 @@ public interface SecurityGroupAsyncClient {
|
|||
@Consumes
|
||||
ListenableFuture<Boolean> deleteSecurityGroup(@PathParam("id") String id);
|
||||
|
||||
|
||||
/**
|
||||
* @see SecurityGroupClient#createSecurityGroupRule
|
||||
*/
|
||||
|
@ -115,17 +114,13 @@ public interface SecurityGroupAsyncClient {
|
|||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Payload("%7B\"security_group_rule\":%7B\"ip_protocol\":\"{ip_protocol}\"," +
|
||||
"\"from_port\":\"{from_port}\",\"to_port\":\"{to_port}\"," +
|
||||
"\"cidr\":\"{cidr}\",\"group_id\":\"{group_id}\",\"parent_group_id\":\"{parent_group_id}\"%7D%7D")
|
||||
ListenableFuture<SecurityGroupRule> createSecurityGroupRule(
|
||||
@PayloadParam("ip_protocol") String ip_protocol,
|
||||
@PayloadParam("from_port") String from_port,
|
||||
@PayloadParam("to_port") String to_port,
|
||||
@PayloadParam("cidr") String cidr,
|
||||
@PayloadParam("group_id") String group_id,
|
||||
@PayloadParam("parent_group_id") String parent_group_id);
|
||||
|
||||
@Payload("%7B\"security_group_rule\":%7B\"ip_protocol\":\"{ip_protocol}\","
|
||||
+ "\"from_port\":\"{from_port}\",\"to_port\":\"{to_port}\","
|
||||
+ "\"cidr\":\"{cidr}\",\"group_id\":\"{group_id}\",\"parent_group_id\":\"{parent_group_id}\"%7D%7D")
|
||||
ListenableFuture<SecurityGroupRule> createSecurityGroupRule(@PayloadParam("ip_protocol") String ip_protocol,
|
||||
@PayloadParam("from_port") String from_port, @PayloadParam("to_port") String to_port,
|
||||
@PayloadParam("cidr") String cidr, @PayloadParam("group_id") String group_id,
|
||||
@PayloadParam("parent_group_id") String parent_group_id);
|
||||
|
||||
/**
|
||||
* @see SecurityGroupClient#deleteSecurityGroupRule
|
||||
|
|
|
@ -72,7 +72,7 @@ public interface SecurityGroupClient {
|
|||
* @return a new Security Group Rule
|
||||
*/
|
||||
SecurityGroupRule createSecurityGroupRule(String ip_protocol, String from_port, String to_port, String cidr,
|
||||
String group_id, String parent_group_id);
|
||||
String group_id, String parent_group_id);
|
||||
|
||||
/**
|
||||
* Delete a Security Group Rule.
|
||||
|
|
|
@ -42,7 +42,8 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* <p/>
|
||||
*
|
||||
* @see ExtensionClient
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
|
||||
* @see <a href=
|
||||
* "http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -60,7 +61,6 @@ public interface ExtensionAsyncClient {
|
|||
@ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
|
||||
ListenableFuture<Set<Extension>> listExtensions();
|
||||
|
||||
|
||||
/**
|
||||
* @see ExtensionClient#getExtensionByAlias
|
||||
*/
|
||||
|
|
|
@ -29,7 +29,8 @@ import org.jclouds.openstack.nova.v1_1.domain.Extension;
|
|||
* <p/>
|
||||
*
|
||||
* @see ExtensionClient
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
|
||||
* @see <a href=
|
||||
* "http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
|
|
@ -43,10 +43,11 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* <p/>
|
||||
*
|
||||
* @see FlavorClient
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-compute/1.1/content/Flavors-d1e4180.html"
|
||||
* @see <a href=
|
||||
* "http://docs.openstack.org/api/openstack-compute/1.1/content/Flavors-d1e4180.html"
|
||||
* />
|
||||
* @author Jeremy Daggett
|
||||
* TODO: Need a ListFlavorOptions class minDisk=minDiskInGB& minRam=minRamInMB& marker=markerID&limit=int
|
||||
* @author Jeremy Daggett TODO: Need a ListFlavorOptions class
|
||||
* minDisk=minDiskInGB& minRam=minRamInMB& marker=markerID&limit=int
|
||||
*/
|
||||
@SkipEncoding({ '/', '=' })
|
||||
@RequestFilters(AuthenticateRequest.class)
|
||||
|
|
|
@ -30,7 +30,8 @@ import org.jclouds.openstack.nova.v1_1.domain.Image;
|
|||
* <p/>
|
||||
*
|
||||
* @see ImageAsyncClient
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-compute/1.1/content/Servers-d1e2073.html"
|
||||
* @see <a href=
|
||||
* "http://docs.openstack.org/api/openstack-compute/1.1/content/Servers-d1e2073.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -63,7 +64,8 @@ public interface ImageClient {
|
|||
/**
|
||||
* Delete the specified image
|
||||
*
|
||||
* @param id id of the image
|
||||
* @param id
|
||||
* id of the image
|
||||
* @return server or null if not found
|
||||
*/
|
||||
void deleteImage(String id);
|
||||
|
|
|
@ -55,7 +55,8 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* <p/>
|
||||
*
|
||||
* @see ServerClient
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-compute/1.1/content/Servers-d1e2073.html"
|
||||
* @see <a href=
|
||||
* "http://docs.openstack.org/api/openstack-compute/1.1/content/Servers-d1e2073.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -93,14 +94,14 @@ public interface ServerAsyncClient {
|
|||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
ListenableFuture<Server> getServer(@PathParam("id") String id);
|
||||
|
||||
/**
|
||||
* @see ServerClient#deleteServer
|
||||
*/
|
||||
@DELETE
|
||||
@Consumes
|
||||
@ExceptionParser(ReturnFalseOnNotFoundOr404.class)
|
||||
@Path("/servers/{id}")
|
||||
ListenableFuture<Boolean> deleteServer(@PathParam("id") String id);
|
||||
/**
|
||||
* @see ServerClient#deleteServer
|
||||
*/
|
||||
@DELETE
|
||||
@Consumes
|
||||
@ExceptionParser(ReturnFalseOnNotFoundOr404.class)
|
||||
@Path("/servers/{id}")
|
||||
ListenableFuture<Boolean> deleteServer(@PathParam("id") String id);
|
||||
|
||||
/**
|
||||
* @see ServerClient#rebootServer
|
||||
|
@ -151,7 +152,7 @@ public interface ServerAsyncClient {
|
|||
@Path("/servers")
|
||||
@MapBinder(CreateServerOptions.class)
|
||||
ListenableFuture<Server> createServer(@PayloadParam("name") String name, @PayloadParam("imageRef") String imageRef,
|
||||
@PayloadParam("flavorRef") String flavorRef, CreateServerOptions... options);
|
||||
@PayloadParam("flavorRef") String flavorRef, CreateServerOptions... options);
|
||||
|
||||
/**
|
||||
* @see ServerClient#rebuildServer
|
||||
|
@ -162,7 +163,6 @@ public interface ServerAsyncClient {
|
|||
@MapBinder(RebuildServerOptions.class)
|
||||
ListenableFuture<Void> rebuildServer(@PathParam("id") String id, RebuildServerOptions... options);
|
||||
|
||||
|
||||
/**
|
||||
* @see ServerClient#changeAdminPass
|
||||
*/
|
||||
|
|
|
@ -33,7 +33,8 @@ import org.jclouds.openstack.nova.v1_1.options.RebuildServerOptions;
|
|||
* <p/>
|
||||
*
|
||||
* @see ServerAsyncClient
|
||||
* @see <a href="http://docs.openstack.org/api/openstack-compute/1.1/content/Servers-d1e2073.html"
|
||||
* @see <a href=
|
||||
* "http://docs.openstack.org/api/openstack-compute/1.1/content/Servers-d1e2073.html"
|
||||
* />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -67,13 +68,14 @@ public interface ServerClient {
|
|||
* Create a new server
|
||||
*
|
||||
* @param name
|
||||
* name of the server to create
|
||||
* name of the server to create
|
||||
* @param imageRef
|
||||
* reference to the image for the server to use
|
||||
* reference to the image for the server to use
|
||||
* @param flavorRef
|
||||
* reference to the flavor to use when creating the server
|
||||
* reference to the flavor to use when creating the server
|
||||
* @param options
|
||||
* optional parameters to be passed into the server creation request
|
||||
* optional parameters to be passed into the server creation
|
||||
* request
|
||||
* @return the newly created server
|
||||
*/
|
||||
Server createServer(String name, String imageRef, String flavorRef, CreateServerOptions... options);
|
||||
|
@ -87,69 +89,69 @@ public interface ServerClient {
|
|||
*/
|
||||
Boolean deleteServer(String id);
|
||||
|
||||
/**
|
||||
* Reboot a server.
|
||||
*
|
||||
* @param id
|
||||
* id of the server
|
||||
* @param rebootType
|
||||
* The type of reboot to perform (Hard/Soft)
|
||||
*/
|
||||
/**
|
||||
* Reboot a server.
|
||||
*
|
||||
* @param id
|
||||
* id of the server
|
||||
* @param rebootType
|
||||
* The type of reboot to perform (Hard/Soft)
|
||||
*/
|
||||
void rebootServer(String id, RebootType rebootType);
|
||||
|
||||
/**
|
||||
* Resize a server to a new flavor size.
|
||||
*
|
||||
* @param id
|
||||
* id of the server
|
||||
* @param flavorId
|
||||
* id of the new flavor to use
|
||||
*/
|
||||
/**
|
||||
* Resize a server to a new flavor size.
|
||||
*
|
||||
* @param id
|
||||
* id of the server
|
||||
* @param flavorId
|
||||
* id of the new flavor to use
|
||||
*/
|
||||
void resizeServer(String id, String flavorId);
|
||||
|
||||
/**
|
||||
* Confirm a resize operation.
|
||||
*
|
||||
* @param id
|
||||
* id of the server
|
||||
/**
|
||||
* Confirm a resize operation.
|
||||
*
|
||||
* @param id
|
||||
* id of the server
|
||||
*/
|
||||
void confirmResizeServer(String id);
|
||||
|
||||
/**
|
||||
* Revert a resize operation.
|
||||
*
|
||||
* @param id
|
||||
* id of the server
|
||||
*/
|
||||
/**
|
||||
* Revert a resize operation.
|
||||
*
|
||||
* @param id
|
||||
* id of the server
|
||||
*/
|
||||
void revertResizeServer(String id);
|
||||
|
||||
/**
|
||||
* Rebuild a server.
|
||||
*
|
||||
* @param id
|
||||
* id of the server
|
||||
* @param options
|
||||
* Optional paramaters to the rebuilding operation.
|
||||
/**
|
||||
* Rebuild a server.
|
||||
*
|
||||
* @param id
|
||||
* id of the server
|
||||
* @param options
|
||||
* Optional paramaters to the rebuilding operation.
|
||||
*/
|
||||
void rebuildServer(String id, RebuildServerOptions... options);
|
||||
|
||||
/**
|
||||
* Change the administrative password to a server.
|
||||
*
|
||||
* @param id
|
||||
* id of the server
|
||||
* @param adminPass
|
||||
* The new administrative password to use
|
||||
/**
|
||||
* Change the administrative password to a server.
|
||||
*
|
||||
* @param id
|
||||
* id of the server
|
||||
* @param adminPass
|
||||
* The new administrative password to use
|
||||
*/
|
||||
void changeAdminPass(String id, String adminPass);
|
||||
|
||||
/**
|
||||
* Rename a server.
|
||||
*
|
||||
* @param id
|
||||
* id of the server
|
||||
* @param newName
|
||||
* The new name for the server
|
||||
/**
|
||||
* Rename a server.
|
||||
*
|
||||
* @param id
|
||||
* id of the server
|
||||
* @param newName
|
||||
* The new name for the server
|
||||
*/
|
||||
void renameServer(String id, String newName);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.jclouds.rest.ResourceNotFoundException;
|
|||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
//TODO: is there error spec someplace? let's type errors, etc.
|
||||
// TODO: is there error spec someplace? let's type errors, etc.
|
||||
@Singleton
|
||||
public class NovaErrorHandler implements HttpErrorHandler {
|
||||
|
||||
|
@ -45,22 +45,22 @@ public class NovaErrorHandler implements HttpErrorHandler {
|
|||
String message = data != null ? new String(data) : null;
|
||||
|
||||
Exception exception = message != null ? new HttpResponseException(command, response, message)
|
||||
: new HttpResponseException(command, response);
|
||||
: new HttpResponseException(command, response);
|
||||
message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
|
||||
response.getStatusLine());
|
||||
response.getStatusLine());
|
||||
switch (response.getStatusCode()) {
|
||||
case 401:
|
||||
case 403:
|
||||
exception = new AuthorizationException(message, exception);
|
||||
break;
|
||||
case 404:
|
||||
if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
|
||||
exception = new ResourceNotFoundException(message, exception);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
exception = new HttpResponseException(command, response, message);
|
||||
break;
|
||||
case 401:
|
||||
case 403:
|
||||
exception = new AuthorizationException(message, exception);
|
||||
break;
|
||||
case 404:
|
||||
if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
|
||||
exception = new ResourceNotFoundException(message, exception);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
exception = new HttpResponseException(command, response, message);
|
||||
break;
|
||||
}
|
||||
command.setException(exception);
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ import static com.google.common.base.Preconditions.checkState;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
@ -57,10 +57,12 @@ public class CreateServerOptions implements MapBinder {
|
|||
public File(String path, byte[] contents) {
|
||||
this.path = checkNotNull(path, "path");
|
||||
this.contents = Base64.encodeBytes(checkNotNull(contents, "contents"));
|
||||
checkArgument(path.getBytes().length < 255, String.format(
|
||||
"maximum length of path is 255 bytes. Path specified %s is %d bytes", path, path.getBytes().length));
|
||||
checkArgument(contents.length < 10 * 1024, String.format(
|
||||
"maximum size of the file is 10KB. Contents specified is %d bytes", contents.length));
|
||||
checkArgument(
|
||||
path.getBytes().length < 255,
|
||||
String.format("maximum length of path is 255 bytes. Path specified %s is %d bytes", path,
|
||||
path.getBytes().length));
|
||||
checkArgument(contents.length < 10 * 1024,
|
||||
String.format("maximum size of the file is 10KB. Contents specified is %d bytes", contents.length));
|
||||
}
|
||||
|
||||
public String getContents() {
|
||||
|
@ -82,7 +84,7 @@ public class CreateServerOptions implements MapBinder {
|
|||
Map<String, String> metadata;
|
||||
List<File> personality;
|
||||
String key_name;
|
||||
@SerializedName(value="security_groups")
|
||||
@SerializedName(value = "security_groups")
|
||||
Set<SecurityGroup> securityGroups;
|
||||
|
||||
private ServerRequest(String name, String imageRef, String flavorRef) {
|
||||
|
@ -102,42 +104,45 @@ public class CreateServerOptions implements MapBinder {
|
|||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Map<String, String> postParams) {
|
||||
ServerRequest server = new ServerRequest(checkNotNull(postParams.get("name"), "name parameter not present"),
|
||||
checkNotNull(postParams.get("imageRef"), "imageRef parameter not present"), checkNotNull(postParams
|
||||
.get("flavorRef"), "flavorRef parameter not present"));
|
||||
checkNotNull(postParams.get("imageRef"), "imageRef parameter not present"), checkNotNull(
|
||||
postParams.get("flavorRef"), "flavorRef parameter not present"));
|
||||
if (metadata.size() > 0)
|
||||
server.metadata = metadata;
|
||||
if (files.size() > 0)
|
||||
server.personality = files;
|
||||
if (keyName != null)
|
||||
server.key_name = keyName;
|
||||
server.key_name = keyName;
|
||||
if (securityGroups.size() > 0) {
|
||||
server.securityGroups = Sets.newHashSet();
|
||||
for (String groupName : securityGroups) {
|
||||
SecurityGroup group = SecurityGroup.builder().name(groupName).build();
|
||||
server.securityGroups.add(group);
|
||||
}
|
||||
server.securityGroups = Sets.newHashSet();
|
||||
for (String groupName : securityGroups) {
|
||||
SecurityGroup group = SecurityGroup.builder().name(groupName).build();
|
||||
server.securityGroups.add(group);
|
||||
}
|
||||
}
|
||||
if (adminPass != null) {
|
||||
server.adminPass = adminPass;
|
||||
server.adminPass = adminPass;
|
||||
}
|
||||
|
||||
return bindToRequest(request, ImmutableMap.of("server", server));
|
||||
}
|
||||
|
||||
/**
|
||||
* You may further customize a cloud server by injecting data into the file system of the cloud
|
||||
* server itself. This is useful, for example, for inserting ssh keys, setting configuration
|
||||
* files, or storing data that you want to retrieve from within the instance itself. It is
|
||||
* intended to provide a minimal amount of launch-time personalization. If significant
|
||||
* customization is required, a custom image should be created. The max size of the file path
|
||||
* data is 255 bytes while the max size of the file contents is 10KB. Note that the file contents
|
||||
* should be encoded as a Base64 string and the 10KB limit refers to the number of bytes in the
|
||||
* decoded data not the number of characters in the encoded data. The maximum number of file
|
||||
* path/content pairs that can be supplied is 5. Any existing files that match the specified file
|
||||
* will be renamed to include the extension bak followed by a time stamp. For example, the file
|
||||
* /etc/passwd will be backed up as /etc/passwd.bak.1246036261.5785. All files will have root and
|
||||
* the root group as owner and group owner, respectively and will allow user and group read
|
||||
* access only (-r--r-----).
|
||||
* You may further customize a cloud server by injecting data into the file
|
||||
* system of the cloud server itself. This is useful, for example, for
|
||||
* inserting ssh keys, setting configuration files, or storing data that you
|
||||
* want to retrieve from within the instance itself. It is intended to
|
||||
* provide a minimal amount of launch-time personalization. If significant
|
||||
* customization is required, a custom image should be created. The max size
|
||||
* of the file path data is 255 bytes while the max size of the file contents
|
||||
* is 10KB. Note that the file contents should be encoded as a Base64 string
|
||||
* and the 10KB limit refers to the number of bytes in the decoded data not
|
||||
* the number of characters in the encoded data. The maximum number of file
|
||||
* path/content pairs that can be supplied is 5. Any existing files that
|
||||
* match the specified file will be renamed to include the extension bak
|
||||
* followed by a time stamp. For example, the file /etc/passwd will be backed
|
||||
* up as /etc/passwd.bak.1246036261.5785. All files will have root and the
|
||||
* root group as owner and group owner, respectively and will allow user and
|
||||
* group read access only (-r--r-----).
|
||||
*/
|
||||
public CreateServerOptions withFile(String path, byte[] contents) {
|
||||
checkState(files.size() < 5, "maximum number of files allowed is 5");
|
||||
|
@ -146,45 +151,47 @@ public class CreateServerOptions implements MapBinder {
|
|||
}
|
||||
|
||||
public CreateServerOptions withAdminPass(String adminPass) {
|
||||
checkNotNull(adminPass, "adminPass");
|
||||
this.adminPass = adminPass;
|
||||
return this;
|
||||
checkNotNull(adminPass, "adminPass");
|
||||
this.adminPass = adminPass;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom cloud server metadata can also be supplied at launch time. This metadata is stored in
|
||||
* the API system where it is retrievable by querying the API for server status. The maximum size
|
||||
* of the metadata key and value is each 255 bytes and the maximum number of key-value pairs that
|
||||
* can be supplied per server is 5.
|
||||
* Custom cloud server metadata can also be supplied at launch time. This
|
||||
* metadata is stored in the API system where it is retrievable by querying
|
||||
* the API for server status. The maximum size of the metadata key and value
|
||||
* is each 255 bytes and the maximum number of key-value pairs that can be
|
||||
* supplied per server is 5.
|
||||
*/
|
||||
public CreateServerOptions withMetadata(Map<String, String> metadata) {
|
||||
checkNotNull(metadata, "metadata");
|
||||
checkArgument(metadata.size() <= 5, "you cannot have more then 5 metadata values. You specified: "
|
||||
+ metadata.size());
|
||||
checkArgument(metadata.size() <= 5,
|
||||
"you cannot have more then 5 metadata values. You specified: " + metadata.size());
|
||||
for (Entry<String, String> entry : metadata.entrySet()) {
|
||||
checkArgument(
|
||||
entry.getKey().getBytes().length < 255,
|
||||
String.format("maximum length of metadata key is 255 bytes. Key specified %s is %d bytes",
|
||||
entry.getKey(), entry.getKey().getBytes().length));
|
||||
checkArgument(entry.getKey().getBytes().length < 255, String.format(
|
||||
"maximum length of metadata key is 255 bytes. Key specified %s is %d bytes", entry.getKey(), entry
|
||||
.getKey().getBytes().length));
|
||||
checkArgument(entry.getKey().getBytes().length < 255, String.format(
|
||||
"maximum length of metadata value is 255 bytes. Value specified for %s (%s) is %d bytes", entry
|
||||
.getKey(), entry.getValue(), entry.getValue().getBytes().length));
|
||||
"maximum length of metadata value is 255 bytes. Value specified for %s (%s) is %d bytes",
|
||||
entry.getKey(), entry.getValue(), entry.getValue().getBytes().length));
|
||||
}
|
||||
this.metadata = metadata;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A keypair name can be defined when creating a server. This key will be
|
||||
* linked to the server and used to SSH connect to the machine
|
||||
*
|
||||
* @param keyName
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* A keypair name can be defined when creating a server. This key will be
|
||||
* linked to the server and used to SSH connect to the machine
|
||||
*
|
||||
* @param keyName
|
||||
* @return
|
||||
*/
|
||||
public CreateServerOptions withKeyName(String keyName) {
|
||||
checkNotNull(keyName, "keyName");
|
||||
this.keyName = keyName;
|
||||
return this;
|
||||
}
|
||||
checkNotNull(keyName, "keyName");
|
||||
this.keyName = keyName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the security group name to be used when creating a server.
|
||||
|
@ -193,10 +200,10 @@ public class CreateServerOptions implements MapBinder {
|
|||
* @return
|
||||
*/
|
||||
public CreateServerOptions withSecurityGroup(String groupName) {
|
||||
checkNotNull(groupName, "groupName");
|
||||
this.securityGroups.add(groupName);
|
||||
return this;
|
||||
}
|
||||
checkNotNull(groupName, "groupName");
|
||||
this.securityGroups.add(groupName);
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
|
@ -209,9 +216,9 @@ public class CreateServerOptions implements MapBinder {
|
|||
}
|
||||
|
||||
public static CreateServerOptions withAdminPass(String adminPass) {
|
||||
CreateServerOptions options = new CreateServerOptions();
|
||||
return options.withAdminPass(adminPass);
|
||||
}
|
||||
CreateServerOptions options = new CreateServerOptions();
|
||||
return options.withAdminPass(adminPass);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CreateServerOptions#withMetadata(Map<String, String>)
|
||||
|
@ -225,17 +232,17 @@ public class CreateServerOptions implements MapBinder {
|
|||
* @see CreateServerOptions#withKeyName(String)
|
||||
*/
|
||||
public static CreateServerOptions withKeyName(String keyName) {
|
||||
CreateServerOptions options = new CreateServerOptions();
|
||||
return options.withKeyName(keyName);
|
||||
}
|
||||
CreateServerOptions options = new CreateServerOptions();
|
||||
return options.withKeyName(keyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CreateServerOptions#withGroupName(String)
|
||||
*/
|
||||
public static CreateServerOptions withSecurityGroup(String name) {
|
||||
CreateServerOptions options = new CreateServerOptions();
|
||||
return options.withSecurityGroup(name);
|
||||
}
|
||||
CreateServerOptions options = new CreateServerOptions();
|
||||
return options.withSecurityGroup(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,20 +52,24 @@ public class PasswordAuthenticationExpectTest extends BaseNovaClientExpectTest {
|
|||
}
|
||||
|
||||
public void testListServersWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listServers = HttpRequest.builder().method("GET").endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/servers")).headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
|
||||
authToken).build()).build();
|
||||
HttpRequest listServers = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/servers"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listServersResponse = HttpResponse.builder().statusCode(200).payload(
|
||||
payloadFromResource("/server_list.json")).build();
|
||||
HttpResponse listServersResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/server_list.json")).build();
|
||||
|
||||
NovaClient clientWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
|
||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||
|
||||
assertEquals(clientWhenServersExist.getConfiguredRegions(), ImmutableSet.of("North"));
|
||||
|
||||
assertEquals(clientWhenServersExist.getServerClientForRegion("North").listServers().toString(), new ParseServerListTest().expected().toString());
|
||||
assertEquals(clientWhenServersExist.getServerClientForRegion("North").listServers().toString(),
|
||||
new ParseServerListTest().expected().toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -41,16 +41,19 @@ import com.google.common.collect.ImmutableMultimap;
|
|||
public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTest {
|
||||
|
||||
public void testListServersWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listServers = HttpRequest.builder().method("GET").endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/servers/detail")).headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
|
||||
authToken).build()).build();
|
||||
HttpRequest listServers = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/servers/detail"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listServersResponse = HttpResponse.builder().statusCode(200).payload(
|
||||
payloadFromResource("/server_list_details.json")).build();
|
||||
HttpResponse listServersResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/server_list_details.json")).build();
|
||||
|
||||
ComputeService clientWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||
|
||||
assertNotNull(clientWhenServersExist.listAssignableLocations());
|
||||
assertEquals(clientWhenServersExist.listAssignableLocations().size(), 1);
|
||||
|
@ -63,15 +66,18 @@ public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTe
|
|||
}
|
||||
|
||||
public void testListServersWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest listServers = HttpRequest.builder().method("GET").endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/servers/detail")).headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
|
||||
authToken).build()).build();
|
||||
HttpRequest listServers = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/servers/detail"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listServersResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
ComputeService clientWhenNoServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||
|
||||
assertTrue(clientWhenNoServersExist.listNodes().isEmpty());
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.UUID;
|
|||
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.openstack.nova.v1_1.compute.functions.FlavorToHardware;
|
||||
import org.jclouds.openstack.nova.v1_1.domain.Flavor;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -37,21 +36,14 @@ import com.google.common.base.Suppliers;
|
|||
*
|
||||
* @author Matt Stephenson
|
||||
*/
|
||||
public class FlavorToHardwareTest
|
||||
{
|
||||
public class FlavorToHardwareTest {
|
||||
@Test
|
||||
public void testConversion()
|
||||
{
|
||||
public void testConversion() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Flavor flavorToConvert = Flavor.builder()
|
||||
.id(id.toString())
|
||||
.name("Test Flavor " + id)
|
||||
.ram(262144)
|
||||
.disk(10000)
|
||||
.vcpus(16)
|
||||
.build();
|
||||
Flavor flavorToConvert = Flavor.builder().id(id.toString()).name("Test Flavor " + id).ram(262144).disk(10000)
|
||||
.vcpus(16).build();
|
||||
|
||||
Hardware converted = new FlavorToHardware(Suppliers.<Location>ofInstance(null)).apply(flavorToConvert);
|
||||
Hardware converted = new FlavorToHardware(Suppliers.<Location> ofInstance(null)).apply(flavorToConvert);
|
||||
|
||||
assertEquals(converted.getName(), flavorToConvert.getName());
|
||||
assertEquals(converted.getId(), flavorToConvert.getId());
|
||||
|
@ -60,7 +52,7 @@ public class FlavorToHardwareTest
|
|||
|
||||
assertNotNull(converted.getProcessors());
|
||||
assertFalse(converted.getProcessors().isEmpty());
|
||||
assertEquals(converted.getProcessors().iterator().next().getCores(), (double)flavorToConvert.getVcpus());
|
||||
assertEquals(converted.getProcessors().iterator().next().getCores(), (double) flavorToConvert.getVcpus());
|
||||
|
||||
assertNotNull(converted.getVolumes());
|
||||
assertFalse(converted.getVolumes().isEmpty());
|
||||
|
|
|
@ -27,7 +27,6 @@ import javax.annotation.Nullable;
|
|||
import org.jclouds.compute.domain.OperatingSystem;
|
||||
import org.jclouds.compute.domain.OsFamily;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.openstack.nova.v1_1.compute.functions.NovaImageToImage;
|
||||
import org.jclouds.openstack.nova.v1_1.domain.Image;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -39,15 +38,15 @@ import com.google.common.base.Suppliers;
|
|||
*
|
||||
* @author Matt Stephenson
|
||||
*/
|
||||
public class NovaImageToImageTest
|
||||
{
|
||||
public class NovaImageToImageTest {
|
||||
@Test
|
||||
public void testConversion()
|
||||
{
|
||||
public void testConversion() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Image novaImageToConvert = Image.builder().id(id.toString()).name("Test Image " + id).build();
|
||||
OperatingSystem operatingSystem = new OperatingSystem(OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86", "My Test OS", true);
|
||||
NovaImageToImage converter = new NovaImageToImage(new MockImageToOsConverter(operatingSystem),Suppliers.<Location>ofInstance(null));
|
||||
OperatingSystem operatingSystem = new OperatingSystem(OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86",
|
||||
"My Test OS", true);
|
||||
NovaImageToImage converter = new NovaImageToImage(new MockImageToOsConverter(operatingSystem),
|
||||
Suppliers.<Location> ofInstance(null));
|
||||
org.jclouds.compute.domain.Image convertedImage = converter.apply(novaImageToConvert);
|
||||
|
||||
assertEquals(convertedImage.getId(), novaImageToConvert.getId());
|
||||
|
@ -57,25 +56,21 @@ public class NovaImageToImageTest
|
|||
assertEquals(convertedImage.getOperatingSystem(), operatingSystem);
|
||||
}
|
||||
|
||||
private class MockImageToOsConverter implements Function<Image, OperatingSystem>
|
||||
{
|
||||
private class MockImageToOsConverter implements Function<Image, OperatingSystem> {
|
||||
|
||||
private final OperatingSystem operatingSystem;
|
||||
|
||||
public MockImageToOsConverter(OperatingSystem operatingSystem)
|
||||
{
|
||||
public MockImageToOsConverter(OperatingSystem operatingSystem) {
|
||||
this.operatingSystem = operatingSystem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OperatingSystem apply(@Nullable Image image)
|
||||
{
|
||||
public OperatingSystem apply(@Nullable Image image) {
|
||||
return operatingSystem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object o)
|
||||
{
|
||||
public boolean equals(@Nullable Object o) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import javax.annotation.Nullable;
|
|||
|
||||
import org.jclouds.compute.domain.OperatingSystem;
|
||||
import org.jclouds.compute.domain.OsFamily;
|
||||
import org.jclouds.openstack.nova.v1_1.compute.functions.NovaImageToOperatingSystem;
|
||||
import org.jclouds.openstack.nova.v1_1.domain.Image;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -40,20 +39,20 @@ import com.google.common.collect.ImmutableMap;
|
|||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* Tests for the function for transforming a nova specific Image into a generic OperatingSystem object.
|
||||
* Tests for the function for transforming a nova specific Image into a generic
|
||||
* OperatingSystem object.
|
||||
*
|
||||
* @author Matt Stephenson
|
||||
*/
|
||||
public class NovaImageToOperatingSystemTest
|
||||
{
|
||||
public class NovaImageToOperatingSystemTest {
|
||||
|
||||
@Test(dataProvider = "getOsFamilyValues")
|
||||
public void testOsFamilyValues(OsFamily family)
|
||||
{
|
||||
public void testOsFamilyValues(OsFamily family) {
|
||||
|
||||
Image imageToConvert = Image.builder().id("id-" + family.name()).name(family.name()).build();
|
||||
|
||||
NovaImageToOperatingSystem converter = new NovaImageToOperatingSystem(new HashMap<OsFamily, Map<String, String>>());
|
||||
NovaImageToOperatingSystem converter = new NovaImageToOperatingSystem(
|
||||
new HashMap<OsFamily, Map<String, String>>());
|
||||
|
||||
OperatingSystem convertedOs = converter.apply(imageToConvert);
|
||||
|
||||
|
@ -66,21 +65,18 @@ public class NovaImageToOperatingSystemTest
|
|||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] getOsFamilyValues()
|
||||
{
|
||||
return Iterables.toArray(Iterables.transform(Arrays.asList(OsFamily.values()), new Function<OsFamily, Object[]>()
|
||||
{
|
||||
@Override
|
||||
public Object[] apply(@Nullable OsFamily osFamily)
|
||||
{
|
||||
return new Object[]{osFamily};
|
||||
}
|
||||
}), Object[].class);
|
||||
public Object[][] getOsFamilyValues() {
|
||||
return Iterables.toArray(
|
||||
Iterables.transform(Arrays.asList(OsFamily.values()), new Function<OsFamily, Object[]>() {
|
||||
@Override
|
||||
public Object[] apply(@Nullable OsFamily osFamily) {
|
||||
return new Object[] { osFamily };
|
||||
}
|
||||
}), Object[].class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWindowsServer2008R2x64()
|
||||
{
|
||||
public void testWindowsServer2008R2x64() {
|
||||
String name = "Windows Server 2008 R2 x64";
|
||||
|
||||
Image imageToConvert = Image.builder().id("id-" + name).name(name).build();
|
||||
|
@ -101,8 +97,7 @@ public class NovaImageToOperatingSystemTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testWindows98x86()
|
||||
{
|
||||
public void testWindows98x86() {
|
||||
String name = "Windows 98 x86";
|
||||
|
||||
Image imageToConvert = Image.builder().id("id-" + name).name(name).build();
|
||||
|
@ -123,13 +118,13 @@ public class NovaImageToOperatingSystemTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRHEL()
|
||||
{
|
||||
public void testRHEL() {
|
||||
String name = "Red Hat EL";
|
||||
|
||||
Image imageToConvert = Image.builder().id("id-" + name).name(name).build();
|
||||
|
||||
NovaImageToOperatingSystem converter = new NovaImageToOperatingSystem(new HashMap<OsFamily, Map<String, String>>());
|
||||
NovaImageToOperatingSystem converter = new NovaImageToOperatingSystem(
|
||||
new HashMap<OsFamily, Map<String, String>>());
|
||||
|
||||
OperatingSystem convertedOs = converter.apply(imageToConvert);
|
||||
|
||||
|
@ -142,13 +137,13 @@ public class NovaImageToOperatingSystemTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testOEL()
|
||||
{
|
||||
public void testOEL() {
|
||||
String name = "Oracle EL";
|
||||
|
||||
Image imageToConvert = Image.builder().id("id-" + name).name(name).build();
|
||||
|
||||
NovaImageToOperatingSystem converter = new NovaImageToOperatingSystem(new HashMap<OsFamily, Map<String, String>>());
|
||||
NovaImageToOperatingSystem converter = new NovaImageToOperatingSystem(
|
||||
new HashMap<OsFamily, Map<String, String>>());
|
||||
|
||||
OperatingSystem convertedOs = converter.apply(imageToConvert);
|
||||
|
||||
|
|
|
@ -18,39 +18,32 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.compute.functions;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.openstack.nova.v1_1.compute.functions.ServerToNodeMetadata;
|
||||
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.ServerStatus;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
* Tests for the function for transforming a nova specific Server into a generic NodeMetadata object.
|
||||
* Tests for the function for transforming a nova specific Server into a generic
|
||||
* NodeMetadata object.
|
||||
*
|
||||
* @author Matt Stephenson
|
||||
*/
|
||||
public class ServerToNodeMetadataTest
|
||||
{
|
||||
public class ServerToNodeMetadataTest {
|
||||
@Test
|
||||
public void testConversion()
|
||||
{
|
||||
public void testConversion() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Server serverToConvert = Server.builder()
|
||||
.id(id.toString())
|
||||
.name("Test Server " + id)
|
||||
.privateAddresses(Address.createV4("10.0.0.1"))
|
||||
.publicAddresses(Address.createV4("1.0.1.1"))
|
||||
.status(ServerStatus.ACTIVE)
|
||||
.metadata(ImmutableMap.of("test", "testing"))
|
||||
.build();
|
||||
Server serverToConvert = Server.builder().id(id.toString()).name("Test Server " + id)
|
||||
.privateAddresses(Address.createV4("10.0.0.1")).publicAddresses(Address.createV4("1.0.1.1"))
|
||||
.status(ServerStatus.ACTIVE).metadata(ImmutableMap.of("test", "testing")).build();
|
||||
|
||||
ServerToNodeMetadata converter = new ServerToNodeMetadata();
|
||||
|
||||
|
@ -71,6 +64,6 @@ public class ServerToNodeMetadataTest
|
|||
|
||||
assertNotNull(convertedNodeMetadata.getUserMetadata());
|
||||
assertEquals(convertedNodeMetadata.getUserMetadata().size(), 1);
|
||||
assertEquals(convertedNodeMetadata.getUserMetadata().get("test"),"testing");
|
||||
assertEquals(convertedNodeMetadata.getUserMetadata().get("test"), "testing");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,143 +43,117 @@ import com.google.common.collect.ImmutableSet;
|
|||
@Test(groups = "unit", testName = "FloatingIPClientExpectTest")
|
||||
public class FloatingIPClientExpectTest extends BaseNovaClientExpectTest {
|
||||
|
||||
public void testListFloatingIPsWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listFloatingIPs = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-floating-ips"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
public void testListFloatingIPsWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listFloatingIPs = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-floating-ips"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listFloatingIPsResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/floatingip_list.json")).build();
|
||||
HttpResponse listFloatingIPsResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/floatingip_list.json")).build();
|
||||
|
||||
NovaClient clientWhenFloatingIPsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
listFloatingIPs, listFloatingIPsResponse);
|
||||
NovaClient clientWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listFloatingIPs, listFloatingIPsResponse);
|
||||
|
||||
assertEquals(clientWhenFloatingIPsExist.getConfiguredRegions(),
|
||||
ImmutableSet.of("North"));
|
||||
assertEquals(clientWhenFloatingIPsExist.getConfiguredRegions(), ImmutableSet.of("North"));
|
||||
|
||||
assertEquals(clientWhenFloatingIPsExist.getFloatingIPExtensionForRegion("North").get()
|
||||
.listFloatingIPs().toString(), new ParseFloatingIPListTest().expected()
|
||||
.toString());
|
||||
}
|
||||
assertEquals(clientWhenFloatingIPsExist.getFloatingIPExtensionForRegion("North").get().listFloatingIPs()
|
||||
.toString(), new ParseFloatingIPListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListFloatingIPsWhenResponseIs404() throws Exception {
|
||||
HttpRequest listFloatingIPs = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-floating-ips"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
public void testListFloatingIPsWhenResponseIs404() throws Exception {
|
||||
HttpRequest listFloatingIPs = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-floating-ips"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listFloatingIPsResponse = HttpResponse.builder().statusCode(404)
|
||||
.build();
|
||||
HttpResponse listFloatingIPsResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
listFloatingIPs, listFloatingIPsResponse);
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listFloatingIPs, listFloatingIPsResponse);
|
||||
|
||||
assertTrue(clientWhenNoServersExist.getFloatingIPExtensionForRegion("North").get()
|
||||
.listFloatingIPs().isEmpty());
|
||||
}
|
||||
assertTrue(clientWhenNoServersExist.getFloatingIPExtensionForRegion("North").get().listFloatingIPs().isEmpty());
|
||||
}
|
||||
|
||||
public void testGetFloatingIPWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest getFloatingIP = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-floating-ips/1"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
public void testGetFloatingIPWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest getFloatingIP = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-floating-ips/1"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse getFloatingIPResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/floatingip_details.json")).build();
|
||||
HttpResponse getFloatingIPResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/floatingip_details.json")).build();
|
||||
|
||||
NovaClient clientWhenFloatingIPsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
getFloatingIP, getFloatingIPResponse);
|
||||
NovaClient clientWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, getFloatingIP, getFloatingIPResponse);
|
||||
|
||||
assertEquals(clientWhenFloatingIPsExist.getFloatingIPExtensionForRegion("North").get()
|
||||
.getFloatingIP("1").toString(),
|
||||
new ParseFloatingIPTest().expected().toString());
|
||||
}
|
||||
assertEquals(clientWhenFloatingIPsExist.getFloatingIPExtensionForRegion("North").get().getFloatingIP("1")
|
||||
.toString(), new ParseFloatingIPTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testGetFloatingIPWhenResponseIs404() throws Exception {
|
||||
HttpRequest getFloatingIP = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-floating-ips/1"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
public void testGetFloatingIPWhenResponseIs404() throws Exception {
|
||||
HttpRequest getFloatingIP = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-floating-ips/1"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse getFloatingIPResponse = HttpResponse.builder().statusCode(404).build();
|
||||
HttpResponse getFloatingIPResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
getFloatingIP, getFloatingIPResponse);
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, getFloatingIP, getFloatingIPResponse);
|
||||
|
||||
assertNull(clientWhenNoServersExist.getFloatingIPExtensionForRegion("North").get()
|
||||
.getFloatingIP("1"));
|
||||
}
|
||||
assertNull(clientWhenNoServersExist.getFloatingIPExtensionForRegion("North").get().getFloatingIP("1"));
|
||||
}
|
||||
|
||||
public void testAllocateWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest allocateFloatingIP = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-floating-ips"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build())
|
||||
.payload(payloadFromStringWithContentType("{}", "application/json")).build();
|
||||
public void testAllocateWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest allocateFloatingIP = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-floating-ips"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build())
|
||||
.payload(payloadFromStringWithContentType("{}", "application/json")).build();
|
||||
|
||||
HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/floatingip_details.json")).build();
|
||||
HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/floatingip_details.json")).build();
|
||||
|
||||
NovaClient clientWhenFloatingIPsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
allocateFloatingIP, allocateFloatingIPResponse);
|
||||
NovaClient clientWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, allocateFloatingIP, allocateFloatingIPResponse);
|
||||
|
||||
assertEquals(clientWhenFloatingIPsExist.getFloatingIPExtensionForRegion("North").get()
|
||||
.allocate().toString(),
|
||||
new ParseFloatingIPTest().expected().toString());
|
||||
assertEquals(clientWhenFloatingIPsExist.getFloatingIPExtensionForRegion("North").get().allocate().toString(),
|
||||
new ParseFloatingIPTest().expected().toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void testAllocateWhenResponseIs404() throws Exception {
|
||||
HttpRequest allocateFloatingIP = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-floating-ips"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build())
|
||||
.payload(payloadFromStringWithContentType("{}", "application/json")).build();
|
||||
public void testAllocateWhenResponseIs404() throws Exception {
|
||||
HttpRequest allocateFloatingIP = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-floating-ips"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build())
|
||||
.payload(payloadFromStringWithContentType("{}", "application/json")).build();
|
||||
|
||||
HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(404).build();
|
||||
HttpResponse allocateFloatingIPResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
allocateFloatingIP, allocateFloatingIPResponse);
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, allocateFloatingIP, allocateFloatingIPResponse);
|
||||
|
||||
assertNull(clientWhenNoServersExist.getFloatingIPExtensionForRegion("North").get()
|
||||
.allocate());
|
||||
}
|
||||
assertNull(clientWhenNoServersExist.getFloatingIPExtensionForRegion("North").get().allocate());
|
||||
}
|
||||
|
||||
}
|
|
@ -25,19 +25,18 @@ import static org.testng.Assert.assertTrue;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Iterables;
|
||||
import org.jclouds.openstack.nova.v1_1.domain.Address;
|
||||
import org.jclouds.openstack.nova.v1_1.domain.FloatingIP;
|
||||
import org.jclouds.openstack.nova.v1_1.domain.Server;
|
||||
import org.jclouds.openstack.nova.v1_1.domain.ServerStatus;
|
||||
import org.jclouds.openstack.nova.v1_1.extensions.FloatingIPClient;
|
||||
import org.jclouds.openstack.nova.v1_1.features.FlavorClient;
|
||||
import org.jclouds.openstack.nova.v1_1.features.ImageClient;
|
||||
import org.jclouds.openstack.nova.v1_1.features.ServerClient;
|
||||
import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
/**
|
||||
|
@ -48,7 +47,7 @@ import com.google.common.collect.Multimap;
|
|||
@Test(groups = "live", testName = "FloatingIPClientLiveTest")
|
||||
public class FloatingIPClientLiveTest extends BaseNovaClientLiveTest {
|
||||
|
||||
private static final int INCONSISTENCY_WINDOW = 5000;
|
||||
private static final int INCONSISTENCY_WINDOW = 5000;
|
||||
|
||||
@Test
|
||||
public void testListFloatingIPs() throws Exception {
|
||||
|
@ -63,7 +62,6 @@ public class FloatingIPClientLiveTest extends BaseNovaClientLiveTest {
|
|||
for (FloatingIP ip : response) {
|
||||
FloatingIP newDetails = client.getFloatingIP(ip.getId());
|
||||
|
||||
|
||||
assertEquals(newDetails.getId(), ip.getId());
|
||||
assertEquals(newDetails.getIp(), ip.getIp());
|
||||
assertEquals(newDetails.getFixedIp(), ip.getFixedIp());
|
||||
|
@ -73,129 +71,127 @@ public class FloatingIPClientLiveTest extends BaseNovaClientLiveTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllocateAndDeallocateFloatingIPs() throws Exception {
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
Optional<FloatingIPClient> clientOption = context.getApi().getFloatingIPExtensionForRegion(regionId);
|
||||
if (!clientOption.isPresent())
|
||||
continue;
|
||||
FloatingIPClient client = clientOption.get();
|
||||
FloatingIP floatingIP = client.allocate();
|
||||
assertNotNull(floatingIP);
|
||||
@Test
|
||||
public void testAllocateAndDeallocateFloatingIPs() throws Exception {
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
Optional<FloatingIPClient> clientOption = context.getApi().getFloatingIPExtensionForRegion(regionId);
|
||||
if (!clientOption.isPresent())
|
||||
continue;
|
||||
FloatingIPClient client = clientOption.get();
|
||||
FloatingIP floatingIP = client.allocate();
|
||||
assertNotNull(floatingIP);
|
||||
|
||||
Set<FloatingIP> response = client.listFloatingIPs();
|
||||
boolean ipInSet = false;
|
||||
for (FloatingIP ip : response) {
|
||||
if (ip.getId().equals(floatingIP.getId())) ipInSet = true;
|
||||
Set<FloatingIP> response = client.listFloatingIPs();
|
||||
boolean ipInSet = false;
|
||||
for (FloatingIP ip : response) {
|
||||
if (ip.getId().equals(floatingIP.getId()))
|
||||
ipInSet = true;
|
||||
}
|
||||
assertTrue(ipInSet);
|
||||
|
||||
client.deallocate(floatingIP.getId());
|
||||
|
||||
response = client.listFloatingIPs();
|
||||
ipInSet = false;
|
||||
for (FloatingIP ip : response) {
|
||||
if (ip.getId().equals(floatingIP.getId())) {
|
||||
ipInSet = true;
|
||||
}
|
||||
assertTrue(ipInSet);
|
||||
}
|
||||
assertFalse(ipInSet);
|
||||
}
|
||||
}
|
||||
|
||||
client.deallocate(floatingIP.getId());
|
||||
@Test
|
||||
public void testAddAndRemoveFloatingIp() throws Exception {
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
Optional<FloatingIPClient> clientOption = context.getApi().getFloatingIPExtensionForRegion(regionId);
|
||||
if (!clientOption.isPresent())
|
||||
continue;
|
||||
FloatingIPClient client = clientOption.get();
|
||||
ServerClient serverClient = context.getApi().getServerClientForRegion(regionId);
|
||||
Server server = serverClient.createServer("test", imageIdForRegion(regionId), flavorRefForRegion(regionId));
|
||||
blockUntilServerActive(server.getId(), serverClient);
|
||||
FloatingIP floatingIP = client.allocate();
|
||||
assertNotNull(floatingIP);
|
||||
try {
|
||||
client.addFloatingIP(server.getId(), floatingIP.getIp());
|
||||
assertEventually(new ServerHasFloatingIP(serverClient, server.getId(), floatingIP.getIp()));
|
||||
} finally {
|
||||
client.removeFloatingIP(server.getId(), floatingIP.getIp());
|
||||
serverClient.deleteServer(server.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response = client.listFloatingIPs();
|
||||
ipInSet = false;
|
||||
for (FloatingIP ip : response) {
|
||||
if (ip.getId().equals(floatingIP.getId())) {
|
||||
ipInSet = true;
|
||||
}
|
||||
private String imageIdForRegion(String regionId) {
|
||||
ImageClient imageClient = context.getApi().getImageClientForRegion(regionId);
|
||||
return Iterables.getLast(imageClient.listImages()).getId();
|
||||
}
|
||||
|
||||
private String flavorRefForRegion(String regionId) {
|
||||
FlavorClient flavorClient = context.getApi().getFlavorClientForRegion(regionId);
|
||||
return Iterables.getLast(flavorClient.listFlavors()).getId();
|
||||
}
|
||||
|
||||
private void blockUntilServerActive(String serverId, ServerClient client) throws InterruptedException {
|
||||
Server currentDetails = null;
|
||||
for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.ACTIVE; currentDetails = client
|
||||
.getServer(serverId)) {
|
||||
System.out.printf("blocking on status active%n%s%n", currentDetails);
|
||||
Thread.sleep(5 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void assertEventually(Runnable assertion) {
|
||||
long start = System.currentTimeMillis();
|
||||
AssertionError error = null;
|
||||
for (int i = 0; i < 30; i++) {
|
||||
try {
|
||||
assertion.run();
|
||||
if (i > 0)
|
||||
System.err.printf("%d attempts and %dms asserting %s%n", i + 1, System.currentTimeMillis() - start,
|
||||
assertion.getClass().getSimpleName());
|
||||
return;
|
||||
} catch (AssertionError e) {
|
||||
error = e;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(INCONSISTENCY_WINDOW / 30);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
if (error != null)
|
||||
throw error;
|
||||
|
||||
}
|
||||
|
||||
public static final class ServerHasFloatingIP implements Runnable {
|
||||
private final ServerClient client;
|
||||
private final String serverId;
|
||||
private final String floatingIP;
|
||||
|
||||
public ServerHasFloatingIP(ServerClient serverClient, String serverId, String floatingIP) {
|
||||
this.client = serverClient;
|
||||
this.serverId = serverId;
|
||||
this.floatingIP = floatingIP;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
Server server = client.getServer(serverId);
|
||||
boolean ipInServerAddresses = false;
|
||||
Multimap<Address.Type, Address> addresses = server.getAddresses();
|
||||
for (Address address : addresses.values()) {
|
||||
if (address.getAddr().equals(floatingIP)) {
|
||||
ipInServerAddresses = true;
|
||||
}
|
||||
}
|
||||
assertFalse(ipInSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAddAndRemoveFloatingIp() throws Exception {
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
Optional<FloatingIPClient> clientOption = context.getApi().getFloatingIPExtensionForRegion(regionId);
|
||||
if (!clientOption.isPresent())
|
||||
continue;
|
||||
FloatingIPClient client = clientOption.get();
|
||||
ServerClient serverClient = context.getApi().getServerClientForRegion(regionId);
|
||||
Server server = serverClient.createServer("test", imageIdForRegion(regionId), flavorRefForRegion(regionId));
|
||||
blockUntilServerActive(server.getId(), serverClient);
|
||||
FloatingIP floatingIP = client.allocate();
|
||||
assertNotNull(floatingIP);
|
||||
try {
|
||||
client.addFloatingIP(server.getId(), floatingIP.getIp());
|
||||
assertEventually(new ServerHasFloatingIP(serverClient, server.getId(), floatingIP.getIp()));
|
||||
}
|
||||
finally {
|
||||
client.removeFloatingIP(server.getId(), floatingIP.getIp());
|
||||
serverClient.deleteServer(server.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String imageIdForRegion(String regionId) {
|
||||
ImageClient imageClient = context.getApi().getImageClientForRegion(regionId);
|
||||
return Iterables.getLast(imageClient.listImages()).getId();
|
||||
}
|
||||
|
||||
private String flavorRefForRegion(String regionId) {
|
||||
FlavorClient flavorClient = context.getApi().getFlavorClientForRegion(regionId);
|
||||
return Iterables.getLast(flavorClient.listFlavors()).getId();
|
||||
}
|
||||
|
||||
private void blockUntilServerActive(String serverId, ServerClient client) throws InterruptedException {
|
||||
Server currentDetails = null;
|
||||
for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.ACTIVE; currentDetails = client
|
||||
.getServer(serverId)) {
|
||||
System.out.printf("blocking on status active%n%s%n", currentDetails);
|
||||
Thread.sleep(5 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void assertEventually(Runnable assertion) {
|
||||
long start = System.currentTimeMillis();
|
||||
AssertionError error = null;
|
||||
for (int i = 0; i < 30; i++) {
|
||||
try {
|
||||
assertion.run();
|
||||
if (i > 0)
|
||||
System.err.printf("%d attempts and %dms asserting %s%n", i + 1, System.currentTimeMillis() - start,
|
||||
assertion.getClass().getSimpleName());
|
||||
return;
|
||||
} catch (AssertionError e) {
|
||||
error = e;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(INCONSISTENCY_WINDOW / 30);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
if (error != null)
|
||||
throw error;
|
||||
|
||||
}
|
||||
|
||||
public static final class ServerHasFloatingIP implements Runnable {
|
||||
private final ServerClient client;
|
||||
private final String serverId;
|
||||
private final String floatingIP;
|
||||
|
||||
public ServerHasFloatingIP(ServerClient serverClient, String serverId, String floatingIP) {
|
||||
this.client = serverClient;
|
||||
this.serverId = serverId;
|
||||
this.floatingIP = floatingIP;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
Server server = client.getServer(serverId);
|
||||
boolean ipInServerAddresses = false;
|
||||
Multimap<Address.Type, Address>addresses = server.getAddresses();
|
||||
for (Address address : addresses.values()){
|
||||
if (address.getAddr().equals(floatingIP)) {
|
||||
ipInServerAddresses = true;
|
||||
}
|
||||
}
|
||||
assertTrue(ipInServerAddresses);
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
assertTrue(ipInServerAddresses);
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.extensions;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.openstack.nova.v1_1.NovaClient;
|
||||
|
@ -28,11 +31,8 @@ import org.jclouds.openstack.nova.v1_1.parse.ParseKeyPairListTest;
|
|||
import org.jclouds.openstack.nova.v1_1.parse.ParseKeyPairTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Tests annotation parsing of {@code KeyPairAsyncClient}
|
||||
|
@ -40,127 +40,111 @@ import static org.testng.Assert.assertTrue;
|
|||
* @author Michael Arnold
|
||||
*/
|
||||
@Test(groups = "unit", testName = "KeyPairClientExpectTest")
|
||||
public class KeyPairClientExpectTest extends BaseNovaClientExpectTest {
|
||||
public class KeyPairClientExpectTest extends BaseNovaClientExpectTest {
|
||||
|
||||
public void testListKeyPairsWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listKeyPairs = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-keypairs"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
public void testListKeyPairsWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listKeyPairs = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-keypairs"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listKeyPairsResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/keypair_list.json")).build();
|
||||
HttpResponse listKeyPairsResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/keypair_list.json")).build();
|
||||
|
||||
NovaClient clientWhenServersExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
listKeyPairs, listKeyPairsResponse);
|
||||
NovaClient clientWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listKeyPairs, listKeyPairsResponse);
|
||||
|
||||
assertEquals(clientWhenServersExist.getConfiguredRegions(),
|
||||
ImmutableSet.of("North"));
|
||||
assertEquals(clientWhenServersExist.getConfiguredRegions(), ImmutableSet.of("North"));
|
||||
|
||||
assertEquals(clientWhenServersExist.getKeyPairClientForRegion("North")
|
||||
.listKeyPairs().toString(), new ParseKeyPairListTest().expected()
|
||||
.toString());
|
||||
}
|
||||
assertEquals(clientWhenServersExist.getKeyPairClientForRegion("North").listKeyPairs().toString(),
|
||||
new ParseKeyPairListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListKeyPairsWhenResponseIs404() throws Exception {
|
||||
HttpRequest listKeyPairs = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-keypairs"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
public void testListKeyPairsWhenResponseIs404() throws Exception {
|
||||
HttpRequest listKeyPairs = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-keypairs"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listKeyPairsResponse = HttpResponse.builder().statusCode(404)
|
||||
.build();
|
||||
HttpResponse listKeyPairsResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
listKeyPairs, listKeyPairsResponse);
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listKeyPairs, listKeyPairsResponse);
|
||||
|
||||
assertTrue(clientWhenNoServersExist.getKeyPairClientForRegion("North")
|
||||
.listKeyPairs().isEmpty());
|
||||
assertTrue(clientWhenNoServersExist.getKeyPairClientForRegion("North").listKeyPairs().isEmpty());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void testCreateKeyPair() throws Exception {
|
||||
HttpRequest createKeyPair = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-keypairs"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build())
|
||||
.payload(payloadFromStringWithContentType("{\"keypair\":{\"name\":\"testkeypair\"}}",
|
||||
public void testCreateKeyPair() throws Exception {
|
||||
HttpRequest createKeyPair = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-keypairs"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build())
|
||||
.payload(payloadFromStringWithContentType("{\"keypair\":{\"name\":\"testkeypair\"}}", "application/json"))
|
||||
.build();
|
||||
|
||||
HttpResponse createKeyPairResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/keypair_created.json")).build();
|
||||
|
||||
NovaClient clientWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, createKeyPair, createKeyPairResponse);
|
||||
|
||||
assertEquals(clientWhenServersExist.getKeyPairClientForRegion("North").createKeyPair("testkeypair").toString(),
|
||||
new ParseKeyPairTest().expected().toString());
|
||||
|
||||
}
|
||||
|
||||
public void testCreateKeyPairWithPublicKey() throws Exception {
|
||||
HttpRequest createKeyPair = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-keypairs"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build())
|
||||
.payload(
|
||||
payloadFromStringWithContentType(
|
||||
"{\"keypair\":{\"name\":\"testkeypair\",\"public_key\":\"ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001\n\"}}",
|
||||
"application/json")).build();
|
||||
|
||||
HttpResponse createKeyPairResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/keypair_created.json")).build();
|
||||
HttpResponse createKeyPairResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/keypair_created.json")).build();
|
||||
|
||||
NovaClient clientWhenServersExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
createKeyPair, createKeyPairResponse);
|
||||
NovaClient clientWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, createKeyPair, createKeyPairResponse);
|
||||
|
||||
assertEquals(clientWhenServersExist.getKeyPairClientForRegion("North")
|
||||
.createKeyPair("testkeypair").toString(),
|
||||
new ParseKeyPairTest().expected().toString());
|
||||
assertEquals(
|
||||
clientWhenServersExist
|
||||
.getKeyPairClientForRegion("North")
|
||||
.createKeyPairWithPublicKey(
|
||||
"testkeypair",
|
||||
"ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001\n")
|
||||
.toString(), new ParseKeyPairTest().expected().toString());
|
||||
}
|
||||
|
||||
}
|
||||
public void testDeleteKeyPair() throws Exception {
|
||||
HttpRequest deleteKeyPair = HttpRequest
|
||||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-keypairs/testkeypair"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "*/*").put("X-Auth-Token", authToken)
|
||||
.build()).build();
|
||||
|
||||
public void testCreateKeyPairWithPublicKey() throws Exception {
|
||||
HttpRequest createKeyPair = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-keypairs"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build())
|
||||
.payload(payloadFromStringWithContentType("{\"keypair\":{\"name\":\"testkeypair\",\"public_key\":\"ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001\n\"}}",
|
||||
"application/json")).build();
|
||||
HttpResponse deleteKeyPairResponse = HttpResponse.builder().statusCode(202).build();
|
||||
|
||||
HttpResponse createKeyPairResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/keypair_created.json")).build();
|
||||
NovaClient clientWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, deleteKeyPair, deleteKeyPairResponse);
|
||||
|
||||
NovaClient clientWhenServersExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
createKeyPair, createKeyPairResponse);
|
||||
|
||||
assertEquals(clientWhenServersExist.getKeyPairClientForRegion("North")
|
||||
.createKeyPairWithPublicKey("testkeypair", "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001\n")
|
||||
.toString(),
|
||||
new ParseKeyPairTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testDeleteKeyPair() throws Exception {
|
||||
HttpRequest deleteKeyPair = HttpRequest
|
||||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-keypairs/testkeypair"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "*/*")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
|
||||
HttpResponse deleteKeyPairResponse = HttpResponse.builder().statusCode(202).build();
|
||||
|
||||
NovaClient clientWhenServersExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
deleteKeyPair, deleteKeyPairResponse);
|
||||
|
||||
assertTrue(clientWhenServersExist.getKeyPairClientForRegion("North").deleteKeyPair("testkeypair"));
|
||||
}
|
||||
assertTrue(clientWhenServersExist.getKeyPairClientForRegion("North").deleteKeyPair("testkeypair"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,16 +18,14 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.extensions;
|
||||
|
||||
import org.jclouds.openstack.nova.v1_1.domain.KeyPair;
|
||||
import org.jclouds.openstack.nova.v1_1.extensions.KeyPairClient;
|
||||
import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import org.jclouds.openstack.nova.v1_1.domain.KeyPair;
|
||||
import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code KeyPairClient}
|
||||
|
@ -35,47 +33,47 @@ import static org.testng.Assert.assertTrue;
|
|||
* @author Michael Arnold
|
||||
*/
|
||||
@Test(groups = "live", testName = "KeyPairClientLiveTest")
|
||||
public class KeyPairClientLiveTest extends BaseNovaClientLiveTest {
|
||||
public class KeyPairClientLiveTest extends BaseNovaClientLiveTest {
|
||||
|
||||
public void testListKeyPairs() throws Exception {
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
KeyPairClient client = context.getApi().getKeyPairClientForRegion(regionId);
|
||||
Set<Map<String, KeyPair>> keyPairsList = client.listKeyPairs();
|
||||
assertNotNull(keyPairsList);
|
||||
}
|
||||
}
|
||||
public void testListKeyPairs() throws Exception {
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
KeyPairClient client = context.getApi().getKeyPairClientForRegion(regionId);
|
||||
Set<Map<String, KeyPair>> keyPairsList = client.listKeyPairs();
|
||||
assertNotNull(keyPairsList);
|
||||
}
|
||||
}
|
||||
|
||||
public void testCreateAndDeleteKeyPair() throws Exception {
|
||||
final String KEYPAIR_NAME = "testkp";
|
||||
for(String regionId : context.getApi().getConfiguredRegions()) {
|
||||
KeyPairClient client = context.getApi().getKeyPairClientForRegion(regionId);
|
||||
KeyPair keyPair = null;
|
||||
try {
|
||||
keyPair = client.createKeyPair(KEYPAIR_NAME);
|
||||
assertNotNull(keyPair);
|
||||
} finally {
|
||||
if (keyPair != null) {
|
||||
client.deleteKeyPair(KEYPAIR_NAME);
|
||||
}
|
||||
public void testCreateAndDeleteKeyPair() throws Exception {
|
||||
final String KEYPAIR_NAME = "testkp";
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
KeyPairClient client = context.getApi().getKeyPairClientForRegion(regionId);
|
||||
KeyPair keyPair = null;
|
||||
try {
|
||||
keyPair = client.createKeyPair(KEYPAIR_NAME);
|
||||
assertNotNull(keyPair);
|
||||
} finally {
|
||||
if (keyPair != null) {
|
||||
client.deleteKeyPair(KEYPAIR_NAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testCreateAndDeleteKeyPairWithPublicKey() throws Exception {
|
||||
final String KEYPAIR_NAME = "testkp";
|
||||
final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrrBREFxz3002l1HuXz0+UOdJQ/mOYD5DiJwwB/TOybwIKQJPOxJWA9gBoo4k9dthTKBTaEYbzrll7iZcp59E80S6mNiAr3mUgi+x5Y8uyXeJ2Ws+h6peVyFVUu9epkwpcTd1GVfdcVWsTajwDz9+lxCDhl0RZKDFoT0scTxbj/w== nova@nv-aw2az2-api0002";
|
||||
public void testCreateAndDeleteKeyPairWithPublicKey() throws Exception {
|
||||
final String KEYPAIR_NAME = "testkp";
|
||||
final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrrBREFxz3002l1HuXz0+UOdJQ/mOYD5DiJwwB/TOybwIKQJPOxJWA9gBoo4k9dthTKBTaEYbzrll7iZcp59E80S6mNiAr3mUgi+x5Y8uyXeJ2Ws+h6peVyFVUu9epkwpcTd1GVfdcVWsTajwDz9+lxCDhl0RZKDFoT0scTxbj/w== nova@nv-aw2az2-api0002";
|
||||
|
||||
for(String regionId : context.getApi().getConfiguredRegions()) {
|
||||
KeyPairClient client = context.getApi().getKeyPairClientForRegion(regionId);
|
||||
KeyPair keyPair = null;
|
||||
try {
|
||||
keyPair = client.createKeyPairWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY);
|
||||
assertNotNull(keyPair);
|
||||
} finally {
|
||||
if (keyPair != null) {
|
||||
client.deleteKeyPair(KEYPAIR_NAME);
|
||||
}
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
KeyPairClient client = context.getApi().getKeyPairClientForRegion(regionId);
|
||||
KeyPair keyPair = null;
|
||||
try {
|
||||
keyPair = client.createKeyPairWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY);
|
||||
assertNotNull(keyPair);
|
||||
} finally {
|
||||
if (keyPair != null) {
|
||||
client.deleteKeyPair(KEYPAIR_NAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
package org.jclouds.openstack.nova.v1_1.extensions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.openstack.nova.v1_1.NovaClient;
|
||||
|
@ -34,13 +34,10 @@ import org.jclouds.openstack.nova.v1_1.parse.ParseSecurityGroupListTest;
|
|||
import org.jclouds.openstack.nova.v1_1.parse.ParseSecurityGroupTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests annotation parsing of {@code SecurityGroupAsyncClient}
|
||||
*
|
||||
|
@ -48,218 +45,177 @@ import static org.testng.Assert.assertTrue;
|
|||
*/
|
||||
@Test(groups = "unit", testName = "SecurityGroupClientExpectTest")
|
||||
public class SecurityGroupClientExpectTest extends BaseNovaClientExpectTest {
|
||||
public void testListSecurityGroupsWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listSecurityGroups = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-security-groups"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
public void testListSecurityGroupsWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listSecurityGroups = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-security-groups"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listSecurityGroupsResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/securitygroup_list.json")).build();
|
||||
HttpResponse listSecurityGroupsResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/securitygroup_list.json")).build();
|
||||
|
||||
NovaClient clientWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listSecurityGroups, listSecurityGroupsResponse);
|
||||
|
||||
NovaClient clientWhenSecurityGroupsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
listSecurityGroups, listSecurityGroupsResponse);
|
||||
assertEquals(clientWhenSecurityGroupsExist.getConfiguredRegions(), ImmutableSet.of("North"));
|
||||
|
||||
assertEquals(clientWhenSecurityGroupsExist.getConfiguredRegions(),
|
||||
ImmutableSet.of("North"));
|
||||
assertEquals(clientWhenSecurityGroupsExist.getSecurityGroupClientForRegion("North").listSecurityGroups()
|
||||
.toString(), new ParseSecurityGroupListTest().expected().toString());
|
||||
}
|
||||
|
||||
assertEquals(clientWhenSecurityGroupsExist.getSecurityGroupClientForRegion("North")
|
||||
.listSecurityGroups().toString(), new ParseSecurityGroupListTest().expected()
|
||||
.toString());
|
||||
}
|
||||
public void testListSecurityGroupsWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest listListSecurityGroups = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-security-groups"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
public void testListSecurityGroupsWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest listListSecurityGroups = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-security-groups"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
HttpResponse listListSecurityGroupsResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
HttpResponse listListSecurityGroupsResponse = HttpResponse.builder().statusCode(404)
|
||||
.build();
|
||||
NovaClient clientWhenNoSecurityGroupsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listListSecurityGroups, listListSecurityGroupsResponse);
|
||||
|
||||
NovaClient clientWhenNoSecurityGroupsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
listListSecurityGroups, listListSecurityGroupsResponse);
|
||||
assertTrue(clientWhenNoSecurityGroupsExist.getSecurityGroupClientForRegion("North").listSecurityGroups()
|
||||
.isEmpty());
|
||||
}
|
||||
|
||||
assertTrue(clientWhenNoSecurityGroupsExist.getSecurityGroupClientForRegion("North")
|
||||
.listSecurityGroups().isEmpty());
|
||||
}
|
||||
public void testGetSecurityGroupWhenResponseIs2xx() throws Exception {
|
||||
|
||||
public void testGetSecurityGroupWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest getSecurityGroup = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-security-groups/0"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpRequest getSecurityGroup = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-security-groups/0"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/securitygroup_details.json")).build();
|
||||
|
||||
HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/securitygroup_details.json")).build();
|
||||
NovaClient clientWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, getSecurityGroup, getSecurityGroupResponse);
|
||||
|
||||
NovaClient clientWhenSecurityGroupsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
getSecurityGroup, getSecurityGroupResponse);
|
||||
assertEquals(clientWhenSecurityGroupsExist.getSecurityGroupClientForRegion("North").getSecurityGroup("0")
|
||||
.toString(), new ParseSecurityGroupTest().expected().toString());
|
||||
}
|
||||
|
||||
assertEquals(clientWhenSecurityGroupsExist.getSecurityGroupClientForRegion("North")
|
||||
.getSecurityGroup("0").toString(),
|
||||
new ParseSecurityGroupTest().expected().toString());
|
||||
}
|
||||
public void testGetSecurityGroupWhenResponseIs404() throws Exception {
|
||||
HttpRequest getSecurityGroup = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-security-groups/0"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
public void testGetSecurityGroupWhenResponseIs404() throws Exception {
|
||||
HttpRequest getSecurityGroup = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-security-groups/0"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(404).build();
|
||||
NovaClient clientWhenNoSecurityGroupsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, getSecurityGroup, getSecurityGroupResponse);
|
||||
|
||||
NovaClient clientWhenNoSecurityGroupsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
getSecurityGroup, getSecurityGroupResponse);
|
||||
assertNull(clientWhenNoSecurityGroupsExist.getSecurityGroupClientForRegion("North").getSecurityGroup("0"));
|
||||
|
||||
assertNull(clientWhenNoSecurityGroupsExist.getSecurityGroupClientForRegion("North").getSecurityGroup("0"));
|
||||
}
|
||||
|
||||
}
|
||||
public void testCreateSecurityGroupWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest createSecurityGroup = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-security-groups"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build())
|
||||
.payload(
|
||||
payloadFromStringWithContentType(
|
||||
"{\"security_group\":{\"name\":\"name\",\"description\":\"description\"}}", "application/json"))
|
||||
.build();
|
||||
|
||||
public void testCreateSecurityGroupWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest createSecurityGroup = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-security-groups"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build())
|
||||
.payload(payloadFromStringWithContentType("{\"security_group\":{\"name\":\"name\",\"description\":\"description\"}}",
|
||||
HttpResponse createSecurityGroupResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/securitygroup_created.json")).build();
|
||||
|
||||
NovaClient clientWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, createSecurityGroup, createSecurityGroupResponse);
|
||||
|
||||
assertEquals(
|
||||
clientWhenSecurityGroupsExist.getSecurityGroupClientForRegion("North")
|
||||
.createSecurityGroup("name", "description").toString(), createSecurityGroupExpected().toString());
|
||||
}
|
||||
|
||||
public void testDeleteSecurityGroupWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest deleteSecurityGroup = HttpRequest
|
||||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-security-groups/160"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "*/*").put("X-Auth-Token", authToken)
|
||||
.build()).build();
|
||||
|
||||
HttpResponse deleteSecurityGroupResponse = HttpResponse.builder().statusCode(202).build();
|
||||
|
||||
NovaClient clientWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, deleteSecurityGroup, deleteSecurityGroupResponse);
|
||||
|
||||
assertTrue(clientWhenServersExist.getSecurityGroupClientForRegion("North").deleteSecurityGroup("160"));
|
||||
|
||||
}
|
||||
|
||||
public void testCreateSecurityGroupRuleWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest createSecurityGroupRule = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-security-group-rules"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build())
|
||||
.payload(
|
||||
payloadFromStringWithContentType(
|
||||
"{\"security_group_rule\":{\"ip_protocol\":\"tcp\",\"from_port\":\"80\",\"to_port\":\"8080\",\"cidr\":\"0.0.0.0/0\",\"group_id\":\"\",\"parent_group_id\":\"161\"}}",
|
||||
"application/json")).build();
|
||||
|
||||
HttpResponse createSecurityGroupResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/securitygroup_created.json")).build();
|
||||
HttpResponse createSecurityGroupRuleResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/securitygrouprule_created.json")).build();
|
||||
|
||||
NovaClient clientWhenSecurityGroupsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
createSecurityGroup, createSecurityGroupResponse);
|
||||
NovaClient clientWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, createSecurityGroupRule, createSecurityGroupRuleResponse);
|
||||
|
||||
assertEquals(clientWhenSecurityGroupsExist.getSecurityGroupClientForRegion("North")
|
||||
.createSecurityGroup("name", "description").toString(),
|
||||
createSecurityGroupExpected().toString());
|
||||
}
|
||||
assertEquals(
|
||||
clientWhenSecurityGroupsExist.getSecurityGroupClientForRegion("North")
|
||||
.createSecurityGroupRule("tcp", "80", "8080", "0.0.0.0/0", "", "161").toString(),
|
||||
createSecurityGroupRuleExpected().toString());
|
||||
}
|
||||
|
||||
public void testDeleteSecurityGroupWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest deleteSecurityGroup = HttpRequest
|
||||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-security-groups/160"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "*/*")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
public void testDeleteSecurityGroupRuleWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest deleteSecurityGroupRule = HttpRequest
|
||||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/os-security-group-rules/161"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "*/*").put("X-Auth-Token", authToken)
|
||||
.build()).build();
|
||||
|
||||
HttpResponse deleteSecurityGroupRuleResponse = HttpResponse.builder().statusCode(202).build();
|
||||
|
||||
HttpResponse deleteSecurityGroupResponse = HttpResponse.builder().statusCode(202).build();
|
||||
NovaClient clientWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, deleteSecurityGroupRule, deleteSecurityGroupRuleResponse);
|
||||
|
||||
NovaClient clientWhenServersExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
deleteSecurityGroup, deleteSecurityGroupResponse);
|
||||
assertTrue(clientWhenSecurityGroupsExist.getSecurityGroupClientForRegion("North").deleteSecurityGroupRule("161"));
|
||||
|
||||
assertTrue(clientWhenServersExist.getSecurityGroupClientForRegion("North").deleteSecurityGroup("160"));
|
||||
}
|
||||
|
||||
}
|
||||
private SecurityGroup createSecurityGroupExpected() {
|
||||
return SecurityGroup.builder().description("description").id("160").name("name")
|
||||
.rules(ImmutableSet.<SecurityGroupRule> of()).tenantId("dev_16767499955063").build();
|
||||
}
|
||||
|
||||
public void testCreateSecurityGroupRuleWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest createSecurityGroupRule = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-security-group-rules"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String>builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build())
|
||||
.payload(payloadFromStringWithContentType("{\"security_group_rule\":{\"ip_protocol\":\"tcp\",\"from_port\":\"80\",\"to_port\":\"8080\",\"cidr\":\"0.0.0.0/0\",\"group_id\":\"\",\"parent_group_id\":\"161\"}}",
|
||||
"application/json")).build();
|
||||
|
||||
|
||||
HttpResponse createSecurityGroupRuleResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/securitygrouprule_created.json")).build();
|
||||
|
||||
NovaClient clientWhenSecurityGroupsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
createSecurityGroupRule, createSecurityGroupRuleResponse);
|
||||
|
||||
assertEquals(clientWhenSecurityGroupsExist.getSecurityGroupClientForRegion("North")
|
||||
.createSecurityGroupRule("tcp", "80", "8080", "0.0.0.0/0", "", "161").toString(),
|
||||
createSecurityGroupRuleExpected().toString());
|
||||
}
|
||||
|
||||
public void testDeleteSecurityGroupRuleWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest deleteSecurityGroupRule = HttpRequest
|
||||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/os-security-group-rules/161"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "*/*")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
|
||||
HttpResponse deleteSecurityGroupRuleResponse = HttpResponse.builder().statusCode(202).build();
|
||||
|
||||
NovaClient clientWhenSecurityGroupsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
deleteSecurityGroupRule, deleteSecurityGroupRuleResponse);
|
||||
|
||||
assertTrue(clientWhenSecurityGroupsExist.getSecurityGroupClientForRegion("North")
|
||||
.deleteSecurityGroupRule("161"));
|
||||
|
||||
}
|
||||
|
||||
private SecurityGroup createSecurityGroupExpected() {
|
||||
return SecurityGroup
|
||||
.builder()
|
||||
.description("description")
|
||||
.id("160")
|
||||
.name("name")
|
||||
.rules(ImmutableSet.<SecurityGroupRule> of())
|
||||
.tenantId("dev_16767499955063")
|
||||
.build();
|
||||
}
|
||||
|
||||
private SecurityGroupRule createSecurityGroupRuleExpected() {
|
||||
return SecurityGroupRule
|
||||
.builder()
|
||||
.fromPort(80)
|
||||
.group(ImmutableMap.<String, String> of())
|
||||
.id("218")
|
||||
.ipProtocol(SecurityGroupRule.IpProtocol.TCP)
|
||||
.ipRange(ImmutableMap.of("cidr","0.0.0.0/0"))
|
||||
.parentGroupId("161")
|
||||
.toPort(8080)
|
||||
.build();
|
||||
}
|
||||
private SecurityGroupRule createSecurityGroupRuleExpected() {
|
||||
return SecurityGroupRule.builder().fromPort(80).group(ImmutableMap.<String, String> of()).id("218")
|
||||
.ipProtocol(SecurityGroupRule.IpProtocol.TCP).ipRange(ImmutableMap.of("cidr", "0.0.0.0/0"))
|
||||
.parentGroupId("161").toPort(8080).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.extensions;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.openstack.nova.v1_1.domain.SecurityGroup;
|
||||
import org.jclouds.openstack.nova.v1_1.domain.SecurityGroupRule;
|
||||
import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code SecurityGroupClient}
|
||||
*
|
||||
|
@ -35,54 +35,54 @@ import static org.testng.Assert.assertNotNull;
|
|||
@Test(groups = "live", testName = "SecurityGroupClientLiveTest")
|
||||
public class SecurityGroupClientLiveTest extends BaseNovaClientLiveTest {
|
||||
|
||||
public static final String SECURITY_GROUP_NAME = "testsg";
|
||||
public static final String SECURITY_GROUP_NAME = "testsg";
|
||||
|
||||
public void listSecurityGroups() throws Exception {
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
SecurityGroupClient client = context.getApi().getSecurityGroupClientForRegion(regionId);
|
||||
Set<SecurityGroup> securityGroupsList = client.listSecurityGroups();
|
||||
assertNotNull(securityGroupsList);
|
||||
}
|
||||
}
|
||||
public void listSecurityGroups() throws Exception {
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
SecurityGroupClient client = context.getApi().getSecurityGroupClientForRegion(regionId);
|
||||
Set<SecurityGroup> securityGroupsList = client.listSecurityGroups();
|
||||
assertNotNull(securityGroupsList);
|
||||
}
|
||||
}
|
||||
|
||||
public void createGetAndDeleteSecurityGroup() throws Exception {
|
||||
for(String regionId : context.getApi().getConfiguredRegions()) {
|
||||
SecurityGroupClient client = context.getApi().getSecurityGroupClientForRegion(regionId);
|
||||
SecurityGroup securityGroup = null;
|
||||
String id;
|
||||
try {
|
||||
securityGroup = client.createSecurityGroup(SECURITY_GROUP_NAME, "test security group");
|
||||
assertNotNull(securityGroup);
|
||||
id = securityGroup.getId();
|
||||
SecurityGroup theGroup = client.getSecurityGroup(id);
|
||||
assertNotNull(theGroup);
|
||||
} finally {
|
||||
if (securityGroup != null) {
|
||||
client.deleteSecurityGroup(securityGroup.getId());
|
||||
}
|
||||
public void createGetAndDeleteSecurityGroup() throws Exception {
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
SecurityGroupClient client = context.getApi().getSecurityGroupClientForRegion(regionId);
|
||||
SecurityGroup securityGroup = null;
|
||||
String id;
|
||||
try {
|
||||
securityGroup = client.createSecurityGroup(SECURITY_GROUP_NAME, "test security group");
|
||||
assertNotNull(securityGroup);
|
||||
id = securityGroup.getId();
|
||||
SecurityGroup theGroup = client.getSecurityGroup(id);
|
||||
assertNotNull(theGroup);
|
||||
} finally {
|
||||
if (securityGroup != null) {
|
||||
client.deleteSecurityGroup(securityGroup.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void createAndDeleteSecurityGroupRule() throws Exception {
|
||||
for(String regionId : context.getApi().getConfiguredRegions()) {
|
||||
SecurityGroupClient client = context.getApi().getSecurityGroupClientForRegion(regionId);
|
||||
SecurityGroup securityGroup = null;
|
||||
public void createAndDeleteSecurityGroupRule() throws Exception {
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
SecurityGroupClient client = context.getApi().getSecurityGroupClientForRegion(regionId);
|
||||
SecurityGroup securityGroup = null;
|
||||
|
||||
try {
|
||||
securityGroup = client.createSecurityGroup(SECURITY_GROUP_NAME, "test security group");
|
||||
assertNotNull(securityGroup);
|
||||
try {
|
||||
securityGroup = client.createSecurityGroup(SECURITY_GROUP_NAME, "test security group");
|
||||
assertNotNull(securityGroup);
|
||||
|
||||
SecurityGroupRule rule = client.createSecurityGroupRule(
|
||||
"tcp", "443", "443", "0.0.0.0/0", "", securityGroup.getId());
|
||||
assertNotNull(rule);
|
||||
SecurityGroupRule rule = client.createSecurityGroupRule("tcp", "443", "443", "0.0.0.0/0", "",
|
||||
securityGroup.getId());
|
||||
assertNotNull(rule);
|
||||
|
||||
} finally {
|
||||
if (securityGroup != null) {
|
||||
client.deleteSecurityGroup(securityGroup.getId());
|
||||
}
|
||||
} finally {
|
||||
if (securityGroup != null) {
|
||||
client.deleteSecurityGroup(securityGroup.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,48 +47,38 @@ public class ExtensionClientExpectTest extends BaseNovaClientExpectTest {
|
|||
HttpRequest listExtensions = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/extensions"))
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/extensions"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listExtensionsResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/extension_list.json")).build();
|
||||
|
||||
NovaClient clientWhenExtensionsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
listExtensions, listExtensionsResponse);
|
||||
NovaClient clientWhenExtensionsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listExtensions, listExtensionsResponse);
|
||||
|
||||
assertEquals(clientWhenExtensionsExist.getConfiguredRegions(),
|
||||
ImmutableSet.of("North"));
|
||||
assertEquals(clientWhenExtensionsExist.getConfiguredRegions(), ImmutableSet.of("North"));
|
||||
|
||||
assertEquals(clientWhenExtensionsExist.getExtensionClientForRegion("North")
|
||||
.listExtensions().toString(), new ParseExtensionListTest().expected()
|
||||
.toString());
|
||||
assertEquals(clientWhenExtensionsExist.getExtensionClientForRegion("North").listExtensions().toString(),
|
||||
new ParseExtensionListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListExtensionsWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest listExtensions = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/extensions"))
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/extensions"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listExtensionsResponse = HttpResponse.builder().statusCode(404)
|
||||
.build();
|
||||
HttpResponse listExtensionsResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
listExtensions, listExtensionsResponse);
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listExtensions, listExtensionsResponse);
|
||||
|
||||
assertTrue(clientWhenNoServersExist.getExtensionClientForRegion("North")
|
||||
.listExtensions().isEmpty());
|
||||
assertTrue(clientWhenNoServersExist.getExtensionClientForRegion("North").listExtensions().isEmpty());
|
||||
}
|
||||
|
||||
// TODO: gson deserializer for Multimap
|
||||
|
@ -97,42 +87,35 @@ public class ExtensionClientExpectTest extends BaseNovaClientExpectTest {
|
|||
HttpRequest getExtension = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/extensions/RS-PIE"))
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/extensions/RS-PIE"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse getExtensionResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/extension_details.json")).build();
|
||||
|
||||
NovaClient clientWhenExtensionsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
getExtension, getExtensionResponse);
|
||||
NovaClient clientWhenExtensionsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, getExtension, getExtensionResponse);
|
||||
|
||||
assertEquals(clientWhenExtensionsExist.getExtensionClientForRegion("North")
|
||||
.getExtensionByAlias("RS-PIE").toString(),
|
||||
new ParseExtensionTest().expected().toString());
|
||||
assertEquals(clientWhenExtensionsExist.getExtensionClientForRegion("North").getExtensionByAlias("RS-PIE")
|
||||
.toString(), new ParseExtensionTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testGetExtensionByAliasWhenResponseIs404() throws Exception {
|
||||
HttpRequest getExtension = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/extensions/RS-PIE"))
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/extensions/RS-PIE"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse getExtensionResponse = HttpResponse.builder().statusCode(404)
|
||||
.payload(payloadFromResource("/extension_details.json")).build();
|
||||
|
||||
NovaClient clientWhenNoExtensionsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
getExtension, getExtensionResponse);
|
||||
NovaClient clientWhenNoExtensionsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, getExtension, getExtensionResponse);
|
||||
|
||||
assertNull(clientWhenNoExtensionsExist.getExtensionClientForRegion("North").getExtensionByAlias("RS-PIE"));
|
||||
|
||||
|
|
|
@ -47,48 +47,38 @@ public class FlavorClientExpectTest extends BaseNovaClientExpectTest {
|
|||
HttpRequest listFlavors = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/flavors"))
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/flavors"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listFlavorsResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/flavor_list.json")).build();
|
||||
|
||||
NovaClient clientWhenFlavorsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
listFlavors, listFlavorsResponse);
|
||||
NovaClient clientWhenFlavorsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listFlavors, listFlavorsResponse);
|
||||
|
||||
assertEquals(clientWhenFlavorsExist.getConfiguredRegions(),
|
||||
ImmutableSet.of("North"));
|
||||
assertEquals(clientWhenFlavorsExist.getConfiguredRegions(), ImmutableSet.of("North"));
|
||||
|
||||
assertEquals(clientWhenFlavorsExist.getFlavorClientForRegion("North")
|
||||
.listFlavors().toString(), new ParseFlavorListTest().expected()
|
||||
.toString());
|
||||
assertEquals(clientWhenFlavorsExist.getFlavorClientForRegion("North").listFlavors().toString(),
|
||||
new ParseFlavorListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListFlavorsWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest listFlavors = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/flavors"))
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/flavors"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listFlavorsResponse = HttpResponse.builder().statusCode(404)
|
||||
.build();
|
||||
HttpResponse listFlavorsResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
listFlavors, listFlavorsResponse);
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listFlavors, listFlavorsResponse);
|
||||
|
||||
assertTrue(clientWhenNoServersExist.getFlavorClientForRegion("North")
|
||||
.listFlavors().isEmpty());
|
||||
assertTrue(clientWhenNoServersExist.getFlavorClientForRegion("North").listFlavors().isEmpty());
|
||||
}
|
||||
|
||||
// TODO: gson deserializer for Multimap
|
||||
|
@ -97,42 +87,36 @@ public class FlavorClientExpectTest extends BaseNovaClientExpectTest {
|
|||
HttpRequest getFlavor = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/flavors/52415800-8b69-11e0-9b19-734f1195ff37"))
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/flavors/52415800-8b69-11e0-9b19-734f1195ff37"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse getFlavorResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/flavor_details.json")).build();
|
||||
|
||||
NovaClient clientWhenFlavorsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
getFlavor, getFlavorResponse);
|
||||
NovaClient clientWhenFlavorsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, getFlavor, getFlavorResponse);
|
||||
|
||||
assertEquals(clientWhenFlavorsExist.getFlavorClientForRegion("North")
|
||||
.getFlavor("52415800-8b69-11e0-9b19-734f1195ff37").toString(),
|
||||
new ParseFlavorTest().expected().toString());
|
||||
assertEquals(
|
||||
clientWhenFlavorsExist.getFlavorClientForRegion("North").getFlavor("52415800-8b69-11e0-9b19-734f1195ff37")
|
||||
.toString(), new ParseFlavorTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testGetFlavorWhenResponseIs404() throws Exception {
|
||||
HttpRequest getFlavor = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/flavors/123"))
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/flavors/123"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse getFlavorResponse = HttpResponse.builder().statusCode(404)
|
||||
.payload(payloadFromResource("/flavor_details.json")).build();
|
||||
|
||||
NovaClient clientWhenNoFlavorsExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
getFlavor, getFlavorResponse);
|
||||
NovaClient clientWhenNoFlavorsExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, getFlavor, getFlavorResponse);
|
||||
|
||||
assertNull(clientWhenNoFlavorsExist.getFlavorClientForRegion("North").getFlavor("123"));
|
||||
|
||||
|
|
|
@ -18,21 +18,22 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.features;
|
||||
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.openstack.nova.v1_1.NovaClient;
|
||||
import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientExpectTest;
|
||||
import org.jclouds.openstack.nova.v1_1.parse.ParseImageTest;
|
||||
import org.jclouds.openstack.nova.v1_1.parse.ParseImageListTest;
|
||||
import org.jclouds.openstack.nova.v1_1.parse.ParseImageTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Tests annotation parsing of {@code ImageAsyncClient}
|
||||
|
@ -40,99 +41,83 @@ import static org.testng.Assert.assertTrue;
|
|||
* @author Michael Arnold
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ImageAsyncClientTest")
|
||||
public class ImageClientExpectTest extends BaseNovaClientExpectTest {
|
||||
public void testListImagesWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listImages = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/images"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
public class ImageClientExpectTest extends BaseNovaClientExpectTest {
|
||||
public void testListImagesWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listImages = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/images"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listImagesResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/image_list.json")).build();
|
||||
HttpResponse listImagesResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/image_list.json")).build();
|
||||
|
||||
NovaClient clientWhenImagesExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
listImages, listImagesResponse);
|
||||
NovaClient clientWhenImagesExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listImages, listImagesResponse);
|
||||
|
||||
assertEquals(clientWhenImagesExist.getConfiguredRegions(),
|
||||
ImmutableSet.of("North"));
|
||||
assertEquals(clientWhenImagesExist.getConfiguredRegions(), ImmutableSet.of("North"));
|
||||
|
||||
assertEquals(clientWhenImagesExist.getImageClientForRegion("North")
|
||||
.listImages().toString(), new ParseImageListTest().expected()
|
||||
.toString());
|
||||
}
|
||||
assertEquals(clientWhenImagesExist.getImageClientForRegion("North").listImages().toString(),
|
||||
new ParseImageListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListImagesWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest listImages = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/images"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
public void testListImagesWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest listImages = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/images"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listImagesResponse = HttpResponse.builder().statusCode(404).build();
|
||||
HttpResponse listImagesResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
listImages, listImagesResponse);
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listImages, listImagesResponse);
|
||||
|
||||
assertTrue(clientWhenNoServersExist.getImageClientForRegion("North")
|
||||
.listImages().isEmpty());
|
||||
}
|
||||
assertTrue(clientWhenNoServersExist.getImageClientForRegion("North").listImages().isEmpty());
|
||||
}
|
||||
|
||||
public void testGetImageWhenResponseIs2xx() throws Exception {
|
||||
public void testGetImageWhenResponseIs2xx() throws Exception {
|
||||
|
||||
HttpRequest getImage = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
HttpRequest getImage = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse getImageResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/image_details.json")).build();
|
||||
HttpResponse getImageResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/image_details.json")).build();
|
||||
|
||||
NovaClient clientWhenImagesExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
getImage, getImageResponse);
|
||||
NovaClient clientWhenImagesExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, getImage, getImageResponse);
|
||||
|
||||
assertEquals(clientWhenImagesExist.getImageClientForRegion("North")
|
||||
.getImage("52415800-8b69-11e0-9b19-734f5736d2a2").toString(),
|
||||
new ParseImageTest().expected().toString());
|
||||
}
|
||||
assertEquals(
|
||||
clientWhenImagesExist.getImageClientForRegion("North").getImage("52415800-8b69-11e0-9b19-734f5736d2a2")
|
||||
.toString(), new ParseImageTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testGetImageWhenResponseIs404() throws Exception {
|
||||
HttpRequest getImage = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
public void testGetImageWhenResponseIs404() throws Exception {
|
||||
HttpRequest getImage = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse getImageResponse = HttpResponse.builder().statusCode(404).build();
|
||||
HttpResponse getImageResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaClient clientWhenNoImagesExist = requestsSendResponses(
|
||||
keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess,
|
||||
getImage, getImageResponse);
|
||||
NovaClient clientWhenNoImagesExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, getImage, getImageResponse);
|
||||
|
||||
assertNull(clientWhenNoImagesExist.getImageClientForRegion("North")
|
||||
.getImage("52415800-8b69-11e0-9b19-734f5736d2a2"));
|
||||
|
||||
}
|
||||
assertNull(clientWhenNoImagesExist.getImageClientForRegion("North").getImage(
|
||||
"52415800-8b69-11e0-9b19-734f5736d2a2"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,15 +18,17 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
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.testng.annotations.Test;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ImageClient}
|
||||
*
|
||||
|
@ -35,47 +37,46 @@ import static org.testng.Assert.*;
|
|||
@Test(groups = "live", testName = "ImageClientLiveTest")
|
||||
public class ImageClientLiveTest extends BaseNovaClientLiveTest {
|
||||
|
||||
@Test
|
||||
public void testListImages() throws Exception {
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
ImageClient client = context.getApi().getImageClientForRegion(regionId);
|
||||
Set<Resource> response = client.listImages();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.size() >= 0);
|
||||
for (Resource image : response) {
|
||||
Image newDetails = client.getImage(image.getId());
|
||||
assertNotNull(newDetails);
|
||||
assertEquals(newDetails.getId(), image.getId());
|
||||
assertEquals(newDetails.getName(), image.getName());
|
||||
assertEquals(newDetails.getLinks(), image.getLinks());
|
||||
}
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testListImages() throws Exception {
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
ImageClient client = context.getApi().getImageClientForRegion(regionId);
|
||||
Set<Resource> response = client.listImages();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.size() >= 0);
|
||||
for (Resource image : response) {
|
||||
Image newDetails = client.getImage(image.getId());
|
||||
assertNotNull(newDetails);
|
||||
assertEquals(newDetails.getId(), image.getId());
|
||||
assertEquals(newDetails.getName(), image.getName());
|
||||
assertEquals(newDetails.getLinks(), image.getLinks());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListImagesInDetail() throws Exception {
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
ImageClient client = context.getApi().getImageClientForRegion(regionId);
|
||||
Set<Image> response = client.listImagesInDetail();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.size() >= 0);
|
||||
for (Image image : response) {
|
||||
Image newDetails = client.getImage(image.getId());
|
||||
assertNotNull(newDetails);
|
||||
assertEquals(newDetails.getId(), image.getId());
|
||||
assertEquals(newDetails.getName(), image.getName());
|
||||
assertEquals(newDetails.getLinks(), image.getLinks());
|
||||
assertEquals(newDetails.getCreated(), image.getCreated());
|
||||
assertEquals(newDetails.getMinDisk(), image.getMinDisk());
|
||||
assertEquals(newDetails.getMinRam(), image.getMinRam());
|
||||
assertEquals(newDetails.getProgress(), image.getProgress());
|
||||
assertEquals(newDetails.getStatus(), image.getStatus());
|
||||
assertEquals(newDetails.getServer(), image.getServer());
|
||||
assertEquals(newDetails.getTenantId(), image.getTenantId());
|
||||
assertEquals(newDetails.getUpdated(), image.getUpdated());
|
||||
assertEquals(newDetails.getUserId(), image.getUserId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testListImagesInDetail() throws Exception {
|
||||
for (String regionId : context.getApi().getConfiguredRegions()) {
|
||||
ImageClient client = context.getApi().getImageClientForRegion(regionId);
|
||||
Set<Image> response = client.listImagesInDetail();
|
||||
assertNotNull(response);
|
||||
assertTrue(response.size() >= 0);
|
||||
for (Image image : response) {
|
||||
Image newDetails = client.getImage(image.getId());
|
||||
assertNotNull(newDetails);
|
||||
assertEquals(newDetails.getId(), image.getId());
|
||||
assertEquals(newDetails.getName(), image.getName());
|
||||
assertEquals(newDetails.getLinks(), image.getLinks());
|
||||
assertEquals(newDetails.getCreated(), image.getCreated());
|
||||
assertEquals(newDetails.getMinDisk(), image.getMinDisk());
|
||||
assertEquals(newDetails.getMinRam(), image.getMinRam());
|
||||
assertEquals(newDetails.getProgress(), image.getProgress());
|
||||
assertEquals(newDetails.getStatus(), image.getStatus());
|
||||
assertEquals(newDetails.getServer(), image.getServer());
|
||||
assertEquals(newDetails.getTenantId(), image.getTenantId());
|
||||
assertEquals(newDetails.getUpdated(), image.getUpdated());
|
||||
assertEquals(newDetails.getUserId(), image.getUserId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,33 +42,39 @@ import com.google.common.collect.ImmutableSet;
|
|||
public class ServerClientExpectTest extends BaseNovaClientExpectTest {
|
||||
|
||||
public void testListServersWhenResponseIs2xx() throws Exception {
|
||||
HttpRequest listServers = HttpRequest.builder().method("GET").endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/servers")).headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
|
||||
authToken).build()).build();
|
||||
HttpRequest listServers = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/servers"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listServersResponse = HttpResponse.builder().statusCode(200).payload(
|
||||
payloadFromResource("/server_list.json")).build();
|
||||
HttpResponse listServersResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/server_list.json")).build();
|
||||
|
||||
NovaClient clientWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||
|
||||
assertEquals(clientWhenServersExist.getConfiguredRegions(), ImmutableSet.of("North"));
|
||||
|
||||
assertEquals(clientWhenServersExist.getServerClientForRegion("North").listServers().toString(),
|
||||
new ParseServerListTest().expected().toString());
|
||||
new ParseServerListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListServersWhenReponseIs404IsEmpty() throws Exception {
|
||||
HttpRequest listServers = HttpRequest.builder().method("GET").endpoint(
|
||||
URI.create("https://compute.north.host/v1.1/3456/servers")).headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
|
||||
authToken).build()).build();
|
||||
HttpRequest listServers = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint(URI.create("https://compute.north.host/v1.1/3456/servers"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse listServersResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NovaClient clientWhenNoServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKey,
|
||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||
responseWithKeystoneAccess, listServers, listServersResponse);
|
||||
|
||||
assertTrue(clientWhenNoServersExist.getServerClientForRegion("North").listServers().isEmpty());
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ public class BaseNovaClientLiveTest extends BaseVersionedServiceLiveTest {
|
|||
provider = "openstack-nova";
|
||||
}
|
||||
|
||||
|
||||
protected RestContext<NovaClient, NovaAsyncClient> context;
|
||||
|
||||
@BeforeGroups(groups = { "live" })
|
||||
|
@ -53,7 +52,7 @@ public class BaseNovaClientLiveTest extends BaseVersionedServiceLiveTest {
|
|||
setupCredentials();
|
||||
Properties overrides = setupProperties();
|
||||
context = new RestContextFactory().createContext(provider, identity, credential,
|
||||
ImmutableSet.<Module> of(new SLF4JLoggingModule(), new SshjSshClientModule()), overrides);
|
||||
ImmutableSet.<Module> of(new SLF4JLoggingModule(), new SshjSshClientModule()), overrides);
|
||||
}
|
||||
|
||||
@AfterGroups(groups = "live")
|
||||
|
|
|
@ -37,12 +37,12 @@ public class BaseNovaExpectTest<T> extends BaseRestClientExpectTest<T> {
|
|||
public BaseNovaExpectTest() {
|
||||
provider = "openstack-nova";
|
||||
keystoneAuthWithUsernameAndPassword = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPassword(identity,
|
||||
credential);
|
||||
credential);
|
||||
keystoneAuthWithAccessKeyAndSecretKey = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKey(identity,
|
||||
credential);
|
||||
credential);
|
||||
authToken = KeystoneFixture.INSTANCE.getAuthToken();
|
||||
responseWithKeystoneAccess = KeystoneFixture.INSTANCE.responseWithAccess();
|
||||
// now, createContext arg will need tenant prefix
|
||||
identity = KeystoneFixture.INSTANCE.getTenantName() + ":" + identity;
|
||||
identity = KeystoneFixture.INSTANCE.getTenantName() + ":" + identity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,48 +52,23 @@ public class ParseExtensionListNormalTest extends BaseSetParserTest<Extension> {
|
|||
@SelectJson("extensions")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Set<Extension> expected() {
|
||||
return ImmutableSet
|
||||
.of(Extension
|
||||
.builder()
|
||||
.alias("os-keypairs")
|
||||
.name("Keypairs")
|
||||
.namespace(URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1"))
|
||||
.updated(
|
||||
new SimpleDateFormatDateService()
|
||||
.iso8601SecondsDateParse("2011-08-08T00:00:00+00:00"))
|
||||
.description("Keypair Support")
|
||||
.build(),
|
||||
Extension
|
||||
.builder()
|
||||
.alias("os-volumes")
|
||||
.name("Volumes")
|
||||
.namespace(URI.create("http://docs.openstack.org/ext/volumes/api/v1.1"))
|
||||
.updated(
|
||||
new SimpleDateFormatDateService()
|
||||
.iso8601SecondsDateParse("2011-03-25T00:00:00+00:00"))
|
||||
.description("Volumes support")
|
||||
.build(),
|
||||
Extension
|
||||
.builder()
|
||||
.alias("security_groups")
|
||||
.name("SecurityGroups")
|
||||
.namespace(URI.create("http://docs.openstack.org/ext/securitygroups/api/v1.1"))
|
||||
.updated(
|
||||
new SimpleDateFormatDateService()
|
||||
.iso8601SecondsDateParse("2011-07-21T00:00:00+00:00"))
|
||||
.description("Security group support")
|
||||
.build(),
|
||||
Extension
|
||||
.builder()
|
||||
.alias("os-floating-ips")
|
||||
.name("Floating_ips")
|
||||
.namespace(URI.create("http://docs.openstack.org/ext/floating_ips/api/v1.1"))
|
||||
.updated(
|
||||
new SimpleDateFormatDateService()
|
||||
.iso8601SecondsDateParse("2011-06-16T00:00:00+00:00"))
|
||||
.description("Floating IPs support")
|
||||
.build()
|
||||
);
|
||||
return ImmutableSet.of(
|
||||
Extension.builder().alias("os-keypairs").name("Keypairs")
|
||||
.namespace(URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1"))
|
||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-08-08T00:00:00+00:00"))
|
||||
.description("Keypair Support").build(),
|
||||
Extension.builder().alias("os-volumes").name("Volumes")
|
||||
.namespace(URI.create("http://docs.openstack.org/ext/volumes/api/v1.1"))
|
||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-03-25T00:00:00+00:00"))
|
||||
.description("Volumes support").build(),
|
||||
Extension.builder().alias("security_groups").name("SecurityGroups")
|
||||
.namespace(URI.create("http://docs.openstack.org/ext/securitygroups/api/v1.1"))
|
||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-07-21T00:00:00+00:00"))
|
||||
.description("Security group support").build(),
|
||||
Extension.builder().alias("os-floating-ips").name("Floating_ips")
|
||||
.namespace(URI.create("http://docs.openstack.org/ext/floating_ips/api/v1.1"))
|
||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-06-16T00:00:00+00:00"))
|
||||
.description("Floating IPs support").build());
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
|
|
|
@ -56,45 +56,31 @@ public class ParseExtensionListTest extends BaseSetParserTest<Extension> {
|
|||
public Set<Extension> expected() {
|
||||
return ImmutableSet
|
||||
.of(Extension
|
||||
.builder()
|
||||
.alias("RAX-PIE")
|
||||
.name("Public Image Extension")
|
||||
.namespace(URI.create("http://docs.rackspacecloud.com/servers/api/ext/pie/v1.0"))
|
||||
.updated(
|
||||
new SimpleDateFormatDateService()
|
||||
.iso8601SecondsDateParse("2011-01-22T13:25:27-06:00"))
|
||||
.description("Adds the capability to share an image with other users.")
|
||||
.links(
|
||||
ImmutableSet.of(
|
||||
Link.create(
|
||||
Relation.DESCRIBEDBY,
|
||||
"application/pdf",
|
||||
URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie-20111111.pdf")),
|
||||
Link.create(
|
||||
Relation.DESCRIBEDBY,
|
||||
"application/vnd.sun.wadl+xml",
|
||||
URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie.wadl"))))
|
||||
.build(),
|
||||
Extension
|
||||
.builder()
|
||||
.alias("RAX-CBS")
|
||||
.name("Cloud Block Storage")
|
||||
.namespace(URI.create("http://docs.rackspacecloud.com/servers/api/ext/cbs/v1.0"))
|
||||
.updated(
|
||||
new SimpleDateFormatDateService()
|
||||
.iso8601SecondsDateParse("2011-01-12T11:22:33-06:00"))
|
||||
.description("Allows mounting cloud block storage volumes.")
|
||||
.links(
|
||||
ImmutableSet.of(
|
||||
Link.create(
|
||||
Relation.DESCRIBEDBY,
|
||||
"application/pdf",
|
||||
URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-cbs-20111201.pdf")),
|
||||
Link.create(
|
||||
Relation.DESCRIBEDBY,
|
||||
"application/vnd.sun.wadl+xml",
|
||||
URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-cbs.wadl"))))
|
||||
.build());
|
||||
.builder()
|
||||
.alias("RAX-PIE")
|
||||
.name("Public Image Extension")
|
||||
.namespace(URI.create("http://docs.rackspacecloud.com/servers/api/ext/pie/v1.0"))
|
||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-01-22T13:25:27-06:00"))
|
||||
.description("Adds the capability to share an image with other users.")
|
||||
.links(
|
||||
ImmutableSet.of(
|
||||
Link.create(Relation.DESCRIBEDBY, "application/pdf",
|
||||
URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie-20111111.pdf")),
|
||||
Link.create(Relation.DESCRIBEDBY, "application/vnd.sun.wadl+xml",
|
||||
URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie.wadl")))).build(),
|
||||
Extension
|
||||
.builder()
|
||||
.alias("RAX-CBS")
|
||||
.name("Cloud Block Storage")
|
||||
.namespace(URI.create("http://docs.rackspacecloud.com/servers/api/ext/cbs/v1.0"))
|
||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-01-12T11:22:33-06:00"))
|
||||
.description("Allows mounting cloud block storage volumes.")
|
||||
.links(
|
||||
ImmutableSet.of(Link.create(Relation.DESCRIBEDBY, "application/pdf",
|
||||
URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-cbs-20111201.pdf")),
|
||||
Link.create(Relation.DESCRIBEDBY, "application/vnd.sun.wadl+xml",
|
||||
URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-cbs.wadl"))))
|
||||
.build());
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
|
|
|
@ -57,24 +57,16 @@ public class ParseExtensionTest extends BaseItemParserTest<Extension> {
|
|||
.alias("RS-PIE")
|
||||
.name("Public Image Extension")
|
||||
.namespace(URI.create("http://docs.rackspacecloud.com/servers/api/ext/pie/v1.0"))
|
||||
.updated(
|
||||
new SimpleDateFormatDateService()
|
||||
.iso8601SecondsDateParse("2011-01-22T13:25:27-06:00"))
|
||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-01-22T13:25:27-06:00"))
|
||||
.description("Adds the capability to share an image with other users.")
|
||||
.links(
|
||||
ImmutableSet.of(
|
||||
Link.create(
|
||||
Relation.DESCRIBEDBY,
|
||||
"application/pdf",
|
||||
Link.create(Relation.DESCRIBEDBY, "application/pdf",
|
||||
URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie-20111111.pdf")),
|
||||
Link.create(
|
||||
Relation.DESCRIBEDBY,
|
||||
"application/vnd.sun.wadl+xml",
|
||||
URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie.wadl"))))
|
||||
.build();
|
||||
Link.create(Relation.DESCRIBEDBY, "application/vnd.sun.wadl+xml",
|
||||
URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie.wadl")))).build();
|
||||
}
|
||||
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new NovaParserModule(), new GsonModule());
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ 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.domain.Resource;
|
||||
import org.jclouds.openstack.nova.v1_1.config.NovaParserModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
|
@ -18,9 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.parse;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.json.BaseSetParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.openstack.nova.v1_1.config.NovaParserModule;
|
||||
|
@ -28,9 +30,9 @@ import org.jclouds.openstack.nova.v1_1.domain.FloatingIP;
|
|||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.Set;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -48,22 +50,8 @@ public class ParseFloatingIPListTest extends BaseSetParserTest<FloatingIP> {
|
|||
@SelectJson("floating_ips")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Set<FloatingIP> expected() {
|
||||
return ImmutableSet
|
||||
.of(
|
||||
FloatingIP
|
||||
.builder()
|
||||
.id("1")
|
||||
.instanceId("12")
|
||||
.ip("10.0.0.3")
|
||||
.fixedIp("11.0.0.1")
|
||||
.build(),
|
||||
FloatingIP
|
||||
.builder()
|
||||
.id("2")
|
||||
.instanceId(null)
|
||||
.ip("10.0.0.5")
|
||||
.fixedIp(null)
|
||||
.build());
|
||||
return ImmutableSet.of(FloatingIP.builder().id("1").instanceId("12").ip("10.0.0.3").fixedIp("11.0.0.1").build(),
|
||||
FloatingIP.builder().id("2").instanceId(null).ip("10.0.0.5").fixedIp(null).build());
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.parse;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.json.BaseItemParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.openstack.nova.v1_1.config.NovaParserModule;
|
||||
|
@ -27,8 +28,8 @@ import org.jclouds.openstack.nova.v1_1.domain.FloatingIP;
|
|||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author Michael Arnold
|
||||
|
@ -45,13 +46,7 @@ public class ParseFloatingIPTest extends BaseItemParserTest<FloatingIP> {
|
|||
@SelectJson("floating_ip")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public FloatingIP expected() {
|
||||
return FloatingIP
|
||||
.builder()
|
||||
.id("1")
|
||||
.instanceId("123")
|
||||
.fixedIp("10.0.0.2")
|
||||
.ip("10.0.0.3")
|
||||
.build();
|
||||
return FloatingIP.builder().id("1").instanceId("123").fixedIp("10.0.0.2").ip("10.0.0.3").build();
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
|
|
|
@ -27,8 +27,8 @@ 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.domain.Resource;
|
||||
import org.jclouds.openstack.nova.v1_1.config.NovaParserModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
|
|
@ -27,8 +27,8 @@ 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.domain.Resource;
|
||||
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.ImageStatus;
|
||||
|
@ -59,21 +59,17 @@ public class ParseImageTest extends BaseItemParserTest<Image> {
|
|||
.builder()
|
||||
.id("52415800-8b69-11e0-9b19-734f5736d2a2")
|
||||
.name("My Server Backup")
|
||||
.updated(
|
||||
new SimpleDateFormatDateService()
|
||||
.iso8601SecondsDateParse("2010-10-10T12:00:00Z"))
|
||||
.created(
|
||||
new SimpleDateFormatDateService()
|
||||
.iso8601SecondsDateParse("2010-08-10T12:00:00Z"))
|
||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-10-10T12:00:00Z"))
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-08-10T12:00:00Z"))
|
||||
.tenantId("12345")
|
||||
.userId("joe")
|
||||
.status(ImageStatus.SAVING)
|
||||
.progress(80)
|
||||
.minDisk(5)
|
||||
.minRam(256)
|
||||
.metadata(new ImmutableMap.Builder<String, String>()
|
||||
.put("ImageType", "Gold")
|
||||
.put("ImageVersion", "1.5").build())
|
||||
.metadata(
|
||||
new ImmutableMap.Builder<String, String>().put("ImageType", "Gold").put("ImageVersion", "1.5")
|
||||
.build())
|
||||
.server(
|
||||
Resource
|
||||
.builder()
|
||||
|
|
|
@ -18,59 +18,61 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.parse;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.json.BaseParserTest;
|
||||
import org.jclouds.json.BaseSetParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.openstack.nova.v1_1.config.NovaParserModule;
|
||||
import org.jclouds.openstack.nova.v1_1.domain.KeyPair;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Michael Arnold
|
||||
*/
|
||||
@Test(groups = "unit", testName = "ParseKeyPairListTest")
|
||||
public class ParseKeyPairListTest extends BaseParserTest {
|
||||
public class ParseKeyPairListTest extends BaseParserTest {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/keypair_list.json";
|
||||
}
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/keypair_list.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("keypairs")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Set<Map<String, KeyPair>> expected() {
|
||||
Map<String, KeyPair> kp1 = new HashMap<String, KeyPair>();
|
||||
kp1.put("keypair", KeyPair
|
||||
.builder()
|
||||
.publicKey("ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQCy9EC3O7Ff80vPEfAHDQob61PGwcpYc5KE7tEZnZhrB9n0NyHPRm0E0M+ls3fcTa04HDi+R0DzmRwoyhHQJyI658v8kWZZcuvFjKCcsgsSh/dzdX0xTreLIzSOzt5U7RnZYfshP5cmxtF99yrEY3M/swdin0L+fXsTSkR1B42STQ== nova@nv-aw2az1-api0001")
|
||||
.name("default")
|
||||
.fingerprint("ab:0c:f4:f3:54:c0:5d:3f:ed:62:ad:d3:94:7c:79:7c")
|
||||
.build());
|
||||
Map<String, KeyPair> kp2 = new HashMap<String, KeyPair>();
|
||||
kp2.put("keypair", KeyPair
|
||||
.builder()
|
||||
.publicKey("ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001")
|
||||
.name("testkeypair")
|
||||
.fingerprint("d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4")
|
||||
.build());
|
||||
return ImmutableSet.of(kp1,kp2);
|
||||
}
|
||||
@Override
|
||||
@SelectJson("keypairs")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Set<Map<String, KeyPair>> expected() {
|
||||
Map<String, KeyPair> kp1 = new HashMap<String, KeyPair>();
|
||||
kp1.put(
|
||||
"keypair",
|
||||
KeyPair
|
||||
.builder()
|
||||
.publicKey(
|
||||
"ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQCy9EC3O7Ff80vPEfAHDQob61PGwcpYc5KE7tEZnZhrB9n0NyHPRm0E0M+ls3fcTa04HDi+R0DzmRwoyhHQJyI658v8kWZZcuvFjKCcsgsSh/dzdX0xTreLIzSOzt5U7RnZYfshP5cmxtF99yrEY3M/swdin0L+fXsTSkR1B42STQ== nova@nv-aw2az1-api0001")
|
||||
.name("default").fingerprint("ab:0c:f4:f3:54:c0:5d:3f:ed:62:ad:d3:94:7c:79:7c").build());
|
||||
Map<String, KeyPair> kp2 = new HashMap<String, KeyPair>();
|
||||
kp2.put(
|
||||
"keypair",
|
||||
KeyPair
|
||||
.builder()
|
||||
.publicKey(
|
||||
"ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001")
|
||||
.name("testkeypair").fingerprint("d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4").build());
|
||||
return ImmutableSet.of(kp1, kp2);
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new NovaParserModule(), new GsonModule());
|
||||
}
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new NovaParserModule(), new GsonModule());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,18 +18,18 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.parse;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.json.BaseItemParserTest;
|
||||
import org.jclouds.json.BaseParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.openstack.nova.v1_1.config.NovaParserModule;
|
||||
import org.jclouds.openstack.nova.v1_1.domain.KeyPair;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -38,27 +38,26 @@ import javax.ws.rs.core.MediaType;
|
|||
@Test(groups = "unit", testName = "ParseKeyPairTest")
|
||||
public class ParseKeyPairTest extends BaseItemParserTest<KeyPair> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/keypair_created.json";
|
||||
}
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/keypair_created.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("keypair")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public KeyPair expected() {
|
||||
return KeyPair
|
||||
.builder()
|
||||
.publicKey("ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001\n")
|
||||
.privateKey("-----BEGIN RSA PRIVATE KEY-----\nMIICXQIAAAKBgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABAC\nE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumA\nDSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQIDAQAB\nAoGAW8Ww+KbpQK8smcgCTr/RqcmsSI8VeL2hXjJvDq0L5WbyYuFdkanDvCztUVZn\nsmyfDtwAqZXB4Ct/dN1tY7m8QpdyRaKRW4Q+hghGCAQpsG7rYDdvwdEyvMaW5RA4\ntucQyajMNyQ/tozU3wMx/v8A7RvGcE9tqoG0WK1C3kBu95UCQQDrOd+joYDkvccz\nFIVu5gNPMXEh3fGGzDxk225UlvESquYLzfz4TfmuUjH4Z1BL3wRiwfJsrrjFkm33\njIidDE8PAkEA1qHjxuaIS1yz/rfzErmcOVNlbFHMP4ihjGTTvh1ZctXlNeLwzENQ\nEDaQV3IpUY1KQR6rxcWb5AXgfF9D9PYFpwJBANucAqGAbRgh3lJgPFtXP4u2O0tF\nLPOOxmvbOdybt6KYD4LB5AXmts77SlACFMNhCXUyYaT6UuOSXDyb5gfJsB0CQQC3\nFaGXKU9Z+doQjhlq/6mjvN/nZl80Uvh7Kgb1RVPoAU1kihGeLE0/h0vZTCiyyDNv\nGRqtucMg32J+tUTi0HpBAkAwHiCZMHMeJWHUwIwlRQY/dnR86FWobRl98ViF2rCL\nDHkDVOeIser3Q6zSqU5/m99lX6an5g8pAh/R5LqnOQZC\n-----END RSA PRIVATE KEY-----\n")
|
||||
.name("testkeypair")
|
||||
.userId("65649731189278")
|
||||
.fingerprint("d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4")
|
||||
.build();
|
||||
}
|
||||
@Override
|
||||
@SelectJson("keypair")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public KeyPair expected() {
|
||||
return KeyPair
|
||||
.builder()
|
||||
.publicKey(
|
||||
"ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001\n")
|
||||
.privateKey(
|
||||
"-----BEGIN RSA PRIVATE KEY-----\nMIICXQIAAAKBgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABAC\nE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumA\nDSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQIDAQAB\nAoGAW8Ww+KbpQK8smcgCTr/RqcmsSI8VeL2hXjJvDq0L5WbyYuFdkanDvCztUVZn\nsmyfDtwAqZXB4Ct/dN1tY7m8QpdyRaKRW4Q+hghGCAQpsG7rYDdvwdEyvMaW5RA4\ntucQyajMNyQ/tozU3wMx/v8A7RvGcE9tqoG0WK1C3kBu95UCQQDrOd+joYDkvccz\nFIVu5gNPMXEh3fGGzDxk225UlvESquYLzfz4TfmuUjH4Z1BL3wRiwfJsrrjFkm33\njIidDE8PAkEA1qHjxuaIS1yz/rfzErmcOVNlbFHMP4ihjGTTvh1ZctXlNeLwzENQ\nEDaQV3IpUY1KQR6rxcWb5AXgfF9D9PYFpwJBANucAqGAbRgh3lJgPFtXP4u2O0tF\nLPOOxmvbOdybt6KYD4LB5AXmts77SlACFMNhCXUyYaT6UuOSXDyb5gfJsB0CQQC3\nFaGXKU9Z+doQjhlq/6mjvN/nZl80Uvh7Kgb1RVPoAU1kihGeLE0/h0vZTCiyyDNv\nGRqtucMg32J+tUTi0HpBAkAwHiCZMHMeJWHUwIwlRQY/dnR86FWobRl98ViF2rCL\nDHkDVOeIser3Q6zSqU5/m99lX6an5g8pAh/R5LqnOQZC\n-----END RSA PRIVATE KEY-----\n")
|
||||
.name("testkeypair").userId("65649731189278")
|
||||
.fingerprint("d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4").build();
|
||||
}
|
||||
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new NovaParserModule(), new GsonModule());
|
||||
}
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new NovaParserModule(), new GsonModule());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,10 +18,13 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.parse;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.json.BaseSetParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.openstack.nova.v1_1.config.NovaParserModule;
|
||||
|
@ -30,11 +33,10 @@ import org.jclouds.openstack.nova.v1_1.domain.SecurityGroupRule;
|
|||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -43,65 +45,34 @@ import java.util.Set;
|
|||
@Test(groups = "unit", testName = "ParseSecurityGroupListTest")
|
||||
public class ParseSecurityGroupListTest extends BaseSetParserTest<SecurityGroup> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/securitygroup_list.json";
|
||||
}
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/securitygroup_list.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("security_groups")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Set<SecurityGroup> expected() {
|
||||
@Override
|
||||
@SelectJson("security_groups")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Set<SecurityGroup> expected() {
|
||||
|
||||
Map<String, String> anyCidr = ImmutableMap.<String, String> of("cidr", "0.0.0.0/0");
|
||||
Map<String, String> anyCidr = ImmutableMap.<String, String> of("cidr", "0.0.0.0/0");
|
||||
|
||||
Set<SecurityGroupRule> securityGroupRules = ImmutableSet.<SecurityGroupRule> of(
|
||||
SecurityGroupRule
|
||||
.builder()
|
||||
.fromPort(22)
|
||||
.group(new HashMap<String, String>())
|
||||
.ipProtocol(SecurityGroupRule.IpProtocol.TCP)
|
||||
.toPort(22)
|
||||
.parentGroupId("3")
|
||||
.ipRange(anyCidr)
|
||||
.id("107")
|
||||
.build(),
|
||||
SecurityGroupRule
|
||||
.builder()
|
||||
.fromPort(7600)
|
||||
.group(new HashMap<String, String>())
|
||||
.ipProtocol(SecurityGroupRule.IpProtocol.TCP)
|
||||
.toPort(7600)
|
||||
.parentGroupId("3")
|
||||
.ipRange(anyCidr)
|
||||
.id("118")
|
||||
.build(),
|
||||
SecurityGroupRule
|
||||
.builder()
|
||||
.fromPort(8084)
|
||||
.group(new HashMap<String, String>())
|
||||
.ipProtocol(SecurityGroupRule.IpProtocol.TCP)
|
||||
.toPort(8084)
|
||||
.parentGroupId("3")
|
||||
.ipRange(anyCidr)
|
||||
.id("119")
|
||||
.build()
|
||||
);
|
||||
Set<SecurityGroupRule> securityGroupRules = ImmutableSet.<SecurityGroupRule> of(
|
||||
SecurityGroupRule.builder().fromPort(22).group(new HashMap<String, String>())
|
||||
.ipProtocol(SecurityGroupRule.IpProtocol.TCP).toPort(22).parentGroupId("3").ipRange(anyCidr)
|
||||
.id("107").build(),
|
||||
SecurityGroupRule.builder().fromPort(7600).group(new HashMap<String, String>())
|
||||
.ipProtocol(SecurityGroupRule.IpProtocol.TCP).toPort(7600).parentGroupId("3").ipRange(anyCidr)
|
||||
.id("118").build(),
|
||||
SecurityGroupRule.builder().fromPort(8084).group(new HashMap<String, String>())
|
||||
.ipProtocol(SecurityGroupRule.IpProtocol.TCP).toPort(8084).parentGroupId("3").ipRange(anyCidr)
|
||||
.id("119").build());
|
||||
|
||||
return ImmutableSet
|
||||
.of(
|
||||
SecurityGroup
|
||||
.builder()
|
||||
.description("description1")
|
||||
.id("1")
|
||||
.tenantId("tenant1")
|
||||
.rules(securityGroupRules)
|
||||
.name("name1")
|
||||
.build()
|
||||
);
|
||||
}
|
||||
return ImmutableSet.of(SecurityGroup.builder().description("description1").id("1").tenantId("tenant1")
|
||||
.rules(securityGroupRules).name("name1").build());
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new NovaParserModule(), new GsonModule());
|
||||
}
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new NovaParserModule(), new GsonModule());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.parse;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.json.BaseItemParserTest;
|
||||
import org.jclouds.json.BaseSetParserTest;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.openstack.nova.v1_1.config.NovaParserModule;
|
||||
import org.jclouds.openstack.nova.v1_1.domain.SecurityGroup;
|
||||
|
@ -32,11 +32,10 @@ import org.jclouds.openstack.nova.v1_1.domain.SecurityGroupRule;
|
|||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -45,50 +44,29 @@ import java.util.Set;
|
|||
@Test(groups = "unit", testName = "ParseSecurityGroupTest")
|
||||
public class ParseSecurityGroupTest extends BaseItemParserTest<SecurityGroup> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/securitygroup_details.json";
|
||||
}
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/securitygroup_details.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SelectJson("security_group")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public SecurityGroup expected() {
|
||||
@Override
|
||||
@SelectJson("security_group")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public SecurityGroup expected() {
|
||||
|
||||
Set<SecurityGroupRule> securityGroupRules = ImmutableSet.<SecurityGroupRule> of(
|
||||
SecurityGroupRule
|
||||
.builder()
|
||||
.fromPort(22)
|
||||
.group(new HashMap<String, String>())
|
||||
.ipProtocol(SecurityGroupRule.IpProtocol.TCP)
|
||||
.toPort(22)
|
||||
.parentGroupId("28")
|
||||
.ipRange(ImmutableMap.of("cidr", "10.2.6.0/24"))
|
||||
.id("108")
|
||||
.build(),
|
||||
SecurityGroupRule
|
||||
.builder()
|
||||
.fromPort(22)
|
||||
.group(ImmutableMap.of("tenant_id","admin", "name", "11111"))
|
||||
.ipProtocol(SecurityGroupRule.IpProtocol.TCP)
|
||||
.toPort(22)
|
||||
.parentGroupId("28")
|
||||
.ipRange(new HashMap<String, String>())
|
||||
.id("109")
|
||||
.build()
|
||||
);
|
||||
Set<SecurityGroupRule> securityGroupRules = ImmutableSet.<SecurityGroupRule> of(
|
||||
SecurityGroupRule.builder().fromPort(22).group(new HashMap<String, String>())
|
||||
.ipProtocol(SecurityGroupRule.IpProtocol.TCP).toPort(22).parentGroupId("28")
|
||||
.ipRange(ImmutableMap.of("cidr", "10.2.6.0/24")).id("108").build(),
|
||||
SecurityGroupRule.builder().fromPort(22).group(ImmutableMap.of("tenant_id", "admin", "name", "11111"))
|
||||
.ipProtocol(SecurityGroupRule.IpProtocol.TCP).toPort(22).parentGroupId("28")
|
||||
.ipRange(new HashMap<String, String>()).id("109").build());
|
||||
|
||||
return SecurityGroup
|
||||
.builder()
|
||||
.description("description0")
|
||||
.id("0")
|
||||
.tenantId("tenant0")
|
||||
.rules(securityGroupRules)
|
||||
.name("name0")
|
||||
.build();
|
||||
}
|
||||
return SecurityGroup.builder().description("description0").id("0").tenantId("tenant0").rules(securityGroupRules)
|
||||
.name("name0").build();
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new NovaParserModule(), new GsonModule());
|
||||
}
|
||||
protected Injector injector() {
|
||||
return Guice.createInjector(new NovaParserModule(), new GsonModule());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ 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.domain.Resource;
|
||||
import org.jclouds.openstack.nova.v1_1.config.NovaParserModule;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -54,39 +54,30 @@ public class ParseServerListTest extends BaseSetParserTest<Resource> {
|
|||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Set<Resource> expected() {
|
||||
return ImmutableSet
|
||||
.of(
|
||||
Resource
|
||||
.builder()
|
||||
.id("52415800-8b69-11e0-9b19-734f6af67565")
|
||||
.name("sample-server")
|
||||
.links(
|
||||
Link
|
||||
.create(
|
||||
Relation.SELF,
|
||||
URI
|
||||
.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6af67565")),
|
||||
Link
|
||||
.create(
|
||||
Relation.BOOKMARK,
|
||||
URI
|
||||
.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f6af67565")))
|
||||
.build(),
|
||||
Resource
|
||||
.builder()
|
||||
.id("52415800-8b69-11e0-9b19-734f1f1350e5")
|
||||
.name("sample-server2")
|
||||
.links(
|
||||
Link
|
||||
.create(
|
||||
Relation.SELF,
|
||||
URI
|
||||
.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5")),
|
||||
Link
|
||||
.create(
|
||||
Relation.BOOKMARK,
|
||||
URI
|
||||
.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5")))
|
||||
.build());
|
||||
.of(Resource
|
||||
.builder()
|
||||
.id("52415800-8b69-11e0-9b19-734f6af67565")
|
||||
.name("sample-server")
|
||||
.links(
|
||||
Link.create(
|
||||
Relation.SELF,
|
||||
URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6af67565")),
|
||||
Link.create(
|
||||
Relation.BOOKMARK,
|
||||
URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f6af67565")))
|
||||
.build(),
|
||||
Resource
|
||||
.builder()
|
||||
.id("52415800-8b69-11e0-9b19-734f1f1350e5")
|
||||
.name("sample-server2")
|
||||
.links(
|
||||
Link.create(
|
||||
Relation.SELF,
|
||||
URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5")),
|
||||
Link.create(
|
||||
Relation.BOOKMARK,
|
||||
URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5")))
|
||||
.build());
|
||||
}
|
||||
|
||||
protected Injector injector() {
|
||||
|
|
|
@ -27,8 +27,8 @@ 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.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;
|
||||
|
@ -61,12 +61,8 @@ public class ParseServerTest extends BaseItemParserTest<Server> {
|
|||
.tenantId("1234")
|
||||
.userId("5678")
|
||||
.name("sample-server")
|
||||
.updated(
|
||||
new SimpleDateFormatDateService()
|
||||
.iso8601SecondsDateParse("2010-10-10T12:00:00Z"))
|
||||
.created(
|
||||
new SimpleDateFormatDateService()
|
||||
.iso8601SecondsDateParse("2010-08-10T12:00:00Z"))
|
||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-10-10T12:00:00Z"))
|
||||
.created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-08-10T12:00:00Z"))
|
||||
.hostId("e4d909c290d0fb1ca068ffaddf22cbd0")
|
||||
.accessIPv4("67.23.10.132")
|
||||
.accessIPv6("::babe:67.23.10.132")
|
||||
|
@ -85,27 +81,25 @@ public class ParseServerTest extends BaseItemParserTest<Server> {
|
|||
Relation.BOOKMARK,
|
||||
URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")))
|
||||
.build())
|
||||
.flavor(Resource
|
||||
.builder()
|
||||
.id("52415800-8b69-11e0-9b19-734f216543fd")
|
||||
.name("null")
|
||||
.links(
|
||||
Link.create(
|
||||
Relation.SELF,
|
||||
URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")),
|
||||
Link.create(
|
||||
Relation.BOOKMARK,
|
||||
URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")))
|
||||
.build())
|
||||
.metadata(new ImmutableMap.Builder<String, String>()
|
||||
.put("Server Label", "Web Head 1")
|
||||
.flavor(
|
||||
Resource
|
||||
.builder()
|
||||
.id("52415800-8b69-11e0-9b19-734f216543fd")
|
||||
.name("null")
|
||||
.links(
|
||||
Link.create(
|
||||
Relation.SELF,
|
||||
URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")),
|
||||
Link.create(
|
||||
Relation.BOOKMARK,
|
||||
URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")))
|
||||
.build())
|
||||
.metadata(
|
||||
new ImmutableMap.Builder<String, String>().put("Server Label", "Web Head 1")
|
||||
.put("Image Version", "2.1").build())
|
||||
.publicAddresses(Address.createV4("67.23.10.132"),
|
||||
Address.createV6("::babe:67.23.10.132"),
|
||||
Address.createV4("67.23.10.131"),
|
||||
Address.createV6("::babe:4317:0A83"))
|
||||
.privateAddresses(Address.createV4("10.176.42.16"),
|
||||
Address.createV6("::babe:10.176.42.16")).build();
|
||||
.publicAddresses(Address.createV4("67.23.10.132"), Address.createV6("::babe:67.23.10.132"),
|
||||
Address.createV4("67.23.10.131"), Address.createV6("::babe:4317:0A83"))
|
||||
.privateAddresses(Address.createV4("10.176.42.16"), Address.createV6("::babe:10.176.42.16")).build();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,10 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova.v1_1.predicates;
|
||||
|
||||
import static org.jclouds.openstack.nova.v1_1.predicates.ExtensionPredicates.aliasEquals;
|
||||
import static org.jclouds.openstack.nova.v1_1.predicates.ExtensionPredicates.namespaceEquals;
|
||||
|
||||
import java.net.URI;
|
||||
import static org.jclouds.openstack.nova.v1_1.predicates.ExtensionPredicates.*;
|
||||
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.openstack.nova.v1_1.domain.Extension;
|
||||
|
@ -31,10 +33,10 @@ import org.testng.annotations.Test;
|
|||
*/
|
||||
@Test(groups = "unit", testName = "ExtensionPredicatesTest")
|
||||
public class ExtensionPredicatesTest {
|
||||
Extension ref = Extension.builder().alias("os-keypairs").name("Keypairs").namespace(
|
||||
URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1")).updated(
|
||||
new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-08-08T00:00:00+00:00")).description(
|
||||
"Keypair Support").build();
|
||||
Extension ref = Extension.builder().alias("os-keypairs").name("Keypairs")
|
||||
.namespace(URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1"))
|
||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-08-08T00:00:00+00:00"))
|
||||
.description("Keypair Support").build();
|
||||
|
||||
@Test
|
||||
public void testAliasEqualsWhenEqual() {
|
||||
|
|
Loading…
Reference in New Issue