def setup_key_pair
      public_key, private_key = generate_key
      key_name = "foreman-#{id}#{Foreman.uuid}"
      client.create_ssh_key key_name, public_key
      KeyPair.create! :name => key_name, :compute_resource_id => id, :secret => private_key
    rescue StandardError => e
      logger.warn 'failed to generate key pair'
      logger.error e.message
      logger.error e.backtrace.join("\n")
      destroy_key_pair
      raise
    end
def setup_key_pair
      public_key, private_key = generate_key
      key_name = "foreman-#{id}#{Foreman.uuid}"
      client.create_ssh_key key_name, public_key
      KeyPair.create! :name => key_name, :compute_resource_id => id, :secret => private_key
    rescue StandardError => e
      logger.warn 'failed to generate key pair'
      logger.error e.message
      logger.error e.backtrace.join("\n")
      destroy_key_pair
      raise
    end
Creates a new key pair for each new DigitalOcean compute resource
 After creating the key, it uploads it to DigitalOcean