diff --git a/lib/fog/compute/models/go_grid/password.rb b/lib/fog/compute/models/go_grid/password.rb new file mode 100644 index 000000000..68b617813 --- /dev/null +++ b/lib/fog/compute/models/go_grid/password.rb @@ -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 diff --git a/lib/fog/compute/models/go_grid/passwords.rb b/lib/fog/compute/models/go_grid/passwords.rb new file mode 100644 index 000000000..bbc083058 --- /dev/null +++ b/lib/fog/compute/models/go_grid/passwords.rb @@ -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