mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
added ability to get stored passwords on gogrid
This commit is contained in:
parent
a91afd354f
commit
31fe9282a0
2 changed files with 88 additions and 0 deletions
52
lib/fog/compute/models/go_grid/password.rb
Normal file
52
lib/fog/compute/models/go_grid/password.rb
Normal file
|
@ -0,0 +1,52 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module GoGrid
|
||||
class Compute
|
||||
|
||||
class BlockInstantiationError < StandardError; end
|
||||
|
||||
class Password < Fog::Model
|
||||
|
||||
identity :id
|
||||
|
||||
attribute :server_id
|
||||
attribute :applicationtype
|
||||
attribute :username # server.ram
|
||||
attribute :password_id, :aliases => 'id'
|
||||
attribute :password
|
||||
attribute :server
|
||||
|
||||
def initialize(attributes={})
|
||||
super
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.grid_server_destroy(id)
|
||||
true
|
||||
end
|
||||
|
||||
def image
|
||||
requires :image_id
|
||||
connection.grid_image_get(image_id)
|
||||
end
|
||||
|
||||
def ready?
|
||||
@state == 'On'
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :password_id
|
||||
data = connection.support_password_list()
|
||||
merge_attributes(data.body)
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
36
lib/fog/compute/models/go_grid/passwords.rb
Normal file
36
lib/fog/compute/models/go_grid/passwords.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/go_grid/models/compute/password'
|
||||
|
||||
module Fog
|
||||
module GoGrid
|
||||
class Compute
|
||||
|
||||
class Passwords < Fog::Collection
|
||||
|
||||
model Fog::GoGrid::Compute::Password
|
||||
|
||||
def all
|
||||
data = connection.support_password_list.body['list']
|
||||
load(data)
|
||||
end
|
||||
|
||||
def bootstrap(new_attributes = {})
|
||||
password = create(new_attributes)
|
||||
password.wait_for { ready? }
|
||||
password
|
||||
end
|
||||
|
||||
def get(id)
|
||||
#if server_id && server = connection.grid_server_get(server_id).body['list']
|
||||
if id && server = connection.support_password_get(id).body['list']
|
||||
new(server)
|
||||
end
|
||||
rescue Fog::GoGrid::Compute::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue