Class: KeypairsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- KeypairsController
- Defined in:
- app/controllers/keypairs_controller.rb
Instance Method Summary collapse
- #create_ssh_keypair ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #list ⇒ Object
- #prk_download ⇒ Object
- #show ⇒ Object
- #show_keypairs ⇒ Object
- #total ⇒ Object
Instance Method Details
#create_ssh_keypair ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/keypairs_controller.rb', line 28 def create_ssh_keypair data = { :name => params[:name], :download_once => params[:download_once] } @filename = params[:name] + ".pem" @ssh_key_pair = DcmgrResource::SshKeyPair.create(data) send_data(@ssh_key_pair.private_key,{ :filename => @filename, :type => 'application/pgp-encrypted', :status => 200 }) end |
#destroy ⇒ Object
22 23 24 25 26 |
# File 'app/controllers/keypairs_controller.rb', line 22 def destroy name = params[:id] @ssh_key_pair = DcmgrResource::SshKeyPair.destroy(name) render :json => @ssh_key_pair end |
#index ⇒ Object
4 5 |
# File 'app/controllers/keypairs_controller.rb', line 4 def index end |
#list ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'app/controllers/keypairs_controller.rb', line 7 def list data = { :start => params[:start].to_i - 1, :limit => params[:limit] } @ssh_key_pair = DcmgrResource::SshKeyPair.list(data) respond_with(@ssh_key_pair[0],:to => [:json]) end |
#prk_download ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/keypairs_controller.rb', line 54 def prk_download uuid = params[:id] @ssh_key_pair = DcmgrResource::SshKeyPair.show(uuid) @filename = @ssh_key_pair['name'] + ".pem" send_data(@ssh_key_pair['private_key'],{ :filename => @filename, :type => 'application/pgp-encrypted', :status => 200 }) end |
#show ⇒ Object
16 17 18 19 20 |
# File 'app/controllers/keypairs_controller.rb', line 16 def show uuid = params[:id] @ssh_key_pair = DcmgrResource::SshKeyPair.show(uuid) respond_with(@ssh_key_pair,:to => [:json]) end |
#show_keypairs ⇒ Object
44 45 46 47 |
# File 'app/controllers/keypairs_controller.rb', line 44 def show_keypairs @ssh_key_pair = DcmgrResource::SshKeyPair.list respond_with(@ssh_key_pair[0],:to => [:json]) end |
#total ⇒ Object
49 50 51 52 |
# File 'app/controllers/keypairs_controller.rb', line 49 def total total_resource = DcmgrResource::SshKeyPair.total_resource render :json => total_resource end |