Very odd. Well we don't want to repeat the code twice and we do want to access things from that project. Why is it different here than in the other classes? /cc @neykov On 2 Mar 2015 17:32, "bostko" <[email protected]> wrote:
> Github user bostko commented on a diff in the pull request: > > > https://github.com/apache/incubator-brooklyn/pull/531#discussion_r25617858 > > --- Diff: > software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java > --- > @@ -112,48 +106,65 @@ public void install() { > .execute(); > } > > - private List<String> installLinux(String expandedInstallDir) { > - > DynamicTasks.queueIfPossible(SshTasks.dontRequireTtyForSudo(getMachine(), > SshTasks.OnFailingTask.WARN_OR_IF_DYNAMIC_FAIL_MARKING_INESSENTIAL)).orSubmitAndBlock(); > - > - String installBin = Urls.mergePaths(expandedInstallDir, > "bin"); > - String saveAsYum = "riak.rpm"; > - String saveAsApt = "riak.deb"; > - OsDetails osDetails = getMachine().getOsDetails(); > - > - String downloadUrl; > - String osReleaseCmd; > - if ("debian".equalsIgnoreCase(osDetails.getName())) { > - // TODO osDetails.getName() is returning "linux", instead > of debian/ubuntu on AWS with jenkins image, > - // running as integration test targetting localhost. > - // TODO Debian support (default debian image fails with > 'sudo: command not found') > - downloadUrl = > (String)entity.getAttribute(RiakNode.DOWNLOAD_URL_DEBIAN); > - osReleaseCmd = osDetails.getVersion().substring(0, > osDetails.getVersion().indexOf(".")); > - } else { > - // assume Ubuntu > - downloadUrl = > (String)entity.getAttribute(RiakNode.DOWNLOAD_URL_UBUNTU); > - osReleaseCmd = "`lsb_release -sc` && " + > - "export OS_RELEASE=`([[ \"lucid natty precise\" > =~ (^| )\\$OS_RELEASE($| ) ]] && echo $OS_RELEASE || echo precise)`"; > - } > - String apt = chainGroup( > - //debian fix > - "export > PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", > - "which apt-get", > - ok(sudo("apt-get -y --allow-unauthenticated install > logrotate libpam0g-dev libssl0.9.8")), > - "export OS_NAME=" + > Strings.toLowerCase(osDetails.getName()), > - "export OS_RELEASE=" + osReleaseCmd, > - String.format("wget -O %s %s", saveAsApt, > downloadUrl), > - sudo(String.format("dpkg -i %s", saveAsApt))); > - String yum = chainGroup( > - "which yum", > - ok(sudo("yum -y install openssl")), > - String.format("wget -O %s %s", saveAsYum, > entity.getAttribute(RiakNode.DOWNLOAD_URL_RHEL_CENTOS)), > - sudo(String.format("rpm -Uvh %s", saveAsYum))); > + private List<String> installFromPackageCloud() { > + OsDetails osDetails = > getMachine().getMachineDetails().getOsDetails(); > return ImmutableList.<String>builder() > - .add("mkdir -p " + installBin) > - .add(INSTALL_CURL) > - .add(alternatives(apt, yum)) > - .add("ln -s `which riak` " + > Urls.mergePaths(installBin, "riak")) > - .add("ln -s `which riak-admin` " + > Urls.mergePaths(installBin, "riak-admin")) > + > .add(osDetails.getName().toLowerCase().contains("debian") ? > addSbinPathCommand() : "") > + .add(ifNotExecutable("curl", > Joiner.on('\n').join(installCurl()))) > + .addAll(ifExecutableElse("yum", installDebianBased(), > installRpmBased())) > + .build(); > + } > + > + public List<String> installCurl() { > + return ImmutableList.<String>builder() > + .add(ifExecutableElse("yum", > + BashCommands.sudo("apt-get install > --assume-yes curl"), > + BashCommands.sudo("yum install -y curl"))) > + .build(); > + } > + > + private ImmutableList<String> installDebianBased() { > + return ImmutableList.<String>builder() > + .add("curl > https://packagecloud.io/install/repositories/basho/riak/script.deb | " + > BashCommands.sudo("bash")) > + .add(BashCommands.sudo("apt-get install --assume-yes > riak")) > + .build(); > + } > + > + private ImmutableList<String> installRpmBased() { > + return ImmutableList.<String>builder() > + .add("curl > https://packagecloud.io/install/repositories/basho/riak/script.rpm | " + > BashCommands.sudo("bash")) > + .add(BashCommands.sudo("yum install -y riak")) > + .build(); > + } > + > + private static String addSbinPathCommand() { > + return "export > PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"; > + } > + > + /** > + * Returns a command which > + * executes <code>statement</code> only if <code>command</code> > is NOT found in <code>$PATH</code> > + * > + * @param command > + * @param statement > + * @return command > + */ > + private static String ifNotExecutable(String command, String > statement) { > --- End diff -- > > Actually, I tried to do that and it doesn't resolve correctly the > BashCommands class, it gets it from brooklyn-jmxmp-agent-shaded*.jar > We had a little discussion with Svet about this but we have to > rearrange the dependencies in brooklyn parent which we do not want to do > now. > > > --- > If your project is set up for it, you can reply to this email and have your > reply appear on GitHub as well. If your project does not have this feature > enabled and wishes so, or if the feature is enabled but not working, please > contact infrastructure at [email protected] or file a JIRA ticket > with INFRA. > --- >
