Package org.jclouds.cloudstack.features

Examples of org.jclouds.cloudstack.features.SSHKeyPairClient


public class CreateUniqueKeyPairTest {

   @Test
   public void testLoad() throws UnknownHostException {
      final CloudStackClient client = createMock(CloudStackClient.class);
      SSHKeyPairClient keyClient = createMock(SSHKeyPairClient.class);

      SshKeyPair pair = createMock(SshKeyPair.class);

      expect(client.getSSHKeyPairClient()).andReturn(keyClient);
      expect(keyClient.createSSHKeyPair("group-1")).andReturn(pair);

      replay(client, keyClient);

      CreateUniqueKeyPair parser = Guice.createInjector(new AbstractModule() {
View Full Code Here


    @Override
    public void execute(CloudStackClient cloudStackClient, Pool pool, DelegateExecution execution) {
        String keyName = KeyPairs.formatNameFromBusinessKey(execution.getProcessBusinessKey());
        LOG.info("Creating admin access key pair as {}", keyName);
        SSHKeyPairClient sshKeyPairClient = cloudStackClient.getSSHKeyPairClient();
        try {
            SshKeyPair sshKeyPair = sshKeyPairClient.registerSSHKeyPair(keyName, pool.getAdminAccess().getPublicKey());
            LOG.info("Registered remote key with fingerprint {}", sshKeyPair.getFingerprint());
        } catch (IllegalStateException e) {
            LOG.warn("Key with name {} already exists", keyName);
            SshKeyPair key = sshKeyPairClient.getSSHKeyPair(keyName);
            if (key.getFingerprint().equals(SshKeys.fingerprintPublicKey(pool.getAdminAccess().getPublicKey()))) {
                LOG.info("Fingerprints match. Not updating admin access key pair.");
            } else {
                LOG.info("Fingerprint do not match. Replacing admin access key pair.");
                sshKeyPairClient.deleteSSHKeyPair(keyName);
                sshKeyPairClient.registerSSHKeyPair(keyName, pool.getAdminAccess().getPublicKey());
            }
        }
    }
View Full Code Here

    @Override
    public void execute(CloudStackClient cloudStackClient, Pool pool, DelegateExecution execution) {
        String keyName = KeyPairs.formatNameFromBusinessKey(execution.getProcessBusinessKey());
        LOG.info("Creating admin access key pair as {}", keyName);
        SSHKeyPairClient sshKeyPairClient = cloudStackClient.getSSHKeyPairClient();
        try {
            SshKeyPair sshKeyPair = sshKeyPairClient.registerSSHKeyPair(keyName, pool.getAdminAccess().getPublicKey());
            LOG.info("Registered remote key with fingerprint {}", sshKeyPair.getFingerprint());
        } catch (IllegalStateException e) {
            LOG.warn("Key with name {} already exists", keyName);
            SshKeyPair key = sshKeyPairClient.getSSHKeyPair(keyName);
            if (key.getFingerprint().equals(SshKeys.fingerprintPublicKey(pool.getAdminAccess().getPublicKey()))) {
                LOG.info("Fingerprints match. Not updating admin access key pair.");
            } else {
                LOG.info("Fingerprint do not match. Replacing admin access key pair.");
                sshKeyPairClient.deleteSSHKeyPair(keyName);
                sshKeyPairClient.registerSSHKeyPair(keyName, pool.getAdminAccess().getPublicKey());
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.jclouds.cloudstack.features.SSHKeyPairClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.