Removed unnecessary whitespaces and fixed formatting

This commit is contained in:
Ignasi Barrera 2014-07-14 10:53:08 +02:00
parent e94b878b28
commit 3b2f02b723
10 changed files with 74 additions and 70 deletions

View File

@ -107,13 +107,13 @@ public class AllocateAndAddFloatingIpToNode implements
// 1.) Attempt to allocate from optionally passed poolNames
if (poolNames.isPresent()) {
for (String poolName : poolNames.get()){
for (String poolName : poolNames.get()) {
try {
logger.debug(">> allocating floating IP from pool %s for node(%s)", poolName, nodeID);
ip = floatingIpApi.allocateFromPool(poolName);
if (ip != null)
return Optional.of(ip);
} catch (InsufficientResourcesException ire){
} catch (InsufficientResourcesException ire) {
logger.trace("<< [%s] failed to allocate floating IP from pool %s for node(%s)", ire.getMessage(), poolName, nodeID);
}
}
@ -123,9 +123,9 @@ public class AllocateAndAddFloatingIpToNode implements
try {
logger.debug(">> creating floating IP for node(%s)", nodeID);
ip = floatingIpApi.create();
if(ip != null)
if (ip != null)
return Optional.of(ip);
} catch (InsufficientResourcesException ire){
} catch (InsufficientResourcesException ire) {
logger.trace("<< [%s] failed to create floating IP for node(%s)", ire.getMessage(), nodeID);
}

View File

@ -31,7 +31,7 @@ public class NodeAndNovaTemplateOptions {
private final AtomicReference<NodeMetadata> nodeMetadata;
private final AtomicReference<NovaTemplateOptions> novaTemplateOptions;
protected NodeAndNovaTemplateOptions(AtomicReference<NodeMetadata> nodeMetadata, AtomicReference<NovaTemplateOptions> novaTemplateOptions){
protected NodeAndNovaTemplateOptions(AtomicReference<NodeMetadata> nodeMetadata, AtomicReference<NovaTemplateOptions> novaTemplateOptions) {
this.nodeMetadata = nodeMetadata;
this.novaTemplateOptions = novaTemplateOptions;
}
@ -44,11 +44,11 @@ public class NodeAndNovaTemplateOptions {
return novaTemplateOptions;
}
public static NodeAndNovaTemplateOptions newReference(AtomicReference<NodeMetadata> node, AtomicReference<NovaTemplateOptions> options){
public static NodeAndNovaTemplateOptions newReference(AtomicReference<NodeMetadata> node, AtomicReference<NovaTemplateOptions> options) {
return new NodeAndNovaTemplateOptions(node, options);
}
public static AtomicReference<NodeAndNovaTemplateOptions> newAtomicReference(AtomicReference<NodeMetadata> node, AtomicReference<NovaTemplateOptions> options){
public static AtomicReference<NodeAndNovaTemplateOptions> newAtomicReference(AtomicReference<NodeMetadata> node, AtomicReference<NovaTemplateOptions> options) {
return Atomics.newReference(NodeAndNovaTemplateOptions.newReference(node, options));
}
}

View File

@ -28,7 +28,6 @@ import java.util.Set;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.openstack.nova.v2_0.domain.Network;
import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions;
import org.jclouds.scriptbuilder.domain.Statement;
import com.google.common.base.Objects;
@ -200,7 +199,7 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
/**
* <h3>Note</h3>
*
* This requires that {@link NovaApi#getExtensionForZone(String)} to return
* This requires that {@link org.jclouds.openstack.nova.v2_0.NovaApi#getExtensionForZone(String)} to return
* {@link Optional#isPresent present}
*
* @return true if auto assignment of a floating ip to each vm is enabled
@ -232,7 +231,7 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
/**
* <h3>Note</h3>
*
* This requires that {@link NovaApi#getKeyPairExtensionForZone(String)} to return
* This requires that {@link org.jclouds.openstack.nova.v2_0.NovaApi#getKeyPairExtensionForZone(String)} to return
* {@link Optional#isPresent present}
*
* @return true if auto generation of keypairs is enabled
@ -256,21 +255,21 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
}
/**
* @see CreateServerOptions#getDiskConfig()
* @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getDiskConfig()
*/
public String getDiskConfig() {
return diskConfig;
}
/**
* @see CreateServerOptions#getConfigDrive()
* @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getConfigDrive()
*/
public boolean getConfigDrive() {
return configDrive;
}
/**
* @see CreateServerOptions#getNetworks()
* @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getNetworks()
*/
public Set<Network> getNovaNetworks() {
return novaNetworks;
@ -638,7 +637,7 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
}
/**
* @see CreateServerOptions#getDiskConfig()
* @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getDiskConfig()
*/
public NovaTemplateOptions diskConfig(String diskConfig) {
this.diskConfig = diskConfig;
@ -651,7 +650,7 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
* normally be available through the metadata service by mounting this disk and reading files from it.
* To enable the config drive, set this parameter to "true".
* This has to be enabled for user data cases.
* @see CreateServerOptions#getConfigDrive()
* @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getConfigDrive()
*/
public NovaTemplateOptions configDrive(boolean configDrive) {
this.configDrive = configDrive;
@ -662,7 +661,7 @@ public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
* @param novaNetworks The list of network declarations.
* Nova-specific network declarations allow for specifying network UUIDs, port UUIDs, and fixed IPs.
* Unline {@link #networks(Iterable)} this supports setting additional network parameters and not just network UUIDs.
* @see CreateServerOptions#getNetworks()
* @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getNetworks()
*/
public NovaTemplateOptions novaNetworks(Set<Network> novaNetworks) {
this.novaNetworks = novaNetworks;

View File

@ -160,7 +160,7 @@ public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddT
if (templateOptions.shouldAutoAssignFloatingIp()) {
ListenableFuture<AtomicReference<NodeAndNovaTemplateOptions>> nodeAndNovaTemplateOptions = Futures.transform(future,
new Function<AtomicReference<NodeMetadata>, AtomicReference<NodeAndNovaTemplateOptions>>(){
new Function<AtomicReference<NodeMetadata>, AtomicReference<NodeAndNovaTemplateOptions>>() {
@Override
public AtomicReference<NodeAndNovaTemplateOptions> apply(AtomicReference<NodeMetadata> input) {

View File

@ -33,15 +33,12 @@ import javax.inject.Inject;
import javax.inject.Named;
import org.jclouds.http.HttpRequest;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.domain.Network;
import org.jclouds.openstack.nova.v2_0.domain.Server;
import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Optional;
import com.google.common.collect.ForwardingObject;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@ -208,7 +205,7 @@ public class CreateServerOptions implements MapBinder {
server.availabilityZone = availabilityZone;
if (userData != null)
server.user_data = base64().encode(userData);
if (configDrive == true)
if (configDrive)
server.configDrive = "true";
if (securityGroupNames.size() > 0) {
server.securityGroupNames = Sets.newLinkedHashSet();
@ -367,8 +364,8 @@ public class CreateServerOptions implements MapBinder {
* <p/>
* <h3>Note</h3>
* <p/>
* This requires that {@link NovaApi#getSecurityGroupExtensionForZone(String)} to return
* {@link Optional#isPresent present}
* This requires that {@link org.jclouds.openstack.nova.v2_0.NovaApi#getSecurityGroupExtensionForZone(String)} to return
* {@link com.google.common.base.Optional#isPresent present}
*/
public Set<String> getSecurityGroupNames() {
return securityGroupNames;
@ -413,9 +410,9 @@ public class CreateServerOptions implements MapBinder {
/**
* When you create a server from an image with the diskConfig value set to
* {@link Server#DISK_CONFIG_AUTO}, the server is built with a single partition that is expanded to
* {@link org.jclouds.openstack.nova.v2_0.domain.Server#DISK_CONFIG_AUTO}, the server is built with a single partition that is expanded to
* the disk size of the flavor selected. When you set the diskConfig attribute to
* {@link Server#DISK_CONFIG_MANUAL}, the server is built by using the partition scheme and file
* {@link org.jclouds.openstack.nova.v2_0.domain.Server#DISK_CONFIG_MANUAL}, the server is built by using the partition scheme and file
* system that is in the source image.
* <p/>
* If the target flavor disk is larger, remaining disk space is left unpartitioned. A server inherits the diskConfig

View File

@ -16,18 +16,18 @@
*/
package org.jclouds.openstack.nova.v2_0.predicates;
import com.google.common.base.Predicate;
import org.jclouds.openstack.nova.v2_0.domain.Server;
import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.jclouds.openstack.nova.v2_0.domain.Server.Status;
import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.ACTIVE;
import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.SHUTOFF;
import static org.jclouds.util.Predicates2.retry;
import org.jclouds.openstack.nova.v2_0.domain.Server;
import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import com.google.common.base.Predicate;
/**
* This class tests to see if a Server or ServerCreated has reached a desired status. This class is most useful when
* paired with a RetryablePredicate as in the code below. Together these classes can be used to block execution until

View File

@ -19,7 +19,6 @@ package org.jclouds.openstack.nova.v2_0.internal;
import java.util.Properties;
import java.util.Set;
import com.google.common.collect.*;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.openstack.nova.v2_0.NovaApi;
@ -37,6 +36,10 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Throwables;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Ordering;
/**
* Tests behavior of {@code NovaApi}

View File

@ -16,17 +16,22 @@
*/
package org.jclouds.openstack.nova.v2_0.predicates;
import com.squareup.okhttp.mockwebserver.MockResponse;
import com.squareup.okhttp.mockwebserver.MockWebServer;
import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.ACTIVE;
import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.SHUTOFF;
import static org.jclouds.openstack.nova.v2_0.predicates.ServerPredicates.awaitActive;
import static org.jclouds.openstack.nova.v2_0.predicates.ServerPredicates.awaitShutoff;
import static org.jclouds.openstack.nova.v2_0.predicates.ServerPredicates.awaitStatus;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest;
import org.testng.annotations.Test;
import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.ACTIVE;
import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.SHUTOFF;
import static org.jclouds.openstack.nova.v2_0.predicates.ServerPredicates.*;
import static org.testng.Assert.*;
import com.squareup.okhttp.mockwebserver.MockResponse;
import com.squareup.okhttp.mockwebserver.MockWebServer;
@Test(groups = "unit", testName = "ServerPredicatesMockTest")
public class ServerPredicatesMockTest extends BaseOpenStackMockTest<NovaApi> {
@ -41,7 +46,7 @@ public class ServerPredicatesMockTest extends BaseOpenStackMockTest<NovaApi> {
try {
NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova");
ServerApi serverApi = novaApi.getServerApiForZone(("RegionOne"));
ServerApi serverApi = novaApi.getServerApiForZone("RegionOne");
boolean result = awaitActive(serverApi).apply("71752");
@ -66,7 +71,7 @@ public class ServerPredicatesMockTest extends BaseOpenStackMockTest<NovaApi> {
try {
NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova");
ServerApi serverApi = novaApi.getServerApiForZone(("RegionOne"));
ServerApi serverApi = novaApi.getServerApiForZone("RegionOne");
boolean result = awaitShutoff(serverApi).apply("71752");
@ -88,7 +93,7 @@ public class ServerPredicatesMockTest extends BaseOpenStackMockTest<NovaApi> {
try {
NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova");
ServerApi serverApi = novaApi.getServerApiForZone(("RegionOne"));
ServerApi serverApi = novaApi.getServerApiForZone("RegionOne");
boolean result = awaitStatus(serverApi, ACTIVE, 3, 1).apply("71752");