diff --git a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java index 1c538eff7e..9e67de8d7f 100644 --- a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java +++ b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java @@ -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) diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImage.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImage.java index 13199d56a3..40fd333d4a 100644 --- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImage.java +++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImage.java @@ -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 { 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(); } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java index 610aabcdaa..7df973afa5 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java @@ -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); diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImageTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImageTest.java index 00e9c62700..990055628b 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImageTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImageTest.java @@ -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()); } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java index 8964067bb2..f30bfd94a5 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java @@ -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 serverStateToNodeState = CloudServersComputeServiceDependenciesModule.serverToNodeState; Set images = ImmutableSet.of(); diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java index 1727e586e3..08a27820dc 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java @@ -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() { diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptions.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptions.java index a1f7324712..faebf4eab5 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptions.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptions.java @@ -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 gogrid provider. * *

Usage

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<? extends NodeMetadata> set = client.runNodesWithTag(tag, 2, templateBuilder.build()); + * Set<? extends NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build()); * * * @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} */ diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java index b9cfdab79e..c84b6c9ad6 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java @@ -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 diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java index 60fcb8e2dc..2db8024827 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackParserModule.java @@ -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; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoadBalancerRule.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoadBalancerRule.java index 0db9a40d60..5feb52569c 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoadBalancerRule.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/LoadBalancerRule.java @@ -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; /** diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/UsageRecord.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/UsageRecord.java index a07c28cb20..c3c0c73fad 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/UsageRecord.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/domain/UsageRecord.java @@ -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 * diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java index 3f488e0b94..36aeb96813 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java @@ -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); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java index 118e70902e..8637545271 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java @@ -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"); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/StaticNATVirtualMachineInNetworkLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/StaticNATVirtualMachineInNetworkLiveTest.java index f7ea8d96aa..00970fa02c 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/StaticNATVirtualMachineInNetworkLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/functions/StaticNATVirtualMachineInNetworkLiveTest.java @@ -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"); diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java index 8365bc2929..0842c81890 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/DeltacloudClientLiveTest.java @@ -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 { diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java index 90d1422c07..69876dc4b1 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java @@ -143,8 +143,8 @@ public class RunningInstanceToNodeMetadata implements Function * ComputeService client = // get connection * templateBuilder.options(inboundPorts(22, 80, 8080, 443)); - * Set set = client.runNodesWithTag(tag, 2, templateBuilder.build()); + * Set set = client.createNodesInGroup(tag, 2, templateBuilder.build()); * * * @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 */ @@ -370,16 +362,7 @@ public class EC2TemplateOptions extends TemplateOptions implements Cloneable { public EC2TemplateOptions authorizePublicKey(String publicKey) { 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} */ diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java index ad0e08656a..8243cf2a25 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java @@ -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"); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java index aa68693f42..7d27d65a21 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java @@ -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"); diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java index 56705f9a66..d7bc885e9f 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java @@ -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() { diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java index 5854e4a28e..2a40a467fb 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/compute/NovaComputeServiceLiveTest.java @@ -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 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 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")); } diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java index ec0cfd4750..0df8a12e6f 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/live/novaclient/NovaClientLiveTest.java @@ -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"); diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java index 8287f8cace..e7506fcd4e 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/config/SwiftRestClientModule.java @@ -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; diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java index b898d4c54b..d8d3f115bf 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java @@ -84,8 +84,8 @@ public class VAppToNodeMetadata implements Function { 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(); } } \ No newline at end of file diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java index c870a83391..100af874c6 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java @@ -38,7 +38,7 @@ import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; *

