fog-terremark 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.rubocop.yml +20 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +17 -0
  7. data/CONTRIBUTING.md +18 -0
  8. data/CONTRIBUTORS.md +10 -0
  9. data/Gemfile +4 -0
  10. data/LICENSE.md +20 -0
  11. data/README.md +36 -0
  12. data/Rakefile +11 -0
  13. data/fog-terremark.gemspec +34 -0
  14. data/gemfiles/Gemfile.1.9.2- +8 -0
  15. data/gemfiles/Gemfile.1.9.3+ +7 -0
  16. data/lib/fog/compute/terremark.rb +62 -0
  17. data/lib/fog/compute/terremark/common.rb +18 -0
  18. data/lib/fog/compute/terremark/mock.rb +144 -0
  19. data/lib/fog/compute/terremark/models/address.rb +23 -0
  20. data/lib/fog/compute/terremark/models/addresses.rb +33 -0
  21. data/lib/fog/compute/terremark/models/image.rb +17 -0
  22. data/lib/fog/compute/terremark/models/images.rb +26 -0
  23. data/lib/fog/compute/terremark/models/internetservice.rb +60 -0
  24. data/lib/fog/compute/terremark/models/internetservices.rb +24 -0
  25. data/lib/fog/compute/terremark/models/network.rb +29 -0
  26. data/lib/fog/compute/terremark/models/networks.rb +37 -0
  27. data/lib/fog/compute/terremark/models/nodeservice.rb +44 -0
  28. data/lib/fog/compute/terremark/models/nodeservices.rb +14 -0
  29. data/lib/fog/compute/terremark/models/server.rb +201 -0
  30. data/lib/fog/compute/terremark/models/servers.rb +35 -0
  31. data/lib/fog/compute/terremark/models/task.rb +44 -0
  32. data/lib/fog/compute/terremark/models/tasks.rb +41 -0
  33. data/lib/fog/compute/terremark/models/vdc.rb +39 -0
  34. data/lib/fog/compute/terremark/models/vdcs.rb +36 -0
  35. data/lib/fog/compute/terremark/parser.rb +16 -0
  36. data/lib/fog/compute/terremark/real.rb +67 -0
  37. data/lib/fog/compute/terremark/requests/add_internet_service.rb +54 -0
  38. data/lib/fog/compute/terremark/requests/add_node_service.rb +51 -0
  39. data/lib/fog/compute/terremark/requests/configure_vapp.rb +58 -0
  40. data/lib/fog/compute/terremark/requests/create_internet_service.rb +57 -0
  41. data/lib/fog/compute/terremark/requests/delete_internet_service.rb +21 -0
  42. data/lib/fog/compute/terremark/requests/delete_node_service.rb +21 -0
  43. data/lib/fog/compute/terremark/requests/delete_public_ip.rb +21 -0
  44. data/lib/fog/compute/terremark/requests/delete_vapp.rb +20 -0
  45. data/lib/fog/compute/terremark/requests/deploy_vapp.rb +33 -0
  46. data/lib/fog/compute/terremark/requests/get_catalog.rb +30 -0
  47. data/lib/fog/compute/terremark/requests/get_catalog_item.rb +33 -0
  48. data/lib/fog/compute/terremark/requests/get_internet_services.rb +32 -0
  49. data/lib/fog/compute/terremark/requests/get_keys_list.rb +32 -0
  50. data/lib/fog/compute/terremark/requests/get_network.rb +70 -0
  51. data/lib/fog/compute/terremark/requests/get_network_ips.rb +29 -0
  52. data/lib/fog/compute/terremark/requests/get_node_services.rb +29 -0
  53. data/lib/fog/compute/terremark/requests/get_organization.rb +89 -0
  54. data/lib/fog/compute/terremark/requests/get_organizations.rb +45 -0
  55. data/lib/fog/compute/terremark/requests/get_public_ip.rb +31 -0
  56. data/lib/fog/compute/terremark/requests/get_public_ips.rb +69 -0
  57. data/lib/fog/compute/terremark/requests/get_task.rb +37 -0
  58. data/lib/fog/compute/terremark/requests/get_tasks_list.rb +30 -0
  59. data/lib/fog/compute/terremark/requests/get_vapp.rb +40 -0
  60. data/lib/fog/compute/terremark/requests/get_vapp_template.rb +33 -0
  61. data/lib/fog/compute/terremark/requests/get_vdc.rb +153 -0
  62. data/lib/fog/compute/terremark/requests/instantiate_vapp_template.rb +75 -0
  63. data/lib/fog/compute/terremark/requests/power_off.rb +33 -0
  64. data/lib/fog/compute/terremark/requests/power_on.rb +33 -0
  65. data/lib/fog/compute/terremark/requests/power_reset.rb +33 -0
  66. data/lib/fog/compute/terremark/requests/power_shutdown.rb +22 -0
  67. data/lib/fog/parsers/terremark.rb +26 -0
  68. data/lib/fog/parsers/terremark/base.rb +23 -0
  69. data/lib/fog/parsers/terremark/get_catalog.rb +31 -0
  70. data/lib/fog/parsers/terremark/get_catalog_item.rb +30 -0
  71. data/lib/fog/parsers/terremark/get_internet_services.rb +55 -0
  72. data/lib/fog/parsers/terremark/get_keys_list.rb +36 -0
  73. data/lib/fog/parsers/terremark/get_network_ips.rb +22 -0
  74. data/lib/fog/parsers/terremark/get_node_services.rb +30 -0
  75. data/lib/fog/parsers/terremark/get_organization.rb +46 -0
  76. data/lib/fog/parsers/terremark/get_organizations.rb +27 -0
  77. data/lib/fog/parsers/terremark/get_public_ips.rb +24 -0
  78. data/lib/fog/parsers/terremark/get_tasks_list.rb +33 -0
  79. data/lib/fog/parsers/terremark/get_vapp_template.rb +29 -0
  80. data/lib/fog/parsers/terremark/get_vdc.rb +85 -0
  81. data/lib/fog/parsers/terremark/instantiate_vapp_template.rb +24 -0
  82. data/lib/fog/parsers/terremark/internet_service.rb +56 -0
  83. data/lib/fog/parsers/terremark/network.rb +37 -0
  84. data/lib/fog/parsers/terremark/node_service.rb +26 -0
  85. data/lib/fog/parsers/terremark/public_ip.rb +20 -0
  86. data/lib/fog/parsers/terremark/task.rb +23 -0
  87. data/lib/fog/parsers/terremark/vapp.rb +59 -0
  88. data/lib/fog/terremark.rb +17 -0
  89. data/lib/fog/terremark/vcloud.rb +27 -0
  90. data/lib/fog/terremark/vcloud/mock.rb +24 -0
  91. data/lib/fog/terremark/vcloud/real.rb +66 -0
  92. data/lib/fog/terremark/version.rb +5 -0
  93. data/spec/minitest_helper.rb +31 -0
  94. metadata +251 -0
