deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [1/3] git commit: Core: Moved Deltacloud models to Deltacloud:: namespace (DTACLOUD-507)
Date Tue, 12 Mar 2013 10:08:18 GMT
Core: Moved Deltacloud models to Deltacloud:: namespace (DTACLOUD-507)


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/d4fd74ab
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/d4fd74ab
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/d4fd74ab

Branch: refs/heads/master
Commit: d4fd74ab0ba13453a1c1b2ab96d5d7dbc093c98a
Parents: 1a51026
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Thu Mar 7 13:22:46 2013 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue Mar 12 11:04:08 2013 +0100

----------------------------------------------------------------------
 server/lib/deltacloud/api.rb                       |   11 +-
 server/lib/deltacloud/collections/images.rb        |    2 +-
 server/lib/deltacloud/collections/instances.rb     |    4 +-
 server/lib/deltacloud/drivers/base_driver.rb       |    1 +
 .../drivers/mock/data/instances/inst0.yml          |    6 +-
 .../drivers/mock/data/instances/inst1.yml          |    6 +-
 .../drivers/mock/data/instances/inst2.yml          |    6 +-
 server/lib/deltacloud/drivers/mock/mock_client.rb  |    8 +-
 server/lib/deltacloud/models/address.rb            |   36 ++--
 server/lib/deltacloud/models/base_model.rb         |   57 +++---
 server/lib/deltacloud/models/blob.rb               |   42 ++--
 server/lib/deltacloud/models/bucket.rb             |   37 ++--
 server/lib/deltacloud/models/firewall.rb           |   34 ++--
 server/lib/deltacloud/models/firewall_rule.rb      |   42 ++--
 server/lib/deltacloud/models/image.rb              |   57 +++---
 server/lib/deltacloud/models/instance.rb           |  186 +++++++--------
 server/lib/deltacloud/models/instance_address.rb   |   82 ++++---
 server/lib/deltacloud/models/instance_profile.rb   |   54 +++--
 server/lib/deltacloud/models/key.rb                |   92 ++++----
 server/lib/deltacloud/models/load_balancer.rb      |   63 +++---
 server/lib/deltacloud/models/metric.rb             |  120 +++++-----
 server/lib/deltacloud/models/provider.rb           |   28 ++-
 server/lib/deltacloud/models/realm.rb              |   29 ++-
 server/lib/deltacloud/models/storage_snapshot.rb   |   42 ++--
 server/lib/deltacloud/models/storage_volume.rb     |   69 +++---
 25 files changed, 573 insertions(+), 541 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/api.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/api.rb b/server/lib/deltacloud/api.rb
index 4208a1f..295bbd2 100644
--- a/server/lib/deltacloud/api.rb
+++ b/server/lib/deltacloud/api.rb
@@ -39,7 +39,7 @@ module TestPoller
     opts[:retries] ||= 10
     opts[:time_between_retry] ||= 10
     opts[:timeout] ||= 60
-    opts[:method] ||= self.class.name.downcase.to_sym
+    opts[:method] ||= self.class.name.split('::').last.downcase.to_sym
     opts[:retries].downto(0) do |r|
       result = begin
         timeout(opts[:timeout]) do
@@ -62,12 +62,13 @@ module TestPoller
   end
 end
 
-class Instance; include TestPoller; end
-class Image; include TestPoller; end
-class StorageSnapshot; include TestPoller; end
-
 module Deltacloud
 
+  class Instance; include TestPoller; end
+  class Image; include TestPoller; end
+  class StorageSnapshot; include TestPoller; end
+
+
   def self.drivers
     Drivers.driver_config
   end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/collections/images.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/images.rb b/server/lib/deltacloud/collections/images.rb
index dbdbdfa..80fbf08 100644
--- a/server/lib/deltacloud/collections/images.rb
+++ b/server/lib/deltacloud/collections/images.rb
@@ -23,7 +23,7 @@ module Deltacloud::Collections
 
     new_route_for :images do
       halt 404 unless params[:instance_id]
-      @instance = Instance.new( :id => params[:instance_id] )
+      @instance = Deltacloud::Instance.new( :id => params[:instance_id] )
     end
 
     collection :images do

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/collections/instances.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/collections/instances.rb b/server/lib/deltacloud/collections/instances.rb
index 824ba15..ee48f30 100644
--- a/server/lib/deltacloud/collections/instances.rb
+++ b/server/lib/deltacloud/collections/instances.rb
@@ -22,10 +22,10 @@ module Deltacloud::Collections
     check_features :for => lambda { |c, f| driver.class.has_feature?(c, f) }
 
     new_route_for(:instances) do
-      @instance = Instance.new( { :id=>params[:id], :image_id=>params[:image_id] } )
+      @instance = Deltacloud::Instance.new( { :id=>params[:id], :image_id=>params[:image_id] } )
       @image   = driver.image(credentials, :id => params[:image_id])
       @hardware_profiles = driver.hardware_profiles(credentials, :architecture => @image.architecture )
-      @realms = [Realm.new(:id => params[:realm_id])] if params[:realm_id]
+      @realms = [Deltacloud::Realm.new(:id => params[:realm_id])] if params[:realm_id]
       @realms ||= driver.realms(credentials)
       @firewalls = driver.firewalls(credentials) if driver.class.has_feature? :instances, :firewalls
       @keys = driver.keys(credentials) if driver.class.has_feature? :instances, :authentication_key

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/drivers/base_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/base_driver.rb b/server/lib/deltacloud/drivers/base_driver.rb
index fa1d710..52fbd27 100644
--- a/server/lib/deltacloud/drivers/base_driver.rb
+++ b/server/lib/deltacloud/drivers/base_driver.rb
@@ -25,6 +25,7 @@ module Deltacloud
   class BaseDriver
 
     include Exceptions