* ComputeService client = // get connection * templateBuilder.options(inboundPorts(22, 80, 8080, 443)); - * Set set = client.runNodesWithTag(tag, 2, templateBuilder.build()); + * Set set = client.createNodesInGroup(tag, 2, templateBuilder.build()); * * * @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} */ diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java index 81cf39d556..50c32ec50c 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java @@ -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(); diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/options/TerremarkVCloudTemplateOptions.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/options/TerremarkVCloudTemplateOptions.java index 433421e44f..3ff3904f06 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/options/TerremarkVCloudTemplateOptions.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/compute/options/TerremarkVCloudTemplateOptions.java @@ -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 */ diff --git a/compute/src/main/clojure/org/jclouds/compute.clj b/compute/src/main/clojure/org/jclouds/compute.clj index 2b446f4593..9589d07da4 100644 --- a/compute/src/main/clojure/org/jclouds/compute.clj +++ b/compute/src/main/clojure/org/jclouds/compute.clj @@ -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] diff --git a/compute/src/main/java/org/jclouds/compute/ComputeService.java b/compute/src/main/java/org/jclouds/compute/ComputeService.java index f4ad48a299..701f8f3102 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeService.java @@ -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 createNodesInGroup(String group, int count) throws RunNodesException; - /** - * @see #createNodesInGroup(String , int , Template ) - */ - @Deprecated - Set runNodesWithTag(String tag, int count, Template template) throws RunNodesException; - - /** - * @see #createNodesInGroup(String , int , TemplateOptions ) - */ - @Deprecated - Set runNodesWithTag(String tag, int count, TemplateOptions templateOptions) - throws RunNodesException; - - /** - * @see #createNodesInGroup(String , int ) - */ - @Deprecated - Set 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 listNodesDetailsMatching(Predicate filter); - /** - * @see org.jclouds.io.Payloads - * @see ComputeService#runScriptOnNodesMatching(Predicate, Statement, RunScriptOptions) - */ - @Deprecated - Map runScriptOnNodesMatching(Predicate filter, Payload runScript) - throws RunScriptOnNodesException; - - /** - * @see org.jclouds.io.Payloads - * @see ComputeService#runScriptOnNodesMatching(Predicate, Statement, RunScriptOptions) - */ - @Deprecated - Map runScriptOnNodesMatching(Predicate 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 runScriptOnNodesMatching(Predicate 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 diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceAdapter.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceAdapter.java index bbd896269b..4101128319 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceAdapter.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeServiceAdapter.java @@ -35,7 +35,7 @@ import org.jclouds.javax.annotation.Nullable; public interface ComputeServiceAdapter { /** - * {@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 { * {@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 createNodeWithGroupEncodedIntoName(String tag, String name, Template template); diff --git a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java index 2f778f1f9f..d2a52cfca0 100644 --- a/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java +++ b/compute/src/main/java/org/jclouds/compute/callables/RunScriptOnNodeAsInitScriptUsingSsh.java @@ -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(); } diff --git a/compute/src/main/java/org/jclouds/compute/config/GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull.java b/compute/src/main/java/org/jclouds/compute/config/GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull.java index 4da602e72a..d294de8737 100644 --- a/compute/src/main/java/org/jclouds/compute/config/GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull.java +++ b/compute/src/main/java/org/jclouds/compute/config/GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull.java @@ -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(); diff --git a/compute/src/main/java/org/jclouds/compute/config/PersistNodeCredentialsModule.java b/compute/src/main/java/org/jclouds/compute/config/PersistNodeCredentialsModule.java index 8f76cc83ea..5f995560ea 100644 --- a/compute/src/main/java/org/jclouds/compute/config/PersistNodeCredentialsModule.java +++ b/compute/src/main/java/org/jclouds/compute/config/PersistNodeCredentialsModule.java @@ -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()); } diff --git a/compute/src/main/java/org/jclouds/compute/domain/ImageBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/ImageBuilder.java index 2350e1816e..b079e92864 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/ImageBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/domain/ImageBuilder.java @@ -74,10 +74,14 @@ public class ImageBuilder extends ComputeMetadataBuilder { } return this; } - + /** + *

will be removed in jclouds 1.4.0

