fog 0.3.16 → 0.3.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. data/Gemfile.lock +1 -1
  2. data/README.rdoc +17 -12
  3. data/fog.gemspec +10 -5
  4. data/lib/fog.rb +1 -1
  5. data/lib/fog/aws/models/storage/directory.rb +22 -0
  6. data/lib/fog/aws/models/storage/file.rb +15 -0
  7. data/lib/fog/aws/storage.rb +8 -0
  8. data/lib/fog/core/collection.rb +9 -8
  9. data/lib/fog/core/compute.rb +1 -1
  10. data/lib/fog/google/models/storage/directory.rb +23 -1
  11. data/lib/fog/google/models/storage/file.rb +16 -1
  12. data/lib/fog/google/parsers/storage/access_control_list.rb +16 -14
  13. data/lib/fog/local/models/storage/directory.rb +8 -0
  14. data/lib/fog/local/models/storage/file.rb +4 -0
  15. data/lib/fog/rackspace/cdn.rb +3 -3
  16. data/lib/fog/rackspace/models/storage/directory.rb +18 -0
  17. data/lib/fog/rackspace/models/storage/file.rb +7 -0
  18. data/lib/fog/rackspace/requests/cdn/{get_cdn_containers.rb → get_containers.rb} +3 -3
  19. data/lib/fog/rackspace/requests/cdn/{head_cdn_container.rb → head_container.rb} +3 -3
  20. data/lib/fog/rackspace/requests/cdn/{put_cdn_container.rb → put_container.rb} +3 -3
  21. data/lib/fog/rackspace/storage.rb +10 -0
  22. data/lib/fog/vcloud.rb +32 -153
  23. data/lib/fog/vcloud/collection.rb +18 -0
  24. data/lib/fog/vcloud/mock_data_classes.rb +701 -0
  25. data/lib/fog/vcloud/requests/get_network.rb +8 -8
  26. data/lib/fog/vcloud/requests/get_organization.rb +10 -10
  27. data/lib/fog/vcloud/requests/get_vdc.rb +18 -18
  28. data/lib/fog/vcloud/requests/get_versions.rb +3 -3
  29. data/lib/fog/vcloud/requests/login.rb +2 -2
  30. data/lib/fog/vcloud/terremark/ecloud.rb +65 -109
  31. data/lib/fog/vcloud/terremark/ecloud/models/catalog.rb +1 -0
  32. data/lib/fog/vcloud/terremark/ecloud/models/firewall_acls.rb +1 -0
  33. data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +1 -0
  34. data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +1 -1
  35. data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +1 -0
  36. data/lib/fog/vcloud/terremark/ecloud/models/network.rb +3 -2
  37. data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +1 -0
  38. data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +1 -0
  39. data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +1 -0
  40. data/lib/fog/vcloud/terremark/ecloud/models/server.rb +20 -8
  41. data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +1 -0
  42. data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +1 -0
  43. data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +2 -0
  44. data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +4 -8
  45. data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +4 -7
  46. data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +18 -20
  47. data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +6 -7
  48. data/lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb +40 -9
  49. data/lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb +2 -10
  50. data/lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb +2 -6
  51. data/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +13 -1
  52. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +6 -6
  53. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +6 -7
  54. data/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +34 -33
  55. data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +23 -24
  56. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +10 -13
  57. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +15 -19
  58. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +20 -22
  59. data/lib/fog/vcloud/terremark/ecloud/requests/get_node.rb +12 -15
  60. data/lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb +11 -12
  61. data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb +5 -4
  62. data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb +9 -8
  63. data/lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb +33 -17
  64. data/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb +54 -53
  65. data/lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb +13 -19
  66. data/lib/fog/vcloud/terremark/ecloud/requests/power_off.rb +9 -2
  67. data/lib/fog/vcloud/terremark/ecloud/requests/power_on.rb +2 -4
  68. data/spec/vcloud/bin_spec.rb +3 -6
  69. data/spec/vcloud/models/vdc_spec.rb +8 -8
  70. data/spec/vcloud/requests/get_network_spec.rb +8 -8
  71. data/spec/vcloud/requests/get_organization_spec.rb +9 -9
  72. data/spec/vcloud/requests/get_vdc_spec.rb +7 -7
  73. data/spec/vcloud/requests/get_versions_spec.rb +1 -1
  74. data/spec/vcloud/requests/login_spec.rb +2 -2
  75. data/spec/vcloud/spec_helper.rb +45 -30
  76. data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +10 -14
  77. data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +5 -8
  78. data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +2 -2
  79. data/spec/vcloud/terremark/ecloud/models/network_spec.rb +15 -16
  80. data/spec/vcloud/terremark/ecloud/models/node_spec.rb +7 -7
  81. data/spec/vcloud/terremark/ecloud/models/nodes_spec.rb +1 -1
  82. data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +4 -8
  83. data/spec/vcloud/terremark/ecloud/models/server_spec.rb +42 -0
  84. data/spec/vcloud/terremark/ecloud/models/vdc_spec.rb +7 -7
  85. data/spec/vcloud/terremark/ecloud/models/vdcs_spec.rb +1 -1
  86. data/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb +13 -18
  87. data/spec/vcloud/terremark/ecloud/requests/add_node_spec.rb +9 -5
  88. data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +5 -7
  89. data/spec/vcloud/terremark/ecloud/requests/configure_node_spec.rb +22 -28
  90. data/spec/vcloud/terremark/ecloud/requests/configure_vapp_spec.rb +71 -0
  91. data/spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb +7 -9
  92. data/spec/vcloud/terremark/ecloud/requests/delete_node_spec.rb +3 -7
  93. data/spec/vcloud/terremark/ecloud/requests/delete_vapp_spec.rb +83 -0
  94. data/spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb +6 -5
  95. data/spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb +2 -2
  96. data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +31 -42
  97. data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +4 -7
  98. data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +1 -1
  99. data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +19 -11
  100. data/spec/vcloud/terremark/ecloud/requests/get_node_spec.rb +8 -8
  101. data/spec/vcloud/terremark/ecloud/requests/get_nodes_spec.rb +11 -11
  102. data/spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb +4 -5
  103. data/spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb +6 -6
  104. data/spec/vcloud/terremark/ecloud/requests/get_vapp_spec.rb +36 -19
  105. data/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +21 -18
  106. data/spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb +27 -17
  107. data/spec/vcloud/terremark/ecloud/requests/power_off_spec.rb +34 -0
  108. data/spec/vcloud/terremark/ecloud/requests/power_on_spec.rb +3 -4
  109. data/spec/vcloud/vcloud_spec.rb +2 -2
  110. data/tests/helpers/storage/directory_tests.rb +8 -0
  111. data/tests/helpers/storage/file_tests.rb +4 -0
  112. metadata +11 -6
