You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by dr...@apache.org on 2017/05/31 07:59:02 UTC

[1/2] brooklyn-server git commit: Delete deprecated JCloudsUtil methods

Repository: brooklyn-server
Updated Branches:
  refs/heads/master 947d5ae44 -> b3fa74c00


Delete deprecated JCloudsUtil methods

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/ecaa2098
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/ecaa2098
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/ecaa2098

Branch: refs/heads/master
Commit: ecaa20988c16ce3818bedd27d3c3046c8d94e39a
Parents: dd6d9b7
Author: Aled Sage <al...@gmail.com>
Authored: Tue May 30 14:45:28 2017 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Tue May 30 14:45:28 2017 +0100

----------------------------------------------------------------------
 .../brooklyn/location/jclouds/JcloudsUtil.java  | 279 -------------------
 1 file changed, 279 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ecaa2098/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java
index f43dd87..4e0477e 100644
--- a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java
+++ b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/JcloudsUtil.java
@@ -18,48 +18,21 @@
  */
 package org.apache.brooklyn.location.jclouds;
 
-import static org.jclouds.compute.options.RunScriptOptions.Builder.overrideLoginCredentials;
-import static org.jclouds.compute.util.ComputeServiceUtils.execHttpResponse;
-import static org.jclouds.scriptbuilder.domain.Statements.appendFile;
-import static org.jclouds.scriptbuilder.domain.Statements.exec;
-import static org.jclouds.scriptbuilder.domain.Statements.interpret;
-import static org.jclouds.scriptbuilder.domain.Statements.newStatementList;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
-import javax.annotation.Nullable;
 
-import org.apache.brooklyn.core.config.Sanitizer;
-import org.apache.brooklyn.core.location.LocationConfigKeys;
-import org.apache.brooklyn.core.location.cloud.CloudLocationConfig;
-import org.apache.brooklyn.util.core.config.ConfigBag;
 import org.apache.brooklyn.util.net.Networking;
-import org.apache.brooklyn.util.net.Protocol;
 import org.apache.brooklyn.util.net.ReachableSocketFinder;
-import org.apache.brooklyn.util.ssh.BashCommands;
-import org.apache.brooklyn.util.ssh.IptablesCommands;
-import org.apache.brooklyn.util.ssh.IptablesCommands.Chain;
-import org.apache.brooklyn.util.ssh.IptablesCommands.Policy;
 import org.apache.brooklyn.util.time.Duration;
 import org.jclouds.Constants;
 import org.jclouds.ContextBuilder;
 import org.jclouds.aws.ec2.AWSEC2Api;
-import org.jclouds.blobstore.BlobStoreContext;
 import org.jclouds.compute.ComputeService;
 import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.RunScriptOnNodesException;
-import org.jclouds.compute.domain.ExecResponse;
 import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.compute.options.RunScriptOptions;
-import org.jclouds.compute.predicates.OperatingSystemPredicates;
 import org.jclouds.docker.DockerApi;
 import org.jclouds.docker.domain.Container;
 import org.jclouds.domain.LoginCredentials;
@@ -67,17 +40,12 @@ import org.jclouds.ec2.compute.domain.PasswordDataAndPrivateKey;
 import org.jclouds.ec2.compute.functions.WindowsLoginCredentialsFromEncryptedData;
 import org.jclouds.ec2.domain.PasswordData;
 import org.jclouds.ec2.features.WindowsApi;
-import org.jclouds.encryption.bouncycastle.config.BouncyCastleCryptoModule;
 import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
-import org.jclouds.scriptbuilder.domain.Statement;
-import org.jclouds.scriptbuilder.domain.Statements;
 import org.jclouds.sshj.config.SshjSshClientModule;
 import org.jclouds.util.Predicates2;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.annotations.Beta;
-import com.google.common.base.Charsets;
 import com.google.common.base.Function;
 import com.google.common.base.Predicate;
 import com.google.common.base.Splitter;
