Package org.openstack.model.compute

Examples of org.openstack.model.compute.KeyPair


        create.setName(serverName);

        if (request.sshPublicKey != null) {
          if (cloudBehaviours.supportsPublicKeys()) {
            OpenstackCloudHelpers cloudHelpers = new OpenstackCloudHelpers();
            KeyPair keyPair = cloudHelpers.ensurePublicKeyUploaded(computeClient, request.sshPublicKeyName,
                request.sshPublicKey);
            create.setKeyName(keyPair.getName());
          } else if (cloudBehaviours.supportsFileInjection()) {
            String fileContents = SshKeys.serialize(request.sshPublicKey);
            create.addUploadFile("/root/.ssh/authorized_keys", Utf8.getBytes(fileContents));
          } else {
            throw new OpsException("No supported SSH key mechanism on cloud");
View Full Code Here


    return null;
  }

  public KeyPair ensurePublicKeyUploaded(OpenstackComputeClient compute, String name, PublicKey sshPublicKey)
      throws OpsException {
    KeyPair keyPair = findPublicKey(compute, sshPublicKey);

    if (keyPair == null) {
      if (name == null) {
        name = UUID.randomUUID().toString();
      }

      String publicKey = SshKeys.serialize(sshPublicKey);
      KeyPair create = new KeyPair();
      create.setName(name);
      create.setPublicKey(publicKey);

      log.info("Creating SSH key: " + create.getName());
      compute.root().keyPairs().create(create);
    }

    keyPair = findPublicKey(compute, sshPublicKey);
    if (keyPair == null) {
View Full Code Here

TOP

Related Classes of org.openstack.model.compute.KeyPair

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.