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.reference.ComputeServiceConstants;
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.tools.ant.logging.config.AntLoggingModule;
import com.google.common.base.Charsets;
import com.google.common.base.Splitter;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.io.Files;
@ -130,9 +130,9 @@ public class ComputeTaskUtils {
return options;
}
static void addRunScriptToOptionsIfPresentInNodeElement(NodeElement nodeElement, TemplateOptions options) {
static void addRunScriptToOptionsIfPresentInNodeElement(NodeElement nodeElement, TemplateOptions options) throws IOException {
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)

View File

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

View File

@ -44,6 +44,7 @@ import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationBuilder;
import org.jclouds.domain.LocationScope;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.Logger;
import com.google.common.base.Function;
@ -119,7 +120,7 @@ public class ServerToNodeMetadata implements Function<Server, NodeMetadata> {
builder.state(serverToNodeState.get(from.getStatus()));
builder.publicAddresses(from.getAddresses().getPublicAddresses());
builder.privateAddresses(from.getAddresses().getPrivateAddresses());
builder.credentials(credentialStore.get("node#" + from.getId()));
builder.credentials(LoginCredentials.fromCredentials(credentialStore.get("node#" + from.getId())));
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.options.RebuildServerOptions;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.HttpResponseException;
import org.jclouds.io.Payload;
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);
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 {
client.connect();
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 {
IPSocket socket = new IPSocket(Iterables.get(details.getAddresses().getPublicAddresses(), 0), 22);
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 {
client.connect();
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.OsFamily;
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.config.GsonModule;
import org.testng.annotations.Test;
@ -50,7 +50,7 @@ public class CloudServersImageToImageTest {
.name("CentOS 5.2")
.operatingSystem(
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());
}

View File

@ -43,6 +43,7 @@ import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationBuilder;
import org.jclouds.domain.LocationScope;
import org.jclouds.domain.LoginCredentials;
import org.testng.annotations.Test;
import com.google.common.base.Suppliers;
@ -59,7 +60,7 @@ public class ServerToNodeMetadataTest {
@Test
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;
Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of();

View File

@ -18,21 +18,37 @@
*/
package org.jclouds.cloudsigma;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.gson.Gson;
import com.google.inject.Guice;
import com.google.inject.Module;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
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.predicates.DriveClaimed;
import org.jclouds.cloudsigma.util.Servers;
import org.jclouds.compute.ComputeServiceContextFactory;
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.net.IPSocket;
import org.jclouds.predicates.InetSocketAddressConnect;
@ -44,15 +60,13 @@ import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.gson.Gson;
import com.google.inject.Guice;
import com.google.inject.Module;
/**
* Tests behavior of {@code CloudSigmaClient}
@ -395,7 +409,7 @@ public class CloudSigmaClientLiveTest {
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(new IPSocket(server.getVnc().getIp(), 22), creds);
try {
@ -439,8 +453,8 @@ public class CloudSigmaClientLiveTest {
assertNotNull(drives);
}
protected Credentials getSshCredentials(Server server) {
return new Credentials("root", vncPassword);
protected LoginCredentials getSshCredentials(Server server) {
return LoginCredentials.builder().user("root").password(vncPassword).build();
}
protected void prepareDrive() {

View File

@ -35,7 +35,7 @@ import com.google.common.collect.Sets;
/**
* Contains options supported by the
* {@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.
*
* <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.*;
* ComputeService client = // get connection
* 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>
*
* @author Adrian Cole
@ -262,24 +262,6 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
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)
*/
@ -323,15 +305,6 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
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)
*/
@ -340,32 +313,15 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
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)
*/
@Deprecated
@Override
public CloudStackTemplateOptions runScript(Payload 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}
*/

View File

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

View File

@ -19,20 +19,18 @@
package org.jclouds.cloudstack.config;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.inject.Singleton;
import com.google.common.collect.Sets;
import org.jclouds.cloudstack.domain.Account;
import org.jclouds.cloudstack.domain.Account.State;
import org.jclouds.cloudstack.domain.LoadBalancerRule;
import org.jclouds.cloudstack.domain.User;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
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 java.util.Collections;
import java.util.Set;
import com.google.common.base.CaseFormat;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import com.google.gson.annotations.SerializedName;
/**

View File

@ -18,18 +18,16 @@
*/
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.collect.ImmutableSet;
import com.google.common.collect.Maps;
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
*

View File

@ -55,6 +55,7 @@ import org.jclouds.compute.domain.Template;
import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials;
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.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate;
@ -172,7 +173,7 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien
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);
try {
connectWithRetry(ssh, 5, 2000);

View File

@ -18,13 +18,17 @@
*/
package org.jclouds.cloudstack.features;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import static com.google.common.base.Strings.emptyToNull;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.get;
import static org.testng.Assert.assertEquals;
import java.util.NoSuchElementException;
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.CloudStackClient;
import org.jclouds.cloudstack.CloudStackContext;
@ -50,7 +54,7 @@ import org.jclouds.compute.BaseVersionedServiceLiveTest;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContextFactory;
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.net.IPSocket;
import org.jclouds.predicates.InetSocketAddressConnect;
@ -61,16 +65,13 @@ import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
import static com.google.common.base.Strings.emptyToNull;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.get;
import static org.testng.Assert.assertEquals;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
/**
*
@ -181,7 +182,7 @@ public class BaseCloudStackClientLiveTest extends BaseVersionedServiceLiveTest {
protected void checkSSH(IPSocket 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 {
client.connect();
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.strategy.BlockUntilJobCompletesAndReturnResult;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.net.IPSocket;
import org.jclouds.ssh.SshClient;
import org.testng.annotations.AfterGroups;
@ -111,7 +111,7 @@ public class StaticNATVirtualMachineInNetworkLiveTest extends NATClientLiveTest
checkRule(rule);
IPSocket socket = new IPSocket(ip.getIPAddress(), 22);
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 {
client.connect();
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.TransitionOnAction;
import org.jclouds.deltacloud.options.CreateInstanceOptions;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.HttpRequest;
import org.jclouds.net.IPSocket;
import org.jclouds.ssh.SshClient;
@ -52,7 +52,7 @@ public class DeltacloudClientLiveTest extends ReadOnlyDeltacloudClientLiveTest {
protected String prefix = System.getProperty("user.name") + ".test";
protected Instance instance;
protected Credentials creds;
protected LoginCredentials creds;
public void testCreateInstance() throws Exception {
Logger.getAnonymousLogger().info("starting instance");
@ -133,7 +133,7 @@ public class DeltacloudClientLiveTest extends ReadOnlyDeltacloudClientLiveTest {
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(
new IPSocket(Iterables.get(instance.getPublicAddresses(), 0), 22), creds);
try {

View File

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

View File

@ -54,7 +54,7 @@ import com.google.common.collect.Iterables;
* <p/>
* ComputeService client = // get connection
* 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>
*
* @author Adrian Cole
@ -268,14 +268,6 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
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
*/
@ -371,15 +363,6 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
return EC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey));
}
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public EC2TemplateOptions authorizePublicKey(Payload publicKey) {
return EC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey));
}
/**
* {@inheritDoc}
*/
@ -391,29 +374,12 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable {
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public EC2TemplateOptions installPrivateKey(Payload privateKey) {
return EC2TemplateOptions.class.cast(super.installPrivateKey(privateKey));
}
/**
* {@inheritDoc}
*/
@Override
public EC2TemplateOptions runScript(Payload script) {
return EC2TemplateOptions.class.cast(super.runScript(script));
}
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public EC2TemplateOptions runScript(byte[] script) {
return EC2TemplateOptions.class.cast(super.runScript(script));
}
/**
* {@inheritDoc}
*/

View File

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

View File

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

View File

@ -31,7 +31,7 @@ import java.util.logging.Logger;
import org.jclouds.Constants;
import org.jclouds.compute.ComputeServiceContextFactory;
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.CreateDriveRequest;
import org.jclouds.elasticstack.domain.DriveData;
@ -311,7 +311,7 @@ public class ElasticStackClientLiveTest {
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(
new IPSocket(server.getVnc().getIp(), 22), creds);
try {
@ -371,8 +371,8 @@ public class ElasticStackClientLiveTest {
}
}
protected Credentials getSshCredentials(Server server) {
return new Credentials("toor", server.getVnc().getPassword());
protected LoginCredentials getSshCredentials(Server server) {
return LoginCredentials.builder().user("toor").password(server.getVnc().getPassword()).build();
}
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.newTreeSet;
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.all;
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(
runningInGroup(group),
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())
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,
OperatingSystem os, LoginCredentials creds) throws RunScriptOnNodesException {
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.util.Set;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.HttpResponseException;
import org.jclouds.io.Payload;
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);
//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 {
client.connect();
Payload etcPasswd = client.get("/etc/jclouds.txt");

View File

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

View File

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

View File

@ -38,7 +38,7 @@ import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
* <p/>
* ComputeService client = // get connection
* 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>
*
* @author Adrian Cole
@ -148,22 +148,6 @@ public class VCloudTemplateOptions extends TemplateOptions implements Cloneable
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)
*/
@ -235,15 +219,6 @@ public class VCloudTemplateOptions extends TemplateOptions implements Cloneable
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)
*/
@ -252,32 +227,15 @@ public class VCloudTemplateOptions extends TemplateOptions implements Cloneable
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)
*/
@Deprecated
@Override
public VCloudTemplateOptions runScript(Payload 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}
*/

