Sha256: 306042725a819cb4107063bff74d173f002c50f3b4dd202acac8de0ef7cf8b4a

Contents?: true

Size: 1.58 KB

Versions: 20

Compression:

Stored size: 1.58 KB

Contents


module Rudy; module CLI; 
module AWS; module EC2;
  
  class KeyPairs < Rudy::CLI::CommandBase
    
    def create_keypairs_valid?
      raise Drydock::ArgError.new('name', @alias) unless @argv.name
      true
    end
    def create_keypairs
      rkey = Rudy::AWS::EC2::KeyPairs.new(@@global.accesskey, @@global.secretkey, @@global.region)
      kp = execute_action { rkey.create(@argv.name) }
      if [:s, :string].member?(@@global.format)
        puts "Name: #{kp.name}"
        puts "Fingerprint: #{kp.fingerprint}", $/
        puts "Copy the following private key data into a file."
        puts "Set the permissions to 0600 and keep it safe.", $/
        puts kp.private_key
      else
        puts @@global.verbose > 0 ? kp.inspect : kp.dump(@@global.format)
      end
    end
    
    def destroy_keypairs_valid?
      raise Drydock::ArgError.new('name', @alias) unless @argv.name
      true
    end
    def destroy_keypairs
      rkey = Rudy::AWS::EC2::KeyPairs.new(@@global.accesskey, @@global.secretkey, @@global.region)
      raise "KeyPair #{@argv.name} does not exist" unless rkey.exists?(@argv.name)
      kp = rkey.get(@argv.name)
      puts "Destroying: #{kp.name}"
      execute_check(:medium)
      execute_action { rkey.destroy(kp.name) }
      keypairs
    end
    
    def keypairs
      rkey = Rudy::AWS::EC2::KeyPairs.new(@@global.accesskey, @@global.secretkey, @@global.region)
      (rkey.list || []).each do |kp|
        puts @@global.verbose > 0 ? kp.inspect : kp.dump(@@global.format)
      end
      puts "No keypairs" unless rkey.any?
    end
    
    
  end


end; end
end; end

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
sabat-rudy-0.8.0 lib/rudy/cli/aws/ec2/keypairs.rb
solutious-rudy-0.7.3 lib/rudy/cli/aws/ec2/keypairs.rb
solutious-rudy-0.7.4 lib/rudy/cli/aws/ec2/keypairs.rb
solutious-rudy-0.7.5 lib/rudy/cli/aws/ec2/keypairs.rb
solutious-rudy-0.7.6 lib/rudy/cli/aws/ec2/keypairs.rb
solutious-rudy-0.8.0 lib/rudy/cli/aws/ec2/keypairs.rb
solutious-rudy-0.8.1 lib/rudy/cli/aws/ec2/keypairs.rb
solutious-rudy-0.8.2 lib/rudy/cli/aws/ec2/keypairs.rb
solutious-rudy-0.8.3 lib/rudy/cli/aws/ec2/keypairs.rb
solutious-rudy-0.8.4 lib/rudy/cli/aws/ec2/keypairs.rb
solutious-rudy-0.8.5 lib/rudy/cli/aws/ec2/keypairs.rb
rudy-0.7.4 lib/rudy/cli/aws/ec2/keypairs.rb
rudy-0.7.3 lib/rudy/cli/aws/ec2/keypairs.rb
rudy-0.7.6 lib/rudy/cli/aws/ec2/keypairs.rb
rudy-0.8.2 lib/rudy/cli/aws/ec2/keypairs.rb
rudy-0.8.1 lib/rudy/cli/aws/ec2/keypairs.rb
rudy-0.8.0 lib/rudy/cli/aws/ec2/keypairs.rb
rudy-0.8.4 lib/rudy/cli/aws/ec2/keypairs.rb
rudy-0.8.3 lib/rudy/cli/aws/ec2/keypairs.rb
rudy-0.8.5 lib/rudy/cli/aws/ec2/keypairs.rb