@Test(expectedExceptions = UnsupportedOperationException.class) public void testInstallRSAPrivateKeyWINDOWS() { new InstallRSAPrivateKey("-----BEGIN RSA PRIVATE KEY-----\n-----END RSA PRIVATE KEY-----\n") .render(OsFamily.WINDOWS); } }
statements.add(new AuthorizeRSAPublicKeys(sshDir, authorizeRSAPublicKeys)); if (installRSAPrivateKey != null) statements.add(new InstallRSAPrivateKey(sshDir, installRSAPrivateKey));
statements.add(new AuthorizeRSAPublicKeys(sshDir, authorizeRSAPublicKeys)); if (installRSAPrivateKey != null) statements.add(new InstallRSAPrivateKey(sshDir, installRSAPrivateKey));
statements.add(new AuthorizeRSAPublicKeys(sshDir, authorizeRSAPublicKeys)); if (installRSAPrivateKey != null) statements.add(new InstallRSAPrivateKey(sshDir, installRSAPrivateKey));
public void testInstallRSAPrivateKeyUNIXSpecifiedHome() { assertEquals( new InstallRSAPrivateKey("/home/me/.ssh", "-----BEGIN RSA PRIVATE KEY-----\n-----END RSA PRIVATE KEY-----\n") .render(OsFamily.UNIX), "mkdir -p /home/me/.ssh\n"+ "rm /home/me/.ssh/id_rsa\n"+ "cat >> /home/me/.ssh/id_rsa <<-'END_OF_JCLOUDS_FILE'\n"+ "\t-----BEGIN RSA PRIVATE KEY-----\n"+ "\t-----END RSA PRIVATE KEY-----\n"+ "\t\n"+ "END_OF_JCLOUDS_FILE\n"+ "chmod 600 /home/me/.ssh/id_rsa\n"); }
statements.add(new AuthorizeRSAPublicKeys(sshDir, authorizeRSAPublicKeys, login)); if (installRSAPrivateKey != null) statements.add(new InstallRSAPrivateKey(sshDir, installRSAPrivateKey));
public void testInstallRSAPrivateKeyUNIXCurrentUser() { assertEquals( new InstallRSAPrivateKey("-----BEGIN RSA PRIVATE KEY-----\n-----END RSA PRIVATE KEY-----\n") .render(OsFamily.UNIX), "mkdir -p ~/.ssh\n"+ "rm ~/.ssh/id_rsa\n"+ "cat >> ~/.ssh/id_rsa <<-'END_OF_JCLOUDS_FILE'\n"+ "\t-----BEGIN RSA PRIVATE KEY-----\n"+ "\t-----END RSA PRIVATE KEY-----\n"+ "\t\n"+ "END_OF_JCLOUDS_FILE\n"+ "chmod 600 ~/.ssh/id_rsa\n"); }
statements.add(new AuthorizeRSAPublicKeys(sshDir, authorizeRSAPublicKeys, login)); if (installRSAPrivateKey != null) statements.add(new InstallRSAPrivateKey(sshDir, installRSAPrivateKey));
public void testInstallRSAPrivateKeyUNIXCurrentUser() { assertEquals( new InstallRSAPrivateKey("-----BEGIN RSA PRIVATE KEY-----\n-----END RSA PRIVATE KEY-----\n") .render(OsFamily.UNIX), "mkdir -p ~/.ssh\n" + "rm ~/.ssh/id_rsa\n" + "cat >> ~/.ssh/id_rsa <<-'END_OF_JCLOUDS_FILE'\n" + "\t-----BEGIN RSA PRIVATE KEY-----\n" + "\t-----END RSA PRIVATE KEY-----\n" + "\t\n" + "END_OF_JCLOUDS_FILE\n" + "chmod 600 ~/.ssh/id_rsa\n"); }
statements.add(new AuthorizeRSAPublicKeys(sshDir, authorizeRSAPublicKeys, login)); if (installRSAPrivateKey != null) statements.add(new InstallRSAPrivateKey(sshDir, installRSAPrivateKey));
@Test(expectedExceptions = UnsupportedOperationException.class) public void testInstallRSAPrivateKeyWINDOWS() { new InstallRSAPrivateKey("-----BEGIN RSA PRIVATE KEY-----\n-----END RSA PRIVATE KEY-----\n") .render(OsFamily.WINDOWS); } }
@Override public Statement apply(NodeMetadata node, TemplateOptions options) { ImmutableList.Builder<Statement> builder = ImmutableList.builder(); if (options.getRunScript() != null) { builder.add(options.getRunScript()); } if (options.getPrivateKey() != null) { builder.add(new InstallRSAPrivateKey(options.getPrivateKey())); } ImmutableList<Statement> bootstrap = builder.build(); if (!bootstrap.isEmpty()) { if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) { options.nameTask("bootstrap"); } return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap); } return null; } }
public void testInstallRSAPrivateKeyUNIXSpecifiedHome() { assertEquals( new InstallRSAPrivateKey("/home/me/.ssh", "-----BEGIN RSA PRIVATE KEY-----\n-----END RSA PRIVATE KEY-----\n") .render(OsFamily.UNIX), "mkdir -p /home/me/.ssh\n" + "rm /home/me/.ssh/id_rsa\n" + "cat >> /home/me/.ssh/id_rsa <<-'END_OF_JCLOUDS_FILE'\n" + "\t-----BEGIN RSA PRIVATE KEY-----\n" + "\t-----END RSA PRIVATE KEY-----\n" + "\t\n" + "END_OF_JCLOUDS_FILE\n" + "chmod 600 /home/me/.ssh/id_rsa\n"); }
@Override public Statement apply(NodeMetadata node, TemplateOptions options) { ImmutableList.Builder<Statement> builder = ImmutableList.builder(); if (options.getRunScript() != null) { builder.add(options.getRunScript()); } if (options.getPrivateKey() != null) { builder.add(new InstallRSAPrivateKey(options.getPrivateKey())); } ImmutableList<Statement> bootstrap = builder.build(); if (!bootstrap.isEmpty()) { if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) { options.nameTask("bootstrap"); } return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap); } return null; } }
@Override public Statement apply(TemplateOptions options) { List<Statement> bootstrap = newArrayList(); if (options.getPublicKey() != null) bootstrap.add(new AuthorizeRSAPublicKeys(ImmutableSet.of(options.getPublicKey()))); if (options.getRunScript() != null) bootstrap.add(options.getRunScript()); if (options.getPrivateKey() != null) bootstrap.add(new InstallRSAPrivateKey(options.getPrivateKey())); if (bootstrap.size() >= 1) { if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) options.nameTask("bootstrap"); return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap); } return null; }
@Override public Statement apply(TemplateOptions options) { List<Statement> bootstrap = newArrayList(); if (options.getPublicKey() != null) bootstrap.add(new AuthorizeRSAPublicKeys(ImmutableSet.of(options.getPublicKey()))); if (options.getRunScript() != null) bootstrap.add(options.getRunScript()); if (options.getPrivateKey() != null) bootstrap.add(new InstallRSAPrivateKey(options.getPrivateKey())); if (bootstrap.size() >= 1) { if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) options.nameTask("bootstrap"); return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap); } return null; }
@Override public Statement apply(NodeMetadata node, TemplateOptions options) { String user = options.getLoginUser(); if (user == null && node.getCredentials() != null) { user = node.getCredentials().getUser(); } List<Statement> bootstrap = newArrayList(); if (options.getPublicKey() != null) bootstrap.add(new AuthorizeRSAPublicKeys(ImmutableSet.of(options.getPublicKey()), user)); if (options.getRunScript() != null) bootstrap.add(options.getRunScript()); if (options.getPrivateKey() != null) bootstrap.add(new InstallRSAPrivateKey(options.getPrivateKey())); if (bootstrap.size() >= 1) { if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) options.nameTask("bootstrap"); return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap); } return null; }
@Override public Statement apply(NodeMetadata node, TemplateOptions options) { String user = options.getLoginUser(); if (user == null && node.getCredentials() != null) { user = node.getCredentials().getUser(); } List<Statement> bootstrap = newArrayList(); if (options.getPublicKey() != null) bootstrap.add(new AuthorizeRSAPublicKeys(ImmutableSet.of(options.getPublicKey()), user)); if (options.getRunScript() != null) bootstrap.add(options.getRunScript()); if (options.getPrivateKey() != null) bootstrap.add(new InstallRSAPrivateKey(options.getPrivateKey())); if (bootstrap.size() >= 1) { if (options.getTaskName() == null && !(options.getRunScript() instanceof InitScript)) options.nameTask("bootstrap"); return bootstrap.size() == 1 ? bootstrap.get(0) : new StatementList(bootstrap); } return null; }