fog 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. data/.gitignore +1 -0
  2. data/Rakefile +3 -3
  3. data/changelog.txt +213 -0
  4. data/docs/compute/index.markdown +15 -1
  5. data/fog.gemspec +3 -3
  6. data/lib/fog.rb +1 -1
  7. data/lib/fog/aws.rb +9 -0
  8. data/lib/fog/aws/auto_scaling.rb +3 -1
  9. data/lib/fog/aws/cloud_formation.rb +2 -0
  10. data/lib/fog/aws/cloud_watch.rb +2 -0
  11. data/lib/fog/aws/compute.rb +9 -3
  12. data/lib/fog/aws/elasticache.rb +8 -1
  13. data/lib/fog/aws/elb.rb +2 -0
  14. data/lib/fog/aws/models/cloud_watch/metric_statistic.rb +1 -2
  15. data/lib/fog/aws/models/compute/security_group.rb +1 -1
  16. data/lib/fog/aws/models/compute/server.rb +3 -1
  17. data/lib/fog/aws/models/dns/records.rb +3 -3
  18. data/lib/fog/aws/models/elb/load_balancer.rb +6 -0
  19. data/lib/fog/aws/models/storage/file.rb +2 -2
  20. data/lib/fog/aws/models/storage/files.rb +4 -4
  21. data/lib/fog/aws/parsers/compute/describe_instance_status.rb +64 -0
  22. data/lib/fog/aws/parsers/compute/describe_security_groups.rb +1 -1
  23. data/lib/fog/aws/parsers/sqs/receive_message.rb +1 -1
  24. data/lib/fog/aws/parsers/sts/get_session_token.rb +31 -0
  25. data/lib/fog/aws/rds.rb +36 -1
  26. data/lib/fog/aws/requests/compute/describe_availability_zones.rb +3 -0
  27. data/lib/fog/aws/requests/compute/describe_instance_status.rb +36 -0
  28. data/lib/fog/aws/requests/compute/describe_security_groups.rb +2 -0
  29. data/lib/fog/aws/requests/elb/set_load_balancer_listener_ssl_certificate.rb +27 -0
  30. data/lib/fog/aws/requests/rds/create_db_instance.rb +64 -1
  31. data/lib/fog/aws/requests/rds/delete_db_instance.rb +19 -3
  32. data/lib/fog/aws/requests/rds/describe_db_instances.rb +40 -1
  33. data/lib/fog/aws/requests/rds/describe_db_reserved_instances.rb +1 -1
  34. data/lib/fog/aws/requests/rds/modify_db_instance.rb +24 -1
  35. data/lib/fog/aws/requests/rds/reboot_db_instance.rb +17 -1
  36. data/lib/fog/aws/requests/storage/{hash_to_acl.rb → acl_utils.rb} +8 -0
  37. data/lib/fog/aws/requests/storage/copy_object.rb +8 -0
  38. data/lib/fog/aws/requests/storage/get_bucket_acl.rb +7 -1
  39. data/lib/fog/aws/requests/storage/get_object_acl.rb +7 -1
  40. data/lib/fog/aws/requests/storage/get_object_http_url.rb +4 -3
  41. data/lib/fog/aws/requests/storage/get_object_https_url.rb +4 -3
  42. data/lib/fog/aws/requests/storage/put_bucket_acl.rb +2 -2
  43. data/lib/fog/aws/requests/storage/put_object_acl.rb +1 -1
  44. data/lib/fog/aws/requests/sts/get_federation_token.rb +20 -0
  45. data/lib/fog/aws/requests/sts/get_session_token.rb +18 -0
  46. data/lib/fog/aws/simpledb.rb +5 -1
  47. data/lib/fog/aws/sns.rb +2 -0
  48. data/lib/fog/aws/sqs.rb +5 -1
  49. data/lib/fog/aws/storage.rb +6 -0
  50. data/lib/fog/aws/sts.rb +137 -0
  51. data/lib/fog/bin.rb +1 -0
  52. data/lib/fog/bin/aws.rb +2 -0
  53. data/lib/fog/bin/clodo.rb +31 -0
  54. data/lib/fog/brightbox/compute.rb +7 -0
  55. data/lib/fog/brightbox/models/compute/cloud_ip.rb +10 -2
  56. data/lib/fog/brightbox/models/compute/firewall_policies.rb +29 -0
  57. data/lib/fog/brightbox/models/compute/firewall_policy.rb +65 -0
  58. data/lib/fog/brightbox/models/compute/firewall_rule.rb +54 -0
  59. data/lib/fog/brightbox/models/compute/firewall_rules.rb +24 -0
  60. data/lib/fog/brightbox/models/compute/image.rb +2 -0
  61. data/lib/fog/brightbox/models/compute/server.rb +41 -6
  62. data/lib/fog/brightbox/models/compute/server_group.rb +56 -17
  63. data/lib/fog/brightbox/requests/compute/remove_firewall_policy.rb +14 -0
  64. data/lib/fog/clodo.rb +34 -0
  65. data/lib/fog/clodo/compute.rb +152 -0
  66. data/lib/fog/clodo/models/compute/image.rb +31 -0
  67. data/lib/fog/clodo/models/compute/images.rb +28 -0
  68. data/lib/fog/clodo/models/compute/server.rb +163 -0
  69. data/lib/fog/clodo/models/compute/servers.rb +36 -0
  70. data/lib/fog/clodo/requests/compute/add_ip_address.rb +49 -0
  71. data/lib/fog/clodo/requests/compute/create_server.rb +112 -0
  72. data/lib/fog/clodo/requests/compute/delete_ip_address.rb +47 -0
  73. data/lib/fog/clodo/requests/compute/delete_server.rb +44 -0
  74. data/lib/fog/clodo/requests/compute/get_image_details.rb +20 -0
  75. data/lib/fog/clodo/requests/compute/get_server_details.rb +49 -0
  76. data/lib/fog/clodo/requests/compute/list_images.rb +48 -0
  77. data/lib/fog/clodo/requests/compute/list_images_detail.rb +61 -0
  78. data/lib/fog/clodo/requests/compute/list_servers.rb +50 -0
  79. data/lib/fog/clodo/requests/compute/list_servers_detail.rb +51 -0
  80. data/lib/fog/clodo/requests/compute/move_ip_address.rb +34 -0
  81. data/lib/fog/clodo/requests/compute/reboot_server.rb +19 -0
  82. data/lib/fog/clodo/requests/compute/rebuild_server.rb +21 -0
  83. data/lib/fog/clodo/requests/compute/server_action.rb +25 -0
  84. data/lib/fog/clodo/requests/compute/start_server.rb +19 -0
  85. data/lib/fog/clodo/requests/compute/stop_server.rb +19 -0
  86. data/lib/fog/compute.rb +3 -0
  87. data/lib/fog/core/credentials.rb +3 -3
  88. data/lib/fog/core/errors.rb +2 -0
  89. data/lib/fog/core/wait_for.rb +1 -1
  90. data/lib/fog/dnsmadeeasy/dns.rb +1 -1
  91. data/lib/fog/libvirt/compute.rb +2 -0
  92. data/lib/fog/libvirt/models/compute/nodes.rb +1 -3
  93. data/lib/fog/libvirt/models/compute/server.rb +8 -1
  94. data/lib/fog/providers.rb +1 -0
  95. data/lib/fog/rackspace/dns.rb +10 -2
  96. data/lib/fog/rackspace/load_balancers.rb +3 -0
  97. data/lib/fog/rackspace/models/compute/server.rb +2 -2
  98. data/lib/fog/rackspace/models/dns/callback.rb +3 -1
  99. data/lib/fog/rackspace/models/dns/record.rb +4 -0
  100. data/lib/fog/rackspace/models/load_balancers/load_balancer.rb +18 -8
  101. data/lib/fog/rackspace/requests/load_balancers/delete_nodes.rb +1 -2
  102. data/lib/fog/rackspace/requests/load_balancers/get_error_page.rb +15 -0
  103. data/lib/fog/rackspace/requests/load_balancers/list_load_balancers.rb +8 -2
  104. data/lib/fog/rackspace/requests/load_balancers/remove_error_page.rb +15 -0
  105. data/lib/fog/rackspace/requests/load_balancers/set_error_page.rb +21 -0
  106. data/lib/fog/vcloud/compute.rb +7 -1
  107. data/lib/fog/vcloud/models/compute/catalogs.rb +4 -5
  108. data/lib/fog/vcloud/models/compute/helpers/status.rb +37 -0
  109. data/lib/fog/vcloud/models/compute/network.rb +13 -49
  110. data/lib/fog/vcloud/models/compute/networks.rb +12 -3
  111. data/lib/fog/vcloud/models/compute/organization.rb +44 -0
  112. data/lib/fog/vcloud/models/compute/organizations.rb +29 -0
  113. data/lib/fog/vcloud/models/compute/server.rb +35 -56
  114. data/lib/fog/vcloud/models/compute/servers.rb +11 -13
  115. data/lib/fog/vcloud/models/compute/vapp.rb +41 -0
  116. data/lib/fog/vcloud/models/compute/vapps.rb +32 -0
  117. data/lib/fog/vcloud/models/compute/vdc.rb +11 -26
  118. data/lib/fog/vcloud/models/compute/vdcs.rb +6 -8
  119. data/lib/fog/vcloud/requests/compute/get_server.rb +10 -0
  120. data/lib/fog/vsphere/compute.rb +1 -0
  121. data/lib/fog/vsphere/models/compute/server.rb +18 -0
  122. data/lib/fog/vsphere/models/compute/servers.rb +8 -2
  123. data/lib/fog/vsphere/requests/compute/datacenters.rb +34 -0
  124. data/lib/fog/vsphere/requests/compute/list_virtual_machines.rb +132 -91
  125. data/lib/fog/vsphere/requests/compute/vm_clone.rb +76 -37
  126. data/spec/lib/fog/aws/parsers/sqs/receive_message_spec.rb +58 -0
  127. data/tests/aws/models/elb/model_tests.rb +5 -0
  128. data/tests/aws/requests/compute/instance_tests.rb +23 -0
  129. data/tests/aws/requests/compute/security_group_tests.rb +1 -0
  130. data/tests/aws/requests/elb/listener_tests.rb +4 -0
  131. data/tests/aws/requests/storage/{hash_to_acl_tests.rb → acl_utils_tests.rb} +38 -2
  132. data/tests/aws/requests/storage/bucket_tests.rb +0 -3
  133. data/tests/aws/requests/storage/object_tests.rb +2 -4
  134. data/tests/aws/requests/sts/get_federation_token_tests.rb +21 -0
  135. data/tests/aws/requests/sts/session_token_tests.rb +16 -0
  136. data/tests/brightbox/requests/compute/account_tests.rb +11 -6
  137. data/tests/brightbox/requests/compute/api_client_tests.rb +23 -12
  138. data/tests/brightbox/requests/compute/cloud_ip_tests.rb +32 -17
  139. data/tests/brightbox/requests/compute/helper.rb +29 -3
  140. data/tests/brightbox/requests/compute/image_tests.rb +17 -14
  141. data/tests/brightbox/requests/compute/interface_tests.rb +3 -2
  142. data/tests/brightbox/requests/compute/load_balancer_tests.rb +57 -11
  143. data/tests/brightbox/requests/compute/server_group_tests.rb +29 -22
  144. data/tests/brightbox/requests/compute/server_tests.rb +41 -22
  145. data/tests/brightbox/requests/compute/server_type_tests.rb +7 -6
  146. data/tests/brightbox/requests/compute/user_tests.rb +11 -16
  147. data/tests/brightbox/requests/compute/zone_tests.rb +7 -6
  148. data/tests/clodo/requests/compute/image_tests.rb +36 -0
  149. data/tests/clodo/requests/compute/server_tests.rb +152 -0
  150. data/tests/compute/helper.rb +1 -1
  151. data/tests/core/credential_tests.rb +2 -2
  152. data/tests/glesys/requests/compute/helper.rb +91 -66
  153. data/tests/glesys/requests/compute/ip_tests.rb +1 -1
  154. data/tests/glesys/requests/compute/server_tests.rb +5 -5
  155. data/tests/helpers/mock_helper.rb +2 -0
  156. data/tests/rackspace/models/dns/zone_tests.rb +14 -0
  157. data/tests/rackspace/models/{access_list_tests.rb → load_balancers/access_list_tests.rb} +0 -0
  158. data/tests/rackspace/models/{access_lists_tests.rb → load_balancers/access_lists_tests.rb} +0 -0
  159. data/tests/rackspace/models/{load_balancer_tests.rb → load_balancers/load_balancer_tests.rb} +25 -0
  160. data/tests/rackspace/models/{load_balancers_tests.rb → load_balancers/load_balancers_tests.rb} +0 -0
  161. data/tests/rackspace/models/{node_tests.rb → load_balancers/node_tests.rb} +0 -0
  162. data/tests/rackspace/models/{nodes_tests.rb → load_balancers/nodes_tests.rb} +0 -0
  163. data/tests/rackspace/models/{virtual_ip_tests.rb → load_balancers/virtual_ip_tests.rb} +0 -0
  164. data/tests/rackspace/models/{virtual_ips_tests.rb → load_balancers/virtual_ips_tests.rb} +0 -0
  165. data/tests/rackspace/requests/dns/dns_tests.rb +4 -2
  166. data/tests/rackspace/requests/load_balancers/error_page_tests.rb +31 -0
  167. data/tests/rackspace/requests/load_balancers/helper.rb +27 -11
  168. data/tests/rackspace/requests/load_balancers/load_balancer_tests.rb +4 -1
  169. data/tests/rackspace/requests/load_balancers/node_tests.rb +24 -25
  170. data/tests/slicehost/requests/compute/slice_tests.rb +2 -2
  171. data/tests/storm_on_demand/requests/compute/server_tests.rb +3 -3
  172. data/tests/vcloud/data/api_+_v1.0_+_admin_+_network_+_2 +110 -0
  173. data/tests/vcloud/data/api_+_v1.0_+_login +5 -0
  174. data/tests/vcloud/data/api_+_v1.0_+_network_+_1 +44 -0
  175. data/tests/vcloud/data/api_+_v1.0_+_network_+_2 +31 -0
  176. data/tests/vcloud/data/api_+_v1.0_+_org_+_1 +17 -0
  177. data/tests/vcloud/data/api_+_v1.0_+_vApp_+_vapp-1 +369 -0
  178. data/tests/vcloud/data/api_+_v1.0_+_vApp_+_vm-1 +139 -0
  179. data/tests/vcloud/data/api_+_v1.0_+_vApp_+_vm-2 +155 -0
  180. data/tests/vcloud/data/api_+_v1.0_+_vdc_+_1 +61 -0
  181. data/tests/vcloud/models/compute/conn_helper.rb +20 -0
  182. data/tests/vcloud/models/compute/network_tests.rb +65 -0
  183. data/tests/vcloud/models/compute/networks_tests.rb +42 -0
  184. data/tests/vcloud/models/compute/organization_tests.rb +13 -0
  185. data/tests/vcloud/models/compute/organizations_tests.rb +14 -0
  186. data/tests/vcloud/models/compute/server_tests.rb +136 -0
  187. data/tests/vcloud/models/compute/servers_tests.rb +10 -89
  188. data/tests/vcloud/models/compute/vapp_tests.rb +27 -0
  189. data/tests/vcloud/models/compute/vapps_tests.rb +17 -0
  190. data/tests/vcloud/models/compute/vdc_tests.rb +42 -0
  191. data/tests/vcloud/models/compute/vdcs_tests.rb +17 -0
  192. data/tests/vsphere/requests/compute/vm_clone_tests.rb +2 -6
  193. metadata +151 -55
