You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2013/03/07 13:24:13 UTC

[PATCH core 1/3] Core: make 'turn' to report colored dots

From: Michal Fojtik <mf...@redhat.com>


Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 server/tests/test_helper.rb | 1 +
 1 file changed, 1 insertion(+)

diff --git a/server/tests/test_helper.rb b/server/tests/test_helper.rb
index 61ee26d..b0184f3 100644
--- a/server/tests/test_helper.rb
+++ b/server/tests/test_helper.rb
@@ -25,6 +25,7 @@ end
 #
 begin
   require 'turn'
+  Turn.config.format = :dot
 rescue LoadError => e
   # We'll be fine
 end
-- 
1.8.1.4


[PATCH core 2/3] Core: Moved Deltacloud models to Deltacloud:: namespace (DTACLOUD-507)

Posted by mf...@redhat.com.
From: Michal Fojtik <mf...@redhat.com>


Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 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(-)

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
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
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
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],
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
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
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
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
 
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
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
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
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
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
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
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
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
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
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
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
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
-
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
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
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
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
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
-- 
1.8.1.4


[PATCH core 3/3] Core: Fixed tests to use Deltacloud::MODEL

Posted by mf...@redhat.com.
From: Michal Fojtik <mf...@redhat.com>


Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 .../deltacloud/collections/instances_collection_test.rb    |  5 ++++-
 server/tests/deltacloud/common.rb                          |  2 +-
 server/tests/drivers/ec2/buckets_test.rb                   |  2 +-
 server/tests/drivers/ec2/images_test.rb                    |  4 ++--
 server/tests/drivers/ec2/instance_test.rb                  | 12 ++++++------
 server/tests/drivers/ec2/keys_test.rb                      |  6 +++---
 server/tests/drivers/ec2/realms_test.rb                    |  4 ++--
 server/tests/drivers/ec2/storage_snapshots_test.rb         |  2 +-
 server/tests/drivers/fgcp/images_test.rb                   |  4 ++--
 server/tests/drivers/fgcp/provider_test.rb                 |  2 +-
 server/tests/drivers/fgcp/realms_test.rb                   |  4 ++--
 server/tests/drivers/fgcp/storage_volumes_test.rb          |  8 ++++----
 server/tests/drivers/gogrid/images_test.rb                 |  4 ++--
 server/tests/drivers/gogrid/instances_test.rb              |  4 ++--
 server/tests/drivers/gogrid/realms_test.rb                 |  4 ++--
 server/tests/drivers/mock/images_test.rb                   |  8 ++++----
 server/tests/drivers/mock/instances_test.rb                | 14 +++++++-------
 server/tests/drivers/mock/keys_test.rb                     |  6 +++---
 server/tests/drivers/mock/realms_test.rb                   |  4 ++--
 server/tests/drivers/mock/storage_snapshots_test.rb        |  4 ++--
 server/tests/drivers/mock/storage_volumes_test.rb          |  8 ++++----
 server/tests/drivers/models/instance_test.rb               |  4 ++--
 server/tests/drivers/openstack/images_test.rb              |  4 ++--
 server/tests/drivers/openstack/instances_test.rb           |  2 +-
 server/tests/drivers/openstack/keys_test.rb                |  2 +-
 server/tests/drivers/openstack/realms_test.rb              |  2 +-
 server/tests/drivers/rhevm/images_test.rb                  |  4 ++--
 server/tests/drivers/rhevm/instance_test.rb                |  8 ++++----
 server/tests/drivers/rhevm/provider_test.rb                |  2 +-
 server/tests/drivers/rhevm/realms_test.rb                  |  4 ++--
 server/tests/ec2/query_parser_test.rb                      |  2 +-
 31 files changed, 74 insertions(+), 71 deletions(-)

diff --git a/server/tests/deltacloud/collections/instances_collection_test.rb b/server/tests/deltacloud/collections/instances_collection_test.rb
index f194cd9..5b71d09 100644
--- a/server/tests/deltacloud/collections/instances_collection_test.rb
+++ b/server/tests/deltacloud/collections/instances_collection_test.rb
@@ -37,6 +37,8 @@ describe Deltacloud::Collections::Instances do
     end
   end
 
+  require 'pry'
+
   it 'allow to create and execute actions on created instance' do
     post root_url + '/instances', { :image_id => 'img1', :name => 'test', }
     status.must_equal 201
@@ -47,6 +49,7 @@ describe Deltacloud::Collections::Instances do
     # You can't remove RUNNING instance
     (xml/'error/message').first.text.strip.must_equal 'Method Not Allowed'
     post root_url + '/instances/' + instance_id + '/reboot'
+    binding.pry
     status.must_equal 202
     (xml/'instance/state').first.text.strip.must_equal 'RUNNING'
     post root_url + '/instances/' + instance_id + '/stop'
@@ -70,7 +73,7 @@ describe Deltacloud::Collections::Instances do
     get root_url + "/instances/inst1"
     status.must_equal 200
     json['instance'].wont_be_empty
-    Instance.attributes.each do |attr|
+    Deltacloud::Instance.attributes.each do |attr|
       attr = attr.to_s.gsub(/_id$/,'') if attr.to_s =~ /_id$/
       next if ['launch_time', 'authn_error', 'firewalls', 'keyname', 'username', 'password', 'instance_profile'].include?(attr.to_s)
       json['instance'].keys.must_include attr.to_s
diff --git a/server/tests/deltacloud/common.rb b/server/tests/deltacloud/common.rb
index c31655e..cbcd06b 100644
--- a/server/tests/deltacloud/common.rb
+++ b/server/tests/deltacloud/common.rb
@@ -10,7 +10,7 @@ def check_json_serialization_for(model, sample_id, optional_attrs=[])
   get root_url + "/#{model.to_s.pluralize}/#{sample_id}"
   status.must_equal 200
   json[model.to_s].wont_be_empty