@@ -87,10 +55,7 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Maps;
-import com.google.common.io.Files;
 import com.google.common.net.HostAndPort;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
 import com.google.inject.Module;
 
 public class JcloudsUtil {
@@ -102,228 +67,6 @@ public class JcloudsUtil {
     private JcloudsUtil() {}
 
     /**
-     * @deprecated since 0.7; see {@link BashCommands}
-     */
-    @Deprecated
-    public static String APT_INSTALL = "apt-get install -f -y -qq --force-yes";
-
-    /**
-     * @deprecated since 0.7; see {@link BashCommands}
-     */
-    @Deprecated
-    public static String installAfterUpdatingIfNotPresent(String cmd) {
-       String aptInstallCmd = APT_INSTALL + " " + cmd;
-       return String.format("which %s || (%s || (apt-get update && %s))", cmd, aptInstallCmd, aptInstallCmd);
-    }
-
-    /**
-     * @deprecated since 0.7
-     */
-    @Deprecated
-    public static Predicate<NodeMetadata> predicateMatchingById(final NodeMetadata node) {
-        return predicateMatchingById(node.getId());
-    }
-
-    /**
-     * @deprecated since 0.7
-     */
-    @Deprecated
-    public static Predicate<NodeMetadata> predicateMatchingById(final String id) {
-        Predicate<NodeMetadata> nodePredicate = new Predicate<NodeMetadata>() {
-            @Override public boolean apply(NodeMetadata arg0) {
-                return id.equals(arg0.getId());
-            }
-            @Override public String toString() {
-                return "node.id=="+id;
-            }
-        };
-        return nodePredicate;
-    }
-
-    /**
-     * @deprecated since 0.7; see {@link IptablesCommands}
-     */
-    @Deprecated
-    public static Statement authorizePortInIpTables(int port) {
-        // TODO gogrid rules only allow ports 22, 3389, 80 and 443.
-        // the first rule will be ignored, so we have to apply this
-        // directly
-        return Statements.newStatementList(// just in case iptables are being used, try to open 8080
-                exec("iptables -I INPUT 1 -p tcp --dport " + port + " -j ACCEPT"),//
-                exec("iptables -I RH-Firewall-1-INPUT 1 -p tcp --dport " + port + " -j ACCEPT"),//
-                exec("iptables-save"));
-    }
-
-    /**
-     * @throws RunScriptOnNodesException
-     * @throws IllegalStateException     If do not find exactly one matching node
-     *
-     * @deprecated since 0.7
-     */
-    @Deprecated
-    public static ExecResponse runScriptOnNode(ComputeService computeService, NodeMetadata node, Statement statement, String scriptName) throws RunScriptOnNodesException {
-        // TODO Includes workaround for NodeMetadata's equals/hashcode method being wrong.
-
-        Map<? extends NodeMetadata, ExecResponse> scriptResults = computeService.runScriptOnNodesMatching(
-                JcloudsUtil.predicateMatchingById(node),
-                statement,
-                new RunScriptOptions().nameTask(scriptName));
-        if (scriptResults.isEmpty()) {
-            throw new IllegalStateException("No matching node found when executing script "+scriptName+": expected="+node);
-        } else if (scriptResults.size() > 1) {
-            throw new IllegalStateException("Multiple nodes matched predicate: id="+node.getId()+"; expected="+node+"; actual="+scriptResults.keySet());
-        } else {
-            return Iterables.getOnlyElement(scriptResults.values());
-        }
-    }
-
-    /**
-     * @deprecated since 0.7; see {@link #installJavaAndCurl(OperatingSystem)}
-     */
-    @Deprecated
-    public static final Statement APT_RUN_SCRIPT = newStatementList(//
-          exec(installAfterUpdatingIfNotPresent("curl")),//
-          exec("(which java && java -fullversion 2>&1|egrep -q 1.6 ) ||"),//
-          execHttpResponse(URI.create("http://whirr.s3.amazonaws.com/0.2.0-incubating-SNAPSHOT/sun/java/install")),//
-          exec(new StringBuilder()//
-                .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
-                // jeos hasn't enough room!
-                .append("rm -rf /var/cache/apt /usr/lib/vmware-tools\n")//
-                .append("echo \"export PATH=\\\"$JAVA_HOME/bin/:$PATH\\\"\" >> /root/.bashrc")//
-                .toString()));
-
-    /**
-     * @deprecated since 0.7; see {@link #installJavaAndCurl(OperatingSystem)}
-     */
-    @Deprecated
-    public static final Statement YUM_RUN_SCRIPT = newStatementList(
-          exec("which curl ||yum --nogpgcheck -y install curl"),//
-          exec("(which java && java -fullversion 2>&1|egrep -q 1.6 ) ||"),//
-          execHttpResponse(URI.create("http://whirr.s3.amazonaws.com/0.2.0-incubating-SNAPSHOT/sun/java/install")),//
-          exec(new StringBuilder()//
-                .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n") //
-                .append("echo \"export PATH=\\\"$JAVA_HOME/bin/:$PATH\\\"\" >> /root/.bashrc")//
-                .toString()));
-
-    /**
-     * @deprecated since 0.7; {@link #installJavaAndCurl(OperatingSystem)}
-     */
-    @Deprecated
-    public static final Statement ZYPPER_RUN_SCRIPT = exec(new StringBuilder()//
-          .append("echo nameserver 208.67.222.222 >> /etc/resolv.conf\n")//
-          .append("which curl || zypper install curl\n")//
-          .append("(which java && java -fullversion 2>&1|egrep -q 1.6 ) || zypper install java-1.6.0-openjdk\n")//
-          .toString());
-
-    // Code taken from RunScriptData
-    /**
-     * @deprecated since 0.7; see {@link BashCommands#installJava7()} and {@link BashCommands#INSTALL_CURL}
-     */
-    @Deprecated
-    public static Statement installJavaAndCurl(OperatingSystem os) {
-       if (os == null || OperatingSystemPredicates.supportsApt().apply(os))
-          return APT_RUN_SCRIPT;
-       else if (OperatingSystemPredicates.supportsYum().apply(os))
-          return YUM_RUN_SCRIPT;
-       else if (OperatingSystemPredicates.supportsZypper().apply(os))
-          return ZYPPER_RUN_SCRIPT;
-       else
-          throw new IllegalArgumentException("don't know how to handle" + os.toString());
-    }
-
-    /**
-     * @deprecated since 0.7; see {@link ComputeServiceRegistry#findComputeService(ConfigBag, boolean)}
-     */
-    @Deprecated
-    public static ComputeService findComputeService(ConfigBag conf) {
-        return ComputeServiceRegistryImpl.INSTANCE.findComputeService(conf, true);
-    }
-
-    /**
-     * @deprecated since 0.7; see {@link ComputeServiceRegistry#findComputeService(ConfigBag, boolean)}
-     */
-    @Deprecated
-    public static ComputeService findComputeService(ConfigBag conf, boolean allowReuse) {
-        return ComputeServiceRegistryImpl.INSTANCE.findComputeService(conf, allowReuse);
-    }
-
-    /**
-     * Returns the jclouds modules we typically install
-     *
-     * @deprecated since 0.7; see {@link ComputeServiceRegistry}
-     */
-    @Deprecated
-    public static ImmutableSet<Module> getCommonModules() {
-        return ImmutableSet.<Module> of(
-                new SshjSshClientModule(),
-                new SLF4JLoggingModule(),
-                new BouncyCastleCryptoModule());
-    }
-
-    /**
-     * @deprecated since 0.7
-     */
-    @Deprecated
-    protected static String getDeprecatedProperty(ConfigBag conf, String key) {
-        if (conf.containsKey(key)) {
-            LOG.warn("Jclouds using deprecated brooklyn-jclouds property "+key+": "+Sanitizer.sanitize(conf.getAllConfig()));
-            return (String) conf.getStringKey(key);
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * @deprecated since 0.7
-     */
-    @Deprecated
-    // Do this so that if there's a problem with our USERNAME's ssh key, we can still get in to check
-    // TODO Once we're really confident there are not going to be regular problems, then delete this
-    public static Statement addAuthorizedKeysToRoot(File publicKeyFile) throws IOException {
-        String publicKey = Files.toString(publicKeyFile, Charsets.UTF_8);
-        return addAuthorizedKeysToRoot(publicKey);
-    }
-
-    /**
-     * @deprecated since 0.7
-     */
-    @Deprecated
-    public static Statement addAuthorizedKeysToRoot(String publicKey) {
-        return newStatementList(
-                appendFile("/root/.ssh/authorized_keys", Splitter.on('\n').split(publicKey)),
-                interpret("chmod 600 /root/.ssh/authorized_keys"));
-    }
-
-    /**
-     * @deprecated since 0.9.0; use {@link #getFirstReachableAddress(NodeMetadata, Duration)}
-     */
-    @Deprecated
-    public static String getFirstReachableAddress(ComputeServiceContext context, NodeMetadata node) {
-        // Previously this called jclouds `sshForNode().apply(Node)` to check all IPs of node (private+public),
-        // to find one that is reachable. It does `openSocketFinder.findOpenSocketOnNode(node, node.getLoginPort(), ...)`.
-        // This keeps trying for time org.jclouds.compute.reference.ComputeServiceConstants.Timeouts.portOpen.
-        // TODO Want to configure this timeout here.
-        //
-        // TODO We could perhaps instead just set `templateOptions.blockOnPort(loginPort, 120)`, but need
-        // to be careful to only set that if config WAIT_FOR_SSHABLE is true. For some advanced networking examples
-        // (e.g. using DNAT on CloudStack), the brooklyn machine won't be able to reach the VM until some additional
-        // setup steps have been done. See links from Andrea:
-        //     https://github.com/jclouds/jclouds/pull/895
-        //     https://issues.apache.org/jira/browse/WHIRR-420
-        //     jclouds.ssh.max-retries
-        //     jclouds.ssh.retry-auth
-        //
-        // With `sshForNode`, we'd seen exceptions:
-        //     java.lang.IllegalStateException: Optional.get() cannot be called on an absent value
-        //     from org.jclouds.crypto.ASN1Codec.createASN1Sequence(ASN1Codec.java:86), if the ssh key has a passphrase, against AWS.
-        // And others reported:
-        //     java.lang.IllegalArgumentException: DER length more than 4 bytes
-        //     when using a key with a passphrase (perhaps from other clouds?); not sure if that's this callpath or a different one.
-
-        return getFirstReachableAddress(node, Duration.FIVE_MINUTES);
-    }
-    
-    /**
      * Uses {@link Networking#isReachablePredicate()} to determine reachability.
      * @see #getReachableAddresses(NodeMetadata, Duration, Predicate)
      */
@@ -447,26 +190,4 @@ public class JcloudsUtil {
             }
         }
     }
-
-    /**
-     * @deprecated since 0.7
-     */
-    @Deprecated
-    public static void mapSecurityGroupRuleToIpTables(ComputeService computeService, NodeMetadata node,
-            LoginCredentials credentials, String networkInterface, Iterable<Integer> ports) {
-        for (Integer port : ports) {
-            String insertIptableRule = IptablesCommands.insertIptablesRule(Chain.INPUT, networkInterface,
-                    Protocol.TCP, port, Policy.ACCEPT);
-            Statement statement = Statements.newStatementList(exec(insertIptableRule));
-            ExecResponse response = computeService.runScriptOnNode(node.getId(), statement,
-                    overrideLoginCredentials(credentials).runAsRoot(false));
-            if (response.getExitStatus() != 0) {
-                String msg = String.format("Cannot insert the iptables rule for port %d. Error: %s", port,
-                        response.getError());
-                LOG.error(msg);
-                throw new RuntimeException(msg);
-            }
-        }
-    }
-
 }


[2/2] brooklyn-server git commit: This closes #711

Posted by dr...@apache.org.
This closes #711


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/b3fa74c0
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/b3fa74c0
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/b3fa74c0

Branch: refs/heads/master
Commit: b3fa74c00372ef2d2bd14ebbdf33a5b56cd686a5
Parents: 947d5ae ecaa209
Author: Duncan Godwin <dr...@googlemail.com>
Authored: Wed May 31 08:58:55 2017 +0100
Committer: Duncan Godwin <dr...@googlemail.com>
Committed: Wed May 31 08:58:55 2017 +0100

----------------------------------------------------------------------
 .../brooklyn/location/jclouds/JcloudsUtil.java  | 279 -------------------
 1 file changed, 279 deletions(-)
----------------------------------------------------------------------