org.jclouds.scriptbuilder.domain.Statements.newStatementList()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中org.jclouds.scriptbuilder.domain.Statements.newStatementList()方法的一些代码示例,展示了Statements.newStatementList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Statements.newStatementList()方法的具体详情如下:
包路径:org.jclouds.scriptbuilder.domain.Statements
类名称:Statements
方法名:newStatementList

Statements.newStatementList介绍

暂无

代码示例

代码示例来源:origin: io.brooklyn/brooklyn-locations-jclouds

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"));
}

代码示例来源:origin: jclouds/legacy-jclouds

public String render(OsFamily family) {
 String linesToPrepend = Joiner.on('\n').withKeyValueSeparator(" ").join(params);
 Statement prependSshdConfig = exec(String.format(
      "exec 3<> %1$s && awk -v TEXT=\"%2$s\n\" 'BEGIN {print TEXT}{print}' %1$s >&3", sshdConfig,
      linesToPrepend));
 Statement reloadSshdConfig = exec("hash service 2>&- && service ssh reload 2>&- || /etc/init.d/ssh* reload");
 return newStatementList(prependSshdConfig, reloadSshdConfig).render(family);
}

代码示例来源:origin: org.jclouds/jclouds-scriptbuilder

public String render(OsFamily family) {
 String linesToPrepend = Joiner.on('\n').withKeyValueSeparator(" ").join(params);
 Statement prependSshdConfig = exec(String.format(
      "exec 3<> %1$s && awk -v TEXT=\"%2$s\n\" 'BEGIN {print TEXT}{print}' %1$s >&3", sshdConfig,
      linesToPrepend));
 Statement reloadSshdConfig = exec("hash service 2>&- && service ssh reload 2>&- || /etc/init.d/ssh* reload");
 return newStatementList(prependSshdConfig, reloadSshdConfig).render(family);
}

代码示例来源:origin: io.cloudsoft.jclouds/jclouds-scriptbuilder

public String render(OsFamily family) {
 String linesToPrepend = Joiner.on('\n').withKeyValueSeparator(" ").join(params);
 Statement prependSshdConfig = exec(String.format(
      "exec 3<> %1$s && awk -v TEXT=\"%2$s\n\" 'BEGIN {print TEXT}{print}' %1$s >&3", sshdConfig,
      linesToPrepend));
 Statement reloadSshdConfig = exec("hash service 2>&- && service ssh reload 2>&- || /etc/init.d/ssh* reload");
 return newStatementList(prependSshdConfig, reloadSshdConfig).render(family);
}

代码示例来源:origin: com.amysta.jclouds/jclouds-scriptbuilder

public String render(OsFamily family) {
 String linesToPrepend = Joiner.on('\n').withKeyValueSeparator(" ").join(params);
 Statement prependSshdConfig = exec(String.format(
      "exec 3<> %1$s && awk -v TEXT=\"%2$s\n\" 'BEGIN {print TEXT}{print}' %1$s >&3", sshdConfig,
      linesToPrepend));
 Statement reloadSshdConfig = exec("hash service 2>&- && service ssh reload 2>&- || service sshd reload 2>&- || /etc/init.d/ssh* reload");
 return newStatementList(prependSshdConfig, reloadSshdConfig).render(family);
}

代码示例来源:origin: apache/jclouds

public String render(OsFamily family) {
 String linesToPrepend = Joiner.on('\n').withKeyValueSeparator(" ").join(params);
 Statement prependSshdConfig = exec(String.format(
      "exec 3<> %1$s && awk -v TEXT=\"%2$s\n\" 'BEGIN {print TEXT}{print}' %1$s >&3", sshdConfig,
      linesToPrepend));
 Statement reloadSshdConfig = exec("hash service 2>&- && service ssh reload 2>&- || service sshd reload 2>&- || /etc/init.d/ssh* reload");
 return newStatementList(prependSshdConfig, reloadSshdConfig).render(family);
}

代码示例来源:origin: org.apache.jclouds/jclouds-scriptbuilder

public String render(OsFamily family) {
 String linesToPrepend = Joiner.on('\n').withKeyValueSeparator(" ").join(params);
 Statement prependSshdConfig = exec(String.format(
      "exec 3<> %1$s && awk -v TEXT=\"%2$s\n\" 'BEGIN {print TEXT}{print}' %1$s >&3", sshdConfig,
      linesToPrepend));
 Statement reloadSshdConfig = exec("hash service 2>&- && service ssh reload 2>&- || service sshd reload 2>&- || /etc/init.d/ssh* reload");
 return newStatementList(prependSshdConfig, reloadSshdConfig).render(family);
}