-  klass = self.class.const_get(model.to_s.camelize)
+  klass = Deltacloud.const_get(model.to_s.camelize)
   klass.attributes.each do |attr|
     attr = attr.to_s.gsub(/_id$/,'') if attr.to_s =~ /_id$/
     json[model.to_s].keys.must_include attr.to_s unless optional_attrs.include? attr
diff --git a/server/tests/drivers/ec2/buckets_test.rb b/server/tests/drivers/ec2/buckets_test.rb
index 343283d..983c3f3 100644
--- a/server/tests/drivers/ec2/buckets_test.rb
+++ b/server/tests/drivers/ec2/buckets_test.rb
@@ -36,7 +36,7 @@ describe 'Ec2Driver Buckets' do
     @dcloud_other_provider = Deltacloud::new(:ec2, credentials.merge!(:provider=>"eu-west-1"))
     #get the bucket and check
     retrieved_bucket = @dcloud_other_provider.bucket(:id=>bucket.name)
-    retrieved_bucket.must_be_kind_of Bucket
+    retrieved_bucket.must_be_kind_of Deltacloud::Bucket
     retrieved_bucket.name.must_equal bucket.name
     #delete the bucket
     @driver.delete_bucket(bucket.id)
diff --git a/server/tests/drivers/ec2/images_test.rb b/server/tests/drivers/ec2/images_test.rb
index 05c108a..1b82cb0 100644
--- a/server/tests/drivers/ec2/images_test.rb
+++ b/server/tests/drivers/ec2/images_test.rb
@@ -22,7 +22,7 @@ describe 'Ec2Driver Images' do
 
   it 'must return list of images' do
     @driver.images.wont_be_empty
-    @driver.images.first.must_be_kind_of Image
+    @driver.images.first.must_be_kind_of Deltacloud::Image
   end
 
   it 'must allow to filter images' do
@@ -39,7 +39,7 @@ describe 'Ec2Driver Images' do
 
   it 'must allow to retrieve single image' do
     @driver.image(:id => 'ami-aecd60c7').wont_be_nil
-    @driver.image(:id => 'ami-aecd60c7').must_be_kind_of Image
+    @driver.image(:id => 'ami-aecd60c7').must_be_kind_of Deltacloud::Image
     @driver.image(:id => 'ami-aecd60c7').id.must_equal 'ami-aecd60c7'
     @driver.image(:id => 'ami-aaaaaaaa').must_be_nil
     @driver.image(:id => 'unknown').must_be_nil
diff --git a/server/tests/drivers/ec2/instance_test.rb b/server/tests/drivers/ec2/instance_test.rb
index 2492f08..51f7c52 100644
--- a/server/tests/drivers/ec2/instance_test.rb
+++ b/server/tests/drivers/ec2/instance_test.rb
@@ -22,7 +22,7 @@ describe 'Ec2Driver Instances' do
 
   it 'must return list of instances' do
     @driver.instances.wont_be_empty
-    @driver.instances.first.must_be_kind_of Instance
+    @driver.instances.first.must_be_kind_of Deltacloud::Instance
   end
 
   it 'must allow to filter instances' do
@@ -40,7 +40,7 @@ describe 'Ec2Driver Instances' do
 
   it 'must allow to retrieve single instance' do
     @driver.instance(:id => 'i-4d15f036').wont_be_nil
-    @driver.instance(:id => 'i-4d15f036').must_be_kind_of Instance
+    @driver.instance(:id => 'i-4d15f036').must_be_kind_of Deltacloud::Instance
     @driver.instance(:id => 'i-4d15f036').id.must_equal 'i-4d15f036'
     @driver.instance(:id => 'i-00000000').must_be_nil
     @driver.instance(:id => 'unknown').must_be_nil
@@ -55,7 +55,7 @@ describe 'Ec2Driver Instances' do
                                        :'firewalls1' => 'default'
                                       )
     instance = instance.wait_for!(@driver, record_retries) { |i| i.is_running? }
-    instance.must_be_kind_of Instance
+    instance.must_be_kind_of Deltacloud::Instance
     instance.is_running?.must_equal true
     @driver.instance(:id => instance.id).wont_be_nil
     @driver.instance(:id => instance.id).id.must_equal instance.id
@@ -82,7 +82,7 @@ describe 'Ec2Driver Instances' do
                                       )
     instances.wont_be_empty
     instances.size.must_equal 2
-    instances.each { |i| i.must_be_kind_of Instance }
+    instances.each { |i| i.must_be_kind_of Deltacloud::Instance }
     instances = instances.map { |instance| instance.wait_for!(@driver, record_retries("#{instance.id}-running")) { |i| i.is_running? } }
     instances.each { |i| i.is_running?.must_equal true }
     instances.each { |i| @driver.destroy_instance(i.id) }
@@ -95,7 +95,7 @@ describe 'Ec2Driver Instances' do
     instance = @driver.create_instance('ami-aecd60c7',
                                        :realm_id => realm_id,
                                        :hwp_id => 'm1.small')
-    instance.must_be_kind_of Instance
+    instance.must_be_kind_of Deltacloud::Instance
     instance.realm_id.must_equal realm_id
     @driver.destroy_instance(instance.id)
   end
@@ -103,7 +103,7 @@ describe 'Ec2Driver Instances' do
   it 'must allow to reboot instance in running state' do
     instance = @driver.create_instance('ami-aecd60c7', :realm_id => 'us-east-1a', :hwp_id => 't1.micro')
     instance = instance.wait_for!(@driver, record_retries) { |i| i.is_running? }