@@ -18,19 +18,19 @@ module Fog
18
18
  network_uri = ensure_unparsed(network_uri)
19
19
  type = "application/vnd.vmware.vcloud.network+xml"
20
20
  response = Excon::Response.new
21
- if network = mock_data[:organizations].map { |org| org[:vdcs].map { |vdc| vdc[:networks] } }.flatten.detect { |network| network[:href] == network_uri.to_s }
21
+ if network = mock_data.organizations.map { |org| org.vdcs.map { |vdc| vdc.networks } }.flatten.detect { |network| network.href == network_uri.to_s }
22
22
  xml = Builder::XmlMarkup.new
23
23
  mock_it 200,
24
- xml.Network(xmlns.merge(:href => network[:href], :name => network[:name], :type => type)) {
25
- xml.Description(network[:name])
24
+ xml.Network(xmlns.merge(:href => network.href, :name => network.name, :type => type)) {
25
+ xml.Description(network.name)
26
26
  xml.Configuration {
27
- xml.Gateway(network[:gateway])
28
- xml.Netmask(network[:netmask])
29
- xml.Dns(network[:dns])
27
+ xml.Gateway(network.gateway)
28
+ xml.Netmask(network.netmask)
29
+ xml.Dns(network.dns)
30
30
  }
31
- if network[:features]
31
+ if network.features
32
32
  xml.Features {
33
- if feature = network[:features].detect { |feature| feature[:type] == :fencemode }
33
+ if feature = network.features.detect { |feature| feature[:type] == :FenceMode }
34
34
  xml.FenceMode(feature[:value])
35
35
  end
36
36
  }
@@ -11,29 +11,29 @@ module Fog
11
11
  #
12
12
  # Based off of:
13
13
  # http://support.theenterprisecloud.com/kb/default.asp?id=540&Lang=1&SID=
14
- #
14
+ #
15
15
  # vCloud API Guide v0.9 - Page 26
16
16
  #
17
17
  organization_uri = ensure_unparsed(organization_uri)
18
- if org = mock_data[:organizations].detect { |org| org[:info][:href] == organization_uri }
18
+ if organization = mock_data.organization_from_href(organization_uri)
19
19
  xml = Builder::XmlMarkup.new
20
20
 
21
21
  mock_it 200,
22
- xml.Org(xmlns.merge(:href => org[:info][:href], :name => org[:info][:name])) {
22
+ xml.Org(xmlns.merge(:href => organization.href, :name => organization.name)) {
23
23
 
24
- org[:vdcs].each do |vdc|
24
+ organization.vdcs.each do |vdc|
25
25
  xml.Link(:rel => "down",
26
- :href => vdc[:href],
26
+ :href => vdc.href,
27
27
  :type => "application/vnd.vmware.vcloud.vdc+xml",
28
- :name => vdc[:name])
28
+ :name => vdc.name)
29
29
  xml.Link(:rel => "down",
30
- :href => "#{vdc[:href]}/catalog",
30
+ :href => vdc.catalog.href,
31
31
  :type => "application/vnd.vmware.vcloud.catalog+xml",
32
- :name => "#{vdc[:name]} Catalog")
32
+ :name => vdc.catalog.name)
33
33
  xml.Link(:rel => "down",
34
- :href => "#{vdc[:href]}/tasksList",
34
+ :href => vdc.task_list.href,
35
35
  :type => "application/vnd.vmware.vcloud.tasksList+xml",
36
- :name => "#{vdc[:name]} Tasks List")
36
+ :name => vdc.task_list.name)
37
37
  end
38
38
  },
