Issue 730: removed deprecated methods from ComputeService RunScript/TemplateOptions SshClient.Factory and replaced occurences of Credentials with LoginCredentials whereever possible

This commit is contained in:
Adrian Cole 2011-12-20 23:19:45 -08:00
parent b8c6c73fe8
commit f9b38f646c
76 changed files with 342 additions and 905 deletions

View File

@ -37,15 +37,15 @@ import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.options.TemplateOptions; import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.io.Payloads; import org.jclouds.scriptbuilder.domain.Statements;
import org.jclouds.ssh.jsch.config.JschSshClientModule; import org.jclouds.ssh.jsch.config.JschSshClientModule;
import org.jclouds.tools.ant.logging.config.AntLoggingModule; import org.jclouds.tools.ant.logging.config.AntLoggingModule;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.io.Files; import com.google.common.io.Files;
@ -130,9 +130,9 @@ public class ComputeTaskUtils {
return options; return options;
} }
static void addRunScriptToOptionsIfPresentInNodeElement(NodeElement nodeElement, TemplateOptions options) { static void addRunScriptToOptionsIfPresentInNodeElement(NodeElement nodeElement, TemplateOptions options) throws IOException {
if (nodeElement.getRunscript() != null) if (nodeElement.getRunscript() != null)
options.runScript(Payloads.newFilePayload(nodeElement.getRunscript())); options.runScript(Statements.exec(Files.toString(nodeElement.getRunscript(), Charsets.UTF_8)));
} }
static void addPrivateKeyToOptionsIfPresentInNodeElement(NodeElement nodeElement, TemplateOptions options) static void addPrivateKeyToOptionsIfPresentInNodeElement(NodeElement nodeElement, TemplateOptions options)

View File

@ -24,7 +24,7 @@ import javax.inject.Singleton;
import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.ImageBuilder; import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import com.google.common.base.Function; import com.google.common.base.Function;
@ -48,7 +48,7 @@ public class CloudServersImageToImage implements Function<org.jclouds.cloudserve
builder.description(from.getName()); builder.description(from.getName());
builder.version(from.getUpdated().getTime() + ""); builder.version(from.getUpdated().getTime() + "");
builder.operatingSystem(imageToOs.apply(from)); builder.operatingSystem(imageToOs.apply(from));
builder.defaultCredentials(new Credentials("root", null)); builder.defaultCredentials(LoginCredentials.builder().user("root").build());
Image image = builder.build(); Image image = builder.build();
return image; return image;
} }

View File

@ -44,6 +44,7 @@ import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationBuilder;
import org.jclouds.domain.LocationScope; import org.jclouds.domain.LocationScope;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import com.google.common.base.Function; import com.google.common.base.Function;
@ -119,7 +120,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
builder.state(serverToNodeState.get(from.getStatus())); builder.state(serverToNodeState.get(from.getStatus()));
builder.publicAddresses(from.getAddresses().getPublicAddresses()); builder.publicAddresses(from.getAddresses().getPublicAddresses());
builder.privateAddresses(from.getAddresses().getPrivateAddresses()); builder.privateAddresses(from.getAddresses().getPrivateAddresses());
builder.credentials(credentialStore.get("node#" + from.getId())); builder.credentials(LoginCredentials.fromCredentials(credentialStore.get("node#" + from.getId())));
return builder.build(); return builder.build();
} }

View File