-    instance.must_be_kind_of Instance
+    instance.must_be_kind_of Deltacloud::Instance
     instance.is_running?.must_equal true
     @driver.reboot_instance(instance.id)
     @driver.instance(:id => instance.id).state.must_equal 'RUNNING'
diff --git a/server/tests/drivers/ec2/keys_test.rb b/server/tests/drivers/ec2/keys_test.rb
index e8c659c..9429d4e 100644
--- a/server/tests/drivers/ec2/keys_test.rb
+++ b/server/tests/drivers/ec2/keys_test.rb
@@ -22,7 +22,7 @@ describe 'Ec2Driver Keys' do
 
   it 'must return list of keys' do
     @driver.keys.wont_be_empty
-    @driver.keys.first.must_be_kind_of Key
+    @driver.keys.first.must_be_kind_of Deltacloud::Key
   end
 
   it 'must allow to filter keys' do
@@ -35,7 +35,7 @@ describe 'Ec2Driver Keys' do
 
   it 'must allow to retrieve single key' do
     @driver.key(:id => 'test1').wont_be_nil
-    @driver.key(:id => 'test1').must_be_kind_of Key
+    @driver.key(:id => 'test1').must_be_kind_of Deltacloud::Key
     @driver.key(:id => 'test1').id.must_equal 'test1'
     @driver.key(:id => 'unknown').must_be_nil
   end
@@ -43,7 +43,7 @@ describe 'Ec2Driver Keys' do
   it 'must allow to create a new key' do
     key = @driver.create_key(:key_name => 'test-key-1')
     key.wont_be_nil
-    key.must_be_kind_of Key
+    key.must_be_kind_of Deltacloud::Key
     Proc.new { @driver.create_key(:key_name => 'test-key-1') }.must_raise Deltacloud::Exceptions::ProviderError, 'KeyExist'
     @driver.destroy_key :id => key.id
     @driver.key(:id => key.id).must_be_nil
diff --git a/server/tests/drivers/ec2/realms_test.rb b/server/tests/drivers/ec2/realms_test.rb
index eb5ab1f..7918665 100644
--- a/server/tests/drivers/ec2/realms_test.rb
+++ b/server/tests/drivers/ec2/realms_test.rb
@@ -22,7 +22,7 @@ describe 'Ec2Driver Realms' do
 
   it 'must return list of realms' do
     @driver.realms.wont_be_empty
-    @driver.realms.first.must_be_kind_of Realm
+    @driver.realms.first.must_be_kind_of Deltacloud::Realm
   end
 
   it 'must allow to filter realms' do
@@ -35,7 +35,7 @@ describe 'Ec2Driver Realms' do
 
   it 'must allow to retrieve single realm' do
     @driver.realm(:id => 'us-east-1a').wont_be_nil
-    @driver.realm(:id => 'us-east-1a').must_be_kind_of Realm
+    @driver.realm(:id => 'us-east-1a').must_be_kind_of Deltacloud::Realm
     @driver.realm(:id => 'us-east-1b').id.must_equal 'us-east-1b'
     @driver.realm(:id => 'unknown').must_be_nil
   end
diff --git a/server/tests/drivers/ec2/storage_snapshots_test.rb b/server/tests/drivers/ec2/storage_snapshots_test.rb
index 0ac66d5..81460f0 100644
--- a/server/tests/drivers/ec2/storage_snapshots_test.rb
+++ b/server/tests/drivers/ec2/storage_snapshots_test.rb
@@ -21,7 +21,7 @@ describe 'Ec2Driver StorageSnapshots' do
 
   it 'must return list of storage snapshots' do
     @driver.storage_snapshots.wont_be_empty
-    @driver.storage_snapshots.first.must_be_kind_of StorageSnapshot
+    @driver.storage_snapshots.first.must_be_kind_of Deltacloud::StorageSnapshot
   end
 
   it 'must allow to filter storage snapshots' do
diff --git a/server/tests/drivers/fgcp/images_test.rb b/server/tests/drivers/fgcp/images_test.rb
index 248d108..b08030f 100644
--- a/server/tests/drivers/fgcp/images_test.rb
+++ b/server/tests/drivers/fgcp/images_test.rb
@@ -23,7 +23,7 @@ describe 'FgcpDriver Images' do
   it 'must return list of images' do
     imgs = @driver.images
     imgs.wont_be_empty
-    imgs.first.must_be_kind_of Image
+    imgs.first.must_be_kind_of Deltacloud::Image
   end
 
   it 'must allow to filter images' do
@@ -38,7 +38,7 @@ describe 'FgcpDriver Images' do
   it 'must allow to retrieve single image' do
     img = @driver.image(:id => 'IMG_3c9820_S24FWXU0Q9VH0JK')
     img.wont_be_nil
-    img.must_be_kind_of Image
+    img.must_be_kind_of Deltacloud::Image
     img.id.must_equal 'IMG_3c9820_S24FWXU0Q9VH0JK'
     @driver.image(:id => 'unknown').must_be_nil
   end
diff --git a/server/tests/drivers/fgcp/provider_test.rb b/server/tests/drivers/fgcp/provider_test.rb
index d38d8a5..e3d4952 100644
--- a/server/tests/drivers/fgcp/provider_test.rb
+++ b/server/tests/drivers/fgcp/provider_test.rb
@@ -17,7 +17,7 @@ describe 'FgcpDriver Providers' do
   it 'must support listing of available providers' do
     providers = @driver.providers
     providers.wont_be_empty
-    providers.each { |p| p.must_be_kind_of Provider }
+    providers.each { |p| p.must_be_kind_of Deltacloud::Provider }
     providers.each { |p| p.name.wont_be_empty }
     providers.each { |p| p.url.wont_be_empty }
     providers.each { |p| p.id.wont_be_empty }
diff --git a/server/tests/drivers/fgcp/realms_test.rb b/server/tests/drivers/fgcp/realms_test.rb
index 7a4de63..5a50e0b 100644
--- a/server/tests/drivers/fgcp/realms_test.rb
+++ b/server/tests/drivers/fgcp/realms_test.rb
@@ -23,7 +23,7 @@ describe 'FgcpDriver Realms' do
   it 'must return list of realms' do
     realms = @driver.realms
     realms.wont_be_empty
-    realms.first.must_be_kind_of Realm
+    realms.first.must_be_kind_of Deltacloud::Realm
     # assume at least one vsys has been created, with at least 1 tier network
     realms.size.wont_be :<, 2
   end
@@ -42,7 +42,7 @@ describe 'FgcpDriver Realms' do
   it 'must allow to retrieve single realm' do
     realm = @driver.realm(:id => 'UZXC0GRT-ZG8ZJCJ07-N-DMZ')
     realm.wont_be_nil
-    realm.must_be_kind_of Realm
+    realm.must_be_kind_of Deltacloud::Realm
     realm.state.must_equal 'AVAILABLE'
     realm.id.must_equal 'UZXC0GRT-ZG8ZJCJ07-N-DMZ'
     realm.name.must_equal 'Dies-DC-test [DMZ]'
diff --git a/server/tests/drivers/fgcp/storage_volumes_test.rb b/server/tests/drivers/fgcp/storage_volumes_test.rb
index 4132479..eb026f7 100644
--- a/server/tests/drivers/fgcp/storage_volumes_test.rb
+++ b/server/tests/drivers/fgcp/storage_volumes_test.rb
@@ -22,7 +22,7 @@ describe 'FgcpDriver StorageVolumes' do
 
   it 'must return list of storage_volumes' do
     @driver.storage_volumes.wont_be_empty
-    @driver.storage_volumes.first.must_be_kind_of StorageVolume
+    @driver.storage_volumes.first.must_be_kind_of Deltacloud::StorageVolume
   end
 
   it 'must allow to filter storage_volumes' do
@@ -37,19 +37,19 @@ describe 'FgcpDriver StorageVolumes' do
   it 'must allow to retrieve single storage_volume' do
     storage_volume = @driver.storage_volume(:id => 'UZXC0GRT-ZG8ZJCJ07-D-0039')
     storage_volume.wont_be_nil
-    storage_volume.must_be_kind_of StorageVolume
+    storage_volume.must_be_kind_of Deltacloud::StorageVolume
     storage_volume.id.must_equal 'UZXC0GRT-ZG8ZJCJ07-D-0039'
     @driver.storage_volume(:id => 'unknown').must_be_nil
   end
 
   it 'must allow to create the storage volume' do
     volume = @driver.create_storage_volume(:name => 'Test Volume', :capacity => '2')
-    volume.must_be_kind_of StorageVolume
+    volume.must_be_kind_of Deltacloud::StorageVolume
     volume.name.must_equal 'Test Volume'
     volume.capacity.must_equal '10.0' # note that it's rounded up to a multiple of ten
     volume2 = @driver.storage_volume(:id => volume.id)
     volume2.wont_be_nil
-    volume2.must_be_kind_of StorageVolume
+    volume2.must_be_kind_of Deltacloud::StorageVolume
     volume2.id.must_equal volume.id
     volume2.name.must_equal volume.name
     volume2.capacity.must_equal volume.capacity
diff --git a/server/tests/drivers/gogrid/images_test.rb b/server/tests/drivers/gogrid/images_test.rb
index a055567..15245db 100644
--- a/server/tests/drivers/gogrid/images_test.rb
+++ b/server/tests/drivers/gogrid/images_test.rb
@@ -29,7 +29,7 @@ describe 'GoGridDriver Images' do
 
   it 'must return list of images' do
     @driver.images.wont_be_empty
-    @driver.images.first.must_be_kind_of Image
+    @driver.images.first.must_be_kind_of Deltacloud::Image
   end
 
   it 'must allow to filter images' do
@@ -54,7 +54,7 @@ describe 'GoGridDriver Images' do
     by_id = @driver.image(:id => some_img.id)
 
     by_id.wont_be_nil
-    by_id.must_be_kind_of Image
+    by_id.must_be_kind_of Deltacloud::Image
     by_id.id.must_equal some_img.id
   end
 
diff --git a/server/tests/drivers/gogrid/instances_test.rb b/server/tests/drivers/gogrid/instances_test.rb
index 092c8b7..ed3d965 100644
--- a/server/tests/drivers/gogrid/instances_test.rb
+++ b/server/tests/drivers/gogrid/instances_test.rb
@@ -63,7 +63,7 @@ describe 'GoGridDriver Instances' do
 
   it 'must return list of instances' do
     @driver.instances.wont_be_empty
-    @driver.instances.first.must_be_kind_of Instance
+    @driver.instances.first.must_be_kind_of Deltacloud::Instance
   end
 
   it 'must allow to filter instances' do
@@ -85,7 +85,7 @@ describe 'GoGridDriver Instances' do
   it 'must allow to retrieve single instance' do
     by_id = @driver.instance(:id => instance.id)
     by_id.wont_be_nil
-    by_id.must_be_kind_of Instance
+    by_id.must_be_kind_of Deltacloud::Instance
     by_id.id.must_equal instance.id
     @driver.instance(:id => "unknown").must_be_nil
   end
diff --git a/server/tests/drivers/gogrid/realms_test.rb b/server/tests/drivers/gogrid/realms_test.rb
index a810992..b050aba 100644
--- a/server/tests/drivers/gogrid/realms_test.rb
+++ b/server/tests/drivers/gogrid/realms_test.rb
@@ -22,7 +22,7 @@ describe 'GoGridDriver Realms' do
 
   it 'must return list of realms' do
     @driver.realms.wont_be_empty