39
39
  {'Content-Type' => "application/vnd.vmware.vcloud.org+xml" }
@@ -12,59 +12,59 @@ module Fog
12
12
 
13
13
  def get_vdc(vdc_uri)
14
14
  vdc_uri = ensure_unparsed(vdc_uri)
15
- if vdc = mock_data[:organizations].map { |org| org[:vdcs] }.flatten.detect { |vdc| vdc[:href] == vdc_uri }
15
+ if vdc = mock_data.organizations.map { |org| org.vdcs }.flatten.detect { |vdc| vdc.href == vdc_uri }
16
16
  xml = Builder::XmlMarkup.new
17
17
  mock_it 200,
18
- xml.Vdc(xmlns.merge(:href => vdc[:href], :name => vdc[:name])) {
18
+ xml.Vdc(xmlns.merge(:href => vdc.href, :name => vdc.name)) {
19
19
  xml.Link(:rel => "up",
20
- :href => Fog::Vcloud::Mock.data[:organizations].detect { |org| org[:vdcs].detect { |_vdc| vdc[:href] == _vdc[:href] }[:href] == vdc[:href] }[:info][:href],
20
+ :href => mock_data.organizations.detect { |org| org.vdcs.detect { |_vdc| vdc.href == _vdc.href }.href == vdc.href }.href,
21
21
  :type => "application/vnd.vmware.vcloud.org+xml")
22
22
  xml.Link(:rel => "add",
23
- :href => vdc[:href] + "/action/uploadVAppTemplate",
23
+ :href => vdc.href + "/action/uploadVAppTemplate",
24
24
  :type => "application/vnd.vmware.vcloud.uploadVAppTemplateParams+xml")
25
25
  xml.Link(:rel => "add",
26
- :href => vdc[:href] + "/media",
26
+ :href => vdc.href + "/media",
27
27
  :type => "application/vnd.vmware.vcloud.media+xml")
28
28
  xml.Link(:rel => "add",
29
- :href => vdc[:href] + "/action/instantiateVAppTemplate",
29
+ :href => vdc.href + "/action/instantiateVAppTemplate",
30
30
  :type => "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml")
31
31
  xml.Link(:rel => "add",
32
32
  :type => "application/vnd.vmware.vcloud.cloneVAppParams+xml",
33
- :href => vdc[:href] + "/action/cloneVApp")
33
+ :href => vdc.href + "/action/cloneVApp")
34
34
  xml.Link(:rel => "add",
35
35
  :type => "application/vnd.vmware.vcloud.captureVAppParams+xml",
36
- :href => vdc[:href] + "/action/captureVApp")
36
+ :href => vdc.href + "/action/captureVApp")
37
37
  xml.Link(:rel => "add",
38
38
  :type => "application/vnd.vmware.vcloud.composeVAppParams+xml",
39
- :href => vdc[:href] + "/action/composeVApp")
39
+ :href => vdc.href + "/action/composeVApp")
40
40
  xml.AllocationModel("AllocationPool")