+ * + * @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) { diff --git a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java index 6fb1c7b656..b2c1ccf718 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java +++ b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadata.java @@ -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. diff --git a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java index 6fae4ffcc6..a10e6110e1 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java +++ b/compute/src/main/java/org/jclouds/compute/domain/NodeMetadataBuilder.java @@ -97,9 +97,14 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder { return this; } + /** + *

will be removed in jclouds 1.4.0

+ * + * @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) { diff --git a/compute/src/main/java/org/jclouds/compute/domain/OperatingSystemBuilder.java b/compute/src/main/java/org/jclouds/compute/domain/OperatingSystemBuilder.java deleted file mode 100644 index cfca7f8abc..0000000000 --- a/compute/src/main/java/org/jclouds/compute/domain/OperatingSystemBuilder.java +++ /dev/null @@ -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 { - -} \ No newline at end of file diff --git a/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java b/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java index 56373130c1..4262864686 100644 --- a/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java +++ b/compute/src/main/java/org/jclouds/compute/domain/internal/NodeMetadataImpl.java @@ -108,15 +108,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat this.credentials = credentials; 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 diff --git a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java index 08d3cf31a9..4c2d15d64e 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java +++ b/compute/src/main/java/org/jclouds/compute/internal/BaseComputeService.java @@ -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 runNodesWithTag(String group, int count, Template template) - throws RunNodesException { - return createNodesInGroup(group, count, template); - } - - /** - * {@inheritDoc} - */ - @Override - public Set runNodesWithTag(String group, int count, TemplateOptions templateOptions) - throws RunNodesException { - return createNodesInGroup(group, count, templateBuilder().any().options(templateOptions).build()); - } - - /** - * {@inheritDoc} - */ - @Override - public Set runNodesWithTag(String group, int count) throws RunNodesException { - return createNodesInGroup(group, count, templateOptions()); - } - @Override public Set createNodesInGroup(String group, int count, Template template) throws RunNodesException { @@ -228,7 +198,7 @@ public class BaseComputeService implements ComputeService { Map> responses = runNodesAndAddToSetStrategy.execute(group, count, template, goodNodes, badNodes, customizationResponses); - Map executionExceptions = awaitCompletion(responses, executor, null, logger, "runNodesWithTag(" + Map executionExceptions = awaitCompletion(responses, executor, null, logger, "createNodesInGroup(" + group + ")"); Function 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 runScriptOnNodesMatching(Predicate filter, Payload runScript) - throws RunScriptOnNodesException { - return runScriptOnNodesMatching(filter, runScript, RunScriptOptions.NONE); - } - - /** - * {@inheritDoc} - */ - @Override - public Map runScriptOnNodesMatching(Predicate 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} */ diff --git a/compute/src/main/java/org/jclouds/compute/options/RunScriptOptions.java b/compute/src/main/java/org/jclouds/compute/options/RunScriptOptions.java index dbf5e88cdd..d185c39372 100644 --- a/compute/src/main/java/org/jclouds/compute/options/RunScriptOptions.java +++ b/compute/src/main/java/org/jclouds/compute/options/RunScriptOptions.java @@ -189,9 +189,13 @@ public class RunScriptOptions { protected Optional loginPassword; protected Optional 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) { @@ -202,7 +206,11 @@ public class RunScriptOptions { this.authenticateSudo = overridingCredentials.shouldAuthenticateSudo() ? true : null; return this; } - + + /** + * to be removed in jclouds 1.4.0 + * @see #overrideLoginCredentials + */ @Deprecated public RunScriptOptions overrideLoginUserWith(String loginUser) { return overrideLoginUser(loginUser); @@ -213,7 +221,11 @@ public class RunScriptOptions { this.loginUser = loginUser; return this; } - + + /** + * to be removed in jclouds 1.4.0 + * @see #overrideLoginCredentials + */ @Deprecated public RunScriptOptions overrideLoginCredentialWith(String loginCredential) { checkNotNull(loginCredential, "loginCredential"); diff --git a/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java b/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java index 2e2d3df0a7..1902dfa441 100644 --- a/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java +++ b/compute/src/main/java/org/jclouds/compute/options/TemplateOptions.java @@ -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.

* Usage

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; *

* ComputeService client = // get connection * templateBuilder.options(inboundPorts(22, 80, 8080, 443)); - * Set set = client.runNodesWithTag(tag, 2, templateBuilder.build()); + * Set set = client.createNodesInGroup(tag, 2, templateBuilder.build()); * * * @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 getTags() { return delegate.getTags(); @@ -396,31 +380,31 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable { } /** - *

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

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

- * 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 */ @@ -594,26 +544,6 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable { return options.blockUntilRunning(blockUntilRunning); } -/** - * please use alternative that uses the {@link Statement) object - * - * @see TemplateOptions#runScript(Statement) - */ - @Deprecated - public static TemplateOptions runScript(byte[] script) { - TemplateOptions options = new TemplateOptions(); - return options.runScript(script); - } - - /** - * @see TemplateOptions#runScript(Statement) - * @see org.jclouds.io.Payloads - */ - public static TemplateOptions runScript(Payload script) { - TemplateOptions options = new TemplateOptions(); - return options.runScript(script); - } - /** * @see TemplateOptions#runScript(Statement) */ @@ -621,6 +551,24 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable { 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); + } + + /** + * @see TemplateOptions#runScript(Statement) + * @see org.jclouds.io.Payloads + */ + @Deprecated + public static TemplateOptions runScript(Payload script) { + TemplateOptions options = new TemplateOptions(); + return options.runScript(script); + } /** * please use alternative that uses the {@link org.jclouds.io.Payload} @@ -629,17 +577,7 @@ 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) { + public static TemplateOptions installPrivateKey(String rsaKey) { TemplateOptions options = new TemplateOptions(); return options.installPrivateKey(rsaKey); } @@ -648,24 +586,13 @@ public class TemplateOptions extends RunScriptOptions implements Cloneable { * 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) */ diff --git a/compute/src/main/java/org/jclouds/compute/predicates/NodePredicates.java b/compute/src/main/java/org/jclouds/compute/predicates/NodePredicates.java index ee5ecaf073..5acb6a450a 100644 --- a/compute/src/main/java/org/jclouds/compute/predicates/NodePredicates.java +++ b/compute/src/main/java/org/jclouds/compute/predicates/NodePredicates.java @@ -205,15 +205,6 @@ public class NodePredicates { }; } - /** - * - * @see #inGroup(String) - */ - @Deprecated - public static Predicate 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 runningWithTag(final String tag) { - return runningInGroup(tag); - } - /** * Match nodes with State == RUNNING */ diff --git a/compute/src/main/java/org/jclouds/compute/predicates/RetryIfSocketNotYetOpen.java b/compute/src/main/java/org/jclouds/compute/predicates/RetryIfSocketNotYetOpen.java index 78b704e19d..1779cfe6a7 100644 --- a/compute/src/main/java/org/jclouds/compute/predicates/RetryIfSocketNotYetOpen.java +++ b/compute/src/main/java/org/jclouds/compute/predicates/RetryIfSocketNotYetOpen.java @@ -65,12 +65,6 @@ public class RetryIfSocketNotYetOpen implements Predicate { public RetryIfSocketNotYetOpen(SocketOpen socketTester, Timeouts timeouts) { 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; diff --git a/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java b/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java index 4e5febc51d..fa6119e236 100644 --- a/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java +++ b/compute/src/main/java/org/jclouds/compute/strategy/impl/AdaptingComputeServiceStrategies.java @@ -88,7 +88,7 @@ public class AdaptingComputeServiceStrategies 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; } diff --git a/compute/src/main/java/org/jclouds/ssh/SshClient.java b/compute/src/main/java/org/jclouds/ssh/SshClient.java index 7a0b65baa1..5b2730b726 100644 --- a/compute/src/main/java/org/jclouds/ssh/SshClient.java +++ b/compute/src/main/java/org/jclouds/ssh/SshClient.java @@ -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,23 +33,16 @@ 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); } diff --git a/compute/src/test/clojure/org/jclouds/compute_test.clj b/compute/src/test/clojure/org/jclouds/compute_test.clj index 6dc3e52816..9e7e839a41 100644 --- a/compute/src/test/clojure/org/jclouds/compute_test.clj +++ b/compute/src/test/clojure/org/jclouds/compute_test.clj @@ -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" diff --git a/compute/src/test/clojure/org/jclouds/ssh_test.clj b/compute/src/test/clojure/org/jclouds/ssh_test.clj index 3ca63dd0c5..61799932ae 100644 --- a/compute/src/test/clojure/org/jclouds/ssh_test.clj +++ b/compute/src/test/clojure/org/jclouds/ssh_test.clj @@ -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 diff --git a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java index 05be9dc356..3ea2262417 100644 --- a/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java +++ b/compute/src/test/java/org/jclouds/compute/StubComputeServiceIntegrationTest.java @@ -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> defaultAdminSshKeys() { return Suppliers.> ofInstance(ImmutableMap.of("public", "publicKey", "private", - "privateKey")); + Pems.PRIVATE_PKCS1_MARKER)); } @Override @@ -140,20 +141,29 @@ 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( - new AuthorizationException("Auth fail", null)); + 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) client2.connect(); @@ -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); diff --git a/compute/src/test/java/org/jclouds/compute/options/TemplateOptionsTest.java b/compute/src/test/java/org/jclouds/compute/options/TemplateOptionsTest.java index a57c01e16f..1081d82028 100644 --- a/compute/src/test/java/org/jclouds/compute/options/TemplateOptionsTest.java +++ b/compute/src/test/java/org/jclouds/compute/options/TemplateOptionsTest.java @@ -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); diff --git a/core/src/main/java/org/jclouds/domain/LoginCredentials.java b/core/src/main/java/org/jclouds/domain/LoginCredentials.java index 0aa4867e5f..c22f013e99 100644 --- a/core/src/main/java/org/jclouds/domain/LoginCredentials.java +++ b/core/src/main/java/org/jclouds/domain/LoginCredentials.java @@ -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(); diff --git a/core/src/main/java/org/jclouds/util/ClassLoadingUtils.java b/core/src/main/java/org/jclouds/util/ClassLoadingUtils.java index b24ffbacc2..f46d704ca3 100644 --- a/core/src/main/java/org/jclouds/util/ClassLoadingUtils.java +++ b/core/src/main/java/org/jclouds/util/ClassLoadingUtils.java @@ -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); diff --git a/core/src/test/java/org/jclouds/rest/CredentialStoreModuleTest.java b/core/src/test/java/org/jclouds/rest/CredentialStoreModuleTest.java index 69e41cce4d..7406b38d43 100644 --- a/core/src/test/java/org/jclouds/rest/CredentialStoreModuleTest.java +++ b/core/src/test/java/org/jclouds/rest/CredentialStoreModuleTest.java @@ -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; diff --git a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/config/JschSshClientModule.java b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/config/JschSshClientModule.java index 58fbf15879..a6e67cbc0e 100644 --- a/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/config/JschSshClientModule.java +++ b/drivers/jsch/src/main/java/org/jclouds/ssh/jsch/config/JschSshClientModule.java @@ -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); + @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; } - - public SshClient create(IPSocket socket, String username, byte[] privateKey) { - SshClient client = new JschSshClient(backoffLimitedRetryHandler, socket, timeout, username, null, privateKey); - 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)); } } } \ No newline at end of file diff --git a/drivers/jsch/src/test/java/org/jclouds/ssh/jsch/JschSshClientTest.java b/drivers/jsch/src/test/java/org/jclouds/ssh/jsch/JschSshClientTest.java index 9b5c95907d..e15694d069 100644 --- a/drivers/jsch/src/test/java/org/jclouds/ssh/jsch/JschSshClientTest.java +++ b/drivers/jsch/src/test/java/org/jclouds/ssh/jsch/JschSshClientTest.java @@ -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; } diff --git a/drivers/jsch/src/test/java/org/jclouds/ssh/jsch/config/JschSshClientModuleTest.java b/drivers/jsch/src/test/java/org/jclouds/ssh/jsch/config/JschSshClientModuleTest.java index fd2b628953..135a511081 100644 --- a/drivers/jsch/src/test/java/org/jclouds/ssh/jsch/config/JschSshClientModuleTest.java +++ b/drivers/jsch/src/test/java/org/jclouds/ssh/jsch/config/JschSshClientModuleTest.java @@ -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; } } \ No newline at end of file diff --git a/drivers/sshj/src/main/java/org/jclouds/sshj/config/SshjSshClientModule.java b/drivers/sshj/src/main/java/org/jclouds/sshj/config/SshjSshClientModule.java index ecbf201046..e276712289 100644 --- a/drivers/sshj/src/main/java/org/jclouds/sshj/config/SshjSshClientModule.java +++ b/drivers/sshj/src/main/java/org/jclouds/sshj/config/SshjSshClientModule.java @@ -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)); } } } diff --git a/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java b/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java index 08cba797aa..32d00abbb0 100644 --- a/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java +++ b/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientLiveTest.java @@ -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; diff --git a/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientTest.java b/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientTest.java index 9b5a130b46..08d4b5e9dd 100644 --- a/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientTest.java +++ b/drivers/sshj/src/test/java/org/jclouds/sshj/SshjSshClientTest.java @@ -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; } diff --git a/drivers/sshj/src/test/java/org/jclouds/sshj/config/SshjSshClientModuleTest.java b/drivers/sshj/src/test/java/org/jclouds/sshj/config/SshjSshClientModuleTest.java index 754b524f55..af8aace9c4 100644 --- a/drivers/sshj/src/test/java/org/jclouds/sshj/config/SshjSshClientModuleTest.java +++ b/drivers/sshj/src/test/java/org/jclouds/sshj/config/SshjSshClientModuleTest.java @@ -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; } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilder.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilder.java index 65ec3e2ed5..9afdbf2d71 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilder.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilder.java @@ -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)); - } - } - } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java index 6538a59766..5712324d76 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java @@ -52,7 +52,7 @@ import com.google.common.collect.Iterables; *

* ComputeService client = // get connection * templateBuilder.options(inboundPorts(22, 80, 8080, 443)); - * Set set = client.runNodesWithTag(tag, 2, templateBuilder.build()); + * Set set = client.createNodesInGroup(tag, 2, templateBuilder.build()); * * * @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} */ diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java index 1b613e143d..6ac3308c77 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java @@ -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); } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java index 30d7bb6079..304869fa7f 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java @@ -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
* ex. {@code diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilderTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilderTest.java index 5eb1244ddc..9d318a5af6 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilderTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/AWSEC2PropertiesBuilderTest.java @@ -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(); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index 99bdaacc60..b5f3fbf883 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -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. of(new Log4JLoggingModule()), overrides); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java index c084279627..fb6bb41ce5 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java @@ -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)); diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/options/GoGridTemplateOptions.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/options/GoGridTemplateOptions.java index 9b362d9d39..a2988e3a7c 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/options/GoGridTemplateOptions.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/compute/options/GoGridTemplateOptions.java @@ -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 gogrid provider. * *

Usage

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<? extends NodeMetadata> set = client.runNodesWithTag(tag, 2, templateBuilder.build()); + * Set<? extends NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build()); * * * TODO add GoGrid specific options @@ -93,25 +93,7 @@ public class GoGridTemplateOptions extends TemplateOptions implements Cloneable GoGridTemplateOptions options = new GoGridTemplateOptions(); 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} */ diff --git a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java index f5a7ac56a3..9798bdbba8 100644 --- a/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java +++ b/providers/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java @@ -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"); diff --git a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterClientLiveTest.java b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterClientLiveTest.java index 45bd37536f..fb76ef71eb 100644 --- a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterClientLiveTest.java +++ b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/ServerloveManchesterClientLiveTest.java @@ -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(); } } diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java index 4bf3162c46..f7edebd878 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/compute/functions/SliceToNodeMetadata.java @@ -126,7 +126,7 @@ public class SliceToNodeMetadata implements Function { } })); - builder.credentials(LoginCredentials.builder(credentialStore.get("node#" + from.getId())).build()); + builder.credentials(LoginCredentials.fromCredentials(credentialStore.get("node#" + from.getId()))); return builder.build(); } diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java index 66353c1671..0f371ccd42 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java @@ -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")); diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/options/SoftLayerTemplateOptions.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/options/SoftLayerTemplateOptions.java index 8d60cff2eb..883550a018 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/options/SoftLayerTemplateOptions.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/options/SoftLayerTemplateOptions.java @@ -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 gogrid provider. * *