-    @driver.realms.first.must_be_kind_of Realm
+    @driver.realms.first.must_be_kind_of Deltacloud::Realm
   end
 
   it 'must allow to filter realms' do
@@ -36,7 +36,7 @@ describe 'GoGridDriver Realms' do
 
   it 'must allow to retrieve single realm' do
     @driver.realm(:id => '1').wont_be_nil
-    @driver.realm(:id => '1').must_be_kind_of Realm
+    @driver.realm(:id => '1').must_be_kind_of Deltacloud::Realm
     @driver.realm(:id => '1').id.must_equal '1'
     @driver.realm(:id => '1').name.must_equal 'US-West-1'
     @driver.realm(:id => 'unknown').must_be_nil
diff --git a/server/tests/drivers/mock/images_test.rb b/server/tests/drivers/mock/images_test.rb
index ab2f8b0..6f8ab8b 100644
--- a/server/tests/drivers/mock/images_test.rb
+++ b/server/tests/drivers/mock/images_test.rb
@@ -17,7 +17,7 @@ describe 'MockDriver Images' do
 
   it 'must return list of images' do
     @driver.images.wont_be_empty
-    @driver.images.first.must_be_kind_of Image
+    @driver.images.first.must_be_kind_of Deltacloud::Image
   end
 
   it 'must allow to filter images' do
@@ -32,13 +32,13 @@ describe 'MockDriver Images' do
 
   it 'must allow to retrieve single image' do
     @driver.image(:id => 'img1').wont_be_nil
-    @driver.image(:id => 'img1').must_be_kind_of Image
+    @driver.image(:id => 'img1').must_be_kind_of Deltacloud::Image
     @driver.image(:id => 'img1').id.must_equal 'img1'
     @driver.image(:id => 'unknown').must_be_nil
   end
 
   it 'must allow to create a new image if instance supported' do
-    @driver.create_image(:id => 'inst1', :name => 'img1-test', :description => 'Test1').must_be_kind_of Image
+    @driver.create_image(:id => 'inst1', :name => 'img1-test', :description => 'Test1').must_be_kind_of Deltacloud::Image
     @driver.image(:id => 'img1-test').wont_be_nil
     @driver.image(:id => 'img1-test').id.must_equal 'img1-test'
     @driver.image(:id => 'img1-test').name.must_equal 'img1-test'
@@ -48,7 +48,7 @@ describe 'MockDriver Images' do
   end
 
   it 'must allow to destroy created image' do
-    @driver.create_image(:id => 'inst1', :name => 'img1-test-destroy').must_be_kind_of Image
+    @driver.create_image(:id => 'inst1', :name => 'img1-test-destroy').must_be_kind_of Deltacloud::Image
     @driver.destroy_image('img1-test-destroy')
     @driver.image(:id => 'img1-test-destroy').must_be_nil
   end
diff --git a/server/tests/drivers/mock/instances_test.rb b/server/tests/drivers/mock/instances_test.rb
index 5d26c21..7e93f31 100644
--- a/server/tests/drivers/mock/instances_test.rb
+++ b/server/tests/drivers/mock/instances_test.rb
@@ -17,7 +17,7 @@ describe 'MockDriver Instances' do
 
   it 'must return list of instances' do
     @driver.instances.wont_be_empty
-    @driver.instances.first.must_be_kind_of Instance
+    @driver.instances.first.must_be_kind_of Deltacloud::Instance
   end
 
   it 'must allow to filter instances' do
@@ -32,14 +32,14 @@ describe 'MockDriver Instances' do
 
   it 'must allow to retrieve single instance' do
     @driver.instance(:id => 'inst1').wont_be_nil
-    @driver.instance(:id => 'inst1').must_be_kind_of Instance
+    @driver.instance(:id => 'inst1').must_be_kind_of Deltacloud::Instance
     @driver.instance(:id => 'inst1').id.must_equal 'inst1'
     @driver.instance(:id => 'unknown').must_be_nil
   end
 
   it 'must allow to create a new instance if instance supported' do
     instance = @driver.create_instance('img1', :name => 'inst1-test', :realm_id => 'us', :hwp_id => 'm1-small')
-    instance.must_be_kind_of Instance
+    instance.must_be_kind_of Deltacloud::Instance
     @driver.instance(:id => instance.id).wont_be_nil
     @driver.instance(:id => instance.id).id.must_equal instance.id
     @driver.instance(:id => instance.id).name.must_equal 'inst1-test'
@@ -62,14 +62,14 @@ describe 'MockDriver Instances' do
 
   it 'must allow to destroy created instance' do
     instance = @driver.create_instance('img1', :name => 'inst1-test-destroy')
-    instance.must_be_kind_of Instance
+    instance.must_be_kind_of Deltacloud::Instance
     @driver.destroy_instance(instance.id)
     @driver.instance(:id => instance.id).must_be_nil
   end
 
   it 'must allow to stop instance in running state' do
     instance = @driver.create_instance('img1', :name => 'inst1-test-destroy')
-    instance.must_be_kind_of Instance
+    instance.must_be_kind_of Deltacloud::Instance
     instance.state.must_equal 'RUNNING'
     @driver.stop_instance(instance.id)
     @driver.instance(:id => instance.id).state.must_equal 'STOPPED'
@@ -79,7 +79,7 @@ describe 'MockDriver Instances' do
 
   it 'must allow to start instance in stopped state' do
     instance = @driver.create_instance('img1', :name => 'inst1-test-destroy')