@@ -0,0 +1,36 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/clodo/models/compute/server'
3
+
4
+ module Fog
5
+ module Compute
6
+ class Clodo
7
+
8
+ class Servers < Fog::Collection
9
+
10
+ model Fog::Compute::Clodo::Server
11
+
12
+ def all
13
+ data = connection.list_servers_detail.body['servers']
14
+ load(data)
15
+ end
16
+
17
+ def bootstrap(new_attributes = {})
18
+ server = create(new_attributes)
19
+ server.wait_for { ready? }
20
+ server.setup(:password => server.password)
21
+ server
22
+ end
23
+
24
+ def get(server_id)
25
+ if server = connection.get_server_details(server_id).body['server']
26
+ new(server)
27
+ end
28
+ rescue Fog::Compute::Clodo::NotFound
29
+ nil
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,49 @@
1
+ module Fog
2
+ module Compute
3
+ class Clodo
4
+ class Real
5
+
6
+ # Bye new IP-address for specified server
7
+ # ==== Paramaters
8
+ # * server_id<~Integer> - Id of server to bye IP for
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>
12
+ #
13
+
14
+ def add_ip_address(server_id)
15
+ request(
16
+ :expects => [204],
17
+ :method => 'PUT',
18
+ :path => "servers/#{server_id}/ips"
19
+ )
20
+ end
21
+ end
22
+
23
+ class Mock
24
+ def add_ip_address(server_id)
25
+
26
+ raise Excon::Errors::BadRequest.new(
27
+ "Invalid image ID"
28
+ ) unless server_id > 0
29
+
30
+ data = {
31
+ 'primary_ip' => false,
32
+ 'isp' => false,
33
+ 'ip' => "66.6.#{rand(255)}.#{rand(255)}"
34
+ }
35
+
36
+ raise Excon::Errors::BadRequest unless self.data[:servers][server_id]
37
+
38
+ raise Excon::Errors::BadRequest.new "No addresses" unless self.data[:servers][server_id]['addresses']
39
+
40
+ self.data[:servers][server_id]['addresses']['public'] << data
41
+
42
+ response = Excon::Response.new
43
+ response.status = 204
44
+ response
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,112 @@
1
+ module Fog
2
+ module Compute
3
+ class Clodo
4
+ class Real
5
+ # Input:
6
+ # vps_title - VDS title to display in VDS list
7
+ # vps_type - VDS type (VirtualServer,ScaleServer)
8
+ # vps_memory - memory size in megabytes (for ScaleServer - low limit)
9
+ # vps_memory_max - maximum number of ScaleServer memory megabytes to scale up.
10
+ # vps_hdd - Virtual HDD size im gigabytes.
11
+ # vps_admin - support level (1 - usual&free, 2 - extended, 3 - VIP)
12
+ # vps_os - OS ID to install
13
+ # Output:
14
+ # id - VDS ID
15
+ # name - VDS title
16
+ # imageId - OS ID
17
+ # adminPass - root password
18
+
19
+ def create_server(image_id, options = {})
20
+ data = {
21
+ 'server' => {
22
+ :vps_os => image_id,
23
+ :vps_hdd => options[:vps_hdd]?options[:vps_hdd]:5,
24
+ :vps_memory => options[:vps_memory]?options[:vps_memory]:256,
25
+ :vps_memory_max => options[:vps_memory_max]?options[:vps_memory_max]:1024,
26
+ :vps_admin => options[:vps_admin]?options[:vps_admin]:1
27
+ }
28
+ }
29
+
30
+ data['server'].merge! options if options
31
+
32
+ request(
33
+ :body => MultiJson.encode(data),
34
+ :expects => [200, 202],
35
+ :method => 'POST',
36
+ :path => 'servers'
37
+ )
38
+
39
+ end
40
+ end
41
+
42
+ class Mock
43
+ def create_server(image_id, options = {})
44
+
45
+ raise Excon::Errors::BadRequest.new("Invalid image ID") unless image_id > 0
46
+
47
+ response = Excon::Response.new
48
+ response.status = 202
49
+
50
+ id = Fog::Mock.random_numbers(6).to_i
51
+
52
+ data = {
53
+ 'id' => id,
54
+ 'imageId' => "#{image_id}",
55
+ 'name' => options['name'] || "VPS #{rand(999)}",
56
+ 'adminPass' => '23ryh8udbcbyt'
57
+ }
58
+
59
+ self.data[:last_modified][:servers][id] = Time.now
60
+ self.data[:servers][id] = {
61
+ 'id' => "#{id}",
62
+ 'imageId' => data['imageId'],
63
+ 'name' => data['name'],
64
+ 'vps_os_title' => "OSTitle",
65
+ 'vps_root_pass' => data['adminPass'],
66
+ 'status' => "is_running",
67
+ 'addresses' => {'public' =>[{
68
+ 'primary_ip' => true,
69
+ 'isp' => false,
70
+ 'ip' => '66.6.6.66'
71
+ },
72
+ {
73
+ 'primary_ip' => false,
74
+ 'isp' => false,
75
+ 'ip' => '13.13.13.13'
76
+ }]},
77
+ 'vps_createdate' => "#{Time.now}",
78
+ 'vps_hdd_max' => "5",
79
+ 'vps_traff' => nil,
80
+ 'vps_mem_1h_max' => "0",
81
+ 'vps_mem_load' => "0",
82
+ 'vps_user_pass' => "wer45345ht",
83
+ 'vps_vnc_pass' => "bi65tdfyb",
84
+ 'vps_adddate' => "#{Time.now}",
85
+ 'vps_update' => "#{Time.now}",
86
+ 'vps_mem_1h_min' => "0",
87
+ 'vps_mem_1h_avg' => nil,
88
+ 'vps_memory_max' => options['vps_memory_max'] || "512",
89
+ 'vps_os_version' => "6.6.6",
90
+ 'vps_cpu_1h_max' => "0",
91
+ 'vps_hdd_load' => "0",
92
+ 'vps_disk_load' => "0",
93
+ 'vps_os_type' => options['vps_os_type'] || "VirtualServer",
94
+ 'type' => options['vps_os_type'] || "VirtualServer",
95
+ 'vps_memory' => options['vps_memory'] || "512",
96
+ 'vps_cpu_load' => "0",
97
+ 'vps_update_days' => "0",
98
+ 'vps_os_bits' => "64",
99
+ 'vps_vnc' => "6.6.6.6:5900",
100
+ 'vps_cpu_max' => "0",
101
+ 'vps_cpu_1h_min' => "0",
102
+ 'vps_cpu_1h_avg' => nil
103
+ }
104
+
105
+ response.body = { 'server' => data }
106
+ response
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
112
+
@@ -0,0 +1,47 @@
1
+ module Fog
2
+ module Compute
3
+ class Clodo
4
+ class Real
5
+
6
+ # Delete IP-address from specified server
7
+ # ==== Paramaters
8
+ # * server_id<~Integer> - Id of server to delete IP from
9
+ # * ip<~String> - IP-address to delete
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>
13
+ #
14
+
15
+ def delete_ip_address(server_id, ip)
16
+ data = {'ip' => ip}
17
+
18
+ request(
19
+ :expects => [204],
20
+ :method => 'DELETE',
21
+ :path => "servers/#{server_id}/ips",
22
+ :body => MultiJson.encode(data)
23
+ )
24
+ end
25
+ end
26
+
27
+ class Mock
28
+ def delete_ip_address(server_id, ip)
29
+
30
+ server = self.data[:servers][server_id]
31
+
32
+ raise Excon::Errors::BadRequest.new "Server not found" unless server
33
+
34
+ pa = server['addresses']['public']
35
+
36
+ raise Excon::Errors::BadRequest.new "Address not found" unless pa && pa.reject! {|addr|
37
+ addr['ip'] == ip
38
+ }
39
+
40
+ response = Excon::Response.new
41
+ response.status = 204
42
+ response
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,44 @@
1
+ module Fog
2
+ module Compute
3
+ class Clodo
4
+ class Real
5
+
6
+ # Delete an existing server
7
+ #
8
+ # ==== Parameters
9
+ # * id<~Integer> - Id of server to delete
10
+ #
11
+ def delete_server(server_id)
12
+ request(
13
+ :expects => 204,
14
+ :method => 'DELETE',
15
+ :path => "servers/#{server_id}"
16
+ )
17
+ end
18
+
19
+ end
20
+
21
+ class Mock
22
+
23
+ def delete_server(server_id)
24
+ response = Excon::Response.new
25
+
26
+ if server = list_servers_detail.body['servers'].detect {|_| _['id'].to_i == server_id }
27
+ if server['status'] == 'is_install'
28
+ response.status = 405
29
+ raise(Excon::Errors.status_error({:expects => 204}, response))
30
+ else
31
+ self.data[:last_modified][:servers].delete(server_id)
32
+ self.data[:servers].delete(server_id)
33
+ response.status = 204
34
+ end
35
+ response
36
+ else
37
+ raise Fog::Compute::Clodo::NotFound
38
+ end
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,20 @@
1
+ module Fog
2
+ module Compute
3
+ class Clodo
4
+ class Real
5
+ def get_image_details(image_id)
6
+ request(:expects => [200,203],
7
+ :method => 'GET',
8
+ :path => "images/#{image_id}")
9
+ end
10
+ end
11
+ class Mock
12
+ def get_image_details(image_id)
13
+ response = Excon::Response.new
14
+ response.status = 404
15
+ response
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,49 @@
1
+ module Fog
2
+ module Compute
3
+ class Clodo
4
+ class Real
5
+
6
+ # Get details about a server
7
+ #
8
+ # ==== Parameters
9
+ # * server_id<~Integer> - Id of server to get details for
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>:
13
+ # * body<~Hash>:
14
+ # * 'server'<~Hash>:
15
+ # * 'addresses'<~Hash>:
16
+ # * 'public'<~Array> - public address strings
17
+ # * 'private'<~Array> - private address strings
18
+ # * 'id'<~Integer> - Id of server
19
+ # * 'imageId'<~Integer> - Id of image used to boot server
20
+ # * 'name<~String> - Name of server
21
+ # * 'status'<~String> - Current server status
22
+ def get_server_details(server_id)
23
+ request(
24
+ :expects => [200, 203],
25
+ :method => 'GET',
26
+ :path => "servers/#{server_id}"
27
+ )
28
+ end
29
+
30
+ end
31
+
32
+ class Mock
33
+
34
+ def get_server_details(server_id)
35
+ response = Excon::Response.new
36
+ if server = list_servers_detail.body['servers'].detect {|_| _['id'] == "#{server_id}"}
37
+ response.status = [200, 203][rand(1)]
38
+ response.body = { 'server' => server }
39
+ response.body['server']['id'] = server['id'].to_i
40
+ response
41
+ else
42
+ raise Fog::Compute::Clodo::NotFound
43
+ end
44
+ end
45
+
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,48 @@
1
+ module Fog
2
+ module Compute
3
+ class Clodo
4
+ class Real
5
+
6
+ # List all images (IDs and names only)
7
+ #
8
+ # ==== Returns
9
+ # * response<~Excon::Response>:
10
+ # * body<~Hash>:
11
+ # * 'id'<~Integer> - Id of the image
12
+ # * 'name'<~String> - Name of the image
13
+ # * 'status'<~String> - Status of the image
14
+ # * 'vps_type'<~String> - VirtualServer or ScaleServer
15
+ def list_images
16
+ request(
17
+ :expects => [200, 203],
18
+ :method => 'GET',
19
+ :path => 'images'
20
+ )
21
+ end
22
+
23
+ end
24
+
25
+ class Mock
26
+
27
+ def list_images
28
+ response = Excon::Response.new
29
+ response.status = 200
30
+ response.body = {
31
+ 'images' => [
32
+ { 'name' => 'Debian 6 64 bits',
33
+ 'id' => "541",
34
+ 'vps_type' => 'ScaleServer',
35
+ 'status' => 'ACTIVE' },
36
+ { 'name' => 'CentOS 5.5 32 bits',
37
+ 'id' => "31",
38
+ 'vps_type' => 'VirtualServer',
39
+ 'status' => 'ACTIVE' }
40
+ ]
41
+ }
42
+ response
43
+ end
44
+
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,61 @@
1
+ module Fog
2
+ module Compute
3
+ class Clodo
4
+ class Real
5
+
6
+ # List all images
7
+ #
8
+ # ==== Returns
9
+ # * response<~Excon::Response>:
10
+ # * body<~Hash>:
11
+ # * 'os_type'<~String> - OS distribution
12
+ # * 'os_bits'<~Integer> - OS bits
13
+ # * 'os_hvm'<~Integer> - HVM flag
14
+ # * '_attr'<~Hash>:
15
+ # * 'id'<~Integer> - Id of the image
16
+ # * 'name'<~String> - Name of the image
17
+ # * 'status'<~String> - Status of the image
18
+ # * 'vps_type'<~String> - VirtualServer or ScaleServer
19
+
20
+ def list_images_detail
21
+ request(
22
+ :expects => [200, 203],
23
+ :method => 'GET',
24
+ :path => 'images/detail'
25
+ )
26
+ end
27
+
28
+ end
29
+
30
+ class Mock
31
+
32
+ def list_images_detail
33
+ response = Excon::Response.new
34
+ response.status = 200
35
+ response.body = {
36
+ 'images' => [{ 'os_type' => 'debian',
37
+ 'os_bits' => "64",
38
+ 'os_hvm' => "0",
39
+ '_attr' => {
40
+ 'id' => "541",
41
+ 'name' => 'Debian 6 64 bits',
42
+ 'status' => 'ACTIVE',
43
+ 'vps_type' => 'ScaleServer'
44
+ }},
45
+ { 'os_type' => 'centos',
46
+ 'os_bits' => "32",
47
+ 'os_hvm' => "0",
48
+ '_attr' => {
49
+ 'name' => 'CentOS 5.5 32 bits',
50
+ 'id' => "31",
51
+ 'vps_type' => 'VirtualServer',
52
+ 'status' => 'ACTIVE',
53
+ }}]
54
+ }
55
+ response
56
+ end
57
+
58
+ end
59
+ end
60
+ end
61
+ end