@@ -0,0 +1,89 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get details of an organization
6
+ #
7
+ # ==== Parameters
8
+ # * organization_id<~Integer> - Id of organization to lookup
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * 'description'<~String> - Description of organization
14
+ # * 'links'<~Array> - An array of links to entities in the organization
15
+ # * 'href'<~String> - location of link
16
+ # * 'name'<~String> - name of link
17
+ # * 'rel'<~String> - action to perform
18
+ # * 'type'<~String> - type of link
19
+ # * 'name'<~String> - Name of organization
20
+ def get_organization(organization_id)
21
+ response = request(
22
+ :expects => 200,
23
+ :method => 'GET',
24
+ :parser => Fog::Parsers::Terremark::GetOrganization.new,
25
+ :path => "org/#{organization_id}"
26
+ )
27
+ response
28
+ end
29
+ end
30
+
31
+ module Mock
32
+ def get_organization(organization_id)
33
+ organization_id = organization_id.to_i
34
+ response = Excon::Response.new
35
+
36
+ if org = self.data[:organizations].find { |org| org[:info][:id] == organization_id }
37
+
38
+ body = { "name" => org[:info][:name],
39
+ "href" => "#{@base_url}/org/#{org[:info][:id]}",
40
+ "Links" => [] }
41
+
42
+ body["Links"] = case self
43
+ when Fog::Terremark::Vcloud::Mock
44
+ _vdc_links(org[:vdcs][0])
45
+ when Fog::Terremark::Ecloud::Mock
46
+ org[:vdcs].map do |vdc|
47
+ _vdc_links(vdc)
48
+ end.flatten
49
+ end
50
+
51
+ response.status = 200
52
+ response.body = body
53
+ response.headers = Fog::Compute::Terremark::Mock.headers(response.body, "application/vnd.vmware.vcloud.org+xml")
54
+ else
55
+ response.status = Fog::Compute::Terremark::Mock.unathorized_status
56
+ response.headers = Fog::Compute::Terremark::Mock.error_headers
57
+ end
58
+
59
+ response
60
+ end
61
+
62
+ private
63
+
64
+ def _vdc_links(vdc)
65
+ [
66
+ {
67
+ "name" => vdc[:name],
68
+ "href" => "#{@base_url}/vdc/#{vdc[:id]}",
69
+ "rel" => "down",
70
+ "type" => "application/vnd.vmware.vcloud.vdc+xml"
71
+ },
72
+ {
73
+ "name" => "#{vdc[:name]} Catalog",
74
+ "href" => "#{@base_url}/vdc/#{vdc[:id]}/catalog",
75
+ "rel" => "down",
76
+ "type" => "application/vnd.vmware.vcloud.catalog+xml"
77
+ },
78
+ {
79
+ "name" => "#{vdc[:name]} Tasks List",
80
+ "href" => "#{@base_url}/vdc/#{vdc[:id]}/taskslist",
81
+ "rel" => "down",
82
+ "type" => "application/vnd.vmware.vcloud.tasksList+xml"
83
+ }
84
+ ]
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,45 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get list of organizations
6
+ #
7
+ # ==== Returns
8
+ # * response<~Excon::Response>:
9
+ # * body<~Array>:
10
+ # * 'description'<~String> - Description of organization
11
+ # * 'links'<~Array> - An array of links to entities in the organization
12
+ # * 'name'<~String> - Name of organization
13
+ def get_organizations
14
+ request({
15
+ :expects => 200,
16
+ :headers => {
17
+ 'Authorization' => "Basic #{Base64.encode64("#{@terremark_username}:#{@terremark_password}").chomp!}",
18
+ # Terremark said they're going to remove passing in the Content-Type to login in a future release
19
+ 'Content-Type' => "application/vnd.vmware.vcloud.orgList+xml"
20
+ },
21
+ :method => 'POST',
22
+ :parser => Fog::Parsers::Terremark::GetOrganizations.new,
23
+ :path => 'login'
24
+ })
25
+ end
26
+ end
27
+
28
+ module Mock
29
+ def get_organizations
30
+ response = Excon::Response.new
31
+ org_list = self.data[:organizations].map do |organization|
32
+ { "name" => organization[:info][:name],
33
+ "href" => "#{@base_url}/org/#{organization[:info][:id]}",
34
+ "type" => "application/vnd.vmware.vcloud.org+xml"
35
+ }
36
+ end
37
+ response.body = { "OrgList" => org_list }
38
+ response.status = 200
39
+ response.headers = Fog::Compute::Terremark::Mock.headers(response.body, "application/vnd.vmware.vcloud.orgList+xml")
40
+ response
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get details for a public ip
6
+ #
7
+ # ==== Parameters
8
+ # * public_ip_id<~Integer> - Id of public ip to look up
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * 'PublicIpAddresses'<~Array>
14
+ # * 'href'<~String> - linke to item
15
+ # * 'name'<~String> - name of item
16
+ def get_public_ip(public_ip_id)
17
+ opts = {
18
+ :expects => 200,
19
+ :method => 'GET',
20
+ :parser => Fog::Parsers::Terremark::PublicIp.new,
21
+ :path => "publicIps/#{public_ip_id}"
22
+ }
23
+ if self.class == Fog::Terremark::Ecloud::Real
24
+ opts[:path] = "extensions/publicIp/#{public_ip_id}"
25
+ end
26
+ request(opts)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,69 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get list of public ips
6
+ #
7
+ # ==== Parameters
8
+ # * vdc_id<~Integer> - Id of vdc to find public ips for
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * 'PublicIpAddresses'<~Array>
14
+ # * 'href'<~String> - link to item
15
+ # * 'name'<~String> - name of item
16
+ def get_public_ips(vdc_id)
17
+ opts = {
18
+ :expects => 200,
19
+ :method => 'GET',
20
+ :parser => Fog::Parsers::Terremark::GetPublicIps.new,
21
+ :path => "vdc/#{vdc_id}/publicIps"
22
+ }
23
+ if self.class == Fog::Terremark::Ecloud::Real
24
+ opts[:path] = "extensions/vdc/#{vdc_id}/publicIps"
25
+ end
26
+ request(opts)
27
+ end
28
+ end
29
+
30
+ module Mock
31
+ def get_public_ips(vdc_id)
32
+ vdc_id = vdc_id.to_i
33
+ response = Excon::Response.new
34
+
35
+ vdc = self.data[:organizations].map { |org| org[:vdcs] }.flatten.find { |vdc| vdc[:id] == vdc_id }
36
+ if vdc
37
+ body = { "PublicIpAddresses" => [] }
38
+ vdc[:public_ips].each do |ip|
39
+ ip = { "name" => ip[:name],
40
+ "href" => case self
41
+ when Fog::Terremark::Ecloud::Mock
42
+ "#{@base_url}/extensions/publicIp/#{ip[:id]}"
43
+ when Fog::Terremark::Vcloud::Mock
44
+ "#{@base_url}/PublicIps/#{ip[:id]}"
45
+ end,
46
+ "id" => ip[:id].to_s }
47
+ body["PublicIpAddresses"] << ip
48
+ end
49
+ response.status = 200
50
+ response.body = body
51
+ response.headers = Fog::Compute::Terremark::Mock.headers(response.body,
52
+ case self
53
+ when Fog::Terremark::Ecloud::Mock
54
+ "application/vnd.tmrk.ecloud.publicIpsList+xml"
55
+ when Fog::Terremark::Vcloud::Mock
56
+ "application/xml; charset=utf-8"
57
+ end
58
+ )
59
+ else
60
+ response.status = Fog::Compute::Terremark::Mock.unathorized_status
61
+ response.headers = Fog::Compute::Terremark::Mock.error_headers
62
+ end
63
+
64
+ response
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get details of a task
6
+ #
7
+ # ==== Parameters
8
+ # * task_id<~Integer> - Id of task to lookup
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * 'endTime'<~String> - endTime of task
14
+ # * 'href'<~String> - link to task
15
+ # * 'startTime'<~String> - startTime of task
16
+ # * 'status'<~String> - status of task
17
+ # * 'type'<~String> - type of task
18
+ # * 'Owner'<~String> -
19
+ # * 'href'<~String> - href of owner
20
+ # * 'name'<~String> - name of owner
21
+ # * 'type'<~String> - type of owner
22
+ # * 'Result'<~String> -
23
+ # * 'href'<~String> - href of result
24
+ # * 'name'<~String> - name of result
25
+ # * 'type'<~String> - type of result
26
+ def get_task(task_id)
27
+ request(
28
+ :expects => 200,
29
+ :method => 'GET',
30
+ :parser => Fog::Parsers::Terremark::Task.new,
31
+ :path => "task/#{task_id}"
32
+ )
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get list of tasks
6
+ #
7
+ # ==== Parameters
8
+ # * tasks_list_id<~Integer> - Id of tasks lists to view
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * 'CatalogItems'<~Array>
14
+ # * 'href'<~String> - linke to item
15
+ # * 'name'<~String> - name of item
16
+ # * 'type'<~String> - type of item
17
+ # * 'description'<~String> - Description of catalog
18
+ # * 'name'<~String> - Name of catalog
19
+ def get_tasks_list(tasks_list_id)
20
+ request(
21
+ :expects => 200,
22
+ :method => 'GET',
23
+ :parser => Fog::Parsers::Terremark::GetTasksList.new,
24
+ :path => "tasksList/#{tasks_list_id}"
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,40 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get details of a vapp
6
+ #
7
+ # ==== Parameters
8
+ # * vapp_id<~Integer> - Id of vapp to lookup
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+
14
+ # FIXME
15
+
16
+ # * 'endTime'<~String> - endTime of task
17
+ # * 'href'<~String> - link to task
18
+ # * 'startTime'<~String> - startTime of task
19
+ # * 'status'<~String> - status of task
20
+ # * 'type'<~String> - type of task
21
+ # * 'Owner'<~String> -
22
+ # * 'href'<~String> - href of owner
23
+ # * 'name'<~String> - name of owner
24
+ # * 'type'<~String> - type of owner
25
+ # * 'Result'<~String> -
26
+ # * 'href'<~String> - href of result
27
+ # * 'name'<~String> - name of result
28
+ # * 'type'<~String> - type of result
29
+ def get_vapp(vapp_id)
30
+ request(
31
+ :expects => 200,
32
+ :method => 'GET',
33
+ :parser => Fog::Parsers::Terremark::Vapp.new,
34
+ :path => "vapp/#{vapp_id}"
35
+ )
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,33 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get details of a vapp template
6
+ #
7
+ # ==== Parameters
8
+ # * vapp_template_id<~Integer> - Id of vapp template to lookup
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+
14
+ # FIXME
15
+
16
+ # * 'CatalogItems'<~Array>
17
+ # * 'href'<~String> - linke to item
18
+ # * 'name'<~String> - name of item
19
+ # * 'type'<~String> - type of item
20
+ # * 'description'<~String> - Description of catalog
21
+ # * 'name'<~String> - Name of catalog
22
+ def get_vapp_template(vapp_template_id)
23
+ request(
24
+ :expects => 200,
25
+ :method => 'GET',
26
+ :parser => Fog::Parsers::Terremark::GetVappTemplate.new,
27
+ :path => "vAppTemplate/#{vapp_template_id}"
28
+ )
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,153 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get details of a vdc
6
+ #
7
+ # ==== Parameters
8
+ # * vdc_id<~Integer> - Id of vdc to lookup
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+
14
+ # FIXME
15
+
16
+ # * 'CatalogItems'<~Array>
17
+ # * 'href'<~String> - linke to item
18
+ # * 'name'<~String> - name of item
19
+ # * 'type'<~String> - type of item
20
+ # * 'description'<~String> - Description of catalog
21
+ # * 'name'<~String> - Name of catalog
22
+ def get_vdc(vdc_id)
23
+ request(
24
+ :expects => 200,
25
+ :method => 'GET',
26
+ :parser => Fog::Parsers::Terremark::GetVdc.new,
27
+ :path => "vdc/#{vdc_id}"
28
+ )
29
+ end
30
+ end
31
+
32
+ module Mock
33
+ def get_vdc(vdc_id)
34
+ vdc_id = vdc_id.to_i
35
+ response = Excon::Response.new
36
+
37
+ vdc = self.data[:organizations].map { |org| org[:vdcs] }.flatten.find { |vdc| vdc[:id] == vdc_id }
38
+ if vdc
39
+ body = {
40
+ "name" => vdc[:name],
41
+ "href" => "#{@base_url}/vdc/#{vdc[:id]}",
42
+ "StorageCapacity" => {},
43
+ "ComputeCapacity" => {
44
+ "InstantiatedVmsQuota" => {},
45
+ "DeployedVmsQuota" => {},
46
+ "Cpu" => {},
47
+ "Memory" => {}
48
+ },
49
+ "ResourceEntities" => [],
50
+ "AvailableNetworks" => [],
51
+ "links" => []
52
+ }
53
+
54
+ case self
55
+ when Fog::Terremark::Ecloud::Mock
56
+ body["StorageCapacity"] = { "Units" => "bytes * 10^9" }
57
+ vdc[:storage].each { |k,v| body["StorageCapacity"][k.to_s.capitalize] = v.to_s }
58
+
59
+ body["ComputeCapacity"] = {
60
+ "InstantiatedVmsQuota" => {
61
+ "Limit" => "-1",
62
+ "Used" => "-1"
63
+ },
64
+ "DeployedVmsQuota" => {
65
+ "Limit" => "-1",
66
+ "Used" => "-1"
67
+ },
68
+ "Cpu" => {
69
+ "Units" => "hz * 10^6"
70
+ },
71
+ "Memory" => {
72
+ "Units" => "bytes * 2^20"
73
+ }
74
+ }
75
+
76
+ [:cpu, :memory].each do |key|
77
+ vdc[key].each { |k,v| body["ComputeCapacity"][key.to_s.capitalize][k.to_s.capitalize] = v.to_s }
78
+ end
79
+
80
+ body["links"] << {
81
+ "name" => "Public IPs",
82
+ "href" => "#{@base_url}/extensions/vdc/#{vdc[:id]}/publicIps",
83
+ "rel" => "down",
84
+ "type" => "application/vnd.tmrk.ecloud.publicIpsList+xml"
85
+ }
86
+
87
+ body["links"] << {
88
+ "name" => "Internet Services",
89
+ "href" => "#{@base_url}/extensions/vdc/#{vdc[:id]}/internetServices",
90
+ "rel" => "down",
91
+ "type" => "application/vnd.tmrk.ecloud.internetServicesList+xml"
92
+ }
93
+
94
+ body["links"] << {
95
+ "name" => "Firewall Access List",
96
+ "href" => "#{@base_url}/extensions/vdc/#{vdc[:id]}/firewallAcls",
97
+ "rel" => "down",
98
+ "type" => "application/vnd.tmrk.ecloud.firewallAclsList+xml"
99
+ }
100
+
101
+ when Fog::Terremark::Vcloud::Mock
102
+ body["links"] << {
103
+ "name" => "Public IPs",
104
+ "href" => "#{@base_url}/vdc/#{vdc[:id]}/publicIps",
105
+ "rel" => "down",
106
+ "type" => "application/xml"
107
+ }
108
+
109
+ body["links"] << {
110
+ "name" => "Internet Services",
111
+ "href" => "#{@base_url}/vdc/#{vdc[:id]}/internetServices",
112
+ "rel" => "down",
113
+ "type" => "application/xml"
114
+ }
115
+ end
116
+
117
+ vdc[:vms].each do |vm|
118
+ body["ResourceEntities"] << {
119
+ "name" => vm[:name],
120
+ "href" => "#{@base_url}/vapp/#{vm[:id]}",
121
+ "type" => "application/vnd.vmware.vcloud.vApp+xml"
122
+ }
123
+ end
124
+
125
+ vdc[:networks].each do |network|
126
+ body["AvailableNetworks"] << {
127
+ "name" => network[:name],
128
+ "href" => "#{@base_url}/network/#{network[:id]}",
129
+ "type" => "application/vnd.vmware.vcloud.network+xml"
130
+ }
131
+ end
132
+
133
+ body["links"] << {
134
+ "name" => vdc[:name],
135
+ "href" => "#{@base_url}/vdc/#{vdc[:id]}/catalog",
136
+ "rel" => "down",
137
+ "type" => "application/vnd.vmware.vcloud.catalog+xml"
138
+ }
139
+
140
+ response.status = 200
141
+ response.body = body
142
+ response.headers = Fog::Compute::Terremark::Mock.headers(response.body, "application/vnd.vmware.vcloud.org+xml")
143
+ else
144
+ response.status = Fog::Compute::Terremark::Mock.unathorized_status
145
+ response.headers = Fog::Compute::Terremark::Mock.error_headers
146
+ end
147
+
148
+ response
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end