-    instance.must_be_kind_of Instance
+    instance.must_be_kind_of Deltacloud::Instance
     instance.state.must_equal 'RUNNING'
     @driver.stop_instance(instance.id)
     @driver.instance(:id => instance.id).state.must_equal 'STOPPED'
@@ -91,7 +91,7 @@ describe 'MockDriver Instances' do
 
   it 'must allow to reboot instance in running state' do
     instance = @driver.create_instance('img1', :name => 'inst1-test-destroy')
-    instance.must_be_kind_of Instance
+    instance.must_be_kind_of Deltacloud::Instance
     instance.state.must_equal 'RUNNING'
     @driver.reboot_instance(instance.id)
     @driver.instance(:id => instance.id).state.must_equal 'RUNNING'
diff --git a/server/tests/drivers/mock/keys_test.rb b/server/tests/drivers/mock/keys_test.rb
index ecf7ec8..b491a0e 100644
--- a/server/tests/drivers/mock/keys_test.rb
+++ b/server/tests/drivers/mock/keys_test.rb
@@ -17,7 +17,7 @@ describe 'MockDriver Keys' do
 
   it 'must return list of keys' do
     @driver.keys.wont_be_empty
-    @driver.keys.first.must_be_kind_of Key
+    @driver.keys.first.must_be_kind_of Deltacloud::Key
   end
 
   it 'must allow to filter keys' do
@@ -30,7 +30,7 @@ describe 'MockDriver Keys' do
 
   it 'must allow to retrieve single key' do
     @driver.key(:id => 'test-key').wont_be_nil
-    @driver.key(:id => 'test-key').must_be_kind_of Key
+    @driver.key(:id => 'test-key').must_be_kind_of Deltacloud::Key
     @driver.key(:id => 'test-key').id.must_equal 'test-key'
     @driver.key(:id => 'unknown').must_be_nil
   end
@@ -38,7 +38,7 @@ describe 'MockDriver Keys' do
   it 'must allow to create a new key' do
     key = @driver.create_key(:key_name => 'test1')
     key.wont_be_nil
-    key.must_be_kind_of Key
+    key.must_be_kind_of Deltacloud::Key
     Proc.new { @driver.create_key(:key_name => 'test1') }.must_raise Deltacloud::Exceptions::ForbiddenError, 'KeyExist'
     @driver.destroy_key :id => key.id
     @driver.key(:id => key.id).must_be_nil
diff --git a/server/tests/drivers/mock/realms_test.rb b/server/tests/drivers/mock/realms_test.rb
index 758fa0d..ed0c51a 100644
--- a/server/tests/drivers/mock/realms_test.rb
+++ b/server/tests/drivers/mock/realms_test.rb
@@ -17,7 +17,7 @@ describe 'MockDriver Realms' do
 
   it 'must return list of realms' do
     @driver.realms.wont_be_empty
-    @driver.realms.first.must_be_kind_of Realm
+    @driver.realms.first.must_be_kind_of Deltacloud::Realm
   end
 
   it 'must allow to filter realms' do
@@ -30,7 +30,7 @@ describe 'MockDriver Realms' do
 
   it 'must allow to retrieve single realm' do
     @driver.realm(:id => 'us').wont_be_nil
-    @driver.realm(:id => 'us').must_be_kind_of Realm
+    @driver.realm(:id => 'us').must_be_kind_of Deltacloud::Realm
     @driver.realm(:id => 'us').id.must_equal 'us'
     @driver.realm(:id => 'unknown').must_be_nil
   end
diff --git a/server/tests/drivers/mock/storage_snapshots_test.rb b/server/tests/drivers/mock/storage_snapshots_test.rb
index b77e6e0..be4c88b 100644
--- a/server/tests/drivers/mock/storage_snapshots_test.rb
+++ b/server/tests/drivers/mock/storage_snapshots_test.rb
@@ -17,7 +17,7 @@ describe 'MockDriver StorageSnapshots' do
 
   it 'must return list of storage_snapshots' do
     @driver.storage_snapshots.wont_be_empty
-    @driver.storage_snapshots.first.must_be_kind_of StorageSnapshot
+    @driver.storage_snapshots.first.must_be_kind_of Deltacloud::StorageSnapshot
   end
 
   it 'must allow to filter storage_snapshots' do
@@ -30,7 +30,7 @@ describe 'MockDriver StorageSnapshots' do
 
   it 'must allow to retrieve single storage_snapshot' do
     @driver.storage_snapshot(:id => 'snap1').wont_be_nil
-    @driver.storage_snapshot(:id => 'snap1').must_be_kind_of StorageSnapshot
+    @driver.storage_snapshot(:id => 'snap1').must_be_kind_of Deltacloud::StorageSnapshot
     @driver.storage_snapshot(:id => 'snap1').id.must_equal 'snap1'
     @driver.storage_snapshot(:id => 'unknown').must_be_nil
   end
diff --git a/server/tests/drivers/mock/storage_volumes_test.rb b/server/tests/drivers/mock/storage_volumes_test.rb
index 1394474..1727627 100644
--- a/server/tests/drivers/mock/storage_volumes_test.rb
+++ b/server/tests/drivers/mock/storage_volumes_test.rb
@@ -17,7 +17,7 @@ describe 'MockDriver StorageVolumes' do
 
   it 'must return list of storage_volumes' do
     @driver.storage_volumes.wont_be_empty
-    @driver.storage_volumes.first.must_be_kind_of StorageVolume
+    @driver.storage_volumes.first.must_be_kind_of Deltacloud::StorageVolume
   end
 
   it 'must allow to filter storage_volumes' do
@@ -30,14 +30,14 @@ describe 'MockDriver StorageVolumes' do
 
   it 'must allow to retrieve single storage_volume' do
     @driver.storage_volume(:id => 'vol1').wont_be_nil