@ -48,7 +48,7 @@ import org.jclouds.cloudservers.domain.SharedIpGroup;
import org.jclouds.cloudservers.domain.WeeklyBackup; import org.jclouds.cloudservers.domain.WeeklyBackup;
import org.jclouds.cloudservers.options.RebuildServerOptions; import org.jclouds.cloudservers.options.RebuildServerOptions;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.HttpResponseException; import org.jclouds.http.HttpResponseException;
import org.jclouds.io.Payload; import org.jclouds.io.Payload;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
@ -415,7 +415,7 @@ public class CloudServersClientLiveTest {
IPSocket socket = new IPSocket(Iterables.get(newDetails.getAddresses().getPublicAddresses(), 0), 22); IPSocket socket = new IPSocket(Iterables.get(newDetails.getAddresses().getPublicAddresses(), 0), 22);
socketTester.apply(socket); socketTester.apply(socket);
SshClient client = sshFactory.create(socket, new Credentials("root", pass)); SshClient client = sshFactory.create(socket, LoginCredentials.builder().user("root").password(pass).build());
try { try {
client.connect(); client.connect();
Payload etcPasswd = client.get("/etc/jclouds.txt"); Payload etcPasswd = client.get("/etc/jclouds.txt");
@ -430,7 +430,7 @@ public class CloudServersClientLiveTest {
private ExecResponse exec(Server details, String pass, String command) throws IOException { private ExecResponse exec(Server details, String pass, String command) throws IOException {
IPSocket socket = new IPSocket(Iterables.get(details.getAddresses().getPublicAddresses(), 0), 22); IPSocket socket = new IPSocket(Iterables.get(details.getAddresses().getPublicAddresses(), 0), 22);
socketTester.apply(socket); socketTester.apply(socket);
SshClient client = sshFactory.create(socket, new Credentials("root", pass)); SshClient client = sshFactory.create(socket, LoginCredentials.builder().user("root").password(pass).build());
try { try {
client.connect(); client.connect();
return client.exec(command); return client.exec(command);

View File

@ -29,7 +29,7 @@ import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystem; import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.json.Json; import org.jclouds.json.Json;
import org.jclouds.json.config.GsonModule; import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -50,7 +50,7 @@ public class CloudServersImageToImageTest {
.name("CentOS 5.2") .name("CentOS 5.2")
.operatingSystem( .operatingSystem(
new OperatingSystem.Builder().family(OsFamily.CENTOS).version("5.2").description("CentOS 5.2").is64Bit(true) new OperatingSystem.Builder().family(OsFamily.CENTOS).version("5.2").description("CentOS 5.2").is64Bit(true)
.build()).description("CentOS 5.2").defaultCredentials(new Credentials("root", null)) .build()).description("CentOS 5.2").defaultCredentials(LoginCredentials.builder().user("root").build())
.ids("2").version("1286712000000").build()); .ids("2").version("1286712000000").build());
} }

View File

@ -43,6 +43,7 @@ import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationBuilder;
import org.jclouds.domain.LocationScope; import org.jclouds.domain.LocationScope;
import org.jclouds.domain.LoginCredentials;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Suppliers; import com.google.common.base.Suppliers;
@ -59,7 +60,7 @@ public class ServerToNodeMetadataTest {
@Test @Test
public void testApplyWhereImageAndHardwareNotFoundButCredentialsFound() throws UnknownHostException { public void testApplyWhereImageAndHardwareNotFoundButCredentialsFound() throws UnknownHostException {
Credentials creds = new Credentials("root", "abdce"); LoginCredentials creds = LoginCredentials.builder().user("root").password("abcde").build();
Map<ServerStatus, NodeState> serverStateToNodeState = CloudServersComputeServiceDependenciesModule.serverToNodeState; Map<ServerStatus, NodeState> serverStateToNodeState = CloudServersComputeServiceDependenciesModule.serverToNodeState;
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(); Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of();

View File

@ -18,21 +18,37 @@
*/ */
package org.jclouds.cloudsigma; package org.jclouds.cloudsigma;
import com.google.common.base.Predicate; import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Predicates; import static org.testng.Assert.assertEquals;
import com.google.common.collect.ImmutableMap; import static org.testng.Assert.assertNotNull;
import com.google.common.collect.ImmutableSet;
import com.google.gson.Gson; import java.io.IOException;
import com.google.inject.Guice; import java.util.Properties;
import com.google.inject.Module; import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.cloudsigma.domain.*; import org.jclouds.cloudsigma.domain.ClaimType;
import org.jclouds.cloudsigma.domain.CreateDriveRequest;
import org.jclouds.cloudsigma.domain.DriveData;
import org.jclouds.cloudsigma.domain.DriveInfo;
import org.jclouds.cloudsigma.domain.DriveStatus;
import org.jclouds.cloudsigma.domain.DriveType;
import org.jclouds.cloudsigma.domain.IDEDevice;
import org.jclouds.cloudsigma.domain.Model;
import org.jclouds.cloudsigma.domain.ProfileInfo;
import org.jclouds.cloudsigma.domain.Server;
import org.jclouds.cloudsigma.domain.ServerInfo;
import org.jclouds.cloudsigma.domain.ServerStatus;
import org.jclouds.cloudsigma.domain.StaticIPInfo;
import org.jclouds.cloudsigma.domain.VLANInfo;
import org.jclouds.cloudsigma.options.CloneDriveOptions; import org.jclouds.cloudsigma.options.CloneDriveOptions;
import org.jclouds.cloudsigma.predicates.DriveClaimed; import org.jclouds.cloudsigma.predicates.DriveClaimed;
import org.jclouds.cloudsigma.util.Servers; import org.jclouds.cloudsigma.util.Servers;
import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.InetSocketAddressConnect;
@ -44,15 +60,13 @@ import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.io.IOException; import com.google.common.base.Predicate;
import java.util.Properties; import com.google.common.base.Predicates;
import java.util.Set; import com.google.common.collect.ImmutableMap;
import java.util.concurrent.TimeUnit; import com.google.common.collect.ImmutableSet;
import java.util.logging.Logger; import com.google.gson.Gson;
import com.google.inject.Guice;
import static com.google.common.base.Preconditions.checkNotNull; import com.google.inject.Module;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
/** /**
* Tests behavior of {@code CloudSigmaClient} * Tests behavior of {@code CloudSigmaClient}
@ -395,7 +409,7 @@ public class CloudSigmaClientLiveTest {
assertEquals(client.getDriveInfo(drive.getUuid()), null); assertEquals(client.getDriveInfo(drive.getUuid()), null);
} }
protected void doConnectViaSsh(Server server, Credentials creds) throws IOException { protected void doConnectViaSsh(Server server, LoginCredentials creds) throws IOException {
SshClient ssh = Guice.createInjector(new SshjSshClientModule()).getInstance(SshClient.Factory.class) SshClient ssh = Guice.createInjector(new SshjSshClientModule()).getInstance(SshClient.Factory.class)
.create(new IPSocket(server.getVnc().getIp(), 22), creds); .create(new IPSocket(server.getVnc().getIp(), 22), creds);
try { try {
@ -439,8 +453,8 @@ public class CloudSigmaClientLiveTest {
assertNotNull(drives); assertNotNull(drives);
} }
protected Credentials getSshCredentials(Server server) { protected LoginCredentials getSshCredentials(Server server) {
return new Credentials("root", vncPassword); return LoginCredentials.builder().user("root").password(vncPassword).build();
} }
protected void prepareDrive() { protected void prepareDrive() {

View File

@ -35,7 +35,7 @@ import com.google.common.collect.Sets;
/** /**
* Contains options supported by the * Contains options supported by the
* {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} and * {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} and
* {@link ComputeService#runNodesWithTag(String, int, TemplateOptions)} * {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)}
* operations on the <em>gogrid</em> provider. * operations on the <em>gogrid</em> provider.
* *
* <h2>Usage</h2> The recommended way to instantiate a * <h2>Usage</h2> The recommended way to instantiate a
@ -48,7 +48,7 @@ import com.google.common.collect.Sets;
* import static org.jclouds.compute.options.CloudStackTemplateOptions.Builder.*; * import static org.jclouds.compute.options.CloudStackTemplateOptions.Builder.*;
* ComputeService client = // get connection * ComputeService client = // get connection
* templateBuilder.options(inboundPorts(22, 80, 8080, 443)); * templateBuilder.options(inboundPorts(22, 80, 8080, 443));
* Set&lt;? extends NodeMetadata&gt; set = client.runNodesWithTag(tag, 2, templateBuilder.build()); * Set&lt;? extends NodeMetadata&gt; set = client.createNodesInGroup(tag, 2, templateBuilder.build());
* </pre> * </pre>
* *
* @author Adrian Cole * @author Adrian Cole
@ -262,24 +262,6 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
return CloudStackTemplateOptions.class.cast(options.runScript(script)); return CloudStackTemplateOptions.class.cast(options.runScript(script));
} }
/**
* @see TemplateOptions#installPrivateKey(Payload)
*/
@Deprecated
public static CloudStackTemplateOptions installPrivateKey(Payload rsaKey) {
CloudStackTemplateOptions options = new CloudStackTemplateOptions();
return CloudStackTemplateOptions.class.cast(options.installPrivateKey(rsaKey));
}
/**
* @see TemplateOptions#authorizePublicKey(Payload)
*/
@Deprecated
public static CloudStackTemplateOptions authorizePublicKey(Payload rsaKey) {
CloudStackTemplateOptions options = new CloudStackTemplateOptions();
return CloudStackTemplateOptions.class.cast(options.authorizePublicKey(rsaKey));
}
/** /**
* @see TemplateOptions#userMetadata(Map) * @see TemplateOptions#userMetadata(Map)
*/ */
@ -323,15 +305,6 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
return CloudStackTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); return CloudStackTemplateOptions.class.cast(super.authorizePublicKey(publicKey));
} }
/**
* @see TemplateOptions#authorizePublicKey(Payload)
*/
@Override
@Deprecated
public CloudStackTemplateOptions authorizePublicKey(Payload publicKey) {
return CloudStackTemplateOptions.class.cast(super.authorizePublicKey(publicKey));
}
/** /**
* @see TemplateOptions#installPrivateKey(String) * @see TemplateOptions#installPrivateKey(String)
*/ */
@ -340,32 +313,15 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
return CloudStackTemplateOptions.class.cast(super.installPrivateKey(privateKey)); return CloudStackTemplateOptions.class.cast(super.installPrivateKey(privateKey));
} }
/**
* @see TemplateOptions#installPrivateKey(Payload)
*/
@Override
@Deprecated
public CloudStackTemplateOptions installPrivateKey(Payload privateKey) {
return CloudStackTemplateOptions.class.cast(super.installPrivateKey(privateKey));
}
/** /**
* @see TemplateOptions#runScript(Payload) * @see TemplateOptions#runScript(Payload)
*/ */
@Deprecated
@Override @Override
public CloudStackTemplateOptions runScript(Payload script) { public CloudStackTemplateOptions runScript(Payload script) {
return CloudStackTemplateOptions.class.cast(super.runScript(script)); return CloudStackTemplateOptions.class.cast(super.runScript(script));
} }
/**
* @see TemplateOptions#runScript(byte[])
*/
@Override
@Deprecated
public CloudStackTemplateOptions runScript(byte[] script) {
return CloudStackTemplateOptions.class.cast(super.runScript(script));
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -174,7 +174,7 @@ public class CloudStackComputeServiceAdapter implements
assert vm.getPassword() != null : vm; assert vm.getPassword() != null : vm;
credentials = LoginCredentials.builder().password(vm.getPassword()).build(); credentials = LoginCredentials.builder().password(vm.getPassword()).build();
} else { } else {
credentials = LoginCredentials.builder(credentialStore.get("keypair#" + templateOptions.getKeyPair())).build(); credentials = LoginCredentials.fromCredentials(credentialStore.get("keypair#" + templateOptions.getKeyPair()));
} }
if (templateOptions.shouldSetupStaticNat()) { if (templateOptions.shouldSetupStaticNat()) {
// TODO: possibly not all network ids, do we want to do this // TODO: possibly not all network ids, do we want to do this

View File

@ -19,20 +19,18 @@
package org.jclouds.cloudstack.config; package org.jclouds.cloudstack.config;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.inject.Singleton; import javax.inject.Singleton;
import com.google.common.collect.Sets;
import org.jclouds.cloudstack.domain.Account; import org.jclouds.cloudstack.domain.Account;
import org.jclouds.cloudstack.domain.Account.State; import org.jclouds.cloudstack.domain.Account.State;
import org.jclouds.cloudstack.domain.LoadBalancerRule; import org.jclouds.cloudstack.domain.LoadBalancerRule;
import org.jclouds.cloudstack.domain.User; import org.jclouds.cloudstack.domain.User;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer; import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;

View File

@ -20,12 +20,10 @@ package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collections;
import java.util.Set; import java.util.Set;
import com.google.common.base.CaseFormat; import com.google.common.base.CaseFormat;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
/** /**

View File

@ -18,18 +18,16 @@
*/ */
package org.jclouds.cloudstack.domain; package org.jclouds.cloudstack.domain;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Date;
import java.util.Map;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Represents a usage record from CloudStack * Represents a usage record from CloudStack
* *

View File

@ -55,6 +55,7 @@ import org.jclouds.compute.domain.Template;
import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials; import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials;
import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate; import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;
@ -172,7 +173,7 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien
doConnectViaSsh(socket, prioritizeCredentialsFromTemplate.apply(template, vm.getCredentials())); doConnectViaSsh(socket, prioritizeCredentialsFromTemplate.apply(template, vm.getCredentials()));
} }
protected void doConnectViaSsh(IPSocket socket, Credentials creds) { protected void doConnectViaSsh(IPSocket socket, LoginCredentials creds) {
SshClient ssh = computeContext.utils().sshFactory().create(socket, creds); SshClient ssh = computeContext.utils().sshFactory().create(socket, creds);
try { try {
connectWithRetry(ssh, 5, 2000); connectWithRetry(ssh, 5, 2000);

View File

@ -18,13 +18,17 @@
*/ */
package org.jclouds.cloudstack.features; package org.jclouds.cloudstack.features;
import com.google.common.base.Predicate; import static com.google.common.base.Strings.emptyToNull;
import com.google.common.base.Predicates; import static com.google.common.collect.Iterables.filter;
import com.google.common.collect.ImmutableSet; import static com.google.common.collect.Iterables.get;
import com.google.common.collect.Iterables; import static org.testng.Assert.assertEquals;
import com.google.inject.Guice;
import com.google.inject.Injector; import java.util.NoSuchElementException;
import com.google.inject.Module; import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import org.jclouds.cloudstack.CloudStackAsyncClient; import org.jclouds.cloudstack.CloudStackAsyncClient;
import org.jclouds.cloudstack.CloudStackClient; import org.jclouds.cloudstack.CloudStackClient;
import org.jclouds.cloudstack.CloudStackContext; import org.jclouds.cloudstack.CloudStackContext;
@ -50,7 +54,7 @@ import org.jclouds.compute.BaseVersionedServiceLiveTest;
import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.InetSocketAddressConnect;
@ -61,16 +65,13 @@ import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import java.util.NoSuchElementException; import com.google.common.base.Predicate;
import java.util.Properties; import com.google.common.base.Predicates;
import java.util.Set; import com.google.common.collect.ImmutableSet;
import java.util.concurrent.TimeUnit; import com.google.common.collect.Iterables;
import java.util.logging.Logger; import com.google.inject.Guice;
import com.google.inject.Injector;
import static com.google.common.base.Strings.emptyToNull; import com.google.inject.Module;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.get;
import static org.testng.Assert.assertEquals;
/** /**
* *
@ -181,7 +182,7 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest {
protected void checkSSH(IPSocket socket) { protected void checkSSH(IPSocket socket) {
socketTester.apply(socket); socketTester.apply(socket);
SshClient client = sshFactory.create(socket, new Credentials("root", password)); SshClient client = sshFactory.create(socket, LoginCredentials.builder().user("root").password(password).build());
try { try {
client.connect(); client.connect();
ExecResponse exec = client.exec("echo hello"); ExecResponse exec = client.exec("echo hello");

View File

@ -38,7 +38,7 @@ import org.jclouds.cloudstack.features.VirtualMachineClientLiveTest;
import org.jclouds.cloudstack.predicates.NetworkPredicates; import org.jclouds.cloudstack.predicates.NetworkPredicates;
import org.jclouds.cloudstack.strategy.BlockUntilJobCompletesAndReturnResult; import org.jclouds.cloudstack.strategy.BlockUntilJobCompletesAndReturnResult;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
@ -111,7 +111,7 @@ public class StaticNATVirtualMachineInNetworkLiveTest extends NATClientLiveTest
checkRule(rule); checkRule(rule);
IPSocket socket = new IPSocket(ip.getIPAddress(), 22); IPSocket socket = new IPSocket(ip.getIPAddress(), 22);
socketTester.apply(socket); socketTester.apply(socket);
SshClient client = sshFactory.create(socket, new Credentials("root", password)); SshClient client = sshFactory.create(socket, LoginCredentials.builder().user("root").password(password).build());
try { try {
client.connect(); client.connect();
ExecResponse exec = client.exec("echo hello"); ExecResponse exec = client.exec("echo hello");

View File

@ -30,7 +30,7 @@ import org.jclouds.deltacloud.domain.PasswordAuthentication;
import org.jclouds.deltacloud.domain.Transition; import org.jclouds.deltacloud.domain.Transition;
import org.jclouds.deltacloud.domain.TransitionOnAction; import org.jclouds.deltacloud.domain.TransitionOnAction;
import org.jclouds.deltacloud.options.CreateInstanceOptions; import org.jclouds.deltacloud.options.CreateInstanceOptions;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
@ -52,7 +52,7 @@ public class DeltacloudClientLiveTest extends ReadOnlyDeltacloudClientLiveTest {
protected String prefix = System.getProperty("user.name") + ".test"; protected String prefix = System.getProperty("user.name") + ".test";
protected Instance instance; protected Instance instance;
protected Credentials creds; protected LoginCredentials creds;
public void testCreateInstance() throws Exception { public void testCreateInstance() throws Exception {
Logger.getAnonymousLogger().info("starting instance"); Logger.getAnonymousLogger().info("starting instance");
@ -133,7 +133,7 @@ public class DeltacloudClientLiveTest extends ReadOnlyDeltacloudClientLiveTest {
assert refreshInstance() == null; assert refreshInstance() == null;
} }
protected void doConnectViaSsh(Instance instance, Credentials creds) throws IOException { protected void doConnectViaSsh(Instance instance, LoginCredentials creds) throws IOException {
SshClient ssh = Guice.createInjector(new SshjSshClientModule()).getInstance(SshClient.Factory.class).create( SshClient ssh = Guice.createInjector(new SshjSshClientModule()).getInstance(SshClient.Factory.class).create(
new IPSocket(Iterables.get(instance.getPublicAddresses(), 0), 22), creds); new IPSocket(Iterables.get(instance.getPublicAddresses(), 0), 22), creds);
try { try {

View File

@ -143,8 +143,8 @@ public class RunningInstanceToNodeMetadata implements Function<RunningInstance,
} }
protected void addCredentialsForInstance(NodeMetadataBuilder builder, RunningInstance instance) { protected void addCredentialsForInstance(NodeMetadataBuilder builder, RunningInstance instance) {
builder.credentials(LoginCredentials.builder( builder.credentials(LoginCredentials.fromCredentials(credentialStore.get("node#" + instance.getRegion() + "/"
credentialStore.get("node#" + instance.getRegion() + "/" + instance.getId())).build()); + instance.getId())));
} }
protected Hardware parseHardware(final RunningInstance instance) { protected Hardware parseHardware(final RunningInstance instance) {

View File

@ -54,7 +54,7 @@ import com.google.common.collect.Iterables;
* <p/> * <p/>
* ComputeService client = // get connection * ComputeService client = // get connection
* templateBuilder.options(inboundPorts(22, 80, 8080, 443)); * templateBuilder.options(inboundPorts(22, 80, 8080, 443));
* Set<? extends NodeMetadata> set = client.runNodesWithTag(tag, 2, templateBuilder.build()); * Set<? extends NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build());
* <code> * <code>
* *
* @author Adrian Cole * @author Adrian Cole
@ -268,14 +268,6 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
return EC2TemplateOptions.class.cast(options.blockOnPort(port, seconds)); return EC2TemplateOptions.class.cast(options.blockOnPort(port, seconds));
} }
/**
* @see TemplateOptions#runScript
*/
public static EC2TemplateOptions runScript(byte[] script) {
EC2TemplateOptions options = new EC2TemplateOptions();
return EC2TemplateOptions.class.cast(options.runScript(script));
}
/** /**
* @see TemplateOptions#installPrivateKey * @see TemplateOptions#installPrivateKey
*/ */
@ -371,15 +363,6 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
return EC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey)); return EC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey));
} }
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public EC2TemplateOptions authorizePublicKey(Payload publicKey) {
return EC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey));
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -391,29 +374,12 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
@Deprecated @Deprecated
public EC2TemplateOptions installPrivateKey(Payload privateKey) {
return EC2TemplateOptions.class.cast(super.installPrivateKey(privateKey));
}
/**
* {@inheritDoc}
*/
@Override @Override
public EC2TemplateOptions runScript(Payload script) { public EC2TemplateOptions runScript(Payload script) {
return EC2TemplateOptions.class.cast(super.runScript(script)); return EC2TemplateOptions.class.cast(super.runScript(script));
} }
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public EC2TemplateOptions runScript(byte[] script) {
return EC2TemplateOptions.class.cast(super.runScript(script));
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -37,7 +37,7 @@ import java.util.concurrent.TimeoutException;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.aws.AWSResponseException; import org.jclouds.aws.AWSResponseException;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.BlockDevice;
import org.jclouds.ec2.domain.Image.EbsBlockDevice; import org.jclouds.ec2.domain.Image.EbsBlockDevice;
import org.jclouds.ec2.domain.InstanceState; import org.jclouds.ec2.domain.InstanceState;
@ -328,7 +328,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
instance = getInstance(instanceId); instance = getInstance(instanceId);
blockUntilWeCanSshIntoInstance(instance); blockUntilWeCanSshIntoInstance(instance);
SshClient ssh = sshFactory.create(new IPSocket(instance.getIpAddress(), 22), SshClient ssh = sshFactory.create(new IPSocket(instance.getIpAddress(), 22),
new Credentials("root", keyPair.getKeyMaterial())); LoginCredentials.builder().user("root").privateKey(keyPair.getKeyMaterial()).build());
try { try {
ssh.connect(); ssh.connect();
ExecResponse uptime = ssh.exec("uptime"); ExecResponse uptime = ssh.exec("uptime");
@ -432,7 +432,8 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest {
} }
private void doCheckKey(String address) { private void doCheckKey(String address) {
SshClient ssh = sshFactory.create(new IPSocket(address, 22), new Credentials("root", keyPair.getKeyMaterial())); SshClient ssh = sshFactory.create(new IPSocket(address, 22),
LoginCredentials.builder().user("root").privateKey(keyPair.getKeyMaterial()).build());
try { try {
ssh.connect(); ssh.connect();
ExecResponse hello = ssh.exec("echo hello"); ExecResponse hello = ssh.exec("echo hello");

View File

@ -37,7 +37,7 @@ import java.util.concurrent.TimeoutException;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.aws.AWSResponseException; import org.jclouds.aws.AWSResponseException;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.ec2.domain.Attachment; import org.jclouds.ec2.domain.Attachment;
import org.jclouds.ec2.domain.BlockDevice; import org.jclouds.ec2.domain.BlockDevice;
import org.jclouds.ec2.domain.Image; import org.jclouds.ec2.domain.Image;
@ -303,7 +303,7 @@ public class EBSBootEC2ClientLiveTest {
@Test(enabled = false, dependsOnMethods = "testCreateAndAttachVolume") @Test(enabled = false, dependsOnMethods = "testCreateAndAttachVolume")
void testBundleInstance() { void testBundleInstance() {
SshClient ssh = sshFactory.create(new IPSocket(instance.getIpAddress(), 22), SshClient ssh = sshFactory.create(new IPSocket(instance.getIpAddress(), 22),
new Credentials("ubuntu", keyPair.getKeyMaterial())); LoginCredentials.builder().user("ubuntu").privateKey(keyPair.getKeyMaterial()).build());
try { try {
ssh.connect(); ssh.connect();
} catch (SshException e) {// try twice in case there is a network timeout } catch (SshException e) {// try twice in case there is a network timeout
@ -539,7 +539,8 @@ public class EBSBootEC2ClientLiveTest {
} }
private void doCheckKey(String address) { private void doCheckKey(String address) {
SshClient ssh = sshFactory.create(new IPSocket(address, 22), new Credentials("ubuntu", keyPair.getKeyMaterial())); SshClient ssh = sshFactory.create(new IPSocket(address, 22),
LoginCredentials.builder().user("ubuntu").privateKey(keyPair.getKeyMaterial()).build());
try { try {
ssh.connect(); ssh.connect();
ExecResponse hello = ssh.exec("echo hello"); ExecResponse hello = ssh.exec("echo hello");

View File

@ -31,7 +31,7 @@ import java.util.logging.Logger;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.elasticstack.domain.ClaimType; import org.jclouds.elasticstack.domain.ClaimType;
import org.jclouds.elasticstack.domain.CreateDriveRequest; import org.jclouds.elasticstack.domain.CreateDriveRequest;
import org.jclouds.elasticstack.domain.DriveData; import org.jclouds.elasticstack.domain.DriveData;
@ -311,7 +311,7 @@ public class ElasticStackClientLiveTest {
assertEquals(client.getDriveInfo(drive.getUuid()), null); assertEquals(client.getDriveInfo(drive.getUuid()), null);
} }
protected void doConnectViaSsh(Server server, Credentials creds) throws IOException { protected void doConnectViaSsh(Server server, LoginCredentials creds) throws IOException {
SshClient ssh = Guice.createInjector(new SshjSshClientModule()).getInstance(SshClient.Factory.class).create( SshClient ssh = Guice.createInjector(new SshjSshClientModule()).getInstance(SshClient.Factory.class).create(
new IPSocket(server.getVnc().getIp(), 22), creds); new IPSocket(server.getVnc().getIp(), 22), creds);
try { try {
@ -371,8 +371,8 @@ public class ElasticStackClientLiveTest {
} }
} }
protected Credentials getSshCredentials(Server server) { protected LoginCredentials getSshCredentials(Server server) {
return new Credentials("toor", server.getVnc().getPassword()); return LoginCredentials.builder().user("toor").password(server.getVnc().getPassword()).build();
} }
protected void prepareDrive() { protected void prepareDrive() {

View File

@ -26,7 +26,7 @@ import static com.google.common.collect.Maps.uniqueIndex;
import static com.google.common.collect.Sets.filter; import static com.google.common.collect.Sets.filter;
import static com.google.common.collect.Sets.newTreeSet; import static com.google.common.collect.Sets.newTreeSet;
import static org.jclouds.compute.ComputeTestUtils.buildScript; import static org.jclouds.compute.ComputeTestUtils.buildScript;
import static org.jclouds.compute.options.TemplateOptions.Builder.overrideCredentialsWith; import static org.jclouds.compute.options.TemplateOptions.Builder.overrideLoginCredentials;
import static org.jclouds.compute.predicates.NodePredicates.TERMINATED; import static org.jclouds.compute.predicates.NodePredicates.TERMINATED;
import static org.jclouds.compute.predicates.NodePredicates.all; import static org.jclouds.compute.predicates.NodePredicates.all;
import static org.jclouds.compute.predicates.NodePredicates.inGroup; import static org.jclouds.compute.predicates.NodePredicates.inGroup;
@ -176,7 +176,7 @@ public class NovaComputeServiceLiveTest extends ComputeBase {
for (Map.Entry<? extends NodeMetadata, ExecResponse> response : computeService.runScriptOnNodesMatching( for (Map.Entry<? extends NodeMetadata, ExecResponse> response : computeService.runScriptOnNodesMatching(
runningInGroup(group), runningInGroup(group),
Statements.exec("echo hello"), Statements.exec("echo hello"),
overrideCredentialsWith(LoginCredentials.builder().user("root").privateKey(keyPair.get("private")).build()) overrideLoginCredentials(LoginCredentials.builder().user("root").privateKey(keyPair.get("private")).build())
.wrapInInitScript(false).runAsRoot(false)).entrySet()) .wrapInInitScript(false).runAsRoot(false)).entrySet())
assert response.getValue().getOutput().trim().equals("hello") : response.getKey() + ": " + response.getValue(); assert response.getValue().getOutput().trim().equals("hello") : response.getKey() + ": " + response.getValue();
@ -262,7 +262,7 @@ public class NovaComputeServiceLiveTest extends ComputeBase {
protected Map<? extends NodeMetadata, ExecResponse> runJavaInstallationScriptWithCreds(final String group, protected Map<? extends NodeMetadata, ExecResponse> runJavaInstallationScriptWithCreds(final String group,
OperatingSystem os, LoginCredentials creds) throws RunScriptOnNodesException { OperatingSystem os, LoginCredentials creds) throws RunScriptOnNodesException {
return computeService.runScriptOnNodesMatching(runningInGroup(group), buildScript(os), return computeService.runScriptOnNodesMatching(runningInGroup(group), buildScript(os),
overrideCredentialsWith(creds).nameTask("runJavaInstallationScriptWithCreds")); overrideLoginCredentials(creds).nameTask("runJavaInstallationScriptWithCreds"));
} }

View File

@ -26,7 +26,7 @@ import static org.testng.Assert.assertTrue;
import java.io.IOException; import java.io.IOException;
import java.util.Set; import java.util.Set;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.HttpResponseException; import org.jclouds.http.HttpResponseException;
import org.jclouds.io.Payload; import org.jclouds.io.Payload;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
@ -259,7 +259,8 @@ public class NovaClientLiveTest extends ClientBase {
IPSocket socket = new IPSocket(Iterables.get(server.getAddresses().getPublicAddresses(), 0).getAddress(), 22); IPSocket socket = new IPSocket(Iterables.get(server.getAddresses().getPublicAddresses(), 0).getAddress(), 22);
//socketTester.apply(socket); //socketTester.apply(socket);
SshClient client = sshFactory.create(socket, new Credentials("root", keyPair.get("private"))); SshClient client = sshFactory.create(socket,
LoginCredentials.builder().user("root").privateKey(keyPair.get("private")).build());
try { try {
client.connect(); client.connect();
Payload etcPasswd = client.get("/etc/jclouds.txt"); Payload etcPasswd = client.get("/etc/jclouds.txt");

View File

@ -19,22 +19,16 @@
package org.jclouds.openstack.swift.config; package org.jclouds.openstack.swift.config;
import java.net.URI; import java.net.URI;
import java.util.concurrent.Future;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse; import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse;
import org.jclouds.openstack.config.OpenStackAuthenticationModule.GetAuthenticationResponse;
import org.jclouds.openstack.reference.AuthHeaders; import org.jclouds.openstack.reference.AuthHeaders;
import org.jclouds.openstack.swift.CommonSwiftAsyncClient; import org.jclouds.openstack.swift.CommonSwiftAsyncClient;
import org.jclouds.openstack.swift.CommonSwiftClient; import org.jclouds.openstack.swift.CommonSwiftClient;
import org.jclouds.openstack.swift.SwiftAsyncClient; import org.jclouds.openstack.swift.SwiftAsyncClient;
import org.jclouds.openstack.swift.SwiftClient; import org.jclouds.openstack.swift.SwiftClient;
import org.jclouds.rest.AsyncClientFactory;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import com.google.inject.Provides; import com.google.inject.Provides;

View File

@ -84,8 +84,8 @@ public class VAppToNodeMetadata implements Function<VApp, NodeMetadata> {
Credentials fromApi = getCredentialsFrom(from); Credentials fromApi = getCredentialsFrom(from);
if (fromApi != null && !credentialStore.containsKey("node#" + from.getHref().toASCIIString())) if (fromApi != null && !credentialStore.containsKey("node#" + from.getHref().toASCIIString()))
credentialStore.put("node#" + from.getHref().toASCIIString(), fromApi); credentialStore.put("node#" + from.getHref().toASCIIString(), fromApi);
builder.credentials(LoginCredentials.builder(credentialStore.get("node#" + from.getHref().toASCIIString())) builder.credentials(LoginCredentials.fromCredentials(credentialStore
.build()); .get("node#" + from.getHref().toASCIIString())));
return builder.build(); return builder.build();
} }
} }

View File

@ -38,7 +38,7 @@ import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
* <p/> * <p/>
* ComputeService client = // get connection * ComputeService client = // get connection
* templateBuilder.options(inboundPorts(22, 80, 8080, 443)); * templateBuilder.options(inboundPorts(22, 80, 8080, 443));
* Set<? extends NodeMetadata> set = client.runNodesWithTag(tag, 2, templateBuilder.build()); * Set<? extends NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build());
* <code> * <code>
* *
* @author Adrian Cole * @author Adrian Cole
@ -148,22 +148,6 @@ public class VCloudTemplateOptions extends TemplateOptions implements Cloneable
return VCloudTemplateOptions.class.cast(options.runScript(script)); return VCloudTemplateOptions.class.cast(options.runScript(script));
} }
/**
* @see TemplateOptions#installPrivateKey
*/
public static VCloudTemplateOptions installPrivateKey(Payload rsaKey) {
VCloudTemplateOptions options = new VCloudTemplateOptions();
return VCloudTemplateOptions.class.cast(options.installPrivateKey(rsaKey));
}
/**
* @see TemplateOptions#authorizePublicKey
*/
public static VCloudTemplateOptions authorizePublicKey(Payload rsaKey) {
VCloudTemplateOptions options = new VCloudTemplateOptions();
return VCloudTemplateOptions.class.cast(options.authorizePublicKey(rsaKey));
}
/** /**
* @see TemplateOptions#userMetadata(Map) * @see TemplateOptions#userMetadata(Map)
*/ */
@ -235,15 +219,6 @@ public class VCloudTemplateOptions extends TemplateOptions implements Cloneable
return VCloudTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); return VCloudTemplateOptions.class.cast(super.authorizePublicKey(publicKey));
} }
/**
* @see TemplateOptions#authorizePublicKey(Payload)
*/
@Override
@Deprecated
public VCloudTemplateOptions authorizePublicKey(Payload publicKey) {
return VCloudTemplateOptions.class.cast(super.authorizePublicKey(publicKey));
}
/** /**
* @see TemplateOptions#installPrivateKey(String) * @see TemplateOptions#installPrivateKey(String)
*/ */
@ -252,32 +227,15 @@ public class VCloudTemplateOptions extends TemplateOptions implements Cloneable
return VCloudTemplateOptions.class.cast(super.installPrivateKey(privateKey)); return VCloudTemplateOptions.class.cast(super.installPrivateKey(privateKey));
} }
/**
* @see TemplateOptions#installPrivateKey(Payload)
*/
@Override
@Deprecated
public VCloudTemplateOptions installPrivateKey(Payload privateKey) {
return VCloudTemplateOptions.class.cast(super.installPrivateKey(privateKey));
}
/** /**
* @see TemplateOptions#runScript(Payload) * @see TemplateOptions#runScript(Payload)
*/ */
@Deprecated
@Override @Override
public VCloudTemplateOptions runScript(Payload script) { public VCloudTemplateOptions runScript(Payload script) {
return VCloudTemplateOptions.class.cast(super.runScript(script)); return VCloudTemplateOptions.class.cast(super.runScript(script));
} }
/**
* @see TemplateOptions#runScript(byte[])
*/
@Override
@Deprecated
public VCloudTemplateOptions runScript(byte[] script) {
return VCloudTemplateOptions.class.cast(super.runScript(script));
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -18,19 +18,16 @@
*/ */
package org.jclouds.vcloud.compute.options; package org.jclouds.vcloud.compute.options;
import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.authorizePublicKey;
import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.blockOnPort; import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.blockOnPort;
import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.customizationScript; import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.customizationScript;
import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.description; import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.description;
import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.inboundPorts; import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.inboundPorts;
import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.installPrivateKey;
import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.ipAddressAllocationMode; import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.ipAddressAllocationMode;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.IOException; import java.io.IOException;
import org.jclouds.compute.options.TemplateOptions; import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.io.Payloads;
import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -115,17 +112,6 @@ public class VCloudTemplateOptionsTest {
assertEquals(options.getPrivateKey(), null); assertEquals(options.getPrivateKey(), null);
} }
@Test
public void testinstallPrivateKeyStatic() throws IOException {
VCloudTemplateOptions options = installPrivateKey(Payloads.newPayload("-----BEGIN RSA PRIVATE KEY-----"));
assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----");
}
@Test(expectedExceptions = NullPointerException.class)
public void testinstallPrivateKeyNPE() {
installPrivateKey(null);
}
@Test @Test
public void testauthorizePublicKey() throws IOException { public void testauthorizePublicKey() throws IOException {
VCloudTemplateOptions options = new VCloudTemplateOptions(); VCloudTemplateOptions options = new VCloudTemplateOptions();
@ -139,17 +125,6 @@ public class VCloudTemplateOptionsTest {
assertEquals(options.getPublicKey(), null); assertEquals(options.getPublicKey(), null);
} }
@Test
public void testauthorizePublicKeyStatic() throws IOException {
VCloudTemplateOptions options = authorizePublicKey(Payloads.newPayload("ssh-rsa"));
assertEquals(options.getPublicKey(), "ssh-rsa");
}
@Test(expectedExceptions = NullPointerException.class)
public void testauthorizePublicKeyNPE() {
authorizePublicKey(null);
}
@Test(expectedExceptions = IllegalArgumentException.class) @Test(expectedExceptions = IllegalArgumentException.class)
public void testblockOnPortBadFormat() { public void testblockOnPortBadFormat() {
VCloudTemplateOptions options = new VCloudTemplateOptions(); VCloudTemplateOptions options = new VCloudTemplateOptions();

View File

@ -134,14 +134,6 @@ public class TerremarkVCloudTemplateOptions extends TemplateOptions implements C
return TerremarkVCloudTemplateOptions.class.cast(options.blockUntilRunning(blockUntilRunning)); return TerremarkVCloudTemplateOptions.class.cast(options.blockUntilRunning(blockUntilRunning));
} }
/**
* @see TemplateOptions#runScript
*/
public static TerremarkVCloudTemplateOptions runScript(byte[] script) {
TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
return TerremarkVCloudTemplateOptions.class.cast(options.runScript(script));
}
/** /**
* @see TemplateOptions#installPrivateKey * @see TemplateOptions#installPrivateKey
*/ */
@ -207,15 +199,6 @@ public class TerremarkVCloudTemplateOptions extends TemplateOptions implements C
return TerremarkVCloudTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); return TerremarkVCloudTemplateOptions.class.cast(super.authorizePublicKey(publicKey));
} }
/**
* @see TemplateOptions#authorizePublicKey(Payload)
*/
@Override
@Deprecated
public TerremarkVCloudTemplateOptions authorizePublicKey(Payload publicKey) {
return TerremarkVCloudTemplateOptions.class.cast(super.authorizePublicKey(publicKey));
}
/** /**
* @see TemplateOptions#installPrivateKey(String) * @see TemplateOptions#installPrivateKey(String)
*/ */
@ -224,32 +207,16 @@ public class TerremarkVCloudTemplateOptions extends TemplateOptions implements C
return TerremarkVCloudTemplateOptions.class.cast(super.installPrivateKey(privateKey)); return TerremarkVCloudTemplateOptions.class.cast(super.installPrivateKey(privateKey));
} }
/**
* @see TemplateOptions#installPrivateKey(Payload)
*/
@Override
@Deprecated
public TerremarkVCloudTemplateOptions installPrivateKey(Payload privateKey) {
return TerremarkVCloudTemplateOptions.class.cast(super.installPrivateKey(privateKey));
}
/** /**
* @see TemplateOptions#runScript(Payload) * @see TemplateOptions#runScript(Payload)
*/ */
@Deprecated
@Override @Override
public TerremarkVCloudTemplateOptions runScript(Payload script) { public TerremarkVCloudTemplateOptions runScript(Payload script) {
return TerremarkVCloudTemplateOptions.class.cast(super.runScript(script)); return TerremarkVCloudTemplateOptions.class.cast(super.runScript(script));
} }
/**
* @see TemplateOptions#runScript(byte[])
*/
@Override
@Deprecated
public TerremarkVCloudTemplateOptions runScript(byte[] script) {
return TerremarkVCloudTemplateOptions.class.cast(super.runScript(script));
}
/** /**
* @see TemplateOptions#userMetadata * @see TemplateOptions#userMetadata
*/ */

View File

@ -139,9 +139,7 @@ See http://code.google.com/p/jclouds for details."
"list details of all the nodes in the given group." "list details of all the nodes in the given group."
([group] (nodes-in-group group *compute*)) ([group] (nodes-in-group group *compute*))
([#^String group #^ComputeService compute] ([#^String group #^ComputeService compute]
(filter #(= (.getTag %) group) (nodes-with-details compute)))) (filter #(= (.getGroup %) group) (nodes-with-details compute))))
(deprecate-fwd nodes-with-tag nodes-in-group)
(defn images (defn images
"Retrieve the available images for the compute context." "Retrieve the available images for the compute context."
@ -241,8 +239,6 @@ See http://code.google.com/p/jclouds for details."
([#^String group #^ComputeService compute] ([#^String group #^ComputeService compute]
(.suspendNodesMatching compute (NodePredicates/inGroup group)))) (.suspendNodesMatching compute (NodePredicates/inGroup group))))
(deprecate-fwd suspend-nodes-with-tag suspend-nodes-in-group)
(defn suspend-node (defn suspend-node
"Suspend a node, given its id." "Suspend a node, given its id."
([id] (suspend-node id *compute*)) ([id] (suspend-node id *compute*))
@ -255,8 +251,6 @@ See http://code.google.com/p/jclouds for details."
([#^String group #^ComputeService compute] ([#^String group #^ComputeService compute]
(.resumeNodesMatching compute (NodePredicates/inGroup group)))) (.resumeNodesMatching compute (NodePredicates/inGroup group))))
(deprecate-fwd resume-nodes-with-tag resume-nodes-in-group)
(defn resume-node (defn resume-node
"Resume a node, given its id." "Resume a node, given its id."
([id] (resume-node id *compute*)) ([id] (resume-node id *compute*))
@ -269,8 +263,6 @@ See http://code.google.com/p/jclouds for details."
([#^String group #^ComputeService compute] ([#^String group #^ComputeService compute]
(.rebootNodesMatching compute (NodePredicates/inGroup group)))) (.rebootNodesMatching compute (NodePredicates/inGroup group))))
(deprecate-fwd reboot-nodes-with-tag reboot-nodes-in-group)
(defn reboot-node (defn reboot-node
"Reboot a node, given its id." "Reboot a node, given its id."
([id] (reboot-node id *compute*)) ([id] (reboot-node id *compute*))
@ -283,8 +275,6 @@ See http://code.google.com/p/jclouds for details."
([#^String group #^ComputeService compute] ([#^String group #^ComputeService compute]
(.destroyNodesMatching compute (NodePredicates/inGroup group)))) (.destroyNodesMatching compute (NodePredicates/inGroup group))))
(deprecate-fwd destroy-nodes-with-tag destroy-nodes-in-group)
(defn destroy-node (defn destroy-node
"Destroy a node, given its id." "Destroy a node, given its id."
([id] (destroy-node id *compute*)) ([id] (destroy-node id *compute*))
@ -342,8 +332,6 @@ See http://code.google.com/p/jclouds for details."
[#^NodeMetadata node] [#^NodeMetadata node]
(.getGroup node)) (.getGroup node))
(deprecate-fwd tag group)
(defn hostname (defn hostname
"Returns the compute node's name" "Returns the compute node's name"
[#^ComputeMetadata node] [#^ComputeMetadata node]

View File

@ -35,7 +35,6 @@ import org.jclouds.compute.options.RunScriptOptions;
import org.jclouds.compute.options.TemplateOptions; import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts; import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import org.jclouds.io.Payload;
import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.scriptbuilder.domain.Statement;
import com.google.common.annotations.Beta; import com.google.common.annotations.Beta;
@ -150,25 +149,6 @@ public interface ComputeService {
*/ */
Set<? extends NodeMetadata> createNodesInGroup(String group, int count) throws RunNodesException; Set<? extends NodeMetadata> createNodesInGroup(String group, int count) throws RunNodesException;
/**
* @see #createNodesInGroup(String , int , Template )
*/
@Deprecated
Set<? extends NodeMetadata> runNodesWithTag(String tag, int count, Template template) throws RunNodesException;
/**
* @see #createNodesInGroup(String , int , TemplateOptions )
*/
@Deprecated
Set<? extends NodeMetadata> runNodesWithTag(String tag, int count, TemplateOptions templateOptions)
throws RunNodesException;
/**
* @see #createNodesInGroup(String , int )
*/
@Deprecated
Set<? extends NodeMetadata> runNodesWithTag(String tag, int count) throws RunNodesException;
/** /**
* resume the node from {@link org.jclouds.compute.domain.NodeState#SUSPENDED suspended} state, * resume the node from {@link org.jclouds.compute.domain.NodeState#SUSPENDED suspended} state,
* given its id. * given its id.
@ -265,22 +245,6 @@ public interface ComputeService {
*/ */
Set<? extends NodeMetadata> listNodesDetailsMatching(Predicate<ComputeMetadata> filter); Set<? extends NodeMetadata> listNodesDetailsMatching(Predicate<ComputeMetadata> filter);
/**
* @see org.jclouds.io.Payloads
* @see ComputeService#runScriptOnNodesMatching(Predicate, Statement, RunScriptOptions)
*/
@Deprecated
Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> filter, Payload runScript)
throws RunScriptOnNodesException;
/**
* @see org.jclouds.io.Payloads
* @see ComputeService#runScriptOnNodesMatching(Predicate, Statement, RunScriptOptions)
*/
@Deprecated
Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> filter,
Payload runScript, RunScriptOptions options) throws RunScriptOnNodesException;
/** /**
* *
* @see ComputeService#runScriptOnNodesMatching(Predicate, Statement, RunScriptOptions) * @see ComputeService#runScriptOnNodesMatching(Predicate, Statement, RunScriptOptions)
@ -317,7 +281,7 @@ public interface ComputeService {
* @throws RunScriptOnNodesException * @throws RunScriptOnNodesException
* if anything goes wrong during script execution * if anything goes wrong during script execution
* *
* @see org.jclouds.compute.predicates.NodePredicates#runningWithTag(String) * @see org.jclouds.compute.predicates.NodePredicates#runningInGroup(String)
* @see org.jclouds.scriptbuilder.domain.Statements * @see org.jclouds.scriptbuilder.domain.Statements
*/ */
Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> filter, Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> filter,
@ -340,7 +304,7 @@ public interface ComputeService {
* @throws ScriptStillRunningException * @throws ScriptStillRunningException
* if the script was still running after {@link Timeouts#scriptComplete} * if the script was still running after {@link Timeouts#scriptComplete}
* *
* @see org.jclouds.compute.predicates.NodePredicates#runningWithTag(String) * @see org.jclouds.compute.predicates.NodePredicates#runningInGroup(String)
* @see org.jclouds.scriptbuilder.domain.Statements * @see org.jclouds.scriptbuilder.domain.Statements
*/ */
ExecResponse runScriptOnNode(String id, Statement runScript, RunScriptOptions options); ExecResponse runScriptOnNode(String id, Statement runScript, RunScriptOptions options);
@ -360,7 +324,7 @@ public interface ComputeService {
* @throws IllegalStateException * @throws IllegalStateException
* if the node is not in running state * if the node is not in running state
* *
* @see org.jclouds.compute.predicates.NodePredicates#runningWithTag(String) * @see org.jclouds.compute.predicates.NodePredicates#runningInGroup(String)
* @see org.jclouds.scriptbuilder.domain.Statements * @see org.jclouds.scriptbuilder.domain.Statements
*/ */
@Beta @Beta

View File

@ -35,7 +35,7 @@ import org.jclouds.javax.annotation.Nullable;
public interface ComputeServiceAdapter<N, H, I, L> { public interface ComputeServiceAdapter<N, H, I, L> {
/** /**
* {@link ComputeService#runNodesWithTag(String, int, Template)} generates * {@link ComputeService#createNodesInGroup(String, int, Template)} generates
* the parameters passed into this method such that each node in the set has * the parameters passed into this method such that each node in the set has
* a unique name. * a unique name.
* *
@ -59,7 +59,7 @@ public interface ComputeServiceAdapter<N, H, I, L> {
* {@code hardwareId} used to resume the instance. * {@code hardwareId} used to resume the instance.
* @return library-native representation of a node. * @return library-native representation of a node.
* *
* @see ComputeService#runNodesWithTag(String, int, Template) * @see ComputeService#createNodesInGroup(String, int, Template)
*/ */
NodeAndInitialCredentials<N> createNodeWithGroupEncodedIntoName(String tag, String name, Template template); NodeAndInitialCredentials<N> createNodeWithGroupEncodedIntoName(String tag, String name, Template template);

View File

@ -107,8 +107,8 @@ public class RunScriptOnNodeAsInitScriptUsingSsh extends SudoAwareInitManager im
if (input.getAdminCredentials() != null && input.shouldGrantSudoToAdminUser()) { if (input.getAdminCredentials() != null && input.shouldGrantSudoToAdminUser()) {
ssh.disconnect(); ssh.disconnect();
logger.debug(">> reconnecting as %s@%s", input.getAdminCredentials().identity, ssh.getHostAddress()); logger.debug(">> reconnecting as %s@%s", input.getAdminCredentials().identity, ssh.getHostAddress());
ssh = sshFactory.apply(node = NodeMetadataBuilder.fromNodeMetadata(node).credentials(LoginCredentials.builder( ssh = sshFactory.apply(node = NodeMetadataBuilder.fromNodeMetadata(node)
input.getAdminCredentials()).build()).build()); .credentials(LoginCredentials.fromCredentials(input.getAdminCredentials())).build());
ssh.connect(); ssh.connect();
setupLinkToInitFile(); setupLinkToInitFile();
} }

View File

@ -55,7 +55,7 @@ public class GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull im
@Nullable @Nullable
public LoginCredentials get() { public LoginCredentials get() {
if (credentialStore.containsKey("image")) { if (credentialStore.containsKey("image")) {
return LoginCredentials.builder(credentialStore.get("image")).build(); return LoginCredentials.fromCredentials(credentialStore.get("image"));
} }
Builder builder = LoginCredentials.builder(); Builder builder = LoginCredentials.builder();

View File

@ -60,7 +60,7 @@ public class PersistNodeCredentialsModule extends AbstractModule {
return input; return input;
Credentials credentials = CredentialsFromAdminAccess.INSTANCE.apply(statement); Credentials credentials = CredentialsFromAdminAccess.INSTANCE.apply(statement);
if (credentials != null) { if (credentials != null) {
LoginCredentials creds = LoginCredentials.builder(credentials).build(); LoginCredentials creds = LoginCredentials.fromCredentials(credentials);
input = NodeMetadataBuilder.fromNodeMetadata(input).credentials(creds).build(); input = NodeMetadataBuilder.fromNodeMetadata(input).credentials(creds).build();
credentialStore.put("node#" + input.getId(), input.getCredentials()); credentialStore.put("node#" + input.getId(), input.getCredentials());
} }

View File

@ -74,10 +74,14 @@ public class ImageBuilder extends ComputeMetadataBuilder {
} }
return this; return this;
} }
/**
* <h4>will be removed in jclouds 1.4.0</h4>
*
* @see #defaultCredentials(LoginCredentials)
*/
@Deprecated @Deprecated
public ImageBuilder defaultCredentials(@Nullable Credentials defaultLoginCredentials) { public ImageBuilder defaultCredentials(@Nullable Credentials defaultLoginCredentials) {
return defaultCredentials(LoginCredentials.builder(defaultLoginCredentials).build()); return defaultCredentials(LoginCredentials.fromCredentials(defaultLoginCredentials));
} }
public ImageBuilder defaultCredentials(@Nullable LoginCredentials defaultLoginCredentials) { public ImageBuilder defaultCredentials(@Nullable LoginCredentials defaultLoginCredentials) {

View File

@ -53,12 +53,6 @@ public interface NodeMetadata extends ComputeMetadata {
@Nullable @Nullable
String getGroup(); String getGroup();
/**
* @see #getGroup
*/
@Deprecated
String getTag();
/** /**
* *
* The hardware this node is running, if possible to determine. * The hardware this node is running, if possible to determine.

View File

@ -97,9 +97,14 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder {
return this; return this;
} }
/**
* <h4>will be removed in jclouds 1.4.0</h4>
*
* @see #credentials(LoginCredentials)
*/
@Deprecated @Deprecated
public NodeMetadataBuilder credentials(@Nullable Credentials credentials) { public NodeMetadataBuilder credentials(@Nullable Credentials credentials) {
return credentials(LoginCredentials.builder(credentials).build()); return credentials(LoginCredentials.fromCredentials(credentials));
} }
public NodeMetadataBuilder credentials(@Nullable LoginCredentials credentials) { public NodeMetadataBuilder credentials(@Nullable LoginCredentials credentials) {

View File

@ -1,30 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.compute.domain;
/**
*
* @author Adrian Cole
* @see OperatingSystem.Builder
*/
@Deprecated
public class OperatingSystemBuilder extends OperatingSystem.Builder {
}

View File

@ -109,14 +109,6 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
this.hostname = hostname; this.hostname = hostname;
} }
/**
* {@inheritDoc}
*/
@Override
public String getTag() {
return getGroup();
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -208,7 +200,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
@Override @Override
public String toString() { public String toString() {
return "[id=" + getId() + ", providerId=" + getProviderId() + ", group=" + getTag() + ", name=" + getName() return "[id=" + getId() + ", providerId=" + getProviderId() + ", group=" + getGroup() + ", name=" + getName()
+ ", location=" + getLocation() + ", uri=" + getUri() + ", imageId=" + getImageId() + ", os=" + ", location=" + getLocation() + ", uri=" + getUri() + ", imageId=" + getImageId() + ", os="
+ getOperatingSystem() + ", state=" + getState() + ", loginPort=" + getLoginPort() + ", hostname=" + getOperatingSystem() + ", state=" + getState() + ", loginPort=" + getLoginPort() + ", hostname="
+ getHostname() + ", privateAddresses=" + privateAddresses + ", publicAddresses=" + publicAddresses + getHostname() + ", privateAddresses=" + privateAddresses + ", publicAddresses=" + publicAddresses

View File

@ -32,7 +32,6 @@ import static org.jclouds.compute.predicates.NodePredicates.all;
import static org.jclouds.concurrent.FutureIterables.awaitCompletion; import static org.jclouds.concurrent.FutureIterables.awaitCompletion;
import static org.jclouds.concurrent.FutureIterables.transformParallel; import static org.jclouds.concurrent.FutureIterables.transformParallel;
import java.io.IOException;
import java.util.Map; import java.util.Map;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Set; import java.util.Set;
@ -82,19 +81,16 @@ import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location; import org.jclouds.domain.Location;
import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.domain.LoginCredentials.Builder; import org.jclouds.domain.LoginCredentials.Builder;
import org.jclouds.io.Payload;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.scriptbuilder.domain.Statement; import org.jclouds.scriptbuilder.domain.Statement;
import org.jclouds.scriptbuilder.domain.Statements; import org.jclouds.scriptbuilder.domain.Statements;
import org.jclouds.scriptbuilder.functions.InitAdminAccess; import org.jclouds.scriptbuilder.functions.InitAdminAccess;
import org.jclouds.util.Maps2; import org.jclouds.util.Maps2;
import org.jclouds.util.Strings2;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@ -185,32 +181,6 @@ public class BaseComputeService implements ComputeService {
return context; return context;
} }
/**
* {@inheritDoc}
*/
@Override
public Set<? extends NodeMetadata> runNodesWithTag(String group, int count, Template template)
throws RunNodesException {
return createNodesInGroup(group, count, template);
}
/**
* {@inheritDoc}
*/
@Override
public Set<? extends NodeMetadata> runNodesWithTag(String group, int count, TemplateOptions templateOptions)
throws RunNodesException {
return createNodesInGroup(group, count, templateBuilder().any().options(templateOptions).build());
}
/**
* {@inheritDoc}
*/
@Override
public Set<? extends NodeMetadata> runNodesWithTag(String group, int count) throws RunNodesException {
return createNodesInGroup(group, count, templateOptions());
}
@Override @Override
public Set<? extends NodeMetadata> createNodesInGroup(String group, int count, Template template) public Set<? extends NodeMetadata> createNodesInGroup(String group, int count, Template template)
throws RunNodesException { throws RunNodesException {
@ -228,7 +198,7 @@ public class BaseComputeService implements ComputeService {
Map<?, Future<Void>> responses = runNodesAndAddToSetStrategy.execute(group, count, template, goodNodes, badNodes, Map<?, Future<Void>> responses = runNodesAndAddToSetStrategy.execute(group, count, template, goodNodes, badNodes,
customizationResponses); customizationResponses);
Map<?, Exception> executionExceptions = awaitCompletion(responses, executor, null, logger, "runNodesWithTag(" Map<?, Exception> executionExceptions = awaitCompletion(responses, executor, null, logger, "createNodesInGroup("
+ group + ")"); + group + ")");
Function<NodeMetadata, NodeMetadata> fn = persistNodeCredentials.always(template.getOptions().getRunScript()); Function<NodeMetadata, NodeMetadata> fn = persistNodeCredentials.always(template.getOptions().getRunScript());
badNodes = Maps2.transformKeys(badNodes, fn); badNodes = Maps2.transformKeys(badNodes, fn);
@ -485,30 +455,6 @@ public class BaseComputeService implements ComputeService {
logger.debug("<< suspended"); logger.debug("<< suspended");
} }
/**
* {@inheritDoc}
*/
@Override
public Map<NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> filter, Payload runScript)
throws RunScriptOnNodesException {
return runScriptOnNodesMatching(filter, runScript, RunScriptOptions.NONE);
}
/**
* {@inheritDoc}
*/
@Override
public Map<NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> filter, Payload runScript,
RunScriptOptions options) throws RunScriptOnNodesException {
try {
return runScriptOnNodesMatching(filter,
Statements.exec(Strings2.toStringAndClose(checkNotNull(runScript, "runScript").getInput())), options);
} catch (IOException e) {
Throwables.propagate(e);
return null;
}
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -189,9 +189,13 @@ public class RunScriptOptions {
protected Optional<String> loginPassword; protected Optional<String> loginPassword;
protected Optional<String> loginPrivateKey; protected Optional<String> loginPrivateKey;
/**
* to be removed in jclouds 1.4.0
* @see #overrideLoginCredentials
*/
@Deprecated @Deprecated
public RunScriptOptions overrideCredentialsWith(Credentials overridingCredentials) { public RunScriptOptions overrideCredentialsWith(Credentials overridingCredentials) {
return overrideLoginCredentials(LoginCredentials.builder(overridingCredentials).build()); return overrideLoginCredentials(LoginCredentials.fromCredentials(overridingCredentials));
} }
public RunScriptOptions overrideLoginCredentials(LoginCredentials overridingCredentials) { public RunScriptOptions overrideLoginCredentials(LoginCredentials overridingCredentials) {
@ -203,6 +207,10 @@ public class RunScriptOptions {
return this; return this;
} }
/**
* to be removed in jclouds 1.4.0
* @see #overrideLoginCredentials
*/
@Deprecated @Deprecated
public RunScriptOptions overrideLoginUserWith(String loginUser) { public RunScriptOptions overrideLoginUserWith(String loginUser) {
return overrideLoginUser(loginUser); return overrideLoginUser(loginUser);
@ -214,6 +222,10 @@ public class RunScriptOptions {
return this; return this;
} }
/**
* to be removed in jclouds 1.4.0
* @see #overrideLoginCredentials
*/
@Deprecated @Deprecated
public RunScriptOptions overrideLoginCredentialWith(String loginCredential) { public RunScriptOptions overrideLoginCredentialWith(String loginCredential) {
checkNotNull(loginCredential, "loginCredential"); checkNotNull(loginCredential, "loginCredential");

View File

@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
/** /**
* Contains options supported in the {@code ComputeService#runNodesWithTag} * Contains options supported in the {@code ComputeService#createNodesInGroup}
* operation. <h2> * operation. <h2>
* Usage</h2> The recommended way to instantiate a TemplateOptions object is to * Usage</h2> The recommended way to instantiate a TemplateOptions object is to
* statically import TemplateOptions.* and invoke a static creation method * statically import TemplateOptions.* and invoke a static creation method
@ -50,7 +50,7 @@ import com.google.common.collect.Maps;
* <p/> * <p/>
* ComputeService client = // get connection * ComputeService client = // get connection
* templateBuilder.options(inboundPorts(22, 80, 8080, 443)); * templateBuilder.options(inboundPorts(22, 80, 8080, 443));
* Set<? extends NodeMetadata> set = client.runNodesWithTag(tag, 2, templateBuilder.build()); * Set<? extends NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build());
* <code> * <code>
* *
* @author Adrian Cole * @author Adrian Cole
@ -162,22 +162,11 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
throw new IllegalArgumentException("script is immutable"); throw new IllegalArgumentException("script is immutable");
} }
@Override
public TemplateOptions installPrivateKey(Payload privateKey) {
throw new IllegalArgumentException("privateKey is immutable");
}
@Override @Override
public TemplateOptions dontAuthorizePublicKey() { public TemplateOptions dontAuthorizePublicKey() {
throw new IllegalArgumentException("public key is immutable"); throw new IllegalArgumentException("public key is immutable");
} }
@Override
@Deprecated
public TemplateOptions authorizePublicKey(Payload publicKey) {
throw new IllegalArgumentException("public key is immutable");
}
@Override @Override
public TemplateOptions blockOnPort(int port, int seconds) { public TemplateOptions blockOnPort(int port, int seconds) {
throw new IllegalArgumentException("ports are immutable"); throw new IllegalArgumentException("ports are immutable");
@ -318,11 +307,6 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
throw new IllegalArgumentException("privateKey is immutable"); throw new IllegalArgumentException("privateKey is immutable");
} }
@Override
public TemplateOptions runScript(byte[] script) {
throw new IllegalArgumentException("script is immutable");
}
@Override @Override
public Set<String> getTags() { public Set<String> getTags() {
return delegate.getTags(); return delegate.getTags();
@ -396,31 +380,31 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
} }
/** /**
* <p/> * to be removed in jclouds 1.4.0
* please use alternative that uses the
* {@link org.jclouds.scriptbuilder.domain.Statement} object
* *
* @see TemplateOptions#runScript(Statement) * @see TemplateOptions#runScript(Statement)
* @see org.jclouds.io.Payloads * @see org.jclouds.io.Payloads
*
*/ */
@Deprecated @Deprecated
public TemplateOptions runScript(byte[] script) {
return runScript(Statements.exec(new String(checkNotNull(script, "script"))));
}
/**
* @see TemplateOptions#runScript(Statement)
* @see org.jclouds.io.Payloads
*/
public TemplateOptions runScript(Payload script) { public TemplateOptions runScript(Payload script) {
try { try {
return runScript(Statements.exec(Strings2.toStringAndClose(checkNotNull(script, "script").getInput()))); return runScript(Strings2.toStringAndClose(checkNotNull(script, "script").getInput()));
} catch (IOException e) { } catch (IOException e) {
Throwables.propagate(e); Throwables.propagate(e);
return this; return this;
} }
} }
/**
* This script will be executed as the root user upon system startup. This
* script gets a prologue, so no #!/bin/bash required, path set up, etc
*
*/
public TemplateOptions runScript(String script) {
return runScript(Statements.exec(script));
}
/** /**
* This script will be executed as the root user upon system startup. This * This script will be executed as the root user upon system startup. This
* script gets a prologue, so no #!/bin/bash required, path set up, etc * script gets a prologue, so no #!/bin/bash required, path set up, etc
@ -441,23 +425,6 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
return this; return this;
} }
/**
* replaces the rsa ssh key used at login.
* <p/>
* please use alternative that uses {@link java.lang.String}
*
* @see org.jclouds.io.Payloads
*/
@Deprecated
public TemplateOptions installPrivateKey(Payload privateKey) {
try {
return installPrivateKey(Strings2.toStringAndClose(checkNotNull(privateKey, "privateKey").getInput()));
} catch (IOException e) {
Throwables.propagate(e);
return this;
}
}
public TemplateOptions dontAuthorizePublicKey() { public TemplateOptions dontAuthorizePublicKey() {
this.publicKey = null; this.publicKey = null;
return this; return this;
@ -472,23 +439,6 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
return this; return this;
} }
/**
* authorize an rsa ssh key.
* <p/>
* please use alternative that uses {@link java.lang.String}
*
* @see org.jclouds.io.Payloads
*/
@Deprecated
public TemplateOptions authorizePublicKey(Payload publicKey) {
try {
return authorizePublicKey(Strings2.toStringAndClose(checkNotNull(publicKey, "publicKey").getInput()));
} catch (IOException e) {
Throwables.propagate(e);
return this;
}
}
/** /**
* assigns tags to the created nodes * assigns tags to the created nodes
*/ */
@ -595,12 +545,17 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
} }
/** /**
* please use alternative that uses the {@link Statement) object
*
* @see TemplateOptions#runScript(Statement) * @see TemplateOptions#runScript(Statement)
*/ */
@Deprecated public static TemplateOptions runScript(Statement script) {
public static TemplateOptions runScript(byte[] script) { TemplateOptions options = new TemplateOptions();
return options.runScript(script);
}
/**
* @see TemplateOptions#runScript(String)
*/
public static TemplateOptions runScript(String script) {
TemplateOptions options = new TemplateOptions(); TemplateOptions options = new TemplateOptions();
return options.runScript(script); return options.runScript(script);
} }
@ -609,19 +564,12 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
* @see TemplateOptions#runScript(Statement) * @see TemplateOptions#runScript(Statement)
* @see org.jclouds.io.Payloads * @see org.jclouds.io.Payloads
*/ */
@Deprecated
public static TemplateOptions runScript(Payload script) { public static TemplateOptions runScript(Payload script) {
TemplateOptions options = new TemplateOptions(); TemplateOptions options = new TemplateOptions();
return options.runScript(script); return options.runScript(script);
} }
/**
* @see TemplateOptions#runScript(Statement)
*/
public static TemplateOptions runScript(Statement script) {
TemplateOptions options = new TemplateOptions();
return options.runScript(script);
}
/** /**
* please use alternative that uses the {@link org.jclouds.io.Payload} * please use alternative that uses the {@link org.jclouds.io.Payload}
* object * object
@ -629,43 +577,22 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
* @see org.jclouds.io.Payloads * @see org.jclouds.io.Payloads
* @see #installPrivateKey(Payload) * @see #installPrivateKey(Payload)
*/ */
@Deprecated
public static TemplateOptions installPrivateKey(String rsaKey) { public static TemplateOptions installPrivateKey(String rsaKey) {
TemplateOptions options = new TemplateOptions(); TemplateOptions options = new TemplateOptions();
return options.installPrivateKey(rsaKey); return options.installPrivateKey(rsaKey);
} }
/**
* @see TemplateOptions#installPrivateKey
* @see org.jclouds.io.Payloads
*/
public static TemplateOptions installPrivateKey(Payload rsaKey) {
TemplateOptions options = new TemplateOptions();
return options.installPrivateKey(rsaKey);
}
/** /**
* please use alternative that uses the {@link org.jclouds.io.Payload} * please use alternative that uses the {@link org.jclouds.io.Payload}
* object * object
* *
* @see org.jclouds.io.Payloads * @see #authorizePublicKey(String)
* @see #authorizePublicKey(Payload)
*/ */
@Deprecated
public static TemplateOptions authorizePublicKey(String rsaKey) { public static TemplateOptions authorizePublicKey(String rsaKey) {
TemplateOptions options = new TemplateOptions(); TemplateOptions options = new TemplateOptions();
return options.authorizePublicKey(rsaKey); return options.authorizePublicKey(rsaKey);
} }
/**
* @see TemplateOptions#authorizePublicKey(Payload)
* @see org.jclouds.io.Payloads
*/
public static TemplateOptions authorizePublicKey(Payload rsaKey) {
TemplateOptions options = new TemplateOptions();
return options.authorizePublicKey(rsaKey);
}
/** /**
* @see TemplateOptions#userMetadata(Map) * @see TemplateOptions#userMetadata(Map)
*/ */

View File

@ -205,15 +205,6 @@ public class NodePredicates {
}; };
} }
/**
*
* @see #inGroup(String)
*/
@Deprecated
public static Predicate<NodeMetadata> withTag(final String tag) {
return inGroup(tag);
}
/** /**
* Return nodes with specified group that are in the NODE_RUNNING state. * Return nodes with specified group that are in the NODE_RUNNING state.
* *
@ -236,15 +227,6 @@ public class NodePredicates {
}; };
} }
/**
*
* @see #inGroup(String)
*/
@Deprecated
public static Predicate<NodeMetadata> runningWithTag(final String tag) {
return runningInGroup(tag);
}
/** /**
* Match nodes with State == RUNNING * Match nodes with State == RUNNING
*/ */

View File

@ -66,12 +66,6 @@ public class RetryIfSocketNotYetOpen implements Predicate<IPSocket> {
this(socketTester, Logger.NULL, timeouts.portOpen, TimeUnit.MILLISECONDS); this(socketTester, Logger.NULL, timeouts.portOpen, TimeUnit.MILLISECONDS);
} }
/** @deprecated in favor of specifying explicit time units */
@Deprecated
public RetryIfSocketNotYetOpen(SocketOpen socketTester, Logger logger, long seconds) {
this(socketTester, logger, seconds, TimeUnit.SECONDS);
}
public RetryIfSocketNotYetOpen milliseconds(long milliseconds) { public RetryIfSocketNotYetOpen milliseconds(long milliseconds) {
this.timeoutValue = milliseconds; this.timeoutValue = milliseconds;
this.timeoutUnits = TimeUnit.MILLISECONDS; this.timeoutUnits = TimeUnit.MILLISECONDS;

View File

@ -88,7 +88,7 @@ public class AdaptingComputeServiceStrategies<N, H, I, L> implements CreateNodeW
@Override @Override
public NodeMetadata apply(NodeMetadata arg0) { public NodeMetadata apply(NodeMetadata arg0) {
return credentialStore.containsKey("node#" + arg0.getId()) ? NodeMetadataBuilder.fromNodeMetadata(arg0) return credentialStore.containsKey("node#" + arg0.getId()) ? NodeMetadataBuilder.fromNodeMetadata(arg0)
.credentials(LoginCredentials.builder(credentialStore.get("node#" + arg0.getId())).build()).build() .credentials(LoginCredentials.fromCredentials(credentialStore.get("node#" + arg0.getId()))).build()
: arg0; : arg0;
} }

View File

@ -23,6 +23,7 @@ import javax.annotation.PreDestroy;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.io.Payload; import org.jclouds.io.Payload;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
@ -32,24 +33,17 @@ import org.jclouds.net.IPSocket;
public interface SshClient { public interface SshClient {
interface Factory { interface Factory {
/**
* please use {@link Factory#create(IPSocket, Credentials)}
*
* @return
*/
@Deprecated
SshClient create(IPSocket socket, String username, String password);
/** /**
* please use {@link Factory#create(IPSocket, Credentials)} * To be removed in jclouds 1.5.0
* *
* @return * @see #create(IPSocket, LoginCredentials)
*/ */
@Deprecated @Deprecated
SshClient create(IPSocket socket, String username, byte[] privateKey);
SshClient create(IPSocket socket, Credentials credentials); SshClient create(IPSocket socket, Credentials credentials);
SshClient create(IPSocket socket, LoginCredentials credentials);
} }
String getUsername(); String getUsername();

View File

@ -70,25 +70,6 @@ list, Alan Dipert and MeikelBrandmeyer."
(destroy-nodes-in-group "fred") (destroy-nodes-in-group "fred")
(is (terminated? (first (nodes-in-group "fred"))))) (is (terminated? (first (nodes-in-group "fred")))))
(deftest nodes-test-deprecated
(is (empty? (nodes)))
(is (run-node "deprecated" (build-template
*compute* {} )))
(is (= 1 (count (nodes))))
(is (= 1 (count (nodes-with-tag "deprecated"))))
(suspend-nodes-with-tag "deprecated")
(is (suspended? (first (nodes-with-tag "deprecated"))))
(resume-nodes-with-tag "deprecated")
(is (running? (first (nodes-with-tag "deprecated"))))
(reboot-nodes-with-tag "deprecated")
(is (running? (first (nodes-with-tag "deprecated"))))
(is (run-nodes "deprecated" 2 (build-template
*compute* {} )))
(is (= 3 (count (nodes-with-tag "deprecated"))))
(is (= "deprecated" (tag (first (nodes)))))
(destroy-nodes-with-tag "deprecated")
(is (terminated? (first (nodes-with-tag "deprecated")))))
(deftest build-template-test (deftest build-template-test
(let [service (compute-service "stub" "compute.clj" "")] (let [service (compute-service "stub" "compute.clj" "")]
(testing "nullary" (testing "nullary"

View File

@ -23,6 +23,7 @@
(:import (:import
org.jclouds.ssh.SshClient org.jclouds.ssh.SshClient
org.jclouds.domain.Credentials org.jclouds.domain.Credentials
org.jclouds.domain.LoginCredentials
org.jclouds.io.Payload org.jclouds.io.Payload
org.jclouds.net.IPSocket org.jclouds.net.IPSocket
org.jclouds.compute.domain.ExecResponse)) org.jclouds.compute.domain.ExecResponse))
@ -76,18 +77,14 @@
(deftype SshClientFactory (deftype SshClientFactory
[factory-fn] [factory-fn]
org.jclouds.ssh.SshClient$Factory org.jclouds.ssh.SshClient$Factory
(^org.jclouds.ssh.SshClient
create
[_ ^IPSocket socket ^String username ^String password-or-key]
(factory-fn socket username password-or-key))
(^org.jclouds.ssh.SshClient
create
[_ ^IPSocket socket ^String username ^bytes password-or-key]
(factory-fn socket username password-or-key))
(^org.jclouds.ssh.SshClient (^org.jclouds.ssh.SshClient
create create
[_ ^IPSocket socket ^Credentials credentials] [_ ^IPSocket socket ^Credentials credentials]
(factory-fn socket (.identity credentials) (.credential credentials))) (factory-fn socket (.identity credentials) (.credential credentials)))
(^org.jclouds.ssh.SshClient
create
[_ ^IPSocket socket ^LoginCredentials credentials]
(factory-fn socket (.identity credentials) (.credential credentials)))
) )
(deftype Module (deftype Module

View File

@ -38,7 +38,8 @@ import java.util.concurrent.TimeoutException;
import org.easymock.IArgumentMatcher; import org.easymock.IArgumentMatcher;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.domain.Credentials; import org.jclouds.crypto.Pems;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.io.Payload; import org.jclouds.io.Payload;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;
@ -111,7 +112,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
@Override @Override
public Supplier<Map<String, String>> defaultAdminSshKeys() { public Supplier<Map<String, String>> defaultAdminSshKeys() {
return Suppliers.<Map<String, String>> ofInstance(ImmutableMap.of("public", "publicKey", "private", return Suppliers.<Map<String, String>> ofInstance(ImmutableMap.of("public", "publicKey", "private",
"privateKey")); Pems.PRIVATE_PKCS1_MARKER));
} }
@Override @Override
@ -140,19 +141,28 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
SshClient client4 = createMock(SshClient.class); SshClient client4 = createMock(SshClient.class);
SshClient client5 = createMock(SshClient.class); SshClient client5 = createMock(SshClient.class);
expect(factory.create(new IPSocket("144.175.1.1", 22), new Credentials("root", "password1"))).andReturn( expect(
client1); factory.create(new IPSocket("144.175.1.1", 22),
expect(factory.create(new IPSocket("144.175.1.1", 22), new Credentials("web", "privateKey"))).andReturn( LoginCredentials.builder().user("root").password("password1").build())).andReturn(client1);
client1New).times(10); expect(
factory.create(new IPSocket("144.175.1.1", 22),
LoginCredentials.builder().user("web").privateKey(Pems.PRIVATE_PKCS1_MARKER).build())).andReturn(client1New)
.times(10);
runScriptAndService(client1, client1New); runScriptAndService(client1, client1New);
expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "password2"))).andReturn( expect(
client2).times(4); factory.create(new IPSocket("144.175.1.2", 22),
expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "password2"))).andReturn( LoginCredentials.builder().user("root").password("password2").build())).andReturn(client2)
client2New); .times(4);
expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("foo", "privateKey"))).andReturn( expect(
client2Foo); factory.create(new IPSocket("144.175.1.2", 22),
expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "romeo"))).andThrow( LoginCredentials.builder().user("root").password("password2").build())).andReturn(client2New);
expect(
factory.create(new IPSocket("144.175.1.2", 22),
LoginCredentials.builder().user("foo").privateKey(Pems.PRIVATE_PKCS1_MARKER).build())).andReturn(client2Foo);
expect(
factory.create(new IPSocket("144.175.1.2", 22),
LoginCredentials.builder().user("root").password("romeo").build())).andThrow(
new AuthorizationException("Auth fail", null)); new AuthorizationException("Auth fail", null));
// run script without backgrounding (via predicate) // run script without backgrounding (via predicate)
@ -191,32 +201,43 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
expect(client2Foo.exec("echo $USER\n")).andReturn(new ExecResponse("foo\n", "", 0)); expect(client2Foo.exec("echo $USER\n")).andReturn(new ExecResponse("foo\n", "", 0));
client2Foo.disconnect(); client2Foo.disconnect();
expect(factory.create(new IPSocket("144.175.1.3", 22), new Credentials("root", "password3"))).andReturn( expect(
client3).times(2); factory.create(new IPSocket("144.175.1.3", 22),
expect(factory.create(new IPSocket("144.175.1.4", 22), new Credentials("root", "password4"))).andReturn( LoginCredentials.builder().user("root").password("password3").build())).andReturn(client3)
client4).times(2); .times(2);
expect(factory.create(new IPSocket("144.175.1.5", 22), new Credentials("root", "password5"))).andReturn( expect(
client5).times(2); factory.create(new IPSocket("144.175.1.4", 22),
LoginCredentials.builder().user("root").password("password4").build())).andReturn(client4)
.times(2);
expect(
factory.create(new IPSocket("144.175.1.5", 22),
LoginCredentials.builder().user("root").password("password5").build())).andReturn(client5)
.times(2);
runScriptAndInstallSsh(client3, "bootstrap", 3); runScriptAndInstallSsh(client3, "bootstrap", 3);
runScriptAndInstallSsh(client4, "bootstrap", 4); runScriptAndInstallSsh(client4, "bootstrap", 4);
runScriptAndInstallSsh(client5, "bootstrap", 5); runScriptAndInstallSsh(client5, "bootstrap", 5);
expect( expect(
factory.create(eq(new IPSocket("144.175.1.1", 22)), eq(new Credentials("defaultAdminUsername", factory.create(eq(new IPSocket("144.175.1.1", 22)),
"privateKey")))).andReturn(client1); eq(LoginCredentials.builder().user("defaultAdminUsername").privateKey(Pems.PRIVATE_PKCS1_MARKER).build())))
.andReturn(client1);
expect( expect(
factory.create(eq(new IPSocket("144.175.1.2", 22)), eq(new Credentials("defaultAdminUsername", factory.create(eq(new IPSocket("144.175.1.2", 22)),
"privateKey")))).andReturn(client2); eq(LoginCredentials.builder().user("defaultAdminUsername").privateKey(Pems.PRIVATE_PKCS1_MARKER).build())))
.andReturn(client2);
expect( expect(
factory.create(eq(new IPSocket("144.175.1.3", 22)), eq(new Credentials("defaultAdminUsername", factory.create(eq(new IPSocket("144.175.1.3", 22)),
"privateKey")))).andReturn(client3); eq(LoginCredentials.builder().user("defaultAdminUsername").privateKey(Pems.PRIVATE_PKCS1_MARKER).build())))
.andReturn(client3);
expect( expect(
factory.create(eq(new IPSocket("144.175.1.4", 22)), eq(new Credentials("defaultAdminUsername", factory.create(eq(new IPSocket("144.175.1.4", 22)),
"privateKey")))).andReturn(client4); eq(LoginCredentials.builder().user("defaultAdminUsername").privateKey(Pems.PRIVATE_PKCS1_MARKER).build())))
.andReturn(client4);
expect( expect(
factory.create(eq(new IPSocket("144.175.1.5", 22)), eq(new Credentials("defaultAdminUsername", factory.create(eq(new IPSocket("144.175.1.5", 22)),
"privateKey")))).andReturn(client5); eq(LoginCredentials.builder().user("defaultAdminUsername").privateKey(Pems.PRIVATE_PKCS1_MARKER).build())))
.andReturn(client5);
helloAndJava(client2); helloAndJava(client2);
helloAndJava(client3); helloAndJava(client3);

View File

@ -54,14 +54,12 @@ public class TemplateOptionsTest {
assertEquals(options.getPrivateKey(), null); assertEquals(options.getPrivateKey(), null);
} }
@SuppressWarnings("deprecation")
@Test @Test
public void testinstallPrivateKeyStatic() throws IOException { public void testinstallPrivateKeyStatic() throws IOException {
TemplateOptions options = installPrivateKey("-----BEGIN RSA PRIVATE KEY-----"); TemplateOptions options = installPrivateKey("-----BEGIN RSA PRIVATE KEY-----");
assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----"); assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----");
} }
@SuppressWarnings("deprecation")
@Test(expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
public void testinstallPrivateKeyNPE() { public void testinstallPrivateKeyNPE() {
installPrivateKey((String) null); installPrivateKey((String) null);
@ -86,14 +84,12 @@ public class TemplateOptionsTest {
assertEquals(options.getPublicKey(), null); assertEquals(options.getPublicKey(), null);
} }
@SuppressWarnings("deprecation")
@Test @Test
public void testauthorizePublicKeyStatic() throws IOException { public void testauthorizePublicKeyStatic() throws IOException {
TemplateOptions options = authorizePublicKey("ssh-rsa"); TemplateOptions options = authorizePublicKey("ssh-rsa");
assertEquals(options.getPublicKey(), "ssh-rsa"); assertEquals(options.getPublicKey(), "ssh-rsa");
} }
@SuppressWarnings("deprecation")
@Test(expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
public void testauthorizePublicKeyNPE() { public void testauthorizePublicKeyNPE() {
authorizePublicKey((String) null); authorizePublicKey((String) null);

View File

@ -18,15 +18,24 @@
*/ */
package org.jclouds.domain; package org.jclouds.domain;
import com.google.common.base.Objects;
import com.google.common.base.Optional;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import org.jclouds.util.CredentialUtils; import org.jclouds.util.CredentialUtils;
import com.google.common.base.Optional;
/** /**
* @author Adrian Cole * @author Adrian Cole
*/ */
public class LoginCredentials extends Credentials { public class LoginCredentials extends Credentials {
public static LoginCredentials fromCredentials(Credentials creds) {
if (creds == null)
return null;
if (creds instanceof LoginCredentials)
return LoginCredentials.class.cast(creds);
return builder(creds).build();
}
public static Builder builder(Credentials creds) { public static Builder builder(Credentials creds) {
if (creds == null) if (creds == null)
return builder(); return builder();

View File

@ -38,7 +38,7 @@ public class ClassLoadingUtils {
* @return The class or null if no class loader could load the class. * @return The class or null if no class loader could load the class.
*/ */
public static Class<?> loadClass(Class<?> contextClass, String className) { public static Class<?> loadClass(Class<?> contextClass, String className) {
Class clazz = null; Class<?> clazz = null;
if (contextClass.getClassLoader() != null) { if (contextClass.getClassLoader() != null) {
clazz = silentLoadClass(className, contextClass.getClassLoader()); clazz = silentLoadClass(className, contextClass.getClassLoader());
} }
@ -58,7 +58,7 @@ public class ClassLoadingUtils {
* @param resourceName * @param resourceName
* @return * @return
*/ */
public static URL loadResource(Class contextClass, String resourceName) { public static URL loadResource(Class<?> contextClass, String resourceName) {
URL url = null; URL url = null;
if (contextClass != null) { if (contextClass != null) {
url = Resources.getResource(contextClass, resourceName); url = Resources.getResource(contextClass, resourceName);
@ -79,7 +79,7 @@ public class ClassLoadingUtils {
* @return * @return
*/ */
private static Class<?> silentLoadClass(String className, ClassLoader classLoader) { private static Class<?> silentLoadClass(String className, ClassLoader classLoader) {
Class clazz = null; Class<?> clazz = null;
if (classLoader != null && className != null) { if (classLoader != null && className != null) {
try { try {
clazz = classLoader.loadClass(className); clazz = classLoader.loadClass(className);

View File

@ -28,7 +28,6 @@ import java.io.InputStream;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import com.google.common.base.Joiner;
import org.jclouds.crypto.PemsTest; import org.jclouds.crypto.PemsTest;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials; import org.jclouds.domain.LoginCredentials;

View File

@ -22,6 +22,7 @@ import javax.inject.Named;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.handlers.BackoffLimitedRetryHandler; import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.InetSocketAddressConnect;
@ -29,7 +30,6 @@ import org.jclouds.predicates.SocketOpen;
import org.jclouds.ssh.ConfiguresSshClient; import org.jclouds.ssh.ConfiguresSshClient;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.jsch.JschSshClient; import org.jclouds.ssh.jsch.JschSshClient;
import org.jclouds.util.CredentialUtils;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Inject; import com.google.inject.Inject;
@ -63,22 +63,18 @@ public class JschSshClientModule extends AbstractModule {
this.injector = injector; this.injector = injector;
} }
public SshClient create(IPSocket socket, String username, String password) { @Override
SshClient client = new JschSshClient(backoffLimitedRetryHandler, socket, timeout, username, password, null); public SshClient create(IPSocket socket, LoginCredentials credentials) {
injector.injectMembers(client);// add logger SshClient client = new JschSshClient(backoffLimitedRetryHandler, socket, timeout, credentials.getUser(),
return client; (credentials.getPrivateKey() == null) ? credentials.getPassword() : null,
} credentials.getPrivateKey() != null ? credentials.getPrivateKey().getBytes() : null);
public SshClient create(IPSocket socket, String username, byte[] privateKey) {
SshClient client = new JschSshClient(backoffLimitedRetryHandler, socket, timeout, username, null, privateKey);
injector.injectMembers(client);// add logger injector.injectMembers(client);// add logger
return client; return client;
} }
@Override @Override
public SshClient create(IPSocket socket, Credentials credentials) { public SshClient create(IPSocket socket, Credentials credentials) {
return CredentialUtils.isPrivateKeyCredential(credentials) ? create(socket, credentials.identity, return create(socket, LoginCredentials.fromCredentials(credentials));
credentials.credential.getBytes()) : create(socket, credentials.identity, credentials.credential);
} }
} }
} }

View File

@ -25,7 +25,7 @@ import java.net.ConnectException;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.Properties; import java.util.Properties;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.AuthorizationException;
@ -68,8 +68,8 @@ public class JschSshClientTest {
} }
}, new SLF4JLoggingModule()); }, new SLF4JLoggingModule());
SshClient.Factory factory = i.getInstance(SshClient.Factory.class); SshClient.Factory factory = i.getInstance(SshClient.Factory.class);
JschSshClient ssh = JschSshClient.class.cast(factory.create(new IPSocket("localhost", 22), new Credentials( JschSshClient ssh = JschSshClient.class.cast(factory.create(new IPSocket("localhost", 22), LoginCredentials
"username", "password"))); .builder().user("username").password("password").build()));
return ssh; return ssh;
} }

View File

@ -20,7 +20,7 @@ package org.jclouds.ssh.jsch.config;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
@ -42,7 +42,8 @@ public class JschSshClientModuleTest {
Injector i = Guice.createInjector(new JschSshClientModule(), new SLF4JLoggingModule()); Injector i = Guice.createInjector(new JschSshClientModule(), new SLF4JLoggingModule());
SshClient.Factory factory = i.getInstance(SshClient.Factory.class); SshClient.Factory factory = i.getInstance(SshClient.Factory.class);
SshClient connection = factory.create(new IPSocket("localhost", 22), new Credentials("username", "password")); SshClient connection = factory.create(new IPSocket("localhost", 22), LoginCredentials.builder().user("username")
.password("password").build());
assert connection instanceof JschSshClient; assert connection instanceof JschSshClient;
} }
} }

View File

@ -22,6 +22,7 @@ import javax.inject.Named;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.domain.Credentials; import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.handlers.BackoffLimitedRetryHandler; import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.InetSocketAddressConnect;
@ -29,7 +30,6 @@ import org.jclouds.predicates.SocketOpen;
import org.jclouds.ssh.ConfiguresSshClient; import org.jclouds.ssh.ConfiguresSshClient;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.sshj.SshjSshClient; import org.jclouds.sshj.SshjSshClient;
import org.jclouds.util.CredentialUtils;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Inject; import com.google.inject.Inject;
@ -63,22 +63,18 @@ public class SshjSshClientModule extends AbstractModule {
this.injector = injector; this.injector = injector;
} }
public SshClient create(IPSocket socket, String username, String password) { @Override
SshClient client = new SshjSshClient(backoffLimitedRetryHandler, socket, timeout, username, password, null); public SshClient create(IPSocket socket, LoginCredentials credentials) {
injector.injectMembers(client);// add logger SshClient client = new SshjSshClient(backoffLimitedRetryHandler, socket, timeout, credentials.getUser(),
return client; (credentials.getPrivateKey() == null) ? credentials.getPassword() : null,
} credentials.getPrivateKey() != null ? credentials.getPrivateKey().getBytes() : null);
public SshClient create(IPSocket socket, String username, byte[] privateKey) {
SshClient client = new SshjSshClient(backoffLimitedRetryHandler, socket, timeout, username, null, privateKey);
injector.injectMembers(client);// add logger injector.injectMembers(client);// add logger
return client; return client;
} }
@Override @Override
public SshClient create(IPSocket socket, Credentials credentials) { public SshClient create(IPSocket socket, Credentials credentials) {
return CredentialUtils.isPrivateKeyCredential(credentials) ? create(socket, credentials.identity, return create(socket, LoginCredentials.fromCredentials(credentials));
credentials.credential.getBytes()) : create(socket, credentials.identity, credentials.credential);
} }
} }
} }

View File

@ -27,7 +27,7 @@ import java.io.IOException;
import java.net.InetAddress; import java.net.InetAddress;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.io.Payload; import org.jclouds.io.Payload;
import org.jclouds.io.Payloads; import org.jclouds.io.Payloads;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
@ -38,6 +38,7 @@ import org.jclouds.util.Strings2;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Strings;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.Injector; import com.google.inject.Injector;
@ -111,11 +112,12 @@ public class SshjSshClientLiveTest {
Injector i = Guice.createInjector(new SshjSshClientModule(), new SLF4JLoggingModule()); Injector i = Guice.createInjector(new SshjSshClientModule(), new SLF4JLoggingModule());
SshClient.Factory factory = i.getInstance(SshClient.Factory.class); SshClient.Factory factory = i.getInstance(SshClient.Factory.class);
SshClient connection; SshClient connection;
if (sshKeyFile != null && !sshKeyFile.trim().equals("")) { if (Strings.emptyToNull(sshKeyFile) != null) {
connection = factory.create(new IPSocket(sshHost, port), new Credentials(sshUser, Strings2 connection = factory.create(new IPSocket(sshHost, port), LoginCredentials.builder().user(sshUser)
.toStringAndClose(new FileInputStream(sshKeyFile)))); .privateKey(Strings2.toStringAndClose(new FileInputStream(sshKeyFile))).build());
} else { } else {
connection = factory.create(new IPSocket(sshHost, port), new Credentials(sshUser, sshPass)); connection = factory.create(new IPSocket(sshHost, port),
LoginCredentials.builder().user(sshUser).password(sshPass).build());
} }
connection.connect(); connection.connect();
return connection; return connection;

View File

@ -37,7 +37,7 @@ import net.schmizz.sshj.connection.ConnectionException;
import net.schmizz.sshj.transport.TransportException; import net.schmizz.sshj.transport.TransportException;
import net.schmizz.sshj.userauth.UserAuthException; import net.schmizz.sshj.userauth.UserAuthException;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.BufferLogger; import org.jclouds.logging.BufferLogger;
import org.jclouds.logging.BufferLogger.Record; import org.jclouds.logging.BufferLogger.Record;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
@ -82,8 +82,8 @@ public class SshjSshClientTest {
}, new SLF4JLoggingModule()); }, new SLF4JLoggingModule());
SshClient.Factory factory = i.getInstance(SshClient.Factory.class); SshClient.Factory factory = i.getInstance(SshClient.Factory.class);
SshjSshClient ssh = SshjSshClient.class.cast(factory.create(new IPSocket("localhost", 22), new Credentials( SshjSshClient ssh = SshjSshClient.class.cast(factory.create(new IPSocket("localhost", 22), LoginCredentials
"username", "password"))); .builder().user("username").password("password").build()));
return ssh; return ssh;
} }

View File

@ -18,7 +18,7 @@
*/ */
package org.jclouds.sshj.config; package org.jclouds.sshj.config;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
@ -40,7 +40,8 @@ public class SshjSshClientModuleTest {
Injector i = Guice.createInjector(new SshjSshClientModule(), new SLF4JLoggingModule()); Injector i = Guice.createInjector(new SshjSshClientModule(), new SLF4JLoggingModule());
SshClient.Factory factory = i.getInstance(SshClient.Factory.class); SshClient.Factory factory = i.getInstance(SshClient.Factory.class);
SshClient connection = factory.create(new IPSocket("localhost", 22), new Credentials("username", "password")); SshClient connection = factory.create(new IPSocket("localhost", 22), LoginCredentials.builder().user("username")
.password("password").build());
assert connection instanceof SshjSshClient; assert connection instanceof SshjSshClient;
} }
} }

View File

@ -21,7 +21,6 @@ package org.jclouds.aws.ec2;
import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUERY; import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUERY;
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY; import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY;
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMIs;
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_REGIONS; import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_REGIONS;
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_GENERATE_INSTANCE_NAMES; import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_GENERATE_INSTANCE_NAMES;
import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_NODE_SUSPENDED; import static org.jclouds.compute.reference.ComputeServiceConstants.PROPERTY_TIMEOUT_NODE_SUSPENDED;
@ -77,7 +76,6 @@ public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilde
public Properties build() { public Properties build() {
Properties props = super.build(); Properties props = super.build();
warnAndReplaceIfUsingOldImageKey(props); warnAndReplaceIfUsingOldImageKey(props);
warnAndReplaceIfUsingOldCCImageKey(props);
return props; return props;
} }
@ -98,15 +96,4 @@ public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilde
} }
} }
protected void warnAndReplaceIfUsingOldCCImageKey(Properties props) {
if (props.containsKey(PROPERTY_EC2_CC_AMIs)) {
String amis = properties.remove(PROPERTY_EC2_CC_AMIs).toString();
String value = ("".equals(amis)) ? "" : "image-id=" + amis.replace("us-east-1/", "");
props.setProperty(PROPERTY_EC2_CC_AMI_QUERY, value);
Logger.getAnonymousLogger().warning(
String.format("Property %s is deprecated, please use new syntax: %s=%s", PROPERTY_EC2_CC_AMIs,
PROPERTY_EC2_CC_AMI_QUERY, value));
}
}
} }

View File

@ -52,7 +52,7 @@ import com.google.common.collect.Iterables;
* <p/> * <p/>
* ComputeService client = // get connection * ComputeService client = // get connection
* templateBuilder.options(inboundPorts(22, 80, 8080, 443)); * templateBuilder.options(inboundPorts(22, 80, 8080, 443));
* Set<? extends NodeMetadata> set = client.runNodesWithTag(tag, 2, templateBuilder.build()); * Set<? extends NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build());
* <code> * <code>
* *
* @author Adrian Cole * @author Adrian Cole
@ -359,14 +359,6 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
return options.blockOnPort(port, seconds); return options.blockOnPort(port, seconds);
} }
/**
* @see TemplateOptions#runScript
*/
public static AWSEC2TemplateOptions runScript(byte[] script) {
AWSEC2TemplateOptions options = new AWSEC2TemplateOptions();
return options.runScript(script);
}
/** /**
* @see TemplateOptions#installPrivateKey * @see TemplateOptions#installPrivateKey
*/ */
@ -550,15 +542,6 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
return AWSEC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey)); return AWSEC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey));
} }
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public AWSEC2TemplateOptions authorizePublicKey(Payload publicKey) {
return AWSEC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey));
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -570,29 +553,12 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override
@Deprecated @Deprecated
public AWSEC2TemplateOptions installPrivateKey(Payload privateKey) {
return AWSEC2TemplateOptions.class.cast(super.installPrivateKey(privateKey));
}
/**
* {@inheritDoc}
*/
@Override @Override
public AWSEC2TemplateOptions runScript(Payload script) { public AWSEC2TemplateOptions runScript(Payload script) {
return AWSEC2TemplateOptions.class.cast(super.runScript(script)); return AWSEC2TemplateOptions.class.cast(super.runScript(script));
} }
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public AWSEC2TemplateOptions runScript(byte[] script) {
return AWSEC2TemplateOptions.class.cast(super.runScript(script));
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -60,12 +60,12 @@ public class AWSRunningInstanceToNodeMetadata extends RunningInstanceToNodeMetad
@Override @Override
protected void addCredentialsForInstance(NodeMetadataBuilder builder, RunningInstance instance) { protected void addCredentialsForInstance(NodeMetadataBuilder builder, RunningInstance instance) {
LoginCredentials creds = LoginCredentials.builder( LoginCredentials creds = LoginCredentials.fromCredentials(credentialStore.get("node#" + instance.getRegion()
credentialStore.get("node#" + instance.getRegion() + "/" + instance.getId())).build(); + "/" + instance.getId()));
String spotRequestId = AWSRunningInstance.class.cast(instance).getSpotInstanceRequestId(); String spotRequestId = AWSRunningInstance.class.cast(instance).getSpotInstanceRequestId();
if (creds == null && spotRequestId != null) { if (creds == null && spotRequestId != null) {
creds = LoginCredentials.builder(credentialStore.get("node#" + instance.getRegion() + "/" + spotRequestId)) creds = LoginCredentials.fromCredentials(credentialStore.get("node#" + instance.getRegion() + "/"
.build(); + spotRequestId));
if (creds != null) if (creds != null)
credentialStore.put("node#" + instance.getRegion() + "/" + instance.getId(), creds); credentialStore.put("node#" + instance.getRegion() + "/" + instance.getId(), creds);
} }

View File

@ -27,14 +27,6 @@ import org.jclouds.ec2.reference.EC2Constants;
* @author Adrian Cole * @author Adrian Cole
*/ */
public interface AWSEC2Constants extends EC2Constants { public interface AWSEC2Constants extends EC2Constants {
/**
* amis that work on the cluster instance type
*
* @see InstanceType.CC1_4XLARGE
*/
@Deprecated
public static final String PROPERTY_EC2_CC_AMIs = "jclouds.ec2.cc-amis";
/** /**
* expression to find amis that work on the cluster instance type <br/> * expression to find amis that work on the cluster instance type <br/>
* ex. {@code * ex. {@code

View File

@ -19,8 +19,6 @@
package org.jclouds.aws.ec2; package org.jclouds.aws.ec2;
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUERY; import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_AMI_QUERY;
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY;
import static org.jclouds.aws.ec2.reference.AWSEC2Constants.PROPERTY_EC2_CC_AMIs;
import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS; import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
@ -33,13 +31,6 @@ import org.testng.annotations.Test;
*/ */
@Test(groups = "unit", testName = "AWSEC2PropertiesBuilderTest") @Test(groups = "unit", testName = "AWSEC2PropertiesBuilderTest")
public class AWSEC2PropertiesBuilderTest { public class AWSEC2PropertiesBuilderTest {
public void testConvertCCImageSyntax() {
Properties input = new Properties();
input.setProperty(PROPERTY_EC2_CC_AMIs, "us-east-1/ami-321eed5b,us-east-1/ami-7ea24a17");
Properties props = new AWSEC2PropertiesBuilder(input).build();
assertEquals(props.getProperty(PROPERTY_EC2_CC_AMIs), null);
assertEquals(props.getProperty(PROPERTY_EC2_CC_AMI_QUERY), "image-id=ami-321eed5b,ami-7ea24a17");
}
public void testConvertImageSyntax() { public void testConvertImageSyntax() {
Properties input = new Properties(); Properties input = new Properties();

View File

@ -278,8 +278,8 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
try { try {
Properties overrides = setupProperties(); Properties overrides = setupProperties();
// set owners to nothing // set owners to nothing
overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMIs, "");
overrides.setProperty(EC2Constants.PROPERTY_EC2_AMI_OWNERS, ""); overrides.setProperty(EC2Constants.PROPERTY_EC2_AMI_OWNERS, "");
overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, "");
context = new ComputeServiceContextFactory().createContext(provider, context = new ComputeServiceContextFactory().createContext(provider,
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides); ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides);

View File

@ -22,7 +22,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.get; import static com.google.common.collect.Iterables.get;
import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.collect.Iterables.getOnlyElement;
import static com.google.common.collect.Sets.newTreeSet; import static com.google.common.collect.Sets.newTreeSet;
import static org.jclouds.compute.options.TemplateOptions.Builder.overrideCredentialsWith; import static org.jclouds.compute.options.TemplateOptions.Builder.overrideLoginCredentials;
import static org.jclouds.compute.predicates.NodePredicates.inGroup; import static org.jclouds.compute.predicates.NodePredicates.inGroup;
import static org.jclouds.compute.predicates.NodePredicates.runningInGroup; import static org.jclouds.compute.predicates.NodePredicates.runningInGroup;
import static org.jclouds.scriptbuilder.domain.Statements.exec; import static org.jclouds.scriptbuilder.domain.Statements.exec;
@ -144,7 +144,7 @@ public class AWSKeyPairClientLiveTest {
.runScriptOnNodesMatching( .runScriptOnNodesMatching(
runningInGroup(group), runningInGroup(group),
exec("echo hello"), exec("echo hello"),
overrideCredentialsWith( overrideLoginCredentials(
LoginCredentials.builder().user(first.getCredentials().identity) LoginCredentials.builder().user(first.getCredentials().identity)
.privateKey(keyPair.get("private")).build()).wrapInInitScript(false).runAsRoot(false)); .privateKey(keyPair.get("private")).build()).wrapInInitScript(false).runAsRoot(false));

View File

@ -27,7 +27,7 @@ import org.jclouds.io.Payload;
/** /**
* Contains options supported by the * Contains options supported by the
* {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} and * {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} and
* {@link ComputeService#runNodesWithTag(String, int, TemplateOptions)} * {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)}
* operations on the <em>gogrid</em> provider. * operations on the <em>gogrid</em> provider.
* *
* <h2>Usage</h2> The recommended way to instantiate a * <h2>Usage</h2> The recommended way to instantiate a
@ -40,7 +40,7 @@ import org.jclouds.io.Payload;
* import static org.jclouds.compute.options.GoGridTemplateOptions.Builder.*; * import static org.jclouds.compute.options.GoGridTemplateOptions.Builder.*;
* ComputeService client = // get connection * ComputeService client = // get connection
* templateBuilder.options(inboundPorts(22, 80, 8080, 443)); * templateBuilder.options(inboundPorts(22, 80, 8080, 443));
* Set&lt;? extends NodeMetadata&gt; set = client.runNodesWithTag(tag, 2, templateBuilder.build()); * Set&lt;? extends NodeMetadata&gt; set = client.createNodesInGroup(tag, 2, templateBuilder.build());
* </pre> * </pre>
* *
* TODO add GoGrid specific options * TODO add GoGrid specific options
@ -94,24 +94,6 @@ public class GoGridTemplateOptions extends TemplateOptions implements Cloneable
return GoGridTemplateOptions.class.cast(options.runScript(script)); return GoGridTemplateOptions.class.cast(options.runScript(script));
} }
/**
* @see TemplateOptions#installPrivateKey(Payload)
*/
@Deprecated
public static GoGridTemplateOptions installPrivateKey(Payload rsaKey) {
GoGridTemplateOptions options = new GoGridTemplateOptions();
return GoGridTemplateOptions.class.cast(options.installPrivateKey(rsaKey));
}
/**
* @see TemplateOptions#authorizePublicKey(Payload)
*/
@Deprecated
public static GoGridTemplateOptions authorizePublicKey(Payload rsaKey) {
GoGridTemplateOptions options = new GoGridTemplateOptions();
return GoGridTemplateOptions.class.cast(options.authorizePublicKey(rsaKey));
}
/** /**
* @see TemplateOptions#userMetadata(Map) * @see TemplateOptions#userMetadata(Map)
*/ */
@ -155,15 +137,6 @@ public class GoGridTemplateOptions extends TemplateOptions implements Cloneable
return GoGridTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); return GoGridTemplateOptions.class.cast(super.authorizePublicKey(publicKey));
} }
/**
* @see TemplateOptions#authorizePublicKey(Payload)
*/
@Override
@Deprecated
public GoGridTemplateOptions authorizePublicKey(Payload publicKey) {
return GoGridTemplateOptions.class.cast(super.authorizePublicKey(publicKey));
}
/** /**
* @see TemplateOptions#installPrivateKey(String) * @see TemplateOptions#installPrivateKey(String)
*/ */
@ -172,32 +145,15 @@ public class GoGridTemplateOptions extends TemplateOptions implements Cloneable
return GoGridTemplateOptions.class.cast(super.installPrivateKey(privateKey)); return GoGridTemplateOptions.class.cast(super.installPrivateKey(privateKey));
} }
/**
* @see TemplateOptions#installPrivateKey(Payload)
*/
@Override
@Deprecated
public GoGridTemplateOptions installPrivateKey(Payload privateKey) {
return GoGridTemplateOptions.class.cast(super.installPrivateKey(privateKey));
}
/** /**
* @see TemplateOptions#runScript(Payload) * @see TemplateOptions#runScript(Payload)
*/ */
@Deprecated
@Override @Override
public GoGridTemplateOptions runScript(Payload script) { public GoGridTemplateOptions runScript(Payload script) {
return GoGridTemplateOptions.class.cast(super.runScript(script)); return GoGridTemplateOptions.class.cast(super.runScript(script));
} }
/**
* @see TemplateOptions#runScript(byte[])
*/
@Override
@Deprecated
public GoGridTemplateOptions runScript(byte[] script) {
return GoGridTemplateOptions.class.cast(super.runScript(script));
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.cim.OSType; import org.jclouds.cim.OSType;
import org.jclouds.compute.domain.CIMOperatingSystem; import org.jclouds.compute.domain.CIMOperatingSystem;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.InetSocketAddressConnect;
import org.jclouds.predicates.RetryablePredicate; import org.jclouds.predicates.RetryablePredicate;
@ -40,7 +40,6 @@ import org.jclouds.savvis.vpdc.domain.VMSpec;
import org.jclouds.savvis.vpdc.options.GetVMOptions; import org.jclouds.savvis.vpdc.options.GetVMOptions;
import org.jclouds.savvis.vpdc.reference.VCloudMediaType; import org.jclouds.savvis.vpdc.reference.VCloudMediaType;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.util.InetAddresses2;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -49,7 +48,6 @@ import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.net.HostSpecifier;
@Test(groups = "live") @Test(groups = "live")
public class VMClientLiveTest extends BaseVPDCClientLiveTest { public class VMClientLiveTest extends BaseVPDCClientLiveTest {
@ -279,22 +277,10 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
assert clonedVM.getHref() != null : clonedVM; assert clonedVM.getHref() != null : clonedVM;
} }
private void conditionallyCheckSSH() {
String ip = Iterables.get(vm.getNetworkConnectionSections(), 0).getIpAddress();
assert HostSpecifier.isValid(ip);
if (InetAddresses2.isPrivateIPAddress(ip)) {
ip = Iterables.get(vm.getNetworkConfigSections(), 0).getInternalToExternalNATRules().get(ip);
}
// not sure if the network is public or not, so we have to test
IPSocket socket = new IPSocket(ip, 22);
System.err.printf("testing socket %s%n", socket);
System.err.printf("testing ssh %s%n", socket);
checkSSH(socket);
}
protected void checkSSH(IPSocket socket) { protected void checkSSH(IPSocket socket) {
socketTester.apply(socket); socketTester.apply(socket);
SshClient client = context.utils().sshFactory().create(socket, new Credentials(username, password)); SshClient client = context.utils().sshFactory()
.create(socket, LoginCredentials.builder().user(username).password(password).build());
try { try {
client.connect(); client.connect();
ExecResponse exec = client.exec("echo hello"); ExecResponse exec = client.exec("echo hello");

View File

@ -18,7 +18,7 @@
*/ */
package org.jclouds.serverlove; package org.jclouds.serverlove;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.elasticstack.ElasticStackClientLiveTest; import org.jclouds.elasticstack.ElasticStackClientLiveTest;
import org.jclouds.elasticstack.domain.Server; import org.jclouds.elasticstack.domain.Server;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -27,14 +27,15 @@ import org.testng.annotations.Test;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", sequential = true) @Test(groups = "live", singleThreaded = true)
public class ServerloveManchesterClientLiveTest extends ElasticStackClientLiveTest { public class ServerloveManchesterClientLiveTest extends ElasticStackClientLiveTest {
public ServerloveManchesterClientLiveTest() { public ServerloveManchesterClientLiveTest() {
provider = "serverlove-z1-man"; provider = "serverlove-z1-man";
bootDrive = "574a3921-2926-4a61-bdd9-8d9282b32810"; bootDrive = "574a3921-2926-4a61-bdd9-8d9282b32810";
} }
protected Credentials getSshCredentials(Server server) { @Override
return new Credentials("root", server.getVnc().getPassword()); protected LoginCredentials getSshCredentials(Server server) {
return LoginCredentials.builder().user("root").password(server.getVnc().getPassword()).build();
} }
} }

View File

@ -126,7 +126,7 @@ public class SliceToNodeMetadata implements Function<Slice, NodeMetadata> {
} }
})); }));
builder.credentials(LoginCredentials.builder(credentialStore.get("node#" + from.getId())).build()); builder.credentials(LoginCredentials.fromCredentials(credentialStore.get("node#" + from.getId())));
return builder.build(); return builder.build();
} }

View File

@ -31,7 +31,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.HttpResponseException; import org.jclouds.http.HttpResponseException;
import org.jclouds.io.Payloads; import org.jclouds.io.Payloads;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
@ -285,7 +285,7 @@ public class SlicehostClientLiveTest {
IPSocket socket = new IPSocket(ip, 22); IPSocket socket = new IPSocket(ip, 22);
socketTester.apply(socket); socketTester.apply(socket);
SshClient client = sshFactory.create(socket, new Credentials("root", pass)); SshClient client = sshFactory.create(socket, LoginCredentials.builder().user("root").password(pass).build());
try { try {
client.connect(); client.connect();
client.put("/etc/jclouds.txt", Payloads.newStringPayload("slicehost")); client.put("/etc/jclouds.txt", Payloads.newStringPayload("slicehost"));

View File

@ -33,7 +33,7 @@ import com.google.common.net.InternetDomainName;
/** /**
* Contains options supported by the * Contains options supported by the
* {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} and * {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} and
* {@link ComputeService#runNodesWithTag(String, int, TemplateOptions)} * {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)}
* operations on the <em>gogrid</em> provider. * operations on the <em>gogrid</em> provider.
* *
* <h2>Usage</h2> The recommended way to instantiate a * <h2>Usage</h2> The recommended way to instantiate a
@ -46,7 +46,7 @@ import com.google.common.net.InternetDomainName;
* import static org.jclouds.compute.options.SoftLayerTemplateOptions.Builder.*; * import static org.jclouds.compute.options.SoftLayerTemplateOptions.Builder.*;
* ComputeService client = // get connection * ComputeService client = // get connection
* templateBuilder.options(inboundPorts(22, 80, 8080, 443)); * templateBuilder.options(inboundPorts(22, 80, 8080, 443));
* Set&lt;? extends NodeMetadata&gt; set = client.runNodesWithTag(tag, 2, templateBuilder.build()); * Set&lt;? extends NodeMetadata&gt; set = client.createNodesInGroup(tag, 2, templateBuilder.build());
* </pre> * </pre>
* *
* @author Adrian Cole * @author Adrian Cole
@ -128,24 +128,6 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
return SoftLayerTemplateOptions.class.cast(options.runScript(script)); return SoftLayerTemplateOptions.class.cast(options.runScript(script));
} }
/**
* @see TemplateOptions#installPrivateKey(Payload)
*/
@Deprecated
public static SoftLayerTemplateOptions installPrivateKey(Payload rsaKey) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.installPrivateKey(rsaKey));
}
/**
* @see TemplateOptions#authorizePublicKey(Payload)
*/
@Deprecated
public static SoftLayerTemplateOptions authorizePublicKey(Payload rsaKey) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.authorizePublicKey(rsaKey));
}
/** /**
* @see TemplateOptions#userMetadata(Map) * @see TemplateOptions#userMetadata(Map)
*/ */
@ -189,15 +171,6 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
return SoftLayerTemplateOptions.class.cast(super.authorizePublicKey(publicKey)); return SoftLayerTemplateOptions.class.cast(super.authorizePublicKey(publicKey));
} }
/**
* @see TemplateOptions#authorizePublicKey(Payload)
*/
@Override
@Deprecated
public SoftLayerTemplateOptions authorizePublicKey(Payload publicKey) {
return SoftLayerTemplateOptions.class.cast(super.authorizePublicKey(publicKey));
}
/** /**
* @see TemplateOptions#installPrivateKey(String) * @see TemplateOptions#installPrivateKey(String)
*/ */
@ -206,32 +179,15 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
return SoftLayerTemplateOptions.class.cast(super.installPrivateKey(privateKey)); return SoftLayerTemplateOptions.class.cast(super.installPrivateKey(privateKey));
} }
/**
* @see TemplateOptions#installPrivateKey(Payload)
*/
@Override
@Deprecated
public SoftLayerTemplateOptions installPrivateKey(Payload privateKey) {
return SoftLayerTemplateOptions.class.cast(super.installPrivateKey(privateKey));
}
/** /**
* @see TemplateOptions#runScript(Payload) * @see TemplateOptions#runScript(Payload)
*/ */
@Deprecated
@Override @Override
public SoftLayerTemplateOptions runScript(Payload script) { public SoftLayerTemplateOptions runScript(Payload script) {
return SoftLayerTemplateOptions.class.cast(super.runScript(script)); return SoftLayerTemplateOptions.class.cast(super.runScript(script));
} }
/**
* @see TemplateOptions#runScript(byte[])
*/
@Override
@Deprecated
public SoftLayerTemplateOptions runScript(byte[] script) {
return SoftLayerTemplateOptions.class.cast(super.runScript(script));
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -28,7 +28,7 @@ import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.Template;
import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials; import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials;
import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate; import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate;
import org.jclouds.domain.Credentials; import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.net.IPSocket; import org.jclouds.net.IPSocket;
import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions; import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions;
@ -84,7 +84,7 @@ public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerClientL
doConnectViaSsh(guest.getNode(), prioritizeCredentialsFromTemplate.apply(template, guest.getCredentials())); doConnectViaSsh(guest.getNode(), prioritizeCredentialsFromTemplate.apply(template, guest.getCredentials()));
} }
protected void doConnectViaSsh(VirtualGuest guest, Credentials creds) { protected void doConnectViaSsh(VirtualGuest guest, LoginCredentials creds) {
SshClient ssh = computeContext.utils().sshFactory().create(new IPSocket(guest.getPrimaryIpAddress(), 22), creds); SshClient ssh = computeContext.utils().sshFactory().create(new IPSocket(guest.getPrimaryIpAddress(), 22), creds);
try { try {
ssh.connect(); ssh.connect();

View File

@ -23,8 +23,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map; import java.util.Map;
import com.google.common.base.CaseFormat; import com.google.common.base.CaseFormat;
import com.google.common.base.Function; import com.google.common.cache.CacheBuilder;
import com.google.common.collect.MapMaker; import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
/** /**
@ -55,15 +56,14 @@ public enum ShellToken {
*/ */
FNCE, BEGIN_SCRIPT, END_SCRIPT, BEGIN_FUNCTIONS, EXIT, END_FUNCTIONS, EXPORT, LF, SH, SOURCE, REM, RETURN, ARGS, VARL, VARR, LIBRARY_PATH_VARIABLE; FNCE, BEGIN_SCRIPT, END_SCRIPT, BEGIN_FUNCTIONS, EXIT, END_FUNCTIONS, EXPORT, LF, SH, SOURCE, REM, RETURN, ARGS, VARL, VARR, LIBRARY_PATH_VARIABLE;
private static final Map<OsFamily, Map<String, String>> familyToTokenValueMap = new MapMaker() private static final LoadingCache<OsFamily, Map<String, String>> familyToTokenValueMap = CacheBuilder.newBuilder().build(
.makeComputingMap(new Function<OsFamily, Map<String, String>>() { new CacheLoader<OsFamily, Map<String, String>>() {
@Override @Override
public Map<String, String> apply(OsFamily from) { public Map<String, String> load(OsFamily from) {
Map<String, String> map = Maps.newHashMap(); Map<String, String> map = Maps.newHashMap();
for (ShellToken token : ShellToken.values()) { for (ShellToken token : ShellToken.values()) {
map.put(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, token map.put(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, token.toString()), token.to(from));
.toString()), token.to(from));
} }
return map; return map;
} }
@ -71,7 +71,7 @@ public enum ShellToken {
}); });
public static Map<String, String> tokenValueMap(OsFamily family) { public static Map<String, String> tokenValueMap(OsFamily family) {
return familyToTokenValueMap.get(family); return familyToTokenValueMap.getUnchecked(family);
} }
public String to(OsFamily family) { public String to(OsFamily family) {

View File

@ -87,7 +87,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
builder.state(serverStatusToNodeState.get(from.status)); builder.state(serverStatusToNodeState.get(from.status));
builder.publicAddresses(ImmutableSet.<String> of(from.publicAddress)); builder.publicAddresses(ImmutableSet.<String> of(from.publicAddress));
builder.privateAddresses(ImmutableSet.<String> of(from.privateAddress)); builder.privateAddresses(ImmutableSet.<String> of(from.privateAddress));
builder.credentials(LoginCredentials.builder(credentialStore.get(from.id + "")).build()); builder.credentials(LoginCredentials.fromCredentials(credentialStore.get(from.id + "")));
return builder.build(); return builder.build();
} }