Usage

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<? extends NodeMetadata> set = client.runNodesWithTag(tag, 2, templateBuilder.build()); + * Set<? extends NodeMetadata> set = client.createNodesInGroup(tag, 2, templateBuilder.build()); * * * @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} */ diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java index 27a6c331f0..8d3ddb4260 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java @@ -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(); diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/ShellToken.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/ShellToken.java index 166216eace..7176981696 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/ShellToken.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/domain/ShellToken.java @@ -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,23 +56,22 @@ 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> familyToTokenValueMap = new MapMaker() - .makeComputingMap(new Function>() { + private static final LoadingCache> familyToTokenValueMap = CacheBuilder.newBuilder().build( + new CacheLoader>() { - @Override - public Map apply(OsFamily from) { - Map map = Maps.newHashMap(); - for (ShellToken token : ShellToken.values()) { - map.put(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, token - .toString()), token.to(from)); - } - return map; + @Override + public Map load(OsFamily from) { + Map map = Maps.newHashMap(); + for (ShellToken token : ShellToken.values()) { + map.put(CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, token.toString()), token.to(from)); } + return map; + } - }); + }); public static Map tokenValueMap(OsFamily family) { - return familyToTokenValueMap.get(family); + return familyToTokenValueMap.getUnchecked(family); } public String to(OsFamily family) { diff --git a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/functions/ServerToNodeMetadata.java b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/functions/ServerToNodeMetadata.java index 51d17cbb72..31b3f6f44c 100644 --- a/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/functions/ServerToNodeMetadata.java +++ b/skeletons/standalone-compute/src/main/java/org/jclouds/servermanager/compute/functions/ServerToNodeMetadata.java @@ -87,7 +87,7 @@ public class ServerToNodeMetadata implements Function { builder.state(serverStatusToNodeState.get(from.status)); builder.publicAddresses(ImmutableSet. of(from.publicAddress)); builder.privateAddresses(ImmutableSet. of(from.privateAddress)); - builder.credentials(LoginCredentials.builder(credentialStore.get(from.id + "")).build()); + builder.credentials(LoginCredentials.fromCredentials(credentialStore.get(from.id + ""))); return builder.build(); }