-    @driver.storage_volume(:id => 'vol1').must_be_kind_of StorageVolume
+    @driver.storage_volume(:id => 'vol1').must_be_kind_of Deltacloud::StorageVolume
     @driver.storage_volume(:id => 'vol1').id.must_equal 'vol1'
     @driver.storage_volume(:id => 'unknown').must_be_nil
   end
 
   it 'must allow to create and destroy the storage volume' do
     volume = @driver.create_storage_volume(:name => 'Test Volume', :capacity => '100')
-    volume.must_be_kind_of StorageVolume
+    volume.must_be_kind_of Deltacloud::StorageVolume
     volume.name.must_equal 'Test Volume'
     volume.capacity.must_equal '100'
     @driver.destroy_storage_volume(:id => volume.id)
@@ -46,7 +46,7 @@ describe 'MockDriver StorageVolumes' do
 
   it 'must allow to attach and detach storage volume to instance' do
     volume = @driver.create_storage_volume(:name => 'Test Volume', :capacity => '100')
-    volume.must_be_kind_of StorageVolume
+    volume.must_be_kind_of Deltacloud::StorageVolume
     @driver.attach_storage_volume(:id => volume.id, :device => '/dev/sda', :instance_id => 'inst1')
     @driver.storage_volume(:id => volume.id).instance_id.must_equal 'inst1'
     @driver.storage_volume(:id => volume.id).device.must_equal '/dev/sda'
diff --git a/server/tests/drivers/models/instance_test.rb b/server/tests/drivers/models/instance_test.rb
index 26852ee..c70f725 100644
--- a/server/tests/drivers/models/instance_test.rb
+++ b/server/tests/drivers/models/instance_test.rb
@@ -3,10 +3,10 @@ require 'require_relative' if RUBY_VERSION < '1.9'
 
 require_relative 'common'
 
-describe Instance do
+describe Deltacloud::Instance do
 
   before do
