diff --git a/lib/fog/vcloud/compute.rb b/lib/fog/vcloud/compute.rb
index 6b8aba198..ce8c58a92 100644
--- a/lib/fog/vcloud/compute.rb
+++ b/lib/fog/vcloud/compute.rb
@@ -107,6 +107,7 @@ module Fog
request :get_network_ips
request :get_network_extensions
request :get_organization
+ request :get_server
request :get_task
request :get_task_list
request :get_vapp
diff --git a/lib/fog/vcloud/models/compute/helpers/status.rb b/lib/fog/vcloud/models/compute/helpers/status.rb
new file mode 100644
index 000000000..a4046b0f8
--- /dev/null
+++ b/lib/fog/vcloud/models/compute/helpers/status.rb
@@ -0,0 +1,37 @@
+module Fog
+ module Vcloud
+ class Compute
+ module Helpers
+ module Status
+ def friendly_status
+ load_unless_loaded!
+ case status
+ when '0'
+ 'creating'
+ when '8'
+ 'off'
+ when '4'
+ 'on'
+ else
+ 'unknown'
+ end
+ end
+
+ def on?
+ reload_status
+ status == '4'
+ end
+
+ def off?
+ reload_status
+ status == '8'
+ end
+
+ def reload_status
+ reload # always ensure we have the correct status
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/fog/vcloud/models/compute/network.rb b/lib/fog/vcloud/models/compute/network.rb
index fa4bef055..d3ce0479a 100644
--- a/lib/fog/vcloud/models/compute/network.rb
+++ b/lib/fog/vcloud/models/compute/network.rb
@@ -3,14 +3,13 @@ module Fog
class Compute
class Network < Fog::Vcloud::Model
- identity :href
+ identity :href, :aliases => :Href
ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i, :Id
attribute :name, :aliases => :Name
- #attribute :id, :aliases => :Id
- attribute :description
+ attribute :description, :aliases => :Description
attribute :configuration, :aliases => :Configuration
attribute :links, :aliases => :Link, :type => :array
diff --git a/lib/fog/vcloud/models/compute/networks.rb b/lib/fog/vcloud/models/compute/networks.rb
index 1fca43712..5c9c9307f 100644
--- a/lib/fog/vcloud/models/compute/networks.rb
+++ b/lib/fog/vcloud/models/compute/networks.rb
@@ -14,15 +14,18 @@ module Fog
def all
self.href = connection.default_vdc_href unless self.href
+ data = nil
if self.href =~ /\/vdc\//
check_href!("Vdc")
- if data = connection.get_vdc(self.href).body[:AvailableNetworks][:Network]
- load(data)
- end
- else
+ data = [connection.get_vdc(self.href).body[:AvailableNetworks][:Network]].flatten.compact
+ elsif self.href =~ /\/org\//
check_href!("Org")
- load(connection.get_organization(self.href).body[:Link].select{|l| l[:type] == 'application/vnd.vmware.vcloud.network+xml' })
+ data = connection.get_organization(self.href).body[:Link].select{|l| l[:type] == 'application/vnd.vmware.vcloud.network+xml' }
+ elsif self.href =~ /\/vApp\//
+ check_href!("Vapp")
+ data = [(connection.get_vapp(self.href).body[:NetworkConfigSection]||{})[:NetworkConfig]].flatten.compact.collect{|n| n[:Configuration][:ParentNetwork] unless n[:Configuration].nil? }.compact
end
+ load([*data]) unless data.nil?
end
def get(uri)
diff --git a/lib/fog/vcloud/models/compute/organization.rb b/lib/fog/vcloud/models/compute/organization.rb
index 4a1362467..ac76ec407 100644
--- a/lib/fog/vcloud/models/compute/organization.rb
+++ b/lib/fog/vcloud/models/compute/organization.rb
@@ -8,6 +8,7 @@ module Fog
ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd
attribute :name
+ attribute :description, :aliases => :Description
attribute :type
attribute :full_name, :aliases => :FullName
attribute :other_links, :aliases => :Link
@@ -37,26 +38,6 @@ module Fog
:href => href )
end
- private
-
- def collection_based_on_type(type, klass = nil)
- load_unless_loaded!
- test_links = other_links.kind_of?(Array) ? other_links : [other_links]
- if link = test_links.detect { |link| link[:type] == type }
- case type
- when "application/vnd.vmware.vcloud.catalog+xml"
- Fog::Vcloud::Compute::Catalog
- when "application/vnd.vmware.vcloud.vdc+xml"
- Fog::Vcloud::Compute::Vdc
- when "application/vnd.vmware.vcloud.network+xml"
- Fog::Vcloud::Compute::Network
- when "application/vnd.vmware.vcloud.network+xml"
- Fog::Vcloud::Compute::Network
- end.new( :connection => connection, :href => link[:href] )
- else
- [ ]
- end
- end
end
end
end
diff --git a/lib/fog/vcloud/models/compute/server.rb b/lib/fog/vcloud/models/compute/server.rb
index b4ca48b5d..b9a93a3a7 100644
--- a/lib/fog/vcloud/models/compute/server.rb
+++ b/lib/fog/vcloud/models/compute/server.rb
@@ -1,8 +1,11 @@
+require 'fog/vcloud/models/compute/helpers/status'
module Fog
module Vcloud
class Compute
class Server < Fog::Vcloud::Model
+ include Fog::Vcloud::Compute::Helpers::Status
+
identity :href, :aliases => :Href
ignore_attributes :xmlns, :xmlns_i, :xmlns_xsi, :xmlns_xsd
@@ -10,13 +13,17 @@ module Fog
attribute :type
attribute :name
attribute :status
+ attribute :deployed, :type => :boolean
+ attribute :description, :aliases => :Description
+
+ attribute :vapp_scoped_local_id, :aliases => :VAppScopedLocalId
+
attribute :network_connections, :aliases => :NetworkConnectionSection, :squash => :NetworkConnection
attribute :virtual_hardware, :aliases => :'ovf:VirtualHardwareSection', :squash => :'ovf:Item'
attribute :guest_customization, :aliases => :GuestCustomizationSection
attribute :operating_system, :aliases => :'ovf:OperatingSystemSection'
- attribute :description, :aliases => :Description
attribute :links, :aliases => :Link, :type => :array
attribute :tasks, :aliases => :Tasks, :type => :array
@@ -30,41 +37,22 @@ module Fog
self.operating_system[:'ovf:Description']
end
+ def os_type
+ load_unless_loaded!
+ self.operating_system[:vmw_osType]
+ end
+
def ip_addresses
load_unless_loaded!
self.network_connections.collect{|n| n[:IpAddress] }
end
- def friendly_status
- load_unless_loaded!
- case status
- when '0'
- 'creating'
- when '8'
- 'off'
- when '4'
- 'on'
- else
- 'unkown'
- end
- end
-
def ready?
reload_status # always ensure we have the correct status
running_tasks = tasks && tasks.flatten.any? {|ti| ti.kind_of?(Hash) && ti[:status] == 'running' }
status != '0' && !running_tasks # 0 is provisioning, and no running tasks
end
- def on?
- reload_status # always ensure we have the correct status
- status == '4'
- end
-
- def off?
- reload_status # always ensure we have the correct status
- status == '8'
- end
-
def power_on
power_operation( :power_on => :powerOn )
end
@@ -125,7 +113,7 @@ module Fog
def disks
disk_mess.map do |dm|
- { :number => dm[:"rasd:AddressOnParent"], :size => dm[:"rasd:VirtualQuantity"].to_i, :resource => dm[:"rasd:HostResource"] }
+ { :number => dm[:"rasd:AddressOnParent"].to_i, :size => dm[:"rasd:HostResource"][:vcloud_capacity].to_i, :resource => dm[:"rasd:HostResource"] }
end
end
@@ -241,22 +229,22 @@ module Fog
def memory_mess
load_unless_loaded!
- if virtual_hardware_section
- virtual_hardware_section.detect { |item| item[:"rasd:ResourceType"] == "4" }
+ if virtual_hardware
+ virtual_hardware.detect { |item| item[:"rasd:ResourceType"] == "4" }
end
end
def cpu_mess
load_unless_loaded!
- if virtual_hardware_section
- virtual_hardware_section.detect { |item| item[:"rasd:ResourceType"] == "3" }
+ if virtual_hardware
+ virtual_hardware.detect { |item| item[:"rasd:ResourceType"] == "3" }
end
end
def disk_mess
load_unless_loaded!
- if virtual_hardware_section
- virtual_hardware_section.select { |item| item[:"rasd:ResourceType"] == "17" }
+ if virtual_hardware
+ virtual_hardware.select { |item| item[:"rasd:ResourceType"] == "17" }
else
[]
end
diff --git a/lib/fog/vcloud/models/compute/servers.rb b/lib/fog/vcloud/models/compute/servers.rb
index 2cbb93a25..8c27c84ed 100644
--- a/lib/fog/vcloud/models/compute/servers.rb
+++ b/lib/fog/vcloud/models/compute/servers.rb
@@ -13,14 +13,9 @@ module Fog
attribute :href, :aliases => :Href
def all
- if self.href =~ /\/vdc\//
- check_href!("Vdc")
- load(_vapps)
- else
- check_href!("Vapp")
- attributes[:vapp].load_unless_loaded!
- load(attributes[:vapp].children||[])
- end
+ check_href!("Vapp")
+ vapp.load_unless_loaded!
+ load(vapp.children||[])
end
def get(uri)
@@ -43,19 +38,16 @@ module Fog
private
- def _resource_entities
- if Hash === resource_entities = connection.get_vdc(href).body[:ResourceEntities]
- resource_entities[:ResourceEntity]
- end
+ def vapp
+ @vapp ||= (attributes[:vapp] || init_vapp)
end
- def _vapps
- resource_entities = _resource_entities
- if resource_entities.nil?
- []
- else
- resource_entities.select {|re| re[:type] == 'application/vnd.vmware.vcloud.vApp+xml' }
- end
+ def init_vapp
+ Fog::Vcloud::Compute::Vapp.new(
+ :connection => connection,
+ :href => self.href,
+ :collection => Fog::Vcloud::Compute::Vapps.new(:connection => connection)
+ )
end
end
diff --git a/lib/fog/vcloud/models/compute/vapp.rb b/lib/fog/vcloud/models/compute/vapp.rb
index ab696414e..465759753 100644
--- a/lib/fog/vcloud/models/compute/vapp.rb
+++ b/lib/fog/vcloud/models/compute/vapp.rb
@@ -1,8 +1,11 @@
+require 'fog/vcloud/models/compute/helpers/status'
module Fog
module Vcloud
class Compute
class Vapp < Fog::Vcloud::Model
+ include Fog::Vcloud::Compute::Helpers::Status
+
identity :href
ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd
@@ -10,10 +13,12 @@ module Fog
attribute :name
attribute :type
attribute :status
- attribute :description
+ attribute :description, :aliases => :Description
attribute :deployed, :type => :boolean
+
attribute :children, :aliases => :Children, :squash => :Vm
attribute :lease_settings, :aliases => :LeaseSettingsSection
+
attribute :other_links, :aliases => :Link
def servers
@@ -23,6 +28,13 @@ module Fog
:vapp => self
)
end
+
+ def networks
+ @networks ||= Fog::Vcloud::Compute::Networks.
+ new( :connection => connection,
+ :href => href
+ )
+ end
end
end
end
diff --git a/lib/fog/vcloud/models/compute/vapps.rb b/lib/fog/vcloud/models/compute/vapps.rb
index d4efaa69d..e7fd5d69d 100644
--- a/lib/fog/vcloud/models/compute/vapps.rb
+++ b/lib/fog/vcloud/models/compute/vapps.rb
@@ -9,7 +9,7 @@ module Fog
model Fog::Vcloud::Compute::Vapp
undef_method :create
-
+
attribute :href
def all
diff --git a/lib/fog/vcloud/models/compute/vdc.rb b/lib/fog/vcloud/models/compute/vdc.rb
index f3110e3a1..78744ca34 100644
--- a/lib/fog/vcloud/models/compute/vdc.rb
+++ b/lib/fog/vcloud/models/compute/vdc.rb
@@ -10,13 +10,17 @@ module Fog
attribute :name
attribute :type
attribute :description, :aliases => :Description
- attribute :other_links, :aliases => :Link
+ attribute :network_quota, :aliases => :NetworkQuota, :type => :integer
+ attribute :nic_quota, :aliases => :NicQuota, :type => :integer
+ attribute :vm_quota, :aliases => :VmQuota, :type => :integer
+ attribute :is_enabled, :aliases => :IsEnabled, :type => :boolean
attribute :compute_capacity, :aliases => :ComputeCapacity
attribute :storage_capacity, :aliases => :StorageCapacity
attribute :available_networks, :aliases => :AvailableNetworks, :squash => :Network
+
+ attribute :other_links, :aliases => :Link
+
attribute :resource_entities, :aliases => :ResourceEntities, :squash => :ResourceEntity
- attribute :deployed_vm_quota
- attribute :instantiated_vm_quota
def networks
@networks ||= Fog::Vcloud::Compute::Networks.
@@ -24,12 +28,6 @@ module Fog
:href => href )
end
- def servers
- @servers ||= Fog::Vcloud::Compute::Servers.
- new( :connection => connection,
- :href => href )
- end
-
def vapps
@vapps ||= Fog::Vcloud::Compute::Vapps.
new( :connection => connection,
@@ -37,22 +35,6 @@ module Fog
)
end
- private
-
- def collection_based_on_type(type, klass = nil)
- load_unless_loaded!
- test_links = other_links.kind_of?(Array) ? other_links : [other_links]
- if link = test_links.detect { |link| link[:type] == type }
- case type
- when "application/vnd.vmware.vcloud.catalog+xml"
- Fog::Vcloud::Compute::Catalog
- when "application/vnd.vmware.vcloud.vApp+xml"
- Fog::Vcloud::Compute::Vapp
- end.new( :connection => connection, :href => link[:href] )
- else
- [ ]
- end
- end
end
end
end
diff --git a/lib/fog/vcloud/requests/compute/get_server.rb b/lib/fog/vcloud/requests/compute/get_server.rb
new file mode 100644
index 000000000..633684f33
--- /dev/null
+++ b/lib/fog/vcloud/requests/compute/get_server.rb
@@ -0,0 +1,10 @@
+module Fog
+ module Vcloud
+ class Compute
+
+ class Real
+ basic_request :get_server
+ end
+ end
+ end
+end
diff --git a/tests/vcloud/data/api_+_v1.0_+_admin_+_network_+_2 b/tests/vcloud/data/api_+_v1.0_+_admin_+_network_+_2
new file mode 100644
index 000000000..b478c2c3f
--- /dev/null
+++ b/tests/vcloud/data/api_+_v1.0_+_admin_+_network_+_2
@@ -0,0 +1,110 @@
+
+
+ Internet Connection
+
+
+ false
+ 172.0.0.1
+ 255.255.255.0
+ 172.0.0.2
+ 172.0.0.190
+
+
+ 172.0.0.142
+ 172.0.0.156
+
+
+ 172.0.0.160
+ 172.0.0.184
+
+
+ 172.0.0.195
+ 172.0.0.235
+
+
+
+ 172.0.0.153
+ 172.0.0.147
+ 172.0.0.221
+ 172.0.0.226
+ 172.0.0.151
+ 172.0.0.161
+ 172.0.0.164
+ 172.0.0.163
+ 172.0.0.218
+ 172.0.0.173
+ 172.0.0.172
+ 172.0.0.175
+ 172.0.0.178
+ 172.0.0.197
+ 172.0.0.180
+ 172.0.0.201
+ 172.0.0.156
+ 172.0.0.202
+ 172.0.0.183
+ 172.0.0.149
+ 172.0.0.214
+ 172.0.0.171
+ 172.0.0.162
+ 172.0.0.198
+ 172.0.0.224
+ 172.0.0.195
+ 172.0.0.196
+ 172.0.0.150
+ 172.0.0.169
+ 172.0.0.170
+ 172.0.0.176
+ 172.0.0.200
+ 172.0.0.179
+ 172.0.0.205
+ 172.0.0.213
+ 172.0.0.210
+ 172.0.0.215
+ 172.0.0.219
+ 172.0.0.208
+ 172.0.0.216
+ 172.0.0.217
+ 172.0.0.204
+ 172.0.0.232
+ 172.0.0.154
+ 172.0.0.235
+ 172.0.0.146
+ 172.0.0.209
+ 172.0.0.211
+ 172.0.0.199
+ 172.0.0.155
+ 172.0.0.142
+ 172.0.0.160
+ 172.0.0.212
+ 172.0.0.177
+ 172.0.0.167
+ 172.0.0.166
+ 172.0.0.168
+ 172.0.0.165
+ 172.0.0.181
+ 172.0.0.184
+ 172.0.0.143
+ 172.0.0.230
+ 172.0.0.206
+ 172.0.0.233
+ 172.0.0.222
+ 172.0.0.225
+ 172.0.0.220
+ 172.0.0.227
+ 172.0.0.148
+ 172.0.0.228
+ 172.0.0.229
+ 172.0.0.231
+ 172.0.0.152
+ 172.0.0.145
+ 172.0.0.174
+ 172.0.0.182
+ 172.0.0.203
+ 172.0.0.207
+ 172.0.0.144
+
+
+ isolated
+
+ NETWORK:dvportgroup-230 on com.vmware.vcloud.entity.vimserver:35935555
+
diff --git a/tests/vcloud/data/api_+_v1.0_+_login b/tests/vcloud/data/api_+_v1.0_+_login
new file mode 100644
index 000000000..7817de4db
--- /dev/null
+++ b/tests/vcloud/data/api_+_v1.0_+_login
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/tests/vcloud/data/api_+_v1.0_+_network_+_1 b/tests/vcloud/data/api_+_v1.0_+_network_+_1
new file mode 100644
index 000000000..cdaba51fc
--- /dev/null
+++ b/tests/vcloud/data/api_+_v1.0_+_network_+_1
@@ -0,0 +1,44 @@
+
+
+
+ Some fancy Network
+
+
+ false
+ 192.168.0.1
+ 255.255.255.0
+ 172.0.0.2
+ 172.0.0.190
+
+
+ 192.168.0.101
+ 192.168.0.150
+
+
+
+ 192.168.0.1
+
+
+
+ natRouted
+
+
+ false
+ 3600
+ 7200
+
+ 192.168.0.151
+ 192.168.0.254
+
+
+
+ true
+
+
+ false
+ portForwarding
+ allowTraffic
+
+
+
+
diff --git a/tests/vcloud/data/api_+_v1.0_+_network_+_2 b/tests/vcloud/data/api_+_v1.0_+_network_+_2
new file mode 100644
index 000000000..e41010d90
--- /dev/null
+++ b/tests/vcloud/data/api_+_v1.0_+_network_+_2
@@ -0,0 +1,31 @@
+
+
+
+ Description
+
+
+ false
+ 192.168.251.254
+ 255.255.255.0
+ 192.168.251.254
+
+
+ 192.168.251.101
+ 192.168.251.200
+
+
+
+ isolated
+
+
+ false
+ 3600
+ 7200
+
+ 192.168.251.1
+ 192.168.251.100
+
+
+
+
+
diff --git a/tests/vcloud/data/api_+_v1.0_+_org_+_1 b/tests/vcloud/data/api_+_v1.0_+_org_+_1
new file mode 100644
index 000000000..15183bd3e
--- /dev/null
+++ b/tests/vcloud/data/api_+_v1.0_+_org_+_1
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Some fancy
+
+Description
+ My Full Name
+
diff --git a/tests/vcloud/data/api_+_v1.0_+_vApp_+_vapp-1 b/tests/vcloud/data/api_+_v1.0_+_vApp_+_vapp-1
new file mode 100644
index 000000000..353d7215c
--- /dev/null
+++ b/tests/vcloud/data/api_+_v1.0_+_vApp_+_vapp-1
@@ -0,0 +1,369 @@
+
+
+
+
+
+
+
+
+
+
+ Some Description of a vApp
+
+ Lease settings section
+
+ 0
+ 0
+
+
+ VApp startup section
+
+
+
+
+
+ The list of logical networks
+
+
+
+
+
+ The configuration parameters for logical networks
+
+
+ Some Network Description
+
+
+ false
+ 192.168.2.1
+ 255.255.255.0
+ 192.168.2.1
+
+
+ 192.168.2.101
+ 192.168.2.150
+
+
+
+ 192.168.2.101
+ 192.168.2.1
+ 192.168.2.102
+
+
+
+ natRouted
+
+
+ false
+ 7200
+ 7200
+
+
+
+ true
+
+
+ true
+ ipTranslation
+ allowTraffic
+
+
+ automatic
+ 192.168.1.102
+ vm1
+ 0
+
+
+
+
+ automatic
+ 192.168.1.103
+ vm2
+ 0
+
+
+
+
+
+ true
+
+
+
+
+
+
+
+ vm-595
+ VIRTUAL_MACHINE
+
+
+
+
+
+
+
+
+
+
+
+
+ Virtual hardware requirements
+
+ Virtual Hardware Family
+ 0
+ vm2
+ vmx-07
+
+
+ 00:50:56:01:02:03
+ 0
+ true
+ Network1
+ PCNet32 ethernet adapter
+ Network adapter 0
+ 1
+ PCNet32
+ 10
+
+
+ 0
+ SCSI Controller
+ SCSI Controller 0
+ 2
+ lsilogicsas
+ 6
+
+
+ 0
+ Hard disk
+ Hard disk 1
+
+ 2000
+ 2
+ 17
+
+
+ 0
+ IDE Controller
+ IDE Controller 0
+ 3
+ 5
+
+
+ 0
+ false
+ CD/DVD Drive
+ CD/DVD Drive 1
+
+ 3002
+ 3
+ 15
+
+
+ hertz * 10^6
+ Number of Virtual CPUs
+ 1 virtual CPU(s)
+ 4
+ 0
+ 3
+ 1
+ 0
+
+
+
+ byte * 2^20
+ Memory Size
+ 512 MB of memory
+ 5
+ 0
+ 4
+ 512
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Specifies the operating system installed
+ Red Hat Enterprise Linux 5 (64-bit)
+
+
+
+ Specifies the available VM network connections
+ 0
+
+ 0
+ 192.168.2.102
+ 192.168.1.103
+ true
+ 00:50:56:01:00:03
+ POOL
+
+
+
+
+ Specifies Guest OS Customization Settings
+ true
+ false
+ 2
+ false
+ false
+ true
+ true
+ password
+ false
+
+ vm2
+
+
+ vmware_RHEL5-U5-64-small_v02
+
+
+
+
+
+ vm-594
+ VIRTUAL_MACHINE
+
+
+
+
+
+
+
+
+
+
+
+
+ Virtual hardware requirements
+
+ Virtual Hardware Family
+ 0
+ vm1
+ vmx-07
+
+
+ 00:50:56:01:02:04
+ 0
+ true
+ Network1
+ PCNet32 ethernet adapter
+ Network adapter 0
+ 1
+ PCNet32
+ 10
+
+
+ 0
+ SCSI Controller
+ SCSI Controller 0
+ 2
+ lsilogicsas
+ 6
+
+
+ 0
+ Hard disk
+ Hard disk 1
+
+ 2000
+ 2
+ 17
+
+
+ 0
+ IDE Controller
+ IDE Controller 0
+ 3
+ 5
+
+
+ 0
+ false
+ CD/DVD Drive
+ CD/DVD Drive 1
+
+ 3002
+ 3
+ 15
+
+
+ hertz * 10^6
+ Number of Virtual CPUs
+ 1 virtual CPU(s)
+ 4
+ 0
+ 3
+ 1
+ 0
+
+
+
+ byte * 2^20
+ Memory Size
+ 512 MB of memory
+ 5
+ 0
+ 4
+ 512
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Specifies the operating system installed
+ Red Hat Enterprise Linux 5 (64-bit)
+
+
+
+ Specifies the available VM network connections
+ 0
+
+ 0
+ 192.168.2.101
+ 192.168.1.102
+ true
+ 00:50:56:01:02:04
+ POOL
+
+
+
+
+ Specifies Guest OS Customization Settings
+ true
+ false
+ 1
+ false
+ false
+ true
+ true
+ password
+ false
+
+ vm1
+
+
+ vmware_RHEL5-U5-64-small_v01
+
+
+
diff --git a/tests/vcloud/data/api_+_v1.0_+_vApp_+_vm-1 b/tests/vcloud/data/api_+_v1.0_+_vApp_+_vm-1
new file mode 100644
index 000000000..69b9c3a5a
--- /dev/null
+++ b/tests/vcloud/data/api_+_v1.0_+_vApp_+_vm-1
@@ -0,0 +1,139 @@
+
+
+
+
+
+ vm-594
+ VIRTUAL_MACHINE
+
+
+
+
+
+
+
+
+
+
+
+
+ Virtual hardware requirements
+
+ Virtual Hardware Family
+ 0
+ vm1
+ vmx-07
+
+
+ 00:50:56:01:02:04
+ 0
+ true
+ Network1
+ PCNet32 ethernet adapter
+ Network adapter 0
+ 1
+ PCNet32
+ 10
+
+
+ 0
+ SCSI Controller
+ SCSI Controller 0
+ 2
+ lsilogicsas
+ 6
+
+
+ 0
+ Hard disk
+ Hard disk 1
+
+ 2000
+ 2
+ 17
+
+
+ 0
+ IDE Controller
+ IDE Controller 0
+ 3
+ 5
+
+
+ 0
+ false
+ CD/DVD Drive
+ CD/DVD Drive 1
+
+ 3002
+ 3
+ 15
+
+
+ hertz * 10^6
+ Number of Virtual CPUs
+ 1 virtual CPU(s)
+ 4
+ 0
+ 3
+ 1
+ 0
+
+
+
+ byte * 2^20
+ Memory Size
+ 512 MB of memory
+ 5
+ 0
+ 4
+ 512
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Specifies the operating system installed
+ Red Hat Enterprise Linux 5 (64-bit)
+
+
+
+ Specifies the available VM network connections
+ 0
+
+ 0
+ 192.168.2.101
+ 192.168.1.102
+ true
+ 00:50:56:01:02:04
+ POOL
+
+
+
+
+ Specifies Guest OS Customization Settings
+ true
+ false
+ 1
+ false
+ false
+ true
+ true
+ password
+ false
+
+ vm1
+
+
+ vmware_RHEL5-U5-64-small_v01
+
diff --git a/tests/vcloud/data/api_+_v1.0_+_vApp_+_vm-2 b/tests/vcloud/data/api_+_v1.0_+_vApp_+_vm-2
new file mode 100644
index 000000000..12b0b8195
--- /dev/null
+++ b/tests/vcloud/data/api_+_v1.0_+_vApp_+_vm-2
@@ -0,0 +1,148 @@
+
+
+
+
+
+ vm-595
+ VIRTUAL_MACHINE
+
+
+
+
+
+
+
+
+
+
+ Some VM Description
+
+ Virtual hardware requirements
+
+ Virtual Hardware Family
+ 0
+ vm2
+ vmx-07
+
+
+ 00:50:56:01:02:03
+ 0
+ true
+ Network1
+ PCNet32 ethernet adapter
+ Network adapter 0
+ 1
+ PCNet32
+ 10
+
+
+ 0
+ SCSI Controller
+ SCSI Controller 0
+ 2
+ lsilogicsas
+ 6
+
+
+ 0
+ Hard disk
+ Hard disk 1
+
+ 2000
+ 2
+ 17
+
+
+ 1
+ Hard disk
+ Hard disk 2
+
+ 3000
+ 2
+ 17
+
+
+ 0
+ IDE Controller
+ IDE Controller 0
+ 3
+ 5
+
+
+ 0
+ false
+ CD/DVD Drive
+ CD/DVD Drive 1
+
+ 3002
+ 3
+ 15
+
+
+ hertz * 10^6
+ Number of Virtual CPUs
+ 1 virtual CPU(s)
+ 4
+ 0
+ 3
+ 1
+ 0
+
+
+
+ byte * 2^20
+ Memory Size
+ 512 MB of memory
+ 5
+ 0
+ 4
+ 512
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Specifies the operating system installed
+ Red Hat Enterprise Linux 5 (64-bit)
+
+
+
+ Specifies the available VM network connections
+ 0
+
+ 0
+ 192.168.2.102
+ 192.168.1.103
+ true
+ 00:50:56:01:02:03
+ POOL
+
+
+
+
+ Specifies Guest OS Customization Settings
+ true
+ false
+ 2
+ false
+ false
+ true
+ true
+ password
+ false
+
+ vm2
+
+
+ vmware_RHEL5-U5-64-small_v02
+
diff --git a/tests/vcloud/data/api_+_v1.0_+_vdc_+_1 b/tests/vcloud/data/api_+_v1.0_+_vdc_+_1
new file mode 100644
index 000000000..dd7014701
--- /dev/null
+++ b/tests/vcloud/data/api_+_v1.0_+_vdc_+_1
@@ -0,0 +1,61 @@
+
+
+
+
+
+ resgroup-1
+ RESOURCE_POOL
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some Description
+ AllocationVApp
+
+ MB
+ 10240
+ 102400
+ 101650
+ 0
+
+
+
+ MHz
+ 20000
+ 40000
+ 2000
+ 0
+
+
+ MB
+ 1024
+ 10240
+ 8385
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+ 10
+ 10
+ 10
+ true
+
diff --git a/tests/vcloud/models/compute/conn_helper.rb b/tests/vcloud/models/compute/conn_helper.rb
new file mode 100644
index 000000000..93e551521
--- /dev/null
+++ b/tests/vcloud/models/compute/conn_helper.rb
@@ -0,0 +1,13 @@
+module Fog
+ class Connection
+ def initialize(url, persistent=false, params={})
+ end
+
+ def request(params, &block)
+ Excon::Response.new(
+ :body => File.read(File.expand_path(File.join(File.dirname(__FILE__),'..','..','data',params[:path].gsub(/^\//,'').gsub('/','_+_')))),
+ :status => 200,
+ :header => '')
+ end
+ end
+end
diff --git a/tests/vcloud/models/compute/network_tests.rb b/tests/vcloud/models/compute/network_tests.rb
new file mode 100644
index 000000000..dbe39b795
--- /dev/null
+++ b/tests/vcloud/models/compute/network_tests.rb
@@ -0,0 +1,40 @@
+require "#{File.dirname(__FILE__)}/conn_helper.rb"
+
+require 'fog/vcloud/models/compute/networks'
+
+Shindo.tests("Vcloud::Compute | network", ['vcloud']) do
+ connection = Fog::Vcloud::Compute.new(:vcloud_host => 'vcloud.example.com', :vcloud_username => 'username', :vcloud_password => 'password')
+ tests("an org network") do
+ instance = Fog::Vcloud::Compute::Networks.new(
+ :connection => connection,
+ :href => "https://vcloud.example.com/api/v1.0/vApp/vapp-1"
+ ).first
+ instance.reload
+
+ tests("#href").returns("https://vcloud.example.com/api/v1.0/network/1") { instance.href }
+ tests("#name").returns("Network1") { instance.name }
+ tests("#description").returns("Some fancy Network") { instance.description }
+
+ tests("configuration") do
+ tests("parent network").returns("ParentNetwork1") { instance.configuration[:ParentNetwork][:name]}
+ tests("dns").returns("172.0.0.2") { instance.configuration[:IpScope][:Dns1]}
+ end
+ end
+
+ tests("an external network") do
+ instance = Fog::Vcloud::Compute::Network.new(
+ :connection => connection,
+ :collection => Fog::Vcloud::Compute::Networks.new(:connection => connection),
+ :href => "https://vcloud.example.com/api/v1.0/admin/network/2"
+ )
+ instance.reload
+ tests("#href").returns("https://vcloud.example.com/api/v1.0/admin/network/2") { instance.href }
+ tests("#name").returns("ParentNetwork1") { instance.name }
+ tests("#description").returns("Internet Connection") { instance.description }
+
+ tests("configuration") do
+ tests("dns").returns("172.0.0.2") { instance.configuration[:IpScope][:Dns1]}
+ tests("allocated addresses").returns("172.0.0.144") { instance.configuration[:IpScope][:AllocatedIpAddresses][:IpAddress].first }
+ end
+ end
+end
diff --git a/tests/vcloud/models/compute/networks_tests.rb b/tests/vcloud/models/compute/networks_tests.rb
new file mode 100644
index 000000000..2934e207e
--- /dev/null
+++ b/tests/vcloud/models/compute/networks_tests.rb
@@ -0,0 +1,41 @@
+require "#{File.dirname(__FILE__)}/conn_helper.rb"
+
+require 'fog/vcloud/models/compute/networks'
+
+Shindo.tests("Vcloud::Compute | networks", ['vcloud']) do
+ tests("from an org perspective") do
+ instance = Fog::Vcloud::Compute::Networks.new(
+ :connection => Fog::Vcloud::Compute.new(:vcloud_host => 'vcloud.example.com', :vcloud_username => 'username', :vcloud_password => 'password'),
+ :href => "https://vcloud.example.com/api/v1.0/org/1"
+ )
+
+ tests("collection") do
+ returns(2) { instance.size }
+ returns("https://vcloud.example.com/api/v1.0/network/1") { instance.first.href }
+ end
+ end
+
+ tests("from a vdc perspective") do
+ instance = Fog::Vcloud::Compute::Networks.new(
+ :connection => Fog::Vcloud::Compute.new(:vcloud_host => 'vcloud.example.com', :vcloud_username => 'username', :vcloud_password => 'password'),
+ :href => "https://vcloud.example.com/api/v1.0/vdc/1"
+ )
+
+ tests("collection") do
+ returns(2) { instance.size }
+ returns("https://vcloud.example.com/api/v1.0/network/1") { instance.first.href }
+ end
+ end
+
+ tests("from a vapp perspective") do
+ instance = Fog::Vcloud::Compute::Networks.new(
+ :connection => Fog::Vcloud::Compute.new(:vcloud_host => 'vcloud.example.com', :vcloud_username => 'username', :vcloud_password => 'password'),
+ :href => "https://vcloud.example.com/api/v1.0/vApp/vapp-1"
+ )
+
+ tests("collection") do
+ returns(1) { instance.size }
+ returns("https://vcloud.example.com/api/v1.0/network/1") { instance.first.href }
+ end
+ end
+end
diff --git a/tests/vcloud/models/compute/organization_tests.rb b/tests/vcloud/models/compute/organization_tests.rb
new file mode 100644
index 000000000..3e52c691f
--- /dev/null
+++ b/tests/vcloud/models/compute/organization_tests.rb
@@ -0,0 +1,13 @@
+require "#{File.dirname(__FILE__)}/conn_helper.rb"
+
+Shindo.tests("Vcloud::Compute | organization", ['vcloud']) do
+
+ instance = Fog::Vcloud::Compute.new(:vcloud_host => 'vcloud.example.com', :vcloud_username => 'username', :vcloud_password => 'password').organizations.first
+ instance.reload
+
+ tests("#href").returns('https://vcloud.example.com/api/v1.0/org/1'){ instance.href }
+ tests("#name").returns('Org1'){ instance.name }
+ tests("#full_name").returns('My Full Name'){ instance.full_name }
+ tests("#description").returns("Some fancy\n\nDescription"){ instance.description }
+
+end
diff --git a/tests/vcloud/models/compute/organizations_tests.rb b/tests/vcloud/models/compute/organizations_tests.rb
new file mode 100644
index 000000000..a43add568
--- /dev/null
+++ b/tests/vcloud/models/compute/organizations_tests.rb
@@ -0,0 +1,14 @@
+require "#{File.dirname(__FILE__)}/conn_helper.rb"
+
+require 'fog/vcloud/models/compute/organizations'
+
+Shindo.tests("Vcloud::Compute | organizations", ['vcloud']) do
+
+ instance = Fog::Vcloud::Compute.new(:vcloud_host => 'vcloud.example.com', :vcloud_username => 'username', :vcloud_password => 'password').organizations
+
+ tests("collection") do
+ returns(2) { instance.size }
+ returns("https://vcloud.example.com/api/v1.0/org/1") { instance.first.href }
+ end
+
+end
diff --git a/tests/vcloud/models/compute/server_tests.rb b/tests/vcloud/models/compute/server_tests.rb
new file mode 100644
index 000000000..a6c4c955b
--- /dev/null
+++ b/tests/vcloud/models/compute/server_tests.rb
@@ -0,0 +1,131 @@
+require "#{File.dirname(__FILE__)}/conn_helper.rb"
+
+require 'fog/vcloud/models/compute/servers'
+
+Shindo.tests("Vcloud::Compute | server", ['vcloud']) do
+
+ instance = Fog::Vcloud::Compute::Servers.new(
+ :connection => Fog::Vcloud::Compute.new(:vcloud_host => 'vcloud.example.com', :vcloud_username => 'username', :vcloud_password => 'password'),
+ :href => "https://vcloud.example.com/api/v1.0/vApp/vapp-1"
+ ).first
+ instance.reload
+
+ tests("#href").returns("https://vcloud.example.com/api/v1.0/vApp/vm-2") { instance.href }
+ tests("#name").returns("vm2") { instance.name }
+ tests("#description").returns("Some VM Description") { instance.description }
+ tests("#status").returns('8') { instance.status }
+ tests("#deployed").returns(true) { instance.deployed }
+
+ tests("#os_desc").returns("Red Hat Enterprise Linux 5 (64-bit)") { instance.os_desc }
+ tests("#os_type").returns("rhel5_64Guest") { instance.os_type }
+ tests("#computer_name").returns("vm2") { instance.computer_name }
+
+ tests("cpu count").returns(1) { instance.cpus[:count] }
+
+ tests("amount of memory").returns(512){ instance.memory[:amount] }
+
+ tests("#disks") do
+ tests("#size").returns(2){ instance.disks.size }
+ tests("#size").returns(0){ instance.disks.first[:number] }
+ tests("#size").returns(1600){ instance.disks.first[:size] }
+ end
+
+ tests("#vapp_scoped_local_id").returns("vmware_RHEL5-U5-64-small_v02") { instance.vapp_scoped_local_id }
+
+ tests("#friendly_status").returns('off') { instance.friendly_status }
+ tests("#on?").returns(false) { instance.on? }
+ tests("#off?").returns(true) { instance.off? }
+
+
+ #old tests
+ tests("#server.new('#{Vcloud::Compute::TestSupport::template}')").returns(true) do
+ pending if Fog.mocking?
+ @svr = Vcloud.servers.create :catalog_item_uri => Vcloud::Compute::TestSupport::template, :name => 'fog_test_run', :password => 'password'
+ print "Waiting for server to be ready"
+ @svr.wait_for(1200) { print '.' ; ready? }
+ puts ""
+ @svr.ready?
+ end
+
+ tests("#svr.power_on()").returns(true) do
+ pending if Fog.mocking?
+ @svr.power_on
+ @svr.wait_for { on? }
+ @svr.wait_for { ready? }
+ @svr.on?
+ end
+
+ tests("#svr.description(\"testing\")").returns("testing") do
+ pending if Fog.mocking?
+ @svr.wait_for { ready? }
+ @svr.description = "testing"
+ @svr.save
+ @svr.wait_for { ready? }
+ @svr.description
+ end
+
+ # Power off only stops the OS, doesn't free up resources. #undeploy is for this.
+ tests("#svr.undeploy()").returns(true) do
+ pending if Fog.mocking?
+ @svr.undeploy
+ @svr.wait_for { off? }
+ @svr.wait_for { ready? }
+ @svr.off?
+ end
+
+ tests("#svr.memory(384)").returns(384) do
+ pending if Fog.mocking?
+ raise 'Server template memory already 384m - change to something different' if @svr.memory[:amount] == 384
+ @svr.wait_for { ready? }
+ @svr.memory = 384
+ @svr.save
+ @svr.wait_for { ready? }
+ # Can take a little while for the VM to know it has different ram, and not tied to a task..
+ (1..20).each do |i|
+ break if @svr.reload.memory[:amount] == '384'
+ sleep 1
+ end
+ @svr.reload.memory[:amount]
+ end
+
+ tests("#svr.add_disk(4096)").returns([2, "4096"]) do
+ pending if Fog.mocking?
+ raise 'Server template already has two disks' if @svr.disks.size == 2
+ @svr.wait_for { ready? }
+ @svr.add_disk(4096)
+ @svr.save
+ @svr.wait_for { ready? }
+ # Can take a little while for the VM to know it has different ram, and not tied to a task..
+ (1..20).each do |i|
+ break if @svr.reload.disks.size == 2
+ sleep 1
+ end
+ [
+ @svr.disks.size,
+ @svr.disks[1][:resource][:vcloud_capacity]
+ ]
+ end
+
+ tests("#svr.delete_disk(1)").returns(1) do
+ pending if Fog.mocking?
+ raise "Server doesn't have two disks - did previous step fail? " if @svr.disks.size != 2
+ @svr.wait_for { ready? }
+ sleep 5 # otherwise complains about being busy
+ @svr.delete_disk 1
+ @svr.save
+ @svr.wait_for { ready? }
+ # Can take a little while for the VM to know it has different ram, and not tied to a task..
+ (1..20).each do |i|
+ break if @svr.reload.disks.size == 1
+ sleep 1
+ end
+ @svr.disks.size
+ end
+
+ tests("#svr.destroy").raises(Excon::Errors::Forbidden) do
+ pending if Fog.mocking?
+ @svr.destroy
+ sleep 5 # allow cleanup..
+ Vcloud.servers.get(@svr.href) == nil
+ end
+end
diff --git a/tests/vcloud/models/compute/servers_tests.rb b/tests/vcloud/models/compute/servers_tests.rb
index 073f8fba8..2d41a3910 100644
--- a/tests/vcloud/models/compute/servers_tests.rb
+++ b/tests/vcloud/models/compute/servers_tests.rb
@@ -1,95 +1,15 @@
+require "#{File.dirname(__FILE__)}/conn_helper.rb"
+
+require 'fog/vcloud/models/compute/servers'
+
Shindo.tests("Vcloud::Compute | servers", ['vcloud']) do
+ instance = Fog::Vcloud::Compute::Servers.new(
+ :connection => Fog::Vcloud::Compute.new(:vcloud_host => 'vcloud.example.com', :vcloud_username => 'username', :vcloud_password => 'password'),
+ :href => "https://vcloud.example.com/api/v1.0/vApp/vapp-1"
+ )
- tests("#server.new('#{Vcloud::Compute::TestSupport::template}')").returns(true) do
- pending if Fog.mocking?
- @svr = Vcloud.servers.create :catalog_item_uri => Vcloud::Compute::TestSupport::template, :name => 'fog_test_run', :password => 'password'
- print "Waiting for server to be ready"
- @svr.wait_for(1200) { print '.' ; ready? }
- puts ""
- @svr.ready?
+ tests("collection") do
+ returns(2) { instance.size }
+ returns("https://vcloud.example.com/api/v1.0/vApp/vm-2") { instance.first.href }
end
-
- tests("#svr.power_on()").returns(true) do
- pending if Fog.mocking?
- @svr.power_on
- @svr.wait_for { on? }
- @svr.wait_for { ready? }
- @svr.on?
- end
-
- tests("#svr.description(\"testing\")").returns("testing") do
- pending if Fog.mocking?
- @svr.wait_for { ready? }
- @svr.description = "testing"
- @svr.save
- @svr.wait_for { ready? }
- @svr.description
- end
-
- # Power off only stops the OS, doesn't free up resources. #undeploy is for this.
- tests("#svr.undeploy()").returns(true) do
- pending if Fog.mocking?
- @svr.undeploy
- @svr.wait_for { off? }
- @svr.wait_for { ready? }
- @svr.off?
- end
-
- tests("#svr.memory(384)").returns(384) do
- pending if Fog.mocking?
- raise 'Server template memory already 384m - change to something different' if @svr.memory[:amount] == 384
- @svr.wait_for { ready? }
- @svr.memory = 384
- @svr.save
- @svr.wait_for { ready? }
- # Can take a little while for the VM to know it has different ram, and not tied to a task..
- (1..20).each do |i|
- break if @svr.reload.memory[:amount] == '384'
- sleep 1
- end
- @svr.reload.memory[:amount]
- end
-
- tests("#svr.add_disk(4096)").returns([2, "4096"]) do
- pending if Fog.mocking?
- raise 'Server template already has two disks' if @svr.disks.size == 2
- @svr.wait_for { ready? }
- @svr.add_disk(4096)
- @svr.save
- @svr.wait_for { ready? }
- # Can take a little while for the VM to know it has different ram, and not tied to a task..
- (1..20).each do |i|
- break if @svr.reload.disks.size == 2
- sleep 1
- end
- [
- @svr.disks.size,
- @svr.disks[1][:resource][:vcloud_capacity]
- ]
- end
-
- tests("#svr.delete_disk(1)").returns(1) do
- pending if Fog.mocking?
- raise "Server doesn't have two disks - did previous step fail? " if @svr.disks.size != 2
- @svr.wait_for { ready? }
- sleep 5 # otherwise complains about being busy
- @svr.delete_disk 1
- @svr.save
- @svr.wait_for { ready? }
- # Can take a little while for the VM to know it has different ram, and not tied to a task..
- (1..20).each do |i|
- break if @svr.reload.disks.size == 1
- sleep 1
- end
- @svr.disks.size
- end
-
- tests("#svr.destroy").raises(Excon::Errors::Forbidden) do
- pending if Fog.mocking?
- @svr.destroy
- sleep 5 # allow cleanup..
- Vcloud.servers.get(@svr.href) == nil
- end
-
-
end
diff --git a/tests/vcloud/models/compute/vapp_tests.rb b/tests/vcloud/models/compute/vapp_tests.rb
new file mode 100644
index 000000000..49285a69e
--- /dev/null
+++ b/tests/vcloud/models/compute/vapp_tests.rb
@@ -0,0 +1,27 @@
+require "#{File.dirname(__FILE__)}/conn_helper.rb"
+
+require 'fog/vcloud/models/compute/vapps'
+require 'fog/vcloud/models/compute/vapp'
+
+Shindo.tests("Vcloud::Compute | vapp", ['vcloud']) do
+
+ instance = Fog::Vcloud::Compute::Vapps.new(
+ :connection => Fog::Vcloud::Compute.new(:vcloud_host => 'vcloud.example.com', :vcloud_username => 'username', :vcloud_password => 'password'),
+ :href => "https://vcloud.example.com/api/v1.0/vdc/1"
+ ).first
+ instance.reload
+
+ tests("#href").returns("https://vcloud.example.com/api/v1.0/vApp/vapp-1") { instance.href }
+ tests("#name").returns("vApp1") { instance.name }
+ tests("#description").returns("Some Description of a vApp") { instance.description }
+ tests("#status").returns('8') { instance.status }
+ tests("#deployed").returns(true) { instance.deployed }
+
+ tests("#children").returns(2) { instance.children.size }
+ tests("#servers").returns(2) { instance.servers.size }
+
+ tests("#friendly_status").returns('off') { instance.friendly_status }
+ tests("#on?").returns(false) { instance.on? }
+ tests("#off?").returns(true) { instance.off? }
+
+end
diff --git a/tests/vcloud/models/compute/vapps_tests.rb b/tests/vcloud/models/compute/vapps_tests.rb
new file mode 100644
index 000000000..7d1d8e755
--- /dev/null
+++ b/tests/vcloud/models/compute/vapps_tests.rb
@@ -0,0 +1,17 @@
+require "#{File.dirname(__FILE__)}/conn_helper.rb"
+
+require 'fog/vcloud/models/compute/vapps'
+
+Shindo.tests("Vcloud::Compute | vapps", ['vcloud']) do
+
+ instance = Fog::Vcloud::Compute::Vapps.new(
+ :connection => Fog::Vcloud::Compute.new(:vcloud_host => 'vcloud.example.com', :vcloud_username => 'username', :vcloud_password => 'password'),
+ :href => "https://vcloud.example.com/api/v1.0/vdc/1"
+ )
+
+ tests("collection") do
+ returns(2) { instance.size }
+ returns("https://vcloud.example.com/api/v1.0/vApp/vapp-1") { instance.first.href }
+ end
+
+end
diff --git a/tests/vcloud/models/compute/vdc_tests.rb b/tests/vcloud/models/compute/vdc_tests.rb
new file mode 100644
index 000000000..aa4dc7dc7
--- /dev/null
+++ b/tests/vcloud/models/compute/vdc_tests.rb
@@ -0,0 +1,42 @@
+require "#{File.dirname(__FILE__)}/conn_helper.rb"
+
+require 'fog/vcloud/models/compute/vdcs'
+require 'fog/vcloud/models/compute/vdc'
+
+Shindo.tests("Vcloud::Compute | vdc", ['vcloud']) do
+
+ instance = Fog::Vcloud::Compute::Vdcs.new(
+ :connection => Fog::Vcloud::Compute.new(:vcloud_host => 'vcloud.example.com', :vcloud_username => 'username', :vcloud_password => 'password'),
+ :href => "https://vcloud.example.com/api/v1.0/org/1"
+ ).first
+ instance.reload
+
+ tests("#href").returns("https://vcloud.example.com/api/v1.0/vdc/1") { instance.href }
+ tests("#name").returns("vDC1") { instance.name }
+ tests("#description").returns("Some Description") { instance.description }
+ tests("#network_quota").returns(10) { instance.network_quota }
+ tests("#nic_quota").returns(10) { instance.nic_quota }
+ tests("#vm_quota").returns(10) { instance.vm_quota }
+ tests("#is_enabled").returns(true) { instance.is_enabled }
+
+ tests("#available_networks") do
+ tests("#size").returns(2) { instance.available_networks.size }
+ end
+
+ tests("#storage_capacity") do
+ tests("units").returns("MB") { instance.storage_capacity[:Units] }
+ tests("allocated").returns("10240") { instance.storage_capacity[:Allocated] }
+ end
+
+ tests("#compute_capacity") do
+ tests("cpu") do
+ tests("allocated").returns("20000") { instance.compute_capacity[:Cpu][:Allocated] }
+ tests("units").returns("MHz") { instance.compute_capacity[:Cpu][:Units] }
+ end
+ tests("memory") do
+ tests("allocated").returns("1024") { instance.compute_capacity[:Memory][:Allocated] }
+ tests("units").returns("MB") { instance.compute_capacity[:Memory][:Units] }
+ end
+
+ end
+end
diff --git a/tests/vcloud/models/compute/vdcs_tests.rb b/tests/vcloud/models/compute/vdcs_tests.rb
new file mode 100644
index 000000000..fbe0a6bf0
--- /dev/null
+++ b/tests/vcloud/models/compute/vdcs_tests.rb
@@ -0,0 +1,17 @@
+require "#{File.dirname(__FILE__)}/conn_helper.rb"
+
+require 'fog/vcloud/models/compute/vdcs'
+
+Shindo.tests("Vcloud::Compute | vdcs", ['vcloud']) do
+
+ instance = Fog::Vcloud::Compute::Vdcs.new(
+ :connection => Fog::Vcloud::Compute.new(:vcloud_host => 'vcloud.example.com', :vcloud_username => 'username', :vcloud_password => 'password'),
+ :href => "https://vcloud.example.com/api/v1.0/org/1"
+ )
+
+ tests("collection") do
+ returns(1) { instance.size }
+ returns("https://vcloud.example.com/api/v1.0/vdc/1") { instance.first.href }
+ end
+
+end