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,46 @@
1
+ module Fog
2
+ module Parsers
3
+ module Terremark
4
+ class GetOrganization < Base
5
+ def reset
6
+ @response = { 'Links' => [] }
7
+ end
8
+
9
+ def start_element(name, attributes)
10
+ super
11
+ case name
12
+ when 'Link'
13
+ link = extract_attributes(attributes)
14
+ until attributes.empty?
15
+ if attributes.first.is_a?(Array)
16
+ attribute = attributes.shift
17
+ link[attribute.first] = attribute.last
18
+ else
19
+ link[attributes.shift] = attributes.shift
20
+ end
21
+ end
22
+ @response['Links'] << link
23
+ when 'Org'
24
+ org = extract_attributes(attributes)
25
+ until attributes.empty?
26
+ if attributes.first.is_a?(Array)
27
+ attribute = attributes.shift
28
+ org[attribute.first] = attribute.last
29
+ else
30
+ org[attributes.shift] = attributes.shift
31
+ end
32
+ end
33
+ @response['href'] = org['href']
34
+ @response['name'] = org['name']
35
+ end
36
+ end
37
+
38
+ def end_element(name)
39
+ if name == 'Description'
40
+ @response[name] = value
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,27 @@
1
+ module Fog
2
+ module Parsers
3
+ module Terremark
4
+ class GetOrganizations < Base
5
+ def reset
6
+ @response = { 'OrgList' => [] }
7
+ end
8
+
9
+ def start_element(name, attributes)
10
+ super
11
+ if name == 'Org'
12
+ organization = extract_attributes(attributes)
13
+ until attributes.empty?
14
+ if attributes.first.is_a?(Array)
15
+ attribute = attributes.shift
16
+ organization[attribute.first] = attribute.last
17
+ else
18
+ organization[attributes.shift] = attributes.shift
19
+ end
20
+ end
21
+ @response['OrgList'] << organization
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module Parsers
3
+ module Terremark
4
+ class GetPublicIps< Base
5
+ def reset
6
+ @ip_address = {}
7
+ @response = { 'PublicIpAddresses' => [] }
8
+ end
9
+
10
+ def end_element(name)
11
+ case name
12
+ when 'Href', 'Name'
13
+ @ip_address[name.downcase] = value
14
+ when 'Id'
15
+ @ip_address['id'] = value.to_i
16
+ when 'PublicIPAddress'
17
+ @response['PublicIpAddresses'] << @ip_address
18
+ @ip_address = {}
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ module Fog
2
+ module Parsers
3
+ module Terremark
4
+ class GetTasksList < Base
5
+ def reset
6
+ @response = { 'Tasks' => [] }
7
+ @task = {}
8
+ end
9
+
10
+ def start_element(name, attributes)
11
+ super
12
+ case name
13
+ when 'Owner', 'Result'
14
+ data = extract_templates(attributes)
15
+ @task[name] = data
16
+ when 'Task'
17
+ @task = extract_templates(attributes)
18
+ when 'TasksList'
19
+ tasks_list = extract_templates(attributes)
20
+ @response['href'] = tasks_list['href']
21
+ end
22
+ end
23
+
24
+ def end_element(name)
25
+ if name == 'Task'
26
+ @response['Tasks'] << @task
27
+ @task = {}
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Parsers
3
+ module Terremark
4
+ class GetVappTemplate < Base
5
+ def reset
6
+ @response = { 'Links' => [] }
7
+ end
8
+
9
+ def start_element(name, attributes)
10
+ super
11
+ case name
12
+ when 'Link'
13
+ link = extract_attributes(attributes)
14
+ @response['Links'] << link
15
+ when 'VAppTemplate'
16
+ vapp_template = extract_attributes(attributes)
17
+ @response['name'] = vapp_template['name']
18
+ end
19
+ end
20
+
21
+ def end_element(name)
22
+ if name == 'Description'
23
+ @response['Description'] = value
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,85 @@
1
+ module Fog
2
+ module Parsers
3
+ module Terremark
4
+ class GetVdc < Base
5
+ def reset
6
+ @in_storage_capacity = false
7
+ @in_cpu = false
8
+ @in_memory = false
9
+ @in_instantiated_vms_quota = false
10
+ @in_deployed_vms_quota = false
11
+ @response = {
12
+ 'links' => [],
13
+ 'AvailableNetworks' => [],
14
+ 'ComputeCapacity' => {
15
+ 'Cpu' => {},
16
+ 'DeployedVmsQuota' => {},
17
+ 'InstantiatedVmsQuota' => {},
18
+ 'Memory' => {}
19
+ },
20
+ 'StorageCapacity' => {},
21
+ 'ResourceEntities' => []
22
+ }
23
+ end
24
+
25
+ def start_element(name, attributes)
26
+ super
27
+ case name
28
+ when 'Cpu'
29
+ @in_cpu = true
30
+ when 'DeployedVmsQuota'
31
+ @in_deployed_vms_quota = true
32
+ when 'InstantiatedVmsQuota'
33
+ @in_instantiated_vms_quota = true
34
+ when 'Link'
35
+ link = extract_attributes(attributes)
36
+ @response['links'] << link
37
+ when 'Memory'
38
+ @in_memory = true
39
+ when 'Network'
40
+ network = extract_attributes(attributes)
41
+ @response['AvailableNetworks'] << network
42
+ when 'ResourceEntity'
43
+ resource_entity = extract_attributes(attributes)
44
+ @response['ResourceEntities'] << resource_entity
45
+ when 'StorageCapacity'
46
+ @in_storage_capacity = true
47
+ when 'Vdc'
48
+ vdc = extract_attributes(attributes)
49
+ @response['href'] = vdc['href']
50
+ @response['name'] = vdc['name']
51
+ end
52
+ end
53
+
54
+ def end_element(name)
55
+ case name
56
+ when 'Allocated', 'Limit', 'Units', 'Used'
57
+ if @in_cpu
58
+ @response['ComputeCapacity']['Cpu'][name] = value
59
+ elsif @in_deployed_vms_quota
60
+ @response['ComputeCapacity']['DeployedVmsQuota'][name] = value
61
+ elsif @in_instantiated_vms_quota
62
+ @response['ComputeCapacity']['InstantiatedVmsQuota'][name] = value
63
+ elsif @in_memory
64
+ @response['ComputeCapacity']['Memory'][name] = value
65
+ elsif @in_storage_capacity
66
+ @response['StorageCapacity'][name] = value
67
+ end
68
+ when 'Cpu'
69
+ @in_cpu = false
70
+ when 'DeployedVmsQuota'
71
+ @in_deployed_vms_quota = false
72
+ when 'InstantiatedVmsQuota'
73
+ @in_instantiated_vms_quota = false
74
+ when 'Memory'
75
+ @in_memory = false
76
+ when 'StorageCapacity'
77
+ @in_storage_capacity = false
78
+ when 'Type'
79
+ @response[name] = value
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,24 @@
1
+ module Fog
2
+ module Parsers
3
+ module Terremark
4
+ class InstantiateVappTemplate < Base
5
+ def reset
6
+ @property_key
7
+ @response = { 'Links' => [] }
8
+ end
9
+
10
+ def start_element(name, attributes)
11
+ super
12
+ case name
13
+ when 'Link'
14
+ link = extract_attributes(attributes)
15
+ @response['Links'] << link
16
+ when 'VApp'
17
+ vapp_template = extract_attributes(attributes)
18
+ @response.merge!(vapp_template.reject {|key, value| !['href', 'name', 'size', 'status', 'type'].include?(key)})
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,56 @@
1
+ module Fog
2
+ module Parsers
3
+ module Terremark
4
+ class InternetService < Base
5
+ def reset
6
+ @in_public_ip_address = false
7
+ @response = { 'PublicIpAddress' => {} }
8
+ end
9
+
10
+ def start_element(name, attributes)
11
+ super
12
+ case name
13
+ when 'Href'
14
+ data = extract_attributes(attributes)
15
+ if @in_public_ip_address
16
+ @response['PublicIpAddress'][name] = data
17
+ else
18
+ @response[name] = data
19
+ end
20
+ when 'PublicIpAddress'
21
+ @in_public_ip_address = true
22
+ end
23
+ end
24
+
25
+ def end_element(name)
26
+ case name
27
+ when 'Description', 'Protocol'
28
+ @response[name] = value
29
+ when 'Enabled'
30
+ if value == 'false'
31
+ @response[name] = false
32
+ else
33
+ @response[name] = true
34
+ end
35
+ when 'Id'
36
+ if @in_public_ip_address
37
+ @response['PublicIpAddress'][name] = value.to_i
38
+ else
39
+ @response[name] = value.to_i
40
+ end
41
+ when 'Name'
42
+ if @in_public_ip_address
43
+ @response['PublicIpAddress'][name] = value
44
+ else
45
+ @response[name] = value
46
+ end
47
+ when 'Port', 'Timeout'
48
+ @response[name] = value.to_i
49
+ when 'PublicIpAddress'
50
+ @in_public_ip_address = false
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module Parsers
3
+ module Terremark
4
+ class Network < Base
5
+ def reset
6
+ @response = {
7
+ "links" => []
8
+ }
9
+ end
10
+
11
+ def start_element(name,attributes=[])
12
+ super
13
+ case name
14
+ when "Network"
15
+ @response = extract_attributes(attributes)
16
+ if @response.key?("name")
17
+ @response["subnet"] = @response["name"]
18
+ end
19
+ if @response.key?("href")
20
+ @response["id"] = @response["href"].split("/").last
21
+ end
22
+ when "Link"
23
+ link = extract_attributes(attributes)
24
+ @response["links"] << link
25
+ end
26
+ end
27
+
28
+ def end_element(name)
29
+ case name
30
+ when "Gateway", "Netmask", "FenceMode"
31
+ @response[name.downcase] = value
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module Terremark
4
+ class NodeService < Base
5
+ def reset
6
+ @response = {}
7
+ end
8
+
9
+ def end_element(name)
10
+ case name
11
+ when 'Description', 'Href', 'IpAddress', 'Name', 'Protocol'
12
+ @response[name] = value
13
+ when 'Enabled'
14
+ if value == 'false'
15
+ @response[name] = false
16
+ else
17
+ @response[name] = true
18
+ end
19
+ when 'Id', 'Port'
20
+ @response[name] = value.to_i
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ module Fog
2
+ module Parsers
3
+ module Terremark
4
+ class PublicIp < Base
5
+ def reset
6
+ @response = {}
7
+ end
8
+
9
+ def end_element(name)
10
+ case name
11
+ when 'Href', 'Name'
12
+ @response[name.downcase] = value
13
+ when 'Id'
14
+ @response['id'] = value.to_i
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,23 @@
1
+ module Fog
2
+ module Parsers
3
+ module Terremark
4
+ class Task < Base
5
+ def reset
6
+ @response = {}
7
+ end
8
+
9
+ def start_element(name, attributes)
10
+ super
11
+ case name
12
+ when 'Owner', 'Result', 'Link', 'Error'
13
+ data = extract_attributes(attributes)
14
+ @response[name] = data
15
+ when 'Task'
16
+ task = extract_attributes(attributes)
17
+ @response.merge!(task.reject {|key,value| !['endTime', 'href', 'startTime', 'status', 'type'].include?(key)})
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end