-    @instance = Instance.new(
+    @instance = Deltacloud::Instance.new(
       :id => 'inst1',
       :create_image => true,
       :name => 'Instance',
diff --git a/server/tests/drivers/openstack/images_test.rb b/server/tests/drivers/openstack/images_test.rb
index 7181f7d..66c9695 100644
--- a/server/tests/drivers/openstack/images_test.rb
+++ b/server/tests/drivers/openstack/images_test.rb
@@ -22,7 +22,7 @@ describe 'OpenStackDriver Images' do
 
   it 'must return list of images' do
     @driver.images.wont_be_empty
-    @driver.images.first.must_be_kind_of Image
+    @driver.images.first.must_be_kind_of Deltacloud::Image
   end
 
   it 'must allow to filter images' do
@@ -40,7 +40,7 @@ describe 'OpenStackDriver Images' do
     @driver.image(:id => 'unknown').must_be_nil
     image = @driver.image :id => openstack_image_id
     image.wont_be_nil
-    image.must_be_kind_of Image
+    image.must_be_kind_of Deltacloud::Image
     image.id.must_equal openstack_image_id
     image.name.wont_be_empty
     image.owner_id.wont_be_empty
diff --git a/server/tests/drivers/openstack/instances_test.rb b/server/tests/drivers/openstack/instances_test.rb
index 986bc1a..5bd7780 100644
--- a/server/tests/drivers/openstack/instances_test.rb
+++ b/server/tests/drivers/openstack/instances_test.rb
@@ -29,7 +29,7 @@ describe 'OpenStackDriver Instances' do
 
   it 'must return list of instances' do
     @driver.instances.wont_be_empty
-    @driver.instances.first.must_be_kind_of Instance
+    @driver.instances.first.must_be_kind_of Deltacloud::Instance
   end
 
   it 'must allow to filter instances' do
diff --git a/server/tests/drivers/openstack/keys_test.rb b/server/tests/drivers/openstack/keys_test.rb
index 4e7c7ed..33d741a 100644
--- a/server/tests/drivers/openstack/keys_test.rb
+++ b/server/tests/drivers/openstack/keys_test.rb
@@ -22,7 +22,7 @@ describe 'OpenStackDriver Keys' do
 
   it 'must return list of keys' do
     @driver.keys.wont_be_empty
-    @driver.keys.first.must_be_kind_of Key
+    @driver.keys.first.must_be_kind_of Deltacloud::Key
   end
 
   it 'must allow to filter keys' do
diff --git a/server/tests/drivers/openstack/realms_test.rb b/server/tests/drivers/openstack/realms_test.rb
index f4916f7..ae337ae 100644
--- a/server/tests/drivers/openstack/realms_test.rb
+++ b/server/tests/drivers/openstack/realms_test.rb
@@ -22,7 +22,7 @@ describe 'OpenStackDriver Realms' do
 
   it 'must return list of realms' do
     @driver.realms.wont_be_empty
-    @driver.realms.first.must_be_kind_of Realm
+    @driver.realms.first.must_be_kind_of Deltacloud::Realm
   end
 
   it 'must allow to retrieve single realm' do
diff --git a/server/tests/drivers/rhevm/images_test.rb b/server/tests/drivers/rhevm/images_test.rb
index 7241667..c00ee34 100644
--- a/server/tests/drivers/rhevm/images_test.rb
+++ b/server/tests/drivers/rhevm/images_test.rb
@@ -22,7 +22,7 @@ describe 'RhevmDriver Images' do
 
   it 'must return list of images' do
     @driver.images.wont_be_empty
-    @driver.images.first.must_be_kind_of Image
+    @driver.images.first.must_be_kind_of Deltacloud::Image
   end
 
   it 'must allow to filter images' do
@@ -43,7 +43,7 @@ describe 'RhevmDriver Images' do
     #
     if RUBY_VERSION =~ /^1\.9/
       @driver.image(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').wont_be_nil
-      @driver.image(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').must_be_kind_of Image
+      @driver.image(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').must_be_kind_of Deltacloud::Image
       @driver.image(:id => '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5').id.must_equal '5558c5b6-9dd6-41b7-87f9-7cbce4fd40c5'
       @driver.image(:id => 'ami-aaaaaaaa').must_be_nil
       @driver.image(:id => 'unknown').must_be_nil
diff --git a/server/tests/drivers/rhevm/instance_test.rb b/server/tests/drivers/rhevm/instance_test.rb
index 382cd4a..a193e85 100644
--- a/server/tests/drivers/rhevm/instance_test.rb
+++ b/server/tests/drivers/rhevm/instance_test.rb
@@ -28,7 +28,7 @@ describe 'RhevmDriver Instances' do
 
   it 'must return list of instances' do
     @driver.instances.wont_be_empty
-    @driver.instances.first.must_be_kind_of Instance
+    @driver.instances.first.must_be_kind_of Deltacloud::Instance
   end
 
   it 'must allow to filter instances' do
@@ -43,7 +43,7 @@ describe 'RhevmDriver Instances' do
   it 'must allow to retrieve single instance' do
     @driver.instance(:id => TST_INSTANCE).wont_be_nil
     @driver.instance(:id => TST_INSTANCE).wont_be_nil
-    @driver.instance(:id => TST_INSTANCE).must_be_kind_of Instance
+    @driver.instance(:id => TST_INSTANCE).must_be_kind_of Deltacloud::Instance
     @driver.instance(:id => TST_INSTANCE).id.must_equal TST_INSTANCE
     @driver.instance(:id => 'i-00000000').must_be_nil
     @driver.instance(:id => 'unknown').must_be_nil
@@ -57,7 +57,7 @@ describe 'RhevmDriver Instances' do
                                        :user_data => 'test user data'
                                       )
     instance = instance.wait_for!(@driver, record_retries('', :timeout => 60)) { |i| i.is_stopped? }
-    instance.must_be_kind_of Instance
+    instance.must_be_kind_of Deltacloud::Instance
     instance.is_running?.must_equal false
     @driver.instance(:id => instance.id).wont_be_nil
     @driver.instance(:id => instance.id).id.must_equal instance.id
@@ -82,7 +82,7 @@ describe 'RhevmDriver Instances' do
                                       )
     instance = instance.wait_for!(@driver, record_retries('', :timeout => 60)) { |i| i.is_stopped? }
     skip "Skip this test due to RHEVm bug: https://bugzilla.redhat.com/show_bug.cgi?id=910741"
-    instance.must_be_kind_of Instance
+    instance.must_be_kind_of Deltacloud::Instance
     instance.is_running?.must_equal false
     @driver.instance(:id => instance.id).wont_be_nil
     @driver.instance(:id => instance.id).id.must_equal instance.id
diff --git a/server/tests/drivers/rhevm/provider_test.rb b/server/tests/drivers/rhevm/provider_test.rb
index bde6621..d7f19b7 100644
--- a/server/tests/drivers/rhevm/provider_test.rb
+++ b/server/tests/drivers/rhevm/provider_test.rb
@@ -23,7 +23,7 @@ describe 'RHEV-M provider test' do
 
   it 'must support listing of available providers' do
     @driver.providers.wont_be_empty
-    @driver.providers.each { |p| p.must_be_kind_of Provider }
+    @driver.providers.each { |p| p.must_be_kind_of Deltacloud::Provider }
     @driver.providers.each { |p| p.name.wont_be_empty }
     @driver.providers.each { |p| p.id.wont_be_empty }
     @driver.providers.each { |p| p.url.wont_be_empty }
diff --git a/server/tests/drivers/rhevm/realms_test.rb b/server/tests/drivers/rhevm/realms_test.rb
index 577605d..46a80b8 100644
--- a/server/tests/drivers/rhevm/realms_test.rb
+++ b/server/tests/drivers/rhevm/realms_test.rb
@@ -22,7 +22,7 @@ describe 'RhevmDriver Realms' do
 
   it 'must return list of realms' do
     @driver.realms.wont_be_empty
-    @driver.realms.first.must_be_kind_of Realm
+    @driver.realms.first.must_be_kind_of Deltacloud::Realm
   end
 
   it 'must allow to filter realms' do
@@ -35,7 +35,7 @@ describe 'RhevmDriver Realms' do
 
   it 'must allow to retrieve single realm' do
     @driver.realm(:id => '99408929-82cf-4dc7-a532-9d998063fa95').wont_be_nil
-    @driver.realm(:id => '99408929-82cf-4dc7-a532-9d998063fa95').must_be_kind_of Realm
+    @driver.realm(:id => '99408929-82cf-4dc7-a532-9d998063fa95').must_be_kind_of Deltacloud::Realm
     @driver.realm(:id => 'unknown').must_be_nil
   end
 
diff --git a/server/tests/ec2/query_parser_test.rb b/server/tests/ec2/query_parser_test.rb
index e34e1f9..16682a7 100644
--- a/server/tests/ec2/query_parser_test.rb
+++ b/server/tests/ec2/query_parser_test.rb
@@ -77,7 +77,7 @@ describe Deltacloud::EC2 do
       result.must_respond_to :'perform!'
       realms = result.perform!(@driver.credentials, @driver.backend)
       realms.wont_be_empty
-      realms.first.must_be_kind_of Realm
+      realms.first.must_be_kind_of Deltacloud::Realm
       realms.first.id.must_equal 'us'
     end
 
-- 
1.8.1.4