代码示例来源:origin: io.brooklyn/brooklyn-locations-jclouds

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"));
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testWhenAdminAccessInsideList() {
 AdminAccess.Configuration configuration = createMock(AdminAccess.Configuration.class);
 AdminAccess statement = createMock(AdminAccess.class);
 Credentials creds = createMock(Credentials.class);
 expect(statement.getAdminCredentials()).andReturn(creds);
 replay(configuration);
 replay(statement);
 replay(creds);
 assertEquals(CredentialsFromAdminAccess.INSTANCE.apply(Statements.newStatementList(statement)), creds);
 verify(configuration);
 verify(statement);
 verify(creds);
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testWhenNotAdminAccess() {
 Statement statement = Statements.exec("echo hello");
 assertEquals(CredentialsFromAdminAccess.INSTANCE.apply(statement), null);
 Statement statementList = Statements.newStatementList(statement);
 assertEquals(CredentialsFromAdminAccess.INSTANCE.apply(statementList), null);
}

代码示例来源:origin: apache/jclouds

public void testWhenNotAdminAccess() {
 Statement statement = Statements.exec("echo hello");
 assertEquals(CredentialsFromAdminAccess.INSTANCE.apply(statement), null);
 Statement statementList = Statements.newStatementList(statement);
 assertEquals(CredentialsFromAdminAccess.INSTANCE.apply(statementList), null);
}

代码示例来源:origin: org.apache.whirr/whirr-core

private static void ensureUserExistsAndAuthorizeSudo(
  StatementBuilder builder, String user, String publicKey, String privateKey
) {
 builder.addExport("NEW_USER", user);
 builder.addExport("DEFAULT_HOME", "/home/users");
 builder.addStatement(0, newStatementList(
   ensureUserExistsWithPublicAndPrivateKey(user, publicKey, privateKey),
   makeSudoersOnlyPermitting(user),
   disablePasswordBasedAuth())
 );
}

代码示例来源:origin: apache/attic-whirr

private static void ensureUserExistsAndAuthorizeSudo(
  StatementBuilder builder, String user, String publicKey, String privateKey
) {
 builder.addExport("NEW_USER", user);
 builder.addExport("DEFAULT_HOME", "/home/users");
 builder.addStatement(0, newStatementList(
   ensureUserExistsWithPublicAndPrivateKey(user, publicKey, privateKey),
   makeSudoersOnlyPermitting(user),
   disablePasswordBasedAuth())
 );
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testWhenNotAdminAccess() {
 AdminAccess.Configuration configuration = createMock(AdminAccess.Configuration.class);
 InitAdminAccess initAdminAccess = new InitAdminAccess(configuration);
 replay(configuration);
 initAdminAccess.visit(Statements.exec("echo hello"));
 initAdminAccess.visit(Statements.newStatementList(Statements.exec("echo hello")));
 verify(configuration);
}

代码示例来源:origin: io.brooklyn/brooklyn-locations-jclouds

public Boolean call() {
    Statement statement = Statements.newStatementList(exec("hostname"));
    // NB this assumes passwordless sudo !
    ExecResponse response = computeService.runScriptOnNode(nodeRef.getId(), statement, 
        overrideLoginCredentials(expectedCredentialsRef).runAsRoot(false));
    return response.getExitStatus() == 0;
  }})
.limitTimeTo(delayMs, MILLISECONDS)

代码示例来源:origin: apache/jclouds

public void testWhenNotAdminAccess() {
 AdminAccess.Configuration configuration = createMock(AdminAccess.Configuration.class);
 InitAdminAccess initAdminAccess = new InitAdminAccess(configuration);
 replay(configuration);
 initAdminAccess.visit(Statements.exec("echo hello"));
 initAdminAccess.visit(Statements.newStatementList(Statements.exec("echo hello")));
 verify(configuration);
}

代码示例来源:origin: jclouds/legacy-jclouds

protected static Template addRunScriptToTemplate(Template template) {
 template.getOptions().runScript(Statements.newStatementList(AdminAccess.standard(), InstallJDK.fromOpenJDK()));
 return template;
}

代码示例来源:origin: apache/attic-whirr

/**
 * Record timestamps for this phase execution on the remote machine
 */
@Override
public void beforeBootstrap(ClusterActionEvent event) {
 addStatement(event, Statements.newStatementList(
  exec("date +%s > /tmp/bootstrap-start"),
  exec("sleep 60"), // 1 minute
  exec("date +%s > /tmp/bootstrap-end")
 ));
 recordTime("before-bootstrap");
}

代码示例来源:origin: apache/jclouds

protected Template addRunScriptToTemplate(Template template) {
 template.getOptions().runScript(Statements.newStatementList(AdminAccess.standard(), InstallJDK.fromOpenJDK()));
 return template;
}

代码示例来源:origin: apache/jclouds

@Override
  protected Template addRunScriptToTemplate(Template template) {
   template.getOptions().runScript(
      Statements.newStatementList(new Statement[] { AdminAccess.standard(), Statements.exec("sleep 50"),
         InstallJDK.fromOpenJDK() }));
   return template;
  }
}

相关文章