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,57 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Reserve requested resources and deploy vApp
6
+ #
7
+ # ==== Parameters
8
+ # * vdc_id<~Integer> - Id of vDc to add internet service to
9
+ # * name<~String> - Name of service
10
+ # * protocol<~String> - Protocol of service
11
+ # * port<~Integer> - Port of service
12
+ # * options<~Hash>:
13
+ # * Enabled<~Boolean>: defaults to true
14
+ # * Description<~String>: optional description
15
+ #
16
+ # ==== Returns
17
+ # * response<~Excon::Response>:
18
+ # * body<~Hash>:
19
+ # * 'endTime'<~String> - endTime of task
20
+ # * 'href'<~String> - link to task
21
+ # * 'startTime'<~String> - startTime of task
22
+ # * 'status'<~String> - status of task
23
+ # * 'type'<~String> - type of task
24
+ # * 'Owner'<~String> -
25
+ # * 'href'<~String> - href of owner
26
+ # * 'name'<~String> - name of owner
27
+ # * 'type'<~String> - type of owner
28
+ def create_internet_service(vdc_id, name, protocol, port, options = {})
29
+ unless options.key?('Enabled')
30
+ options['Enabled'] = true
31
+ end
32
+ #Sample: "https://services.vcloudexpress.terremark.com/api/extensions/v1.6/vdc/3142/internetServices"
33
+ path = vdcs.get(vdc_id).links.find { |item| item['name'] == 'Internet Services'}['href'].split(@host)[1]
34
+ data = <<-DATA
35
+ <CreateInternetServiceRequest xml:lang="en" xmlns="urn:tmrk:vCloudExpressExtensions-1.6" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
36
+ <Name>#{name}</Name>
37
+ <Protocol>#{protocol.upcase}</Protocol>
38
+ <Port>#{port}</Port>
39
+ <Enabled>#{options['Enabled']}</Enabled>
40
+ <Description>#{options['Description']}</Description>
41
+ </CreateInternetServiceRequest>
42
+ DATA
43
+ response = request(
44
+ :body => data,
45
+ :expects => 200,
46
+ :headers => {'Content-Type' => 'application/vnd.tmrk.vCloud.internetService+xml'},
47
+ :method => 'POST',
48
+ :parser => Fog::Parsers::Terremark::InternetService.new,
49
+ :path => path,
50
+ :override_path => true
51
+ )
52
+ response
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,21 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Destroy an internet service
6
+ #
7
+ # ==== Parameters
8
+ # * internet_service_id<~Integer> - Id of service to destroy
9
+ #
10
+ def delete_internet_service(internet_service_id)
11
+ request(
12
+ :expects => 200,
13
+ :method => 'DELETE',
14
+ :path => "api/extensions/v1.6/internetService/#{internet_service_id}",
15
+ :override_path => true
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Destroy a node
6
+ #
7
+ # ==== Parameters
8
+ # * node_service_id<~Integer> - Id of node to destroy
9
+ #
10
+ def delete_node_service(node_service_id)
11
+ request(
12
+ :expects => 200,
13
+ :method => 'DELETE',
14
+ :path => "api/extensions/v1.6/nodeService/#{node_service_id}",
15
+ :override_path => true
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Destroy a public ip
6
+ #
7
+ # ==== Parameters
8
+ # * public_ip_id<~Integer> - Id of public ip to destroy
9
+ #
10
+ def delete_public_ip(public_ip_id)
11
+ request(
12
+ :expects => 200,
13
+ :method => 'DELETE',
14
+ :path => "api/extensions/v1.6/publicIp/#{public_ip_id}",
15
+ :override_path => true
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Destroy a vapp
6
+ #
7
+ # ==== Parameters
8
+ # * vapp_id<~Integer> - Id of vapp to destroy
9
+ #
10
+ def delete_vapp(vapp_id)
11
+ request(
12
+ :expects => 202,
13
+ :method => 'DELETE',
14
+ :path => "vApp/#{vapp_id}"
15
+ )
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,33 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Reserve requested resources and deploy vApp
6
+ #
7
+ # ==== Parameters
8
+ # * vapp_id<~Integer> - Id of vApp to deploy
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
+ def deploy_vapp(vapp_id)
23
+ request(
24
+ :expects => 202,
25
+ :method => 'POST',
26
+ :parser => Fog::Parsers::Terremark::Task.new,
27
+ :path => "vApp/#{vapp_id}/action/deploy"
28
+ )
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get details of a catalog
6
+ #
7
+ # ==== Parameters
8
+ # * vdc_id<~Integer> - Id of vdc to view catalog for
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_catalog(vdc_id)
20
+ request(
21
+ :expects => 200,
22
+ :method => 'GET',
23
+ :parser => Fog::Parsers::Terremark::GetCatalog.new,
24
+ :path => "vdc/#{vdc_id}/catalog"
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,33 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get details of a catalog item
6
+ #
7
+ # ==== Parameters
8
+ # * catalog_item_id<~Integer> - Id of catalog item 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_catalog_item(catalog_item_id)
23
+ request(
24
+ :expects => 200,
25
+ :method => 'GET',
26
+ :parser => Fog::Parsers::Terremark::GetCatalogItem.new,
27
+ :path => "catalogItem/#{catalog_item_id}"
28
+ )
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,32 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get a list of all internet services for a vdc
6
+ #
7
+ # ==== Parameters
8
+ # * vdc_id<~Integer> - Id of vDc to get list of internet services for
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * 'InternetServices'<~Array>
14
+ # * 'id'<~String> => id of the internet service
15
+ # * 'name'<~String> => name of service
16
+ # * 'PublicIPAddress'<~Hash>
17
+ # * 'Id'<~String> => id of the public IP
18
+ # * 'name'<~String> => actual ip address
19
+ #
20
+ def get_internet_services(vdc_id)
21
+ request(
22
+ :expects => 200,
23
+ :method => 'GET',
24
+ :parser => Fog::Parsers::Terremark::GetInternetServices.new,
25
+ :path => "api/extensions/v1.6/vdc/#{vdc_id}/internetServices",
26
+ :override_path => true
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get list of SSH keys for 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
+ def get_keys_list(organization_id)
20
+ response = request(
21
+ :expects => 200,
22
+ :method => 'GET',
23
+ :parser => Fog::Parsers::Terremark::GetKeysList.new,
24
+ :path => "api/extensions/v1.6/org/#{organization_id}/keys",
25
+ :override_path => true
26
+ )
27
+ response
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,70 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get details for a Network
6
+ #
7
+ # ==== Parameters
8
+ # * network_id<~Integer> - Id of the network to look up
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # FIXME
14
+ def get_network(network_id)
15
+ request(
16
+ :expects => 200,
17
+ :method => 'GET',
18
+ :parser => Fog::Parsers::Terremark::Network.new,
19
+ :path => "network/#{network_id}"
20
+ )
21
+ end
22
+ end
23
+
24
+ module Mock
25
+ def get_network(network_id)
26
+ network_id = network_id.to_i
27
+ response = Excon::Response.new
28
+ network = self.data[:organizations].map { |org| org[:vdcs].map { |vdc| vdc[:networks] } }.flatten.find { |network| network[:id] == network_id }
29
+ if network
30
+
31
+ body = { "links" => [],
32
+ "type" => "application/vnd.vmware.vcloud.network+xml",
33
+ "href" => "#{@base_url}/network/#{network_id}" }
34
+
35
+ network.each_key do |key|
36
+ body[key.to_s] = network[key]
37
+ end
38
+
39
+ link = { "name" => "IP Addresses",
40
+ "rel" => "down",
41
+ "type" => "application/xml" }
42
+ link["href"] = case self
43
+ when Fog::Terremark::Ecloud::Mock
44
+ "#{@base_url}/extensions/network/#{network_id}/ips"
45
+ when Fog::Terremark::Vcloud::Mock
46
+ "#{@base_url}/network/#{network_id}/ipAddresses"
47
+ end
48
+ body["links"] << link
49
+
50
+ response.status = 200
51
+ response.body = body
52
+ response.headers = Fog::Compute::Terremark::Mock.headers(response.body,
53
+ case self
54
+ when Fog::Terremark::Ecloud::Mock
55
+ "application/vnd.vmware.vcloud.network+xml"
56
+ when Fog::Terremark::Vcloud::Mock
57
+ "application/xml; charset=utf-8"
58
+ end
59
+ )
60
+ else
61
+ response.status = Fog::Compute::Terremark::Mock.unathorized_status
62
+ response.headers = Fog::Compute::Terremark::Mock.error_headers
63
+ end
64
+
65
+ response
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ # Get details for a Network
6
+ #
7
+ # ==== Parameters
8
+ # * network_id<~Integer> - Id of the network to look up
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # FIXME
14
+ def get_network_ips(network_id)
15
+ opts = {
16
+ :expects => 200,
17
+ :method => 'GET',
18
+ :parser => Fog::Parsers::Terremark::GetNetworkIps.new,
19
+ :path => "network/#{network_id}/ipAddresses"
20
+ }
21
+ if self.is_a?(Fog::Terremark::Ecloud::Real)
22
+ opts[:path] = "/extensions/network/#{network_id}/ips"
23
+ end
24
+ request(opts)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Compute
3
+ module Terremark
4
+ module Real
5
+ require 'fog/terremark/parsers/terremark/get_node_services'
6
+
7
+ # Get a list of all internet services for a vdc
8
+ #
9
+ # ==== Parameters
10
+ # * service_id<~Integer> - Id of internet service that we want a list of nodes for
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response>:
14
+ # * body<~Hash>:
15
+
16
+ #
17
+ def get_node_services(service_id)
18
+ request(
19
+ :expects => 200,
20
+ :method => 'GET',
21
+ :parser => Fog::Parsers::Terremark::GetNodeServices.new,
22
+ :path => "api/extensions/v1.6/internetService/#{service_id}/nodeServices",
23
+ :override_path => true
24
+ )
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end