+    include Deltacloud
 
     STATE_MACHINE_OPTS = {
       :all_states => [:start, :pending, :running, :stopping, :stopped, :finish, :error],

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/drivers/mock/data/instances/inst0.yml
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/instances/inst0.yml b/server/lib/deltacloud/drivers/mock/data/instances/inst0.yml
index 59fa3d1..832329a 100644
--- a/server/lib/deltacloud/drivers/mock/data/instances/inst0.yml
+++ b/server/lib/deltacloud/drivers/mock/data/instances/inst0.yml
@@ -1,5 +1,5 @@
 ---
-:instance_profile: !ruby/object:InstanceProfile
+:instance_profile: !ruby/object:Deltacloud::InstanceProfile
   memory: "12288"
   id: m1-large
 :realm_id: us
@@ -8,11 +8,11 @@
 - :stop
 :owner_id: mockuser
 :public_addresses:
-- !ruby/object:InstanceAddress
+- !ruby/object:Deltacloud::InstanceAddress
   address: img1.inst0.public.com
   address_type: :hostname
 :private_addresses:
-- !ruby/object:InstanceAddress
+- !ruby/object:Deltacloud::InstanceAddress
   address: img1.inst0.private.com
   address_type: :hostname
 :create_image: true

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/drivers/mock/data/instances/inst1.yml
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/instances/inst1.yml b/server/lib/deltacloud/drivers/mock/data/instances/inst1.yml
index 661f24c..b1ebb45 100644
--- a/server/lib/deltacloud/drivers/mock/data/instances/inst1.yml
+++ b/server/lib/deltacloud/drivers/mock/data/instances/inst1.yml
@@ -1,14 +1,14 @@
 ---
-:instance_profile: !ruby/object:InstanceProfile
+:instance_profile: !ruby/object:Deltacloud::InstanceProfile
   id: m1-small
 :realm_id: us
 :owner_id: mockuser
 :public_addresses:
-- !ruby/object:InstanceAddress
+- !ruby/object:Deltacloud::InstanceAddress
   address: img1.inst1.public.com
   address_type: :hostname
 :private_addresses:
-- !ruby/object:InstanceAddress
+- !ruby/object:Deltacloud::InstanceAddress
   address: img1.inst1.private.com
   address_type: :hostname
 :create_image: true

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/drivers/mock/data/instances/inst2.yml
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/instances/inst2.yml b/server/lib/deltacloud/drivers/mock/data/instances/inst2.yml
index da944ee..301f1cf 100644
--- a/server/lib/deltacloud/drivers/mock/data/instances/inst2.yml
+++ b/server/lib/deltacloud/drivers/mock/data/instances/inst2.yml
@@ -1,14 +1,14 @@
 ---
-:instance_profile: !ruby/object:InstanceProfile
+:instance_profile: !ruby/object:Deltacloud::InstanceProfile
   id: m1-large
 :realm_id: us
 :owner_id: anotheruser
 :public_addresses:
-- !ruby/object:InstanceAddress
+- !ruby/object:Deltacloud::InstanceAddress
   address: img1.inst2.public.com
   address_type: :hostname
 :private_addresses:
-- !ruby/object:InstanceAddress
+- !ruby/object:Deltacloud::InstanceAddress
   address: img1.inst2.private.com
   address_type: :hostname
 :create_image: true

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/drivers/mock/mock_client.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/mock_client.rb b/server/lib/deltacloud/drivers/mock/mock_client.rb
index d3ac437..f9795c6 100644
--- a/server/lib/deltacloud/drivers/mock/mock_client.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_client.rb
@@ -23,6 +23,9 @@ module Deltacloud::Drivers::Mock
   require 'fileutils'
 
   class Client
+
+    include Deltacloud
+
     def initialize(storage_root)
       @storage_root = storage_root
       @collections = []
@@ -121,13 +124,10 @@ module Deltacloud::Drivers::Mock
       File::join(@storage_root, "cimi", collection.to_s)
     end
 
-
-
-
     private
 
     def collection_name(klass)
-      klass.name.underscore.pluralize
+      klass.name.split('::').last.underscore.pluralize
     end
   end
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/address.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/address.rb b/server/lib/deltacloud/models/address.rb
index ce63524..44d3924 100644
--- a/server/lib/deltacloud/models/address.rb
+++ b/server/lib/deltacloud/models/address.rb
@@ -14,25 +14,27 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-class Address < BaseModel
-  attr_accessor :instance_id
+module Deltacloud
+  class Address < BaseModel
+    attr_accessor :instance_id
 
-  def initialize(init=nil)
-    super(init)
-  end
+    def initialize(init=nil)
+      super(init)
+    end
 
-  def associated?
-    !self.instance_id.nil?
-  end
+    def associated?
+      !self.instance_id.nil?
+    end
 
-  def to_hash(context)
-    r = {
-      :id => self.id,
-      :href => context.address_url(self.id),
-      :associated => associated?
-    }
-    r[:instance_id] = instance_id if associated?
-    r
-  end
+    def to_hash(context)
+      r = {
+        :id => self.id,
+        :href => context.address_url(self.id),
+        :associated => associated?
+      }
+      r[:instance_id] = instance_id if associated?
+      r
+    end
 
+  end
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/base_model.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/base_model.rb b/server/lib/deltacloud/models/base_model.rb
index 613bb1f..f238440 100644
--- a/server/lib/deltacloud/models/base_model.rb
+++ b/server/lib/deltacloud/models/base_model.rb
@@ -14,40 +14,41 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
+module Deltacloud
+  class BaseModel
+
+    attr_accessor :name, :description
+
+    def initialize(init=nil)
+      if ( init )
+        @id=init[:id]
+        init.each{|k,v|
+          self.send( "#{k}=", v ) if ( self.respond_to?( "#{k}=" ) )
+        }
+      end
+    end
 
-class BaseModel
-
-  attr_accessor :name, :description
-
-  def initialize(init=nil)
-    if ( init )
-      @id=init[:id]
-      init.each{|k,v|
-        self.send( "#{k}=", v ) if ( self.respond_to?( "#{k}=" ) )
-      }
+    def self.attr_accessor(*vars)
+      @attributes ||= [:id]
+      @attributes.concat vars
+      super
     end
-  end
 
-  def self.attr_accessor(*vars)
-    @attributes ||= [:id]
-    @attributes.concat vars
-    super
-  end
+    def self.attributes
+      @attributes
+    end
 
-  def self.attributes
-    @attributes
-  end
+    def attributes
+      self.class.attributes
+    end
 
-  def attributes
-    self.class.attributes
-  end
+    def id
+      @id
+    end
 
-  def id
-    @id
-  end
+    def to_entity
+      self.class.name.downcase
+    end
 
-  def to_entity
-    self.class.name.downcase
   end
-
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/blob.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/blob.rb b/server/lib/deltacloud/models/blob.rb
index e3a01ed..0ae6249 100644
--- a/server/lib/deltacloud/models/blob.rb
+++ b/server/lib/deltacloud/models/blob.rb
@@ -14,27 +14,29 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-class Blob < BaseModel
+module Deltacloud
+  class Blob < BaseModel
 
-  #already has an id from basemodel (for the key)
-  attr_accessor :bucket
-  attr_accessor :content_length
-  attr_accessor :content_type
-  attr_accessor :last_modified
-  attr_accessor :content
-  attr_accessor :user_metadata
+    #already has an id from basemodel (for the key)
+    attr_accessor :bucket
+    attr_accessor :content_length
+    attr_accessor :content_type
+    attr_accessor :last_modified
+    attr_accessor :content
+    attr_accessor :user_metadata
 
-  def to_hash(context)
-    {
-      :id => self.id,
-      :href => context.bucket_url(bucket) + '/' + self.id,
-      :bucket => { :rel => :bucket, :href => context.bucket_url(bucket), :id => bucket },
-      :content_length => content_length,
-      :content_type => content_type,
-      :last_modified => last_modified,
-      :content => content,
-      :user_metadata => user_metadata
-    }
-  end
+    def to_hash(context)
+      {
+        :id => self.id,
+        :href => context.bucket_url(bucket) + '/' + self.id,
+        :bucket => { :rel => :bucket, :href => context.bucket_url(bucket), :id => bucket },
+        :content_length => content_length,
+        :content_type => content_type,
+        :last_modified => last_modified,
+        :content => content,
+        :user_metadata => user_metadata
+      }
+    end
 
+  end
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/bucket.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/bucket.rb b/server/lib/deltacloud/models/bucket.rb
index 5ec3537..be287ff 100644
--- a/server/lib/deltacloud/models/bucket.rb
+++ b/server/lib/deltacloud/models/bucket.rb
@@ -14,24 +14,29 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-class Bucket < BaseModel
+module Deltacloud
+  class Bucket < BaseModel
 
-  attr_accessor :name
-  attr_accessor :size
-  attr_accessor :blob_list
+    attr_accessor :name
+    attr_accessor :size
+    attr_accessor :blob_list
 
-  def blob_list
-    @blob_list || []
-  end
+    def blob_list
+      @blob_list || []
+    end
 
-  def to_hash(context)
-    {
-      :id => self.id,
-      :href => context.bucket_url(self.id),
-      :name => name,
-      :size => size,
-      :blob_list => blob_list.map { |b| { :rel => :blob, :href => context.url("/buckets/#{self.id}/#{b}"), :id => b }}
-    }
-  end
+    def to_hash(context)
+      {
+        :id => self.id,
+        :href => context.bucket_url(self.id),
+        :name => name,
+        :size => size,
+        :blob_list => blob_list.map { |b| {
+          :rel => :blob,
+          :href => context.url("/buckets/#{self.id}/#{b}"), :id => b }
+        }
+      }
+    end
 
+  end
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/firewall.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/firewall.rb b/server/lib/deltacloud/models/firewall.rb
index 7d139af..3dedbb0 100644
--- a/server/lib/deltacloud/models/firewall.rb
+++ b/server/lib/deltacloud/models/firewall.rb
@@ -14,22 +14,24 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-class Firewall < BaseModel
-  attr_accessor :name
-  attr_accessor :description
-  attr_accessor :owner_id
-  attr_accessor :rules
+module Deltacloud
+  class Firewall < BaseModel
+    attr_accessor :name
+    attr_accessor :description
+    attr_accessor :owner_id
+    attr_accessor :rules
 
-  def to_hash(context)
-    r = {
-      :id => self.id,
-      :href => context.firewall_url(self.id),
-      :name => name,
-      :description => description,
-      :owner_id => owner_id,
-      :rules => []
-    }
-    r[:rules] = rules.map { |rule| rule.to_hash(context) } if rules and !rules.empty?
-    r
+    def to_hash(context)
+      r = {
+        :id => self.id,
+        :href => context.firewall_url(self.id),
+        :name => name,
+        :description => description,
+        :owner_id => owner_id,
+        :rules => []
+      }
+      r[:rules] = rules.map { |rule| rule.to_hash(context) } if rules and !rules.empty?
+      r
+    end
   end
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/firewall_rule.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/firewall_rule.rb b/server/lib/deltacloud/models/firewall_rule.rb
index 078cf74..dde160e 100644
--- a/server/lib/deltacloud/models/firewall_rule.rb
+++ b/server/lib/deltacloud/models/firewall_rule.rb
@@ -14,26 +14,28 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-class FirewallRule < BaseModel
-  attr_accessor :allow_protocol # tcp/udp/icmp
-  attr_accessor :port_from
-  attr_accessor :port_to
-  attr_accessor :sources
-  attr_accessor :direction #ingress egress
-  attr_accessor :rule_action #Accept/Deny - initially added for FGCP
-  attr_accessor :log_rule #log when rule triggered true/false - added for FGCP
+module Deltacloud
+  class FirewallRule < BaseModel
+    attr_accessor :allow_protocol # tcp/udp/icmp
+    attr_accessor :port_from
+    attr_accessor :port_to
+    attr_accessor :sources
+    attr_accessor :direction #ingress egress
+    attr_accessor :rule_action #Accept/Deny - initially added for FGCP
+    attr_accessor :log_rule #log when rule triggered true/false - added for FGCP
 
-  def to_hash(context)
-    {
-      :id => self.id,
-      :allow_protocol => allow_protocol,
-      :port_from => port_from,
-      :port_to => port_to,
-      :sources => sources,
-      :direction => direction,
-      :rule_action => rule_action,
-      :log_rule => log_rule
-    }.delete_if { |k, v| v.nil? }
-  end
+    def to_hash(context)
+      {
+        :id => self.id,
+        :allow_protocol => allow_protocol,
+        :port_from => port_from,
+        :port_to => port_to,
+        :sources => sources,
+        :direction => direction,
+        :rule_action => rule_action,
+        :log_rule => log_rule
+      }.delete_if { |k, v| v.nil? }
+    end
 
+  end
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/image.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/image.rb b/server/lib/deltacloud/models/image.rb
index c3dc1a8..a86a788 100644
--- a/server/lib/deltacloud/models/image.rb
+++ b/server/lib/deltacloud/models/image.rb
@@ -14,37 +14,38 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
+module Deltacloud
+  class Image < BaseModel
 
-class Image < BaseModel
+    attr_accessor :name
+    attr_accessor :owner_id
+    attr_accessor :description
+    attr_accessor :architecture
+    attr_accessor :state
+    attr_accessor :hardware_profiles
+    attr_accessor :creation_time
+    attr_accessor :root_type
 
-  attr_accessor :name
-  attr_accessor :owner_id
-  attr_accessor :description
-  attr_accessor :architecture
-  attr_accessor :state
-  attr_accessor :hardware_profiles
-  attr_accessor :creation_time
-  attr_accessor :root_type
+    def root_type
+      @root_type || 'transient'
+    end
 
-  def root_type
-    @root_type || 'transient'
-  end
-
-  def to_hash(context)
-    {
-      :id => self.id,
-      :href => context.image_url(self.id),
-      :name => name,
-      :description => description,
-      :owner => owner_id,
-      :architecture => architecture,
-      :state => state,
-      :root_type => root_type,
-      :creation_time => creation_time,
-      :hardware_profiles => hardware_profiles.map { |p|
-        { :id => p.id, :href => context.hardware_profile_url(p.id), :rel => :hardware_profile }
+    def to_hash(context)
+      {
+        :id => self.id,
+        :href => context.image_url(self.id),
+        :name => name,
+        :description => description,
+        :owner => owner_id,
+        :architecture => architecture,
+        :state => state,
+        :root_type => root_type,
+        :creation_time => creation_time,
+        :hardware_profiles => hardware_profiles.map { |p|
+          { :id => p.id, :href => context.hardware_profile_url(p.id), :rel => :hardware_profile }
+        }
       }
-    }
-  end
+    end
 
+  end
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/instance.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/instance.rb b/server/lib/deltacloud/models/instance.rb
index 6fe56c4..6c6b018 100644
--- a/server/lib/deltacloud/models/instance.rb
+++ b/server/lib/deltacloud/models/instance.rb
@@ -14,111 +14,109 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-require 'timeout'
+module Deltacloud
+  class Instance < BaseModel
 
-class Instance < BaseModel
+    attr_accessor :owner_id
+    attr_accessor :image_id
+    attr_accessor :name
+    attr_accessor :realm_id
+    attr_accessor :state
+    attr_accessor :actions
+    attr_accessor :public_addresses
+    attr_accessor :private_addresses
+    attr_accessor :instance_profile
+    attr_accessor :launch_time
+    attr_accessor :keyname
+    attr_accessor :authn_error
+    attr_accessor :username
+    attr_accessor :password
+    attr_accessor :create_image
+    attr_accessor :firewalls
+    attr_accessor :storage_volumes
 
-  include Timeout
-
-  attr_accessor :owner_id
-  attr_accessor :image_id
-  attr_accessor :name
-  attr_accessor :realm_id
-  attr_accessor :state
-  attr_accessor :actions
-  attr_accessor :public_addresses
-  attr_accessor :private_addresses
-  attr_accessor :instance_profile
-  attr_accessor :launch_time
-  attr_accessor :keyname
-  attr_accessor :authn_error
-  attr_accessor :username
-  attr_accessor :password
-  attr_accessor :create_image
-  attr_accessor :firewalls
-  attr_accessor :storage_volumes
-
-  def to_hash(context)
-    r = {
-      :id => self.id,
-      :href => context.instance_url(self.id),
-      :name => name,
-      :state => state,
-      :owner => owner_id,
-      :image => { :href => context.image_url(image_id), :id => image_id, :rel => :image },
-      :realm => { :href => context.realm_url(realm_id), :id => realm_id, :rel => :realm },
-      :actions => actions.compact.map { |a|
-        {
-          :href => context.send("#{a}_instance_url", self.id),
-          :rel => "#{a}",
-          :method => context.instance_action_method(a)
-        }
-      },
-      :hardware_profile => {
-        :id => instance_profile.id,
-        :href => context.hardware_profile_url(instance_profile.id),
-        :rel => :hardware_profile,
-        :properties => instance_profile.overrides
-      },
-      :public_addresses => public_addresses.map { |addr| addr.to_hash(context) },
-      :private_addresses => private_addresses.map { |addr| addr.to_hash(context) }
-    }
-    if context.driver.respond_to? :run_on_instance
-      r[:actions] << { :href => "#{context.run_instance_url(self.id)};id=#{self.id}", :rel => 'run', :method => 'post'}
-    end
-    if can_create_image?
-      r[:actions] << { :href => "#{context.create_image_url};instance_id=#{self.id}", :rel => 'create_image', :method => 'post'}
-    end
-    r.merge!(:create_time => launch_time) if launch_time
-    r.merge!(:create_image => create_image) if create_image
-    r.merge!(:firewalls => firewalls.map { |f| { :id => f, :href => context.firewall_url(f), :rel => :firewall }}) if firewalls
-    if storage_volumes
-      r.merge!(:storage_volumes => storage_volumes.map { |v| { :id => v.keys.first, :href => context.storage_volume_url(v.keys.first), :rel => :storage_volume }})
-    end
-    if context.driver.class.has_feature?(:instances, :authentication_key)
-      r.merge!(:authentication_type => 'key' )
-      r.merge!(:authentication => { :keyname => keyname }) if keyname
+    def to_hash(context)
+      r = {
+        :id => self.id,
+        :href => context.instance_url(self.id),
+        :name => name,
+        :state => state,
+        :owner => owner_id,
+        :image => { :href => context.image_url(image_id), :id => image_id, :rel => :image },
+        :realm => { :href => context.realm_url(realm_id), :id => realm_id, :rel => :realm },
+        :actions => actions.compact.map { |a|
+          {
+            :href => context.send("#{a}_instance_url", self.id),
+            :rel => "#{a}",
+            :method => context.instance_action_method(a)
+          }
+        },
+        :hardware_profile => {
+          :id => instance_profile.id,
+          :href => context.hardware_profile_url(instance_profile.id),
+          :rel => :hardware_profile,
+          :properties => instance_profile.overrides
+        },
+        :public_addresses => public_addresses.map { |addr| addr.to_hash(context) },
+        :private_addresses => private_addresses.map { |addr| addr.to_hash(context) }
+      }
+      if context.driver.respond_to? :run_on_instance
+        r[:actions] << { :href => "#{context.run_instance_url(self.id)};id=#{self.id}", :rel => 'run', :method => 'post'}
+      end
+      if can_create_image?
+        r[:actions] << { :href => "#{context.create_image_url};instance_id=#{self.id}", :rel => 'create_image', :method => 'post'}
+      end
+      r.merge!(:create_time => launch_time) if launch_time
+      r.merge!(:create_image => create_image) if create_image
+      r.merge!(:firewalls => firewalls.map { |f| { :id => f, :href => context.firewall_url(f), :rel => :firewall }}) if firewalls
+      if storage_volumes
+        r.merge!(:storage_volumes => storage_volumes.map { |v| { :id => v.keys.first, :href => context.storage_volume_url(v.keys.first), :rel => :storage_volume }})
+      end
+      if context.driver.class.has_feature?(:instances, :authentication_key)
+        r.merge!(:authentication_type => 'key' )
+        r.merge!(:authentication => { :keyname => keyname }) if keyname
+      end
+      if context.driver.class.has_feature?(:instances, :authentication_password)
+        r[:authentication] && username ? r[:authentication].merge!({ :user => username, :password => password }) :
+                (username ? r.merge!(:authentication => { :user => username, :password => password }) : nil)
+      end
+      r
     end
-    if context.driver.class.has_feature?(:instances, :authentication_password)
-      r[:authentication] && username ? r[:authentication].merge!({ :user => username, :password => password }) :
-              (username ? r.merge!(:authentication => { :user => username, :password => password }) : nil)
+
+    def storage_volumes
+      @storage_volumes || []
     end
-    r
-  end
 
-  def storage_volumes
-    @storage_volumes || []
-  end
+    def can_create_image?
+      self.create_image
+    end
 
-  def can_create_image?
-    self.create_image
-  end
+    def hardware_profile
+      instance_profile
+    end
 
-  def hardware_profile
-    instance_profile
-  end
+    def hardware_profile=(profile)
+      @instance_profile = profile
+    end
 
-  def hardware_profile=(profile)
-    @instance_profile = profile
-  end
+    def initialize(init=nil)
+      super(init)
+      self.actions = [] if self.actions.nil?
+      self.public_addresses = [] if self.public_addresses.nil?
+      self.private_addresses = [] if self.private_addresses.nil?
+    end
 
-  def initialize(init=nil)
-    super(init)
-    self.actions = [] if self.actions.nil?
-    self.public_addresses = [] if self.public_addresses.nil?
-    self.private_addresses = [] if self.private_addresses.nil?
-  end
+    def method_missing(name, *args)
+      if name.to_s =~ /is_(\w+)\?/
+        self.state.downcase.eql?($1)
+      else
+        raise NoMethodError.new(name.to_s)
+      end
+    end
 
-  def method_missing(name, *args)
-    if name.to_s =~ /is_(\w+)\?/
-      self.state.downcase.eql?($1)
-    else
-      raise NoMethodError.new(name.to_s)
+    def authn_feature_failed?
+      return true unless authn_error.nil?
     end
-  end
 
-  def authn_feature_failed?
-    return true unless authn_error.nil?
   end
-
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/instance_address.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/instance_address.rb b/server/lib/deltacloud/models/instance_address.rb
index b0ea9fc..38bff35 100644
--- a/server/lib/deltacloud/models/instance_address.rb
+++ b/server/lib/deltacloud/models/instance_address.rb
@@ -16,54 +16,56 @@
 # Model to store the hardware profile applied to an instance together with
 # any instance-specific overrides
 
-class InstanceAddress
-  attr_accessor :address
-  attr_accessor :port
-  attr_accessor :address_type
+module Deltacloud
+  class InstanceAddress
+    attr_accessor :address
+    attr_accessor :port
+    attr_accessor :address_type
 
-  def initialize(address, opts={})
-    self.address = address
-    self.port = opts[:port] if opts[:port]
-    self.address_type = opts[:type] || :ipv4
-    self
-  end
+    def initialize(address, opts={})
+      self.address = address
+      self.port = opts[:port] if opts[:port]
+      self.address_type = opts[:type] || :ipv4
+      self
+    end
 
-  def address_type
-    (address and !address.strip.empty?) ? @address_type : :unavailable
-  end
+    def address_type
+      (address and !address.strip.empty?) ? @address_type : :unavailable
+    end
 
-  def to_s
-    return ['VNC', address, port].join(':') if is_vnc?
-    address
-  end
+    def to_s
+      return ['VNC', address, port].join(':') if is_vnc?
+      address
+    end
 
-  def to_hash(context)
-    r = {
-      :address => address,
-      :type => address_type
-    }
-    r.merge!(:port => port) if !port.nil?
-    r
-  end
+    def to_hash(context)
+      r = {
+        :address => address,
+        :type => address_type
+      }
+      r.merge!(:port => port) if !port.nil?
+      r
+    end
 
-  def is_mac?
-    address_type == :mac
-  end
+    def is_mac?
+      address_type == :mac
+    end
 
-  def is_ipv4?
-    address_type == :ipv4
-  end
+    def is_ipv4?
+      address_type == :ipv4
+    end
 
-  def is_ipv6?
-    address_type == :ipv6
-  end
+    def is_ipv6?
+      address_type == :ipv6
+    end
 
-  def is_hostname?
-    address_type == :hostname
-  end
+    def is_hostname?
+      address_type == :hostname
+    end
 
-  def is_vnc?
-    address_type == :vnc
-  end
+    def is_vnc?
+      address_type == :vnc
+    end
 
+  end
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/instance_profile.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/instance_profile.rb b/server/lib/deltacloud/models/instance_profile.rb
index 3ecaf5d..af4f13f 100644
--- a/server/lib/deltacloud/models/instance_profile.rb
+++ b/server/lib/deltacloud/models/instance_profile.rb
@@ -17,39 +17,41 @@
 # Model to store the hardware profile applied to an instance together with
 # any instance-specific overrides
 
-class InstanceProfile < BaseModel
-  attr_accessor :memory
-  attr_accessor :storage
-  attr_accessor :architecture
-  attr_accessor :cpu
+module Deltacloud
+  class InstanceProfile < BaseModel
+    attr_accessor :memory
+    attr_accessor :storage
+    attr_accessor :architecture
+    attr_accessor :cpu
 
-  def initialize(hwp_name, args = {})
-    opts = args.inject({ :id => hwp_name.to_s }) do |m, e|
-      k, v = e
-      m[$1] = v if k.to_s =~ /^hwp_(.*)$/
-      m
+    def initialize(hwp_name, args = {})
+      opts = args.inject({ :id => hwp_name.to_s }) do |m, e|
+        k, v = e
+        m[$1] = v if k.to_s =~ /^hwp_(.*)$/
+        m
+      end
+      super(opts)
     end
-    super(opts)
-  end
 
-  def name
-    id
-  end
+    def name
+      id
+    end
 
-  def to_s
-    name
-  end
+    def to_s
+      name
+    end
 
-  def override?(property)
-    overrides.find { |p, v| p == property }
-  end
+    def override?(property)
+      overrides.find { |p, v| p == property }
+    end
 
-  def overrides
-    [:memory, :storage, :architecture, :cpu].inject({}) do |h, p|
-      if v = instance_variable_get("@#{p}")
-        h[p] = v
+    def overrides
+      [:memory, :storage, :architecture, :cpu].inject({}) do |h, p|
+        if v = instance_variable_get("@#{p}")
+          h[p] = v
+        end
+        h
       end
-      h
     end
   end
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/key.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/key.rb b/server/lib/deltacloud/models/key.rb
index 6600a81..52268c1 100644
--- a/server/lib/deltacloud/models/key.rb
+++ b/server/lib/deltacloud/models/key.rb
@@ -14,57 +14,59 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-class Key < BaseModel
+module Deltacloud
+  class Key < BaseModel
 
-  attr_accessor :credential_type
-  attr_accessor :fingerprint
-  attr_accessor :username
-  attr_accessor :password
-  attr_accessor :pem_rsa_key
-  attr_accessor :state
+    attr_accessor :credential_type
+    attr_accessor :fingerprint
+    attr_accessor :username
+    attr_accessor :password
+    attr_accessor :pem_rsa_key
+    attr_accessor :state
 
-  def name
-    super || @id
-  end
+    def name
+      super || @id
+    end
 
-  def is_password?
-    @credential_type.eql?(:password)
-  end
+    def is_password?
+      @credential_type.eql?(:password)
+    end
 
-  def is_key?
-    @credential_type.eql?(:key)
-  end
+    def is_key?
+      @credential_type.eql?(:key)
+    end
 
-  # Mock fingerprint generator
-  # 1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f
-  def self.generate_mock_fingerprint
-    (0..19).map { "%02x" % (rand * 0xff) }.join(':')
-  end
+    # Mock fingerprint generator
+    # 1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f
+    def self.generate_mock_fingerprint
+      (0..19).map { "%02x" % (rand * 0xff) }.join(':')
+    end
 
-  # Mock PEM file
-  # NOTE: This is a fake PEM file, it will not work against SSH
-  def self.generate_mock_pem
-    chars = (('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a + %w(= / + ))
-    pem_material = (1..21).map do
-      (1..75).collect{|a| chars[rand(chars.size)] }.join
-    end.join("\n") + "\n" + (1..68).collect{|a| chars[rand(chars.size)] }.join
-    "-----BEGIN RSA PRIVATE KEY-----\n"+pem_material+"-----END RSA PRIVATE KEY-----"
-  end
+    # Mock PEM file
+    # NOTE: This is a fake PEM file, it will not work against SSH
+    def self.generate_mock_pem
+      chars = (('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a + %w(= / + ))
+      pem_material = (1..21).map do
+        (1..75).collect{|a| chars[rand(chars.size)] }.join
+      end.join("\n") + "\n" + (1..68).collect{|a| chars[rand(chars.size)] }.join
+      "-----BEGIN RSA PRIVATE KEY-----\n"+pem_material+"-----END RSA PRIVATE KEY-----"
+    end
 
-  def to_hash(context)
-    r = {
-      :id => self.id,
-      :href => context.key_url(self.id),
-      :credential_type => credential_type,
-      :username => username,
-      :password => password,
-      :state => state
-    }
-    r[:pem_rsa_key] = pem_rsa_key if pem_rsa_key
-    r[:fingerprint] = fingerprint if fingerprint
-    r[:username] = username if username
-    r[:password] = password if password
-    r
-  end
+    def to_hash(context)
+      r = {
+        :id => self.id,
+        :href => context.key_url(self.id),
+        :credential_type => credential_type,
+        :username => username,
+        :password => password,
+        :state => state
+      }
+      r[:pem_rsa_key] = pem_rsa_key if pem_rsa_key
+      r[:fingerprint] = fingerprint if fingerprint
+      r[:username] = username if username
+      r[:password] = password if password
+      r
+    end
 
+  end
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/load_balancer.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/load_balancer.rb b/server/lib/deltacloud/models/load_balancer.rb
index d604455..e96da40 100644
--- a/server/lib/deltacloud/models/load_balancer.rb
+++ b/server/lib/deltacloud/models/load_balancer.rb
@@ -14,45 +14,46 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
+module Deltacloud
+  class LoadBalancer < BaseModel
 
-class LoadBalancer < BaseModel
+    attr_accessor :realms
+    attr_accessor :listeners
+    attr_accessor :instances
+    attr_accessor :public_addresses
+    attr_accessor :created_at
 
-  attr_accessor :realms
-  attr_accessor :listeners
-  attr_accessor :instances
-  attr_accessor :public_addresses
-  attr_accessor :created_at
-
-  def add_listener(opts)
-    @listeners << Listener.new(opts)
-  end
-
-  def to_hash(context)
-    {
-      :id => self.id,
-      :href => context.load_balancer_url(self.id),
-      :realms => realms,
-      :listeners => listeners.map { |l| l.to_hash(context) },
-      :instances => instances.map { |i| i.to_hash(context) },
-      :public_addresses => public_addresses,
-      :created_at => created_at
-    }
-  end
-
-  class Listener < BaseModel
-    attr_accessor :protocol
-    attr_accessor :load_balancer_port
-    attr_accessor :instance_port
+    def add_listener(opts)
+      @listeners << Listener.new(opts)
+    end
 
     def to_hash(context)
       {
         :id => self.id,
-        :protocol => protocol,
-        :load_balancer_port => load_balancer_port,
-        :instance_port => instance_port
+        :href => context.load_balancer_url(self.id),
+        :realms => realms,
+        :listeners => listeners.map { |l| l.to_hash(context) },
+        :instances => instances.map { |i| i.to_hash(context) },
+        :public_addresses => public_addresses,
+        :created_at => created_at
       }
     end
+
+    class Listener < BaseModel
+      attr_accessor :protocol
+      attr_accessor :load_balancer_port
+      attr_accessor :instance_port
+
+      def to_hash(context)
+        {
+          :id => self.id,
+          :protocol => protocol,
+          :load_balancer_port => load_balancer_port,
+          :instance_port => instance_port
+        }
+      end
+    end
+
   end
 
 end
-

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/metric.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/metric.rb b/server/lib/deltacloud/models/metric.rb
index 6f5cac6..a8648d1 100644
--- a/server/lib/deltacloud/models/metric.rb
+++ b/server/lib/deltacloud/models/metric.rb
@@ -13,89 +13,91 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-class Metric < BaseModel
+module Deltacloud
+  class Metric < BaseModel
 
-  attr_accessor :entity
-  attr_accessor :properties
+    attr_accessor :entity
+    attr_accessor :properties
 
-  MOCK_METRICS_NAMES = [
-    'cpuUtilization',
-    'diskReadRequestCount',
-    'diskReadSector',
-    'diskWriteRequestCount',
-    'diskWriteSector',
-    'nicInputByte',
-    'nicInputPacket',
-    'nicOutputByte',
-    'nicOutputPacket'
-  ]
+    MOCK_METRICS_NAMES = [
+      'cpuUtilization',
+      'diskReadRequestCount',
+      'diskReadSector',
+      'diskWriteRequestCount',
+      'diskWriteSector',
+      'nicInputByte',
+      'nicInputPacket',
+      'nicOutputByte',
+      'nicOutputPacket'
+    ]
 
-  def unknown?
-    self.entity == :unknown
-  end
-
-  def add_property(name, values=nil)
-    self.properties ||= []
-    return self if self.properties.any? { |p| p.name == name }
-    self.properties << Property.new(name, values)
-    self
-  end
-
-  def to_hash(context)
-    {
-      :id => self.id,
-      :href => context.metric_url(self.id),
-      :entity => entity,
-      :properties => properties.map { |p| p.to_hash(context) }
-    }
-  end
-
-  class Property
-    attr_accessor :name, :values
+    def unknown?
+      self.entity == :unknown
+    end
 
-    def initialize(name, values=nil)
-      @name, @values = name, values
+    def add_property(name, values=nil)
+      self.properties ||= []
+      return self if self.properties.any? { |p| p.name == name }
+      self.properties << Property.new(name, values)
+      self
     end
 
     def to_hash(context)
       {
-        :name => name,
-        :values => values
+        :id => self.id,
+        :href => context.metric_url(self.id),
+        :entity => entity,
+        :properties => properties.map { |p| p.to_hash(context) }
       }
     end
 
-    def generate_mock_values!
-      generator = lambda { |name, kind|
-        v = {
-          :min => (1+(rand(49))),
-          :max => (50+(rand(50)))
-        }
-        (name == 'cpuUtilization') ? v[kind].to_f/100 : v[kind]
-      }
-      @values = (0..5).map do |v_id|
+    class Property
+      attr_accessor :name, :values
+
+      def initialize(name, values=nil)
+        @name, @values = name, values
+      end
+
+      def to_hash(context)
         {
-          :minimum => min = generator.call(@name, :min),
-          :maximum => max = generator.call(@name, :max),
-          :average => (min+max)/2,
-          :timestamp => (Time.now-v_id).to_i,
-          :unit => unit_for(@name)
+          :name => name,
+          :values => values
         }
       end
-    end
 
-    private
+      def generate_mock_values!
+        generator = lambda { |name, kind|
+          v = {
+            :min => (1+(rand(49))),
+            :max => (50+(rand(50)))
+          }
+          (name == 'cpuUtilization') ? v[kind].to_f/100 : v[kind]
+        }
+        @values = (0..5).map do |v_id|
+          {
+            :minimum => min = generator.call(@name, :min),
+            :maximum => max = generator.call(@name, :max),
+            :average => (min+max)/2,
+            :timestamp => (Time.now-v_id).to_i,
+            :unit => unit_for(@name)
+          }
+        end
+      end
+
+      private
 
-    def unit_for(name)
-      case name
+      def unit_for(name)
+        case name
         when /Utilization/ then 'Percent'
         when /Byte/ then 'Bytes'
         when /Sector/ then 'Count'
         when /Count/ then 'Count'
         when /Packet/ then 'Count'
         else 'None'
+        end
       end
+
     end
 
   end
-
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/provider.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/provider.rb b/server/lib/deltacloud/models/provider.rb
index fcbc81d..3d475da 100644
--- a/server/lib/deltacloud/models/provider.rb
+++ b/server/lib/deltacloud/models/provider.rb
@@ -16,20 +16,22 @@
 # Model to store the hardware profile applied to an instance together with
 # any instance-specific overrides
 
-class Provider < BaseModel
-  attr_accessor :url
-  attr_accessor :name
+module Deltacloud
+  class Provider < BaseModel
+    attr_accessor :url
+    attr_accessor :name
 
-  def initialize(opts={})
-    super(opts)
-  end
+    def initialize(opts={})
+      super(opts)
+    end
 
-  def to_hash(context)
-    {
-      :id => self.id,
-      :name => name,
-      :url => url
-    }
-  end
+    def to_hash(context)
+      {
+        :id => self.id,
+        :name => name,
+        :url => url
+      }
+    end
 
+  end
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/realm.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/realm.rb b/server/lib/deltacloud/models/realm.rb
index d6e050f..1786162 100644
--- a/server/lib/deltacloud/models/realm.rb
+++ b/server/lib/deltacloud/models/realm.rb
@@ -14,22 +14,23 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
+module Deltacloud
+  class Realm < BaseModel
 
-class Realm < BaseModel
+    attr_accessor :name
+    attr_accessor :limit
+    attr_accessor :state
 
-  attr_accessor :name
-  attr_accessor :limit
-  attr_accessor :state
+    def to_hash(context)
+      r = {
+        :id => self.id,
+        :href => context.realm_url(self.id),
+        :name => name,
+        :state => state,
+        :limit => limit
+      }
+      r
+    end
 
-  def to_hash(context)
-    r = {
-      :id => self.id,
-      :href => context.realm_url(self.id),
-      :name => name,
-      :state => state,
-      :limit => limit
-    }
-    r
   end
-
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/storage_snapshot.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/storage_snapshot.rb b/server/lib/deltacloud/models/storage_snapshot.rb
index c60b055..ea65cd3 100644
--- a/server/lib/deltacloud/models/storage_snapshot.rb
+++ b/server/lib/deltacloud/models/storage_snapshot.rb
@@ -14,28 +14,32 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
+module Deltacloud
+  class StorageSnapshot < BaseModel
 
+    attr_accessor :state
+    attr_accessor :storage_volume_id
+    attr_accessor :created
+    attr_accessor :name
+    attr_accessor :description
 
-class StorageSnapshot < BaseModel
+    def is_completed?
+      state == 'completed'
+    end
 
-  attr_accessor :state
-  attr_accessor :storage_volume_id
-  attr_accessor :created
-  attr_accessor :name
-  attr_accessor :description
+    def to_hash(context)
+      {
+        :id => self.id,
+        :href => context.storage_snapshot_url(self.id),
+        :state => state,
+        :storage_volume => {
+          :id => storage_volume_id,
+          :href => context.storage_volume_url(storage_volume_id),
+          :rel => :storage_volume 
+        },
+        :created => created
+      }
+    end
 
-  def is_completed?
-    state == 'completed'
   end
-
-  def to_hash(context)
-    {
-      :id => self.id,
-      :href => context.storage_snapshot_url(self.id),
-      :state => state,
-      :storage_volume => { :id => storage_volume_id, :href => context.storage_volume_url(storage_volume_id), :rel => :storage_volume },
-      :created => created
-    }
-  end
-
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d4fd74ab/server/lib/deltacloud/models/storage_volume.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/models/storage_volume.rb b/server/lib/deltacloud/models/storage_volume.rb
index 4132592..3aedfad 100644
--- a/server/lib/deltacloud/models/storage_volume.rb
+++ b/server/lib/deltacloud/models/storage_volume.rb
@@ -14,42 +14,43 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
+module Deltacloud
+  class StorageVolume < BaseModel
 
-class StorageVolume < BaseModel
+    attr_accessor :created
+    attr_accessor :state
+    attr_accessor :capacity
+    attr_accessor :instance_id
+    attr_accessor :device
+    attr_accessor :realm_id
+    attr_accessor :actions
+    attr_accessor :name
+    attr_accessor :kind
+    attr_accessor :description # openstack volumes have a display_description attr
 
-  attr_accessor :created
-  attr_accessor :state
-  attr_accessor :capacity
-  attr_accessor :instance_id
-  attr_accessor :device
-  attr_accessor :realm_id
-  attr_accessor :actions
-  attr_accessor :name
-  attr_accessor :kind
-  attr_accessor :description # openstack volumes have a display_description attr
-
-  def to_hash(context)
-    r = {
-      :id => self.id,
-      :href => context.storage_volume_url(self.id),
-      :name => name,
-      :description => description,
-      :state => state,
-      :created => created,
-      :realm => { :id => realm_id, :href => context.realm_url(realm_id), :rel => :realm },
-      :device => device,
-      :kind => kind,
-      :capacity => capacity,
-    }
-    r[:actions] = (actions || []).map { |a|
-      { :href => context.send("#{a}_storage_volume_url", self.id), :rel => a }
-    }
-    if instance_id
-      r[:instance] = { :id => instance_id, :href => context.instance_url(instance_id), :rel => :instance }
-    else
-      r[:instance] = {}
+    def to_hash(context)
+      r = {
+        :id => self.id,
+        :href => context.storage_volume_url(self.id),
+        :name => name,
+        :description => description,
+        :state => state,
+        :created => created,
+        :realm => { :id => realm_id, :href => context.realm_url(realm_id), :rel => :realm },
+        :device => device,
+        :kind => kind,
+        :capacity => capacity,
+      }
+      r[:actions] = (actions || []).map { |a|
+        { :href => context.send("#{a}_storage_volume_url", self.id), :rel => a }
+      }
+      if instance_id
+        r[:instance] = { :id => instance_id, :href => context.instance_url(instance_id), :rel => :instance }
+      else
+        r[:instance] = {}
+      end
+      r
     end
-    r
-  end
 
+  end
 end


Mime
View raw message