Class: KeypairsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/keypairs_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#dispatch, #get_locales, #is_dcmgr?, #set_application, #set_locale

Instance Method Details

#create_ssh_keypairObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/keypairs_controller.rb', line 28

def create_ssh_keypair
  data = {
    :download_once => params[:download_once]
  }
  
  @ssh_key_pair = DcmgrResource::SshKeyPair.create(data)
  @filename = @ssh_key_pair.uuid + ".pem"
  
  send_data(@ssh_key_pair.private_key,{
            :filename => @filename,
            :type => 'application/pgp-encrypted',
            :status => 200
          })
end

#destroyObject



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

#indexObject



4
5
# File 'app/controllers/keypairs_controller.rb', line 4

def index
end

#listObject



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_downloadObject



53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/keypairs_controller.rb', line 53

def prk_download
  uuid = params[:id]
  @ssh_key_pair = DcmgrResource::SshKeyPair.show(uuid)
  @filename = @ssh_key_pair['uuid'] + ".pem"
  send_data(@ssh_key_pair['private_key'],{
            :filename => @filename,
            :type => 'application/pgp-encrypted',
            :status => 200
          })
end

#showObject



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_keypairsObject



43
44
45
46
# File 'app/controllers/keypairs_controller.rb', line 43

def show_keypairs
  @ssh_key_pair = DcmgrResource::SshKeyPair.list
  respond_with(@ssh_key_pair[0],:to => [:json])
end

#totalObject



48
49
50
51
# File 'app/controllers/keypairs_controller.rb', line 48

def total
 total_resource = DcmgrResource::SshKeyPair.total_resource
 render :json => total_resource
end