View File

@ -18,19 +18,16 @@
*/
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.customizationScript;
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.installPrivateKey;
import static org.jclouds.vcloud.compute.options.VCloudTemplateOptions.Builder.ipAddressAllocationMode;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.io.Payloads;
import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
import org.testng.annotations.Test;
@ -115,17 +112,6 @@ public class VCloudTemplateOptionsTest {
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
public void testauthorizePublicKey() throws IOException {
VCloudTemplateOptions options = new VCloudTemplateOptions();
@ -139,17 +125,6 @@ public class VCloudTemplateOptionsTest {
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)
public void testblockOnPortBadFormat() {
VCloudTemplateOptions options = new VCloudTemplateOptions();

View File

@ -134,14 +134,6 @@ public class TerremarkVCloudTemplateOptions extends TemplateOptions implements C
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
*/
@ -207,15 +199,6 @@ public class TerremarkVCloudTemplateOptions extends TemplateOptions implements C
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)
*/
@ -224,32 +207,16 @@ public class TerremarkVCloudTemplateOptions extends TemplateOptions implements C
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)
*/
@Deprecated
@Override
public TerremarkVCloudTemplateOptions runScript(Payload 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
*/

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

View File

@ -35,7 +35,6 @@ import org.jclouds.compute.options.RunScriptOptions;
import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
import org.jclouds.domain.Location;
import org.jclouds.io.Payload;
import org.jclouds.scriptbuilder.domain.Statement;
import com.google.common.annotations.Beta;
@ -150,25 +149,6 @@ public interface ComputeService {
*/
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,
* given its id.
@ -265,22 +245,6 @@ public interface ComputeService {
*/
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)
@ -317,7 +281,7 @@ public interface ComputeService {
* @throws RunScriptOnNodesException
* 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
*/
Map<? extends NodeMetadata, ExecResponse> runScriptOnNodesMatching(Predicate<NodeMetadata> filter,
@ -340,7 +304,7 @@ public interface ComputeService {
* @throws ScriptStillRunningException
* 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
*/
ExecResponse runScriptOnNode(String id, Statement runScript, RunScriptOptions options);
@ -360,7 +324,7 @@ public interface ComputeService {
* @throws IllegalStateException
* 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
*/
@Beta

View File

@ -35,7 +35,7 @@ import org.jclouds.javax.annotation.Nullable;
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
* a unique name.
*
@ -59,7 +59,7 @@ public interface ComputeServiceAdapter<N, H, I, L> {
* {@code hardwareId} used to resume the instance.
* @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);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -97,9 +97,14 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder {
return this;
}
/**
* <h4>will be removed in jclouds 1.4.0</h4>
*
* @see #credentials(LoginCredentials)
*/
@Deprecated
public NodeMetadataBuilder credentials(@Nullable Credentials credentials) {
return credentials(LoginCredentials.builder(credentials).build());
return credentials(LoginCredentials.fromCredentials(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;
}
/**
* {@inheritDoc}
*/
@Override
public String getTag() {
return getGroup();
}
/**
* {@inheritDoc}
*/
@ -208,7 +200,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
@Override
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="
+ getOperatingSystem() + ", state=" + getState() + ", loginPort=" + getLoginPort() + ", hostname="
+ 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.transformParallel;
import java.io.IOException;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
@ -82,19 +81,16 @@ import org.jclouds.domain.Credentials;
import org.jclouds.domain.Location;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.domain.LoginCredentials.Builder;
import org.jclouds.io.Payload;
import org.jclouds.logging.Logger;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.scriptbuilder.domain.Statement;
import org.jclouds.scriptbuilder.domain.Statements;
import org.jclouds.scriptbuilder.functions.InitAdminAccess;
import org.jclouds.util.Maps2;
import org.jclouds.util.Strings2;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
@ -185,32 +181,6 @@ public class BaseComputeService implements ComputeService {
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
public Set<? extends NodeMetadata> createNodesInGroup(String group, int count, Template template)
throws RunNodesException {
@ -228,7 +198,7 @@ public class BaseComputeService implements ComputeService {
Map<?, Future<Void>> responses = runNodesAndAddToSetStrategy.execute(group, count, template, goodNodes, badNodes,
customizationResponses);
Map<?, Exception> executionExceptions = awaitCompletion(responses, executor, null, logger, "runNodesWithTag("
Map<?, Exception> executionExceptions = awaitCompletion(responses, executor, null, logger, "createNodesInGroup("
+ group + ")");
Function<NodeMetadata, NodeMetadata> fn = persistNodeCredentials.always(template.getOptions().getRunScript());
badNodes = Maps2.transformKeys(badNodes, fn);
@ -485,30 +455,6 @@ public class BaseComputeService implements ComputeService {
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}
*/

View File

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

View File

@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
/**
* Contains options supported in the {@code ComputeService#runNodesWithTag}
* Contains options supported in the {@code ComputeService#createNodesInGroup}
* operation. <h2>
* Usage</h2> The recommended way to instantiate a TemplateOptions object is to
* statically import TemplateOptions.* and invoke a static creation method
@ -50,7 +50,7 @@ import com.google.common.collect.Maps;
* <p/>
* ComputeService client = // get connection
* 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>
*
* @author Adrian Cole
@ -162,22 +162,11 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
throw new IllegalArgumentException("script is immutable");
}
@Override
public TemplateOptions installPrivateKey(Payload privateKey) {
throw new IllegalArgumentException("privateKey is immutable");
}
@Override
public TemplateOptions dontAuthorizePublicKey() {
throw new IllegalArgumentException("public key is immutable");
}
@Override
@Deprecated
public TemplateOptions authorizePublicKey(Payload publicKey) {
throw new IllegalArgumentException("public key is immutable");
}
@Override
public TemplateOptions blockOnPort(int port, int seconds) {
throw new IllegalArgumentException("ports are immutable");
@ -318,11 +307,6 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
throw new IllegalArgumentException("privateKey is immutable");
}
@Override
public TemplateOptions runScript(byte[] script) {
throw new IllegalArgumentException("script is immutable");
}
@Override
public Set<String> getTags() {
return delegate.getTags();
@ -396,31 +380,31 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
}
/**
* <p/>
* please use alternative that uses the
* {@link org.jclouds.scriptbuilder.domain.Statement} object
* to be removed in jclouds 1.4.0
*
* @see TemplateOptions#runScript(Statement)
* @see org.jclouds.io.Payloads
*
*/
@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) {
try {
return runScript(Statements.exec(Strings2.toStringAndClose(checkNotNull(script, "script").getInput())));
return runScript(Strings2.toStringAndClose(checkNotNull(script, "script").getInput()));
} catch (IOException e) {
Throwables.propagate(e);
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
* 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;
}
/**
* 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() {
this.publicKey = null;
return this;
@ -472,23 +439,6 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
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
*/
@ -595,12 +545,17 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
}
/**
* please use alternative that uses the {@link Statement) object
*
* @see TemplateOptions#runScript(Statement)
*/
@Deprecated
public static TemplateOptions runScript(byte[] script) {
public static TemplateOptions runScript(Statement script) {
TemplateOptions options = new TemplateOptions();
return options.runScript(script);
}
/**
* @see TemplateOptions#runScript(String)
*/
public static TemplateOptions runScript(String script) {
TemplateOptions options = new TemplateOptions();
return options.runScript(script);
}
@ -609,19 +564,12 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
* @see TemplateOptions#runScript(Statement)
* @see org.jclouds.io.Payloads
*/
@Deprecated
public static TemplateOptions runScript(Payload script) {
TemplateOptions options = new TemplateOptions();
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}
* object
@ -629,43 +577,22 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable {
* @see org.jclouds.io.Payloads
* @see #installPrivateKey(Payload)
*/
@Deprecated
public static TemplateOptions installPrivateKey(String rsaKey) {
TemplateOptions options = new TemplateOptions();
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}
* object
*
* @see org.jclouds.io.Payloads
* @see #authorizePublicKey(Payload)
* @see #authorizePublicKey(String)
*/
@Deprecated
public static TemplateOptions authorizePublicKey(String rsaKey) {
TemplateOptions options = new TemplateOptions();
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)
*/

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.
*
@ -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
*/

View File

@ -66,12 +66,6 @@ public class RetryIfSocketNotYetOpen implements Predicate<IPSocket> {
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) {
this.timeoutValue = milliseconds;
this.timeoutUnits = TimeUnit.MILLISECONDS;

View File

@ -88,7 +88,7 @@ public class AdaptingComputeServiceStrategies<N, H, I, L> implements CreateNodeW
@Override
public NodeMetadata apply(NodeMetadata 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;
}

View File

@ -23,6 +23,7 @@ import javax.annotation.PreDestroy;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.io.Payload;
import org.jclouds.net.IPSocket;
@ -32,24 +33,17 @@ import org.jclouds.net.IPSocket;
public interface SshClient {
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
SshClient create(IPSocket socket, String username, byte[] privateKey);
SshClient create(IPSocket socket, Credentials credentials);
SshClient create(IPSocket socket, LoginCredentials credentials);
}
String getUsername();

View File

@ -70,25 +70,6 @@ list, Alan Dipert and MeikelBrandmeyer."
(destroy-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
(let [service (compute-service "stub" "compute.clj" "")]
(testing "nullary"

View File

@ -23,6 +23,7 @@
(:import
org.jclouds.ssh.SshClient
org.jclouds.domain.Credentials
org.jclouds.domain.LoginCredentials
org.jclouds.io.Payload
org.jclouds.net.IPSocket
org.jclouds.compute.domain.ExecResponse))
@ -76,18 +77,14 @@
(deftype SshClientFactory
[factory-fn]
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
create
[_ ^IPSocket socket ^Credentials 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

View File

@ -38,7 +38,8 @@ import java.util.concurrent.TimeoutException;
import org.easymock.IArgumentMatcher;
import org.jclouds.compute.domain.ExecResponse;
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.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate;
@ -111,7 +112,7 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
@Override
public Supplier<Map<String, String>> defaultAdminSshKeys() {
return Suppliers.<Map<String, String>> ofInstance(ImmutableMap.of("public", "publicKey", "private",
"privateKey"));
Pems.PRIVATE_PKCS1_MARKER));
}
@Override
@ -140,19 +141,28 @@ public class StubComputeServiceIntegrationTest extends BaseComputeServiceLiveTes
SshClient client4 = createMock(SshClient.class);
SshClient client5 = createMock(SshClient.class);
expect(factory.create(new IPSocket("144.175.1.1", 22), new Credentials("root", "password1"))).andReturn(
client1);
expect(factory.create(new IPSocket("144.175.1.1", 22), new Credentials("web", "privateKey"))).andReturn(
client1New).times(10);
expect(
factory.create(new IPSocket("144.175.1.1", 22),
LoginCredentials.builder().user("root").password("password1").build())).andReturn(client1);
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);
expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "password2"))).andReturn(
client2).times(4);
expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "password2"))).andReturn(
client2New);
expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("foo", "privateKey"))).andReturn(
client2Foo);
expect(factory.create(new IPSocket("144.175.1.2", 22), new Credentials("root", "romeo"))).andThrow(
expect(
factory.create(new IPSocket("144.175.1.2", 22),
LoginCredentials.builder().user("root").password("password2").build())).andReturn(client2)
.times(4);
expect(
factory.create(new IPSocket("144.175.1.2", 22),
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));
// 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));
client2Foo.disconnect();
expect(factory.create(new IPSocket("144.175.1.3", 22), new Credentials("root", "password3"))).andReturn(
client3).times(2);
expect(factory.create(new IPSocket("144.175.1.4", 22), new Credentials("root", "password4"))).andReturn(
client4).times(2);
expect(factory.create(new IPSocket("144.175.1.5", 22), new Credentials("root", "password5"))).andReturn(
client5).times(2);
expect(
factory.create(new IPSocket("144.175.1.3", 22),
LoginCredentials.builder().user("root").password("password3").build())).andReturn(client3)
.times(2);
expect(
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(client4, "bootstrap", 4);
runScriptAndInstallSsh(client5, "bootstrap", 5);
expect(
factory.create(eq(new IPSocket("144.175.1.1", 22)), eq(new Credentials("defaultAdminUsername",
"privateKey")))).andReturn(client1);
factory.create(eq(new IPSocket("144.175.1.1", 22)),
eq(LoginCredentials.builder().user("defaultAdminUsername").privateKey(Pems.PRIVATE_PKCS1_MARKER).build())))
.andReturn(client1);
expect(
factory.create(eq(new IPSocket("144.175.1.2", 22)), eq(new Credentials("defaultAdminUsername",
"privateKey")))).andReturn(client2);
factory.create(eq(new IPSocket("144.175.1.2", 22)),
eq(LoginCredentials.builder().user("defaultAdminUsername").privateKey(Pems.PRIVATE_PKCS1_MARKER).build())))
.andReturn(client2);
expect(
factory.create(eq(new IPSocket("144.175.1.3", 22)), eq(new Credentials("defaultAdminUsername",
"privateKey")))).andReturn(client3);
factory.create(eq(new IPSocket("144.175.1.3", 22)),
eq(LoginCredentials.builder().user("defaultAdminUsername").privateKey(Pems.PRIVATE_PKCS1_MARKER).build())))
.andReturn(client3);
expect(
factory.create(eq(new IPSocket("144.175.1.4", 22)), eq(new Credentials("defaultAdminUsername",
"privateKey")))).andReturn(client4);
factory.create(eq(new IPSocket("144.175.1.4", 22)),
eq(LoginCredentials.builder().user("defaultAdminUsername").privateKey(Pems.PRIVATE_PKCS1_MARKER).build())))
.andReturn(client4);
expect(
factory.create(eq(new IPSocket("144.175.1.5", 22)), eq(new Credentials("defaultAdminUsername",
"privateKey")))).andReturn(client5);
factory.create(eq(new IPSocket("144.175.1.5", 22)),
eq(LoginCredentials.builder().user("defaultAdminUsername").privateKey(Pems.PRIVATE_PKCS1_MARKER).build())))
.andReturn(client5);
helloAndJava(client2);
helloAndJava(client3);

View File

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

View File

@ -18,15 +18,24 @@
*/
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.util.CredentialUtils;
import com.google.common.base.Optional;
/**
* @author Adrian Cole
*/
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) {
if (creds == null)
return builder();

View File

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

View File

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

View File

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

View File

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

View File

@ -20,7 +20,7 @@ package org.jclouds.ssh.jsch.config;
import java.net.UnknownHostException;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.net.IPSocket;
import org.jclouds.ssh.SshClient;
@ -42,7 +42,8 @@ public class JschSshClientModuleTest {
Injector i = Guice.createInjector(new JschSshClientModule(), new SLF4JLoggingModule());
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;
}
}

View File

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

View File

@ -27,7 +27,7 @@ import java.io.IOException;
import java.net.InetAddress;
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.Payloads;
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.Test;
import com.google.common.base.Strings;
import com.google.inject.Guice;
import com.google.inject.Injector;
@ -111,11 +112,12 @@ public class SshjSshClientLiveTest {
Injector i = Guice.createInjector(new SshjSshClientModule(), new SLF4JLoggingModule());
SshClient.Factory factory = i.getInstance(SshClient.Factory.class);
SshClient connection;
if (sshKeyFile != null && !sshKeyFile.trim().equals("")) {
connection = factory.create(new IPSocket(sshHost, port), new Credentials(sshUser, Strings2
.toStringAndClose(new FileInputStream(sshKeyFile))));
if (Strings.emptyToNull(sshKeyFile) != null) {
connection = factory.create(new IPSocket(sshHost, port), LoginCredentials.builder().user(sshUser)
.privateKey(Strings2.toStringAndClose(new FileInputStream(sshKeyFile))).build());
} 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();
return connection;

View File

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

View File

@ -18,7 +18,7 @@
*/
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.net.IPSocket;
import org.jclouds.ssh.SshClient;
@ -40,7 +40,8 @@ public class SshjSshClientModuleTest {
Injector i = Guice.createInjector(new SshjSshClientModule(), new SLF4JLoggingModule());
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;
}
}

View File

@ -21,7 +21,6 @@ package org.jclouds.aws.ec2;
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_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_GENERATE_INSTANCE_NAMES;
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() {
Properties props = super.build();
warnAndReplaceIfUsingOldImageKey(props);
warnAndReplaceIfUsingOldCCImageKey(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/>
* ComputeService client = // get connection
* 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>
*
* @author Adrian Cole
@ -359,14 +359,6 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
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
*/
@ -550,15 +542,6 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
return AWSEC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey));
}
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public AWSEC2TemplateOptions authorizePublicKey(Payload publicKey) {
return AWSEC2TemplateOptions.class.cast(super.authorizePublicKey(publicKey));
}
/**
* {@inheritDoc}
*/
@ -570,29 +553,12 @@ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneab
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public AWSEC2TemplateOptions installPrivateKey(Payload privateKey) {
return AWSEC2TemplateOptions.class.cast(super.installPrivateKey(privateKey));
}
/**
* {@inheritDoc}
*/
@Override
public AWSEC2TemplateOptions runScript(Payload script) {
return AWSEC2TemplateOptions.class.cast(super.runScript(script));
}
/**
* {@inheritDoc}
*/
@Override
@Deprecated
public AWSEC2TemplateOptions runScript(byte[] script) {
return AWSEC2TemplateOptions.class.cast(super.runScript(script));
}
/**
* {@inheritDoc}
*/

View File

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

View File

@ -27,14 +27,6 @@ import org.jclouds.ec2.reference.EC2Constants;
* @author Adrian Cole
*/
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/>
* ex. {@code

View File

@ -19,8 +19,6 @@
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_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.testng.Assert.assertEquals;
@ -33,13 +31,6 @@ import org.testng.annotations.Test;
*/
@Test(groups = "unit", testName = "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() {
Properties input = new Properties();

View File

@ -278,8 +278,8 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest {
try {
Properties overrides = setupProperties();
// set owners to nothing
overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMIs, "");
overrides.setProperty(EC2Constants.PROPERTY_EC2_AMI_OWNERS, "");
overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, "");
context = new ComputeServiceContextFactory().createContext(provider,
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.getOnlyElement;
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.runningInGroup;
import static org.jclouds.scriptbuilder.domain.Statements.exec;
@ -144,7 +144,7 @@ public class AWSKeyPairClientLiveTest {
.runScriptOnNodesMatching(
runningInGroup(group),
exec("echo hello"),
overrideCredentialsWith(
overrideLoginCredentials(
LoginCredentials.builder().user(first.getCredentials().identity)
.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
* {@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.
*
* <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.*;
* ComputeService client = // get connection
* 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>
*
* TODO add GoGrid specific options
@ -94,24 +94,6 @@ public class GoGridTemplateOptions extends TemplateOptions implements Cloneable
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)
*/
@ -155,15 +137,6 @@ public class GoGridTemplateOptions extends TemplateOptions implements Cloneable
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)
*/
@ -172,32 +145,15 @@ public class GoGridTemplateOptions extends TemplateOptions implements Cloneable
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)
*/
@Deprecated
@Override
public GoGridTemplateOptions runScript(Payload 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}
*/

View File

@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.cim.OSType;
import org.jclouds.compute.domain.CIMOperatingSystem;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.net.IPSocket;
import org.jclouds.predicates.InetSocketAddressConnect;
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.reference.VCloudMediaType;
import org.jclouds.ssh.SshClient;
import org.jclouds.util.InetAddresses2;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
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.Builder;
import com.google.common.collect.Iterables;
import com.google.common.net.HostSpecifier;
@Test(groups = "live")
public class VMClientLiveTest extends BaseVPDCClientLiveTest {
@ -279,22 +277,10 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
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) {
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 {
client.connect();
ExecResponse exec = client.exec("echo hello");

View File

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

View File

@ -31,7 +31,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.Constants;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.HttpResponseException;
import org.jclouds.io.Payloads;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
@ -285,7 +285,7 @@ public class SlicehostClientLiveTest {
IPSocket socket = new IPSocket(ip, 22);
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 {
client.connect();
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
* {@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.
*
* <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.*;
* ComputeService client = // get connection
* 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>
*
* @author Adrian Cole
@ -128,24 +128,6 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
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)
*/
@ -189,15 +171,6 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
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)
*/
@ -206,32 +179,15 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
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)
*/
@Deprecated
@Override
public SoftLayerTemplateOptions runScript(Payload 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}
*/

View File

@ -28,7 +28,7 @@ import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials;
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.net.IPSocket;
import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions;
@ -84,7 +84,7 @@ public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerClientL
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);
try {
ssh.connect();

View File

@ -23,8 +23,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Map;
import com.google.common.base.CaseFormat;
import com.google.common.base.Function;
import com.google.common.collect.MapMaker;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
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;
private static final Map<OsFamily, Map<String, String>> familyToTokenValueMap = new MapMaker()
.makeComputingMap(new Function<OsFamily, Map<String, String>>() {
private static final LoadingCache<OsFamily, Map<String, String>> familyToTokenValueMap = CacheBuilder.newBuilder().build(
new CacheLoader<OsFamily, Map<String, String>>() {
@Override
public Map<String, String> apply(OsFamily from) {
public Map<String, String> load(OsFamily from) {
Map<String, String> map = Maps.newHashMap();
for (ShellToken token : ShellToken.values()) {
map.put(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, token
.toString()), token.to(from));
map.put(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, token.toString()), token.to(from));
}
return map;
}
@ -71,7 +71,7 @@ public enum ShellToken {
});
public static Map<String, String> tokenValueMap(OsFamily family) {
return familyToTokenValueMap.get(family);
return familyToTokenValueMap.getUnchecked(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.publicAddresses(ImmutableSet.<String> of(from.publicAddress));
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();
}