41
41
  xml.Description(vdc[:name] + " VDC")
42
42
  xml.ResourceEntities {
43
- Fog::Vcloud::Mock.data[:vdc_resources].each do |resource|
43
+ mock_data.organizations.first.vdcs.first.virtual_machines.each do |resource|
44
44
  xml.ResourceEntity(resource)
45
45
  end
46
46
  }
47
47
  xml.AvailableNetworks {
48
- vdc[:networks].each do |network|
49
- xml.Network( :name => network[:name], :href => network[:href], :type => "application/vnd.vmware.vcloud.network+xml" )
48
+ vdc.networks.each do |network|
49
+ xml.Network( :name => network.name, :href => network.href, :type => "application/vnd.vmware.vcloud.network+xml" )
50
50
  end
51
51
  }
52
52
  xml.ComputeCapacity{
53
53
  xml.Cpu {
54
54
  xml.Units("Mhz")
55
- xml.Allocated(vdc[:cpu][:allocated])
56
- xml.Limit(vdc[:cpu][:allocated])
55
+ xml.Allocated(vdc.cpu_allocated)
56
+ xml.Limit(vdc.cpu_allocated)
57
57
  }
58
58
  xml.Memory {
59
59
  xml.Units("MB")
60
- xml.Allocated(vdc[:memory][:allocated])
61
- xml.Limit(vdc[:memory][:allocated])
60
+ xml.Allocated(vdc.memory_allocated)
61
+ xml.Limit(vdc.memory_allocated)
62
62
  }
63
63
  }
64
64
  xml.StorageCapacity{
65
65
  xml.Units("MB")
66
- xml.Allocated(vdc[:storage][:allocated])
67
- xml.Limit(vdc[:storage][:allocated])
66
+ xml.Allocated(vdc.storage_allocated)
67
+ xml.Limit(vdc.storage_allocated)
68
68
  }
69
69
  xml.VmQuota(0)
70
70
  xml.NicQuota(0)
@@ -19,10 +19,10 @@ module Fog
19
19
  mock_it 200,
20
20
  xml.SupportedVersions( xmlns.merge("xmlns" => "http://www.vmware.com/vcloud/versions")) {
21
21
 
22
- mock_data[:versions].select {|version| version[:supported] }.each do |version|
22
+ mock_data.versions.select {|version| version.supported }.each do |version|
23
23
  xml.VersionInfo {
24
- xml.Version(version[:version])
25
- xml.LoginUrl(version[:login_url])
24
+ xml.Version(version.version)
25
+ xml.LoginUrl(version.login_url)
26
26
  }
27
27
  end
28
28
  }
@@ -31,8 +31,8 @@ module Fog
31
31
 
32
32
  mock_it 200,
33
33
  xml.OrgList(xmlns) {
34
- mock_data[:organizations].each do |org|
35
- xml.Org( :type => "application/vnd.vmware.vcloud.org+xml", :href => org[:info][:href], :name => org[:info][:name] )
34
+ mock_data.organizations.each do |organization|
35
+ xml.Org( :type => "application/vnd.vmware.vcloud.org+xml", :href => organization.href, :name => organization.name )
36
36
  end
37
37
  },
38
38
  { 'Set-Cookie' => 'vcloud-token=fc020a05-21d7-4f33-9b2a-25d8cd05a44e; path=/',
@@ -76,125 +76,81 @@ module Fog
76
76
  Fog::Vcloud::Mock.data_reset
77
77
  end
78
78
 
79
- def self.extension_url
80
- self.base_url + "/extensions"
81
- end
82
-
83
79
  def self.data( base_url = self.base_url )
84
- @mock_data ||= begin
85
- vcloud_data = Fog::Vcloud::Mock.data(base_url)
86
- vcloud_data.delete( :versions )
87
- vcloud_data.merge!( :versions => [ { :version => "v0.8b-ext2.3", :login_url => "#{base_url}/login", :supported => true } ] )
88
-
89
- vcloud_data[:organizations][0][:vdcs][0][:public_ips] =
90
- [
91
- { :id => "51",
92
- :href => extension_url + "/publicIp/51",
93
- :name => "99.1.2.3",
94
- :services => [
95
- { :id => "71", :href => extension_url + "/internetService/71", :port => "80", :protocol => 'HTTP', :enabled => "true",
96
- :timeout => "2", :name => 'Web Site', :description => 'Web Servers', :redirect_url => 'http://fakey.com',
97
- :nodes => [ {:id => "81", :href => extension_url + "/nodeService/81", :ip_address => "1.2.3.5",
98
- :name => "Test Node 1", :port => "80", :enabled => "true", :description => "web 1" },
99
- {:id => "82", :href => extension_url + "/nodeService/82", :ip_address => "1.2.3.6",
100
- :name => "Test Node 2", :port => "80", :enabled => "true", :description => "web 2" },
101
- ] },
102
- { :id => "72", :href => extension_url + "/internetService/72", :port => "7000", :protocol => 'HTTP', :enabled => "true",
103
- :timeout => "2", :name => 'An SSH Map', :description => 'SSH 1', :redirect_url => '',
104
- :nodes => [ {:id => "83", :href => extension_url + "/nodeService/83", :ip_address => "1.2.3.5",
105
- :name => "SSH", :port => "22", :enabled => "true", :description => "web ssh" }
106
- ] }
107
- ]
108
- },
109
- { :id => "52",
110
- :href => extension_url + "/publicIp/52",
111
- :name => "99.1.2.4",
112
- :services => [
113
- { :id => "73", :href => extension_url + "/internetService/73", :port => "80", :protocol => 'HTTP', :enabled => "true",
114
- :timeout => "2", :name => 'Web Site', :description => 'Web Servers', :redirect_url => 'http://fakey.com',
115
- :nodes => [] },
116
- { :id => "74", :href => extension_url + "/internetService/74", :port => "7000", :protocol => 'HTTP', :enabled => "true",
117
- :timeout => "2", :name => 'An SSH Map', :description => 'SSH 2', :redirect_url => '',
118
- :nodes => [] }
119
- ]
120
- },
121
- { :id => "53",
122
- :href => extension_url + "/publicIp/53",
123
- :name => "99.1.9.7",
124
- :services => []
125
- }
126
- ]
127
-
128
- vcloud_data[:organizations][0][:vdcs][1][:public_ips] =
129
- [
130
- { :id => "54",
131
- :href => extension_url + "/publicIp/54",
132
- :name => "99.99.99.99",
133
- :services => []
134
- }
135
- ]
136
-
137
- vcloud_data[:organizations].each do |organization|
138
- organization[:info][:extension_href] = extension_url
139
- organization[:vdcs].each do | vdc|
140
- vdc[:extension_href] = "#{base_url}/extensions/vdc/#{vdc[:id]}"
141
- vdc[:networks].each do |network|
142
- network[:extension_href] = "#{extension_url}/network/#{network[:id]}"
143
- network[:rnat] = vdc[:public_ips].first[:name]
80
+ @mock_data ||= Fog::Vcloud::Mock.data(base_url).tap do |vcloud_mock_data|
81
+ vcloud_mock_data.versions.clear
82
+ vcloud_mock_data.versions << MockVersion.new(:version => "v0.8b-ext2.3")
83
+
84
+ vcloud_mock_data.organizations.detect {|o| o.name == "Boom Inc." }.tap do |mock_organization|
85
+ mock_organization.vdcs.detect {|v| v.name == "Boomstick" }.tap do |mock_vdc|
86
+ mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.1.2.3").tap do |mock_public_ip|
87
+ mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({
88
+ :protocol => "HTTP",
89
+ :port => 80,
90
+ :name => "Web Site",
91
+ :description => "Web Servers",
92
+ :redirect_url => "http://fakey.com"
93
+ }, mock_public_ip.internet_service_collection
94
+ ).tap do |mock_public_ip_service|
95
+ mock_public_ip_service.node_collection.items << MockPublicIpInternetServiceNode.new({:ip_address => "1.2.3.5", :name => "Test Node 1", :description => "web 1"}, mock_public_ip_service.node_collection)
96
+ mock_public_ip_service.node_collection.items << MockPublicIpInternetServiceNode.new({:ip_address => "1.2.3.6", :name => "Test Node 2", :description => "web 2"}, mock_public_ip_service.node_collection)
97
+ mock_public_ip_service.node_collection.items << MockPublicIpInternetServiceNode.new({:ip_address => "1.2.3.7", :name => "Test Node 3", :description => "web 3"}, mock_public_ip_service.node_collection)
98
+ end
99
+
100
+ mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({
101
+ :protocol => "TCP",
102
+ :port => 7000,
103
+ :name => "An SSH Map",
104
+ :description => "SSH 1"
105
+ }, mock_public_ip.internet_service_collection
106
+ ).tap do |mock_public_ip_service|
107
+ mock_public_ip_service.node_collection.items << MockPublicIpInternetServiceNode.new({ :ip_address => "1.2.3.5", :port => 22, :name => "SSH", :description => "web ssh" }, mock_public_ip_service.node_collection)
108
+ end
144
109
  end
145
- end
146
- end
147
-
148
- vcloud_data
149
- end
150
- end
151
-
152
- def self.public_ip_href(ip)
153
- "#{base_url}/extensions/publicIp/#{ip[:id]}"
154
- end
155
-
156
- def self.internet_service_href(internet_service)
157
- "#{base_url}/extensions/internetService/#{internet_service[:id]}"
158
- end
159
-
160
- def self.vapp_href(options)
161
- "#{base_url}/vapp/#{options[:id]}"
162
- end
163
-
164
- def self.vapp_template_href(options)
165
- "#{base_url}/vappTemplate/#{options[:id]}"
166
- end
167
110
 
168
- def self.catalog_item_customization_href(options)
169
- "#{base_url}/extensions/template/#{options[:id]}/options/customization"
170
- end
111
+ mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.1.2.4").tap do |mock_public_ip|
112
+ mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({
113
+ :protocol => "HTTP",
114
+ :port => 80,
115
+ :name => "Web Site",
116
+ :description => "Web Servers",
117
+ :redirect_url => "http://fakey.com"
118
+ }, mock_public_ip.internet_service_collection
119
+ )
120
+
121
+ mock_public_ip.internet_service_collection.items << MockPublicIpInternetService.new({
122
+ :protocol => "TCP",
123
+ :port => 7000,
124
+ :name => "An SSH Map",
125
+ :description => "SSH 2"
126
+ }, mock_public_ip.internet_service_collection
127
+ )
128
+ end
171
129
 
172
- def ecloud_xmlns
173
- { :xmlns => "urn:tmrk:eCloudExtensions-2.3", :"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance" }
174
- end
130
+ mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.1.9.7")
131
+ end
175
132
 
176
- def mock_ip_from_service_url(uri)
177
- mock_data[:organizations].map { |org| org[:vdcs] }.flatten.map { |vdc| vdc[:public_ips] }.flatten.compact.detect { |pip| pip[:services].detect { |service| service[:href] == uri } }
178
- end
133
+ mock_organization.vdcs.detect {|v| v.name == "Rock-n-Roll" }.tap do |mock_vdc|
134
+ mock_vdc.public_ip_collection.items << MockPublicIp.new(:name => "99.99.99.99")
135
+ end
136
+ end
179
137
 
180
- def mock_ip_and_service_from_service_url(uri)
181
- if ip = mock_data[:organizations].map { |org| org[:vdcs] }.flatten.map { |vdc| vdc[:public_ips] }.flatten.compact.detect { |pip| pip[:services].detect { |service| service[:href] == uri } }
182
- if desired_service = ip[:services].detect { |service| service[:href] == uri }
183
- [ip, desired_service]
184
- else
185
- [ip, nil]
138
+ vcloud_mock_data.organizations.each do |organization|
139
+ organization.vdcs.each do |vdc|
140
+ vdc.networks.each do |network|
141
+ network[:rnat] = vdc.public_ip_collection.items.first.name
142
+ end
143
+ vdc.virtual_machines.each do |virtual_machine|
144
+ virtual_machine.disks << MockVirtualMachineDisk.new(:size => 25 * 1024)
145
+ virtual_machine.disks << MockVirtualMachineDisk.new(:size => 50 * 1024)
146
+ end
147
+ end
186
148
  end
187
- else
188
- [nil, nil]
189
149
  end
190
150
  end
191
151
 
192
- def mock_node_from_url(uri)
193
- mock_data[:organizations].map { |org| org[:vdcs] }.flatten.map { |vdc| vdc[:public_ips] }.flatten.map { |pip| pip[:services] }.flatten.map { |service| service[:nodes] }.flatten.detect { |node| node[:href] == uri }
194
- end
195
-
196
- def mock_service_from_node_url(uri)
197
- mock_data[:organizations].map { |org| org[:vdcs] }.flatten.map { |vdc| vdc[:public_ips] }.flatten.map { |pip| pip[:services] }.flatten.map { |service| service }.detect {|service| service[:nodes].map { |node| node[:href] }.include?(uri) }
152
+ def ecloud_xmlns
153
+ { :xmlns => "urn:tmrk:eCloudExtensions-2.3", :"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance" }
198
154
  end
199
155
 
200
156
  def mock_data
@@ -10,6 +10,7 @@ module Fog
10
10
  attribute :href, :aliases => :Href
11
11
 
12
12
  def all
13
+ check_href!
13
14
  if data = connection.get_catalog(href).body[:CatalogItems][:CatalogItem]
14
15
  load(data)
15
16
  end
@@ -12,6 +12,7 @@ module Fog
12
12
  attribute :href, :aliases => :Href
13
13
 
14
14
  def all
15
+ check_href! :message => "the Firewall ACL href for the network you want to enumerate"
15
16
  if data = connection.get_firewall_acls(href).body[:FirewallAcl]
16
17
  data = [ data ] if data.is_a?(Hash)
17
18
  load(data)
@@ -12,6 +12,7 @@ module Fog
12
12
  attribute :href, :aliases => :Href
13
13
 
14
14
  def all
15
+ check_href! :message => "the Internet Services for the Vdc you want to enumerate"
15
16
  if data = connection.get_internet_services(href).body[:InternetService]
16
17
  load(data)
17
18
  end
@@ -29,7 +29,7 @@ module Fog
29
29
  def reload
30
30
  super
31
31
  @changed = false
32
- true
32
+ self
33
33
  end
34
34
 
35
35
  private
@@ -14,6 +14,7 @@ module Fog
14
14
  attribute :href
15
15
 
16
16
  def all
17
+ check_href!( :messages => "Ips href of a Network you want to enumerate" )
17
18
  if data = connection.get_network_ips(href).body[:IpAddress]
18
19
  load(data)
19
20
  end
@@ -6,10 +6,10 @@ module Fog
6
6
 
7
7
  identity :href
8
8
 
9
- ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i, :Configuration
9
+ ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i, :Configuration, :Id
10
10
 
11
11
  attribute :name, :aliases => :Name
12
- attribute :id, :aliases => :Id
12
+ #attribute :id, :aliases => :Id
13
13
  attribute :features, :aliases => :Features, :type => :array
14
14
  attribute :links, :aliases => :Link, :type => :array
15
15
  attribute :type
@@ -41,6 +41,7 @@ module Fog
41
41
  def reload
42
42
  super
43
43
  merge_attributes(extension_data.body)
44
+ self
44
45
  end
45
46
 
46
47
  private
@@ -14,6 +14,7 @@ module Fog
14
14
  attribute :href
15
15
 
16
16
  def all
17
+ check_href!("Vdc")
17
18
  if data = connection.get_vdc(href).body[:AvailableNetworks][:Network]
18
19
  load(data)
19
20
  end
@@ -12,6 +12,7 @@ module Fog
12
12
  attribute :href, :aliases => :Href
13
13
 
14
14
  def all
15
+ check_href!( :messages => "the Nodes href of the Internet Service you want to enumerate" )
15
16
  if data = connection.get_nodes(href).body[:NodeService]
16
17
  load(data)
17
18
  end