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,137 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'aws'))
2
+
3
+ module Fog
4
+ module AWS
5
+ class STS < Fog::Service
6
+
7
+ class EntityAlreadyExists < Fog::AWS::STS::Error; end
8
+ class ValidationError < Fog::AWS::STS::Error; end
9
+
10
+ requires :aws_access_key_id, :aws_secret_access_key
11
+ recognizes :host, :path, :port, :scheme, :persistent
12
+
13
+ request_path 'fog/aws/requests/sts'
14
+ request :get_federation_token
15
+ request :get_session_token
16
+
17
+ class Mock
18
+ def self.data
19
+ @data ||= Hash.new do |hash, key|
20
+ hash[key] = {
21
+ :owner_id => Fog::AWS::Mock.owner_id,
22
+ :server_certificates => {}
23
+ }
24
+ end
25
+ end
26
+
27
+ def self.reset
28
+ @data = nil
29
+ end
30
+
31
+ def self.server_certificate_id
32
+ Fog::Mock.random_hex(16)
33
+ end
34
+
35
+ def initialize(options={})
36
+ @aws_access_key_id = options[:aws_access_key_id]
37
+ end
38
+
39
+ def data
40
+ self.class.data[@aws_access_key_id]
41
+ end
42
+
43
+ def reset_data
44
+ self.class.data.delete(@aws_access_key_id)
45
+ end
46
+ end
47
+
48
+ class Real
49
+
50
+ # Initialize connection to STS
51
+ #
52
+ # ==== Notes
53
+ # options parameter must include values for :aws_access_key_id and
54
+ # :aws_secret_access_key in order to create a connection
55
+ #
56
+ # ==== Examples
57
+ # iam = STS.new(
58
+ # :aws_access_key_id => your_aws_access_key_id,
59
+ # :aws_secret_access_key => your_aws_secret_access_key
60
+ # )
61
+ #
62
+ # ==== Parameters
63
+ # * options<~Hash> - config arguments for connection. Defaults to {}.
64
+ #
65
+ # ==== Returns
66
+ # * STS object with connection to AWS.
67
+ def initialize(options={})
68
+ require 'fog/core/parser'
69
+ require 'multi_json'
70
+
71
+ @aws_access_key_id = options[:aws_access_key_id]
72
+ @aws_secret_access_key = options[:aws_secret_access_key]
73
+ @connection_options = options[:connection_options] || {}
74
+ @hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
75
+ @host = options[:host] || 'sts.amazonaws.com'
76
+ @path = options[:path] || '/'
77
+ @persistent = options[:persistent] || false
78
+ @port = options[:port] || 443
79
+ @scheme = options[:scheme] || 'https'
80
+ @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
81
+ end
82
+
83
+ def reload
84
+ @connection.reset
85
+ end
86
+
87
+ private
88
+
89
+ def request(params)
90
+ idempotent = params.delete(:idempotent)
91
+ parser = params.delete(:parser)
92
+
93
+ body = Fog::AWS.signed_params(
94
+ params,
95
+ {
96
+ :aws_access_key_id => @aws_access_key_id,
97
+ :hmac => @hmac,
98
+ :host => @host,
99
+ :path => @path,
100
+ :port => @port,
101
+ :version => '2011-06-15'
102
+ }
103
+ )
104
+
105
+ begin
106
+ response = @connection.request({
107
+ :body => body,
108
+ :expects => 200,
109
+ :idempotent => idempotent,
110
+ :headers => { 'Content-Type' => 'application/x-www-form-urlencoded' },
111
+ :host => @host,
112
+ :method => 'POST',
113
+ :parser => parser
114
+ })
115
+
116
+ response
117
+ rescue Excon::Errors::HTTPStatusError => error
118
+ if match = error.message.match(/<Code>(.*)<\/Code>(?:.*<Message>(.*)<\/Message>)?/m)
119
+ case match[1]
120
+ when 'EntityAlreadyExists', 'KeyPairMismatch', 'LimitExceeded', 'MalformedCertificate', 'ValidationError'
121
+ raise Fog::AWS::STS.const_get(match[1]).slurp(error, match[2])
122
+ else
123
+ raise Fog::AWS::STS::Error.slurp(error, "#{match[1]} => #{match[2]}") if match[1]
124
+ raise
125
+ end
126
+ else
127
+ raise
128
+ end
129
+ end
130
+
131
+
132
+ end
133
+
134
+ end
135
+ end
136
+ end
137
+ end
data/lib/fog/bin.rb CHANGED
@@ -55,6 +55,7 @@ end
55
55
  require 'fog/bin/aws'
56
56
  require 'fog/bin/bluebox'
57
57
  require 'fog/bin/brightbox'
58
+ require 'fog/bin/clodo'
58
59
  require 'fog/bin/dnsimple'
59
60
  require 'fog/bin/dnsmadeeasy'
60
61
  require 'fog/bin/dynect'
data/lib/fog/bin/aws.rb CHANGED
@@ -35,6 +35,8 @@ class AWS < Fog::Bin
35
35
  Fog::AWS::RDS
36
36
  when :sns
37
37
  Fog::AWS::SNS
38
+ when :sts
39
+ Fog::AWS::STS
38
40
  else
39
41
  # @todo Replace most instances of ArgumentError with NotImplementedError
40
42
  # @todo For a list of widely supported Exceptions, see:
@@ -0,0 +1,31 @@
1
+ class Clodo < Fog::Bin
2
+ class << self
3
+
4
+ def class_for(key)
5
+ case key
6
+ when :compute
7
+ Fog::Compute::Clodo
8
+ else
9
+ raise ArgumentError, "Unrecognized service: #{key}"
10
+ end
11
+ end
12
+
13
+ def [](service)
14
+ @@connections ||= Hash.new do |hash, key|
15
+ hash[key] = case key
16
+ when :compute
17
+ Formatador.display_line("[yellow][WARN] Clodo[:compute] is deprecated, use Compute[:clodo] instead[/]")
18
+ Fog::Compute.new(:provider => 'Clodo')
19
+ else
20
+ raise ArgumentError, "Unrecognized service: #{key.inspect}"
21
+ end
22
+ end
23
+ @@connections[service]
24
+ end
25
+
26
+ def services
27
+ Fog::Clodo.services
28
+ end
29
+
30
+ end
31
+ end
@@ -16,6 +16,10 @@ module Fog
16
16
  model :server
17
17
  collection :server_groups
18
18
  model :server_group
19
+ collection :firewall_policies
20
+ model :firewall_policy
21
+ collection :firewall_rules
22
+ model :firewall_rule
19
23
  collection :flavors
20
24
  model :flavor
21
25
  collection :images
@@ -35,6 +39,7 @@ module Fog
35
39
  request :add_nodes_load_balancer
36
40
  request :add_servers_server_group
37
41
  request :apply_to_firewall_policy
42
+ request :remove_firewall_policy
38
43
  request :create_api_client
39
44
  request :create_cloud_ip
40
45
  request :create_firewall_policy
@@ -80,6 +85,7 @@ module Fog
80
85
  request :remove_nodes_load_balancer
81
86
  request :remove_servers_server_group
82
87
  request :reset_ftp_password_account
88
+ request :reset_secret_api_client
83
89
  request :resize_server
84
90
  request :shutdown_server
85
91
  request :snapshot_server
@@ -88,6 +94,7 @@ module Fog
88
94
  request :unmap_cloud_ip
89
95
  request :update_account
90
96
  request :update_api_client
97
+ request :update_cloud_ip
91
98
  request :update_image
92
99
  request :update_load_balancer
93
100
  request :update_server
@@ -23,9 +23,17 @@ module Fog
23
23
  attribute :server_id, :aliases => "server", :squash => "id"
24
24
  attribute :load_balancer, :alias => "load_balancer", :squash => "id"
25
25
 
26
- def map(interface_to_map)
26
+ def map(destination)
27
27
  requires :identity
28
- connection.map_cloud_ip(identity, :interface => interface_to_map)
28
+ case destination
29
+ when Fog::Compute::Brightbox::Server
30
+ final_destination = destination.interfaces.first["id"]
31
+ when Fog::Compute::Brightbox::LoadBalancer
32
+ final_destination = destination.id
33
+ else
34
+ final_destination = destination
35
+ end
36
+ connection.map_cloud_ip(identity, :destination => final_destination)
29
37
  end
30
38
 
31
39
  def mapped?
@@ -0,0 +1,29 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/brightbox/models/compute/firewall_policy'
3
+
4
+ module Fog
5
+ module Compute
6
+ class Brightbox
7
+
8
+ class FirewallPolicies < Fog::Collection
9
+
10
+ model Fog::Compute::Brightbox::FirewallPolicy
11
+
12
+ def all
13
+ data = connection.list_firewall_policies
14
+ load(data)
15
+ end
16
+
17
+ def get(identifier)
18
+ return nil if identifier.nil? || identifier == ""
19
+ data = connection.get_firewall_policy(identifier)
20
+ new(data)
21
+ rescue Excon::Errors::NotFound
22
+ nil
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,65 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Compute
5
+ class Brightbox
6
+
7
+ class FirewallPolicy < Fog::Model
8
+
9
+ identity :id
10
+ attribute :url
11
+ attribute :resource_type
12
+
13
+ attribute :name
14
+ attribute :description
15
+
16
+ attribute :default
17
+
18
+ attribute :server_group_id, :aliases => "server_group", :squash => "id"
19
+ attribute :created_at, :type => :time
20
+ attribute :rules
21
+
22
+ # Sticking with existing Fog behaviour, save does not update but creates a new resource
23
+ def save
24
+ raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
25
+ options = {
26
+ :server_group => server_group_id,
27
+ :name => name,
28
+ :description => description
29
+ }.delete_if {|k,v| v.nil? || v == "" }
30
+ data = connection.create_firewall_policy(options)
31
+ merge_attributes(data)
32
+ true
33
+ end
34
+
35
+ def apply_to(server_group_id)
36
+ requires :identity
37
+ options = {
38
+ :server_group => server_group_id
39
+ }
40
+ data = connection.apply_to_firewall_policy(identity, options)
41
+ merge_attributes(data)
42
+ true
43
+ end
44
+
45
+ def remove(server_group_id)
46
+ requires :identity
47
+ options = {
48
+ :server_group => server_group_id
49
+ }
50
+ data = connection.remove_firewall_policy(identity, options)
51
+ merge_attributes(data)
52
+ true
53
+ end
54
+
55
+ def destroy
56
+ requires :identity
57
+ data = connection.destroy_firewall_policy(identity)
58
+ true
59
+ end
60
+
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,54 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Compute
5
+ class Brightbox
6
+
7
+ class FirewallRule < Fog::Model
8
+
9
+ identity :id
10
+ attribute :url
11
+ attribute :resource_type
12
+
13
+ attribute :description
14
+
15
+ attribute :source
16
+ attribute :source_port
17
+ attribute :destination
18
+ attribute :destination_port
19
+ attribute :protocol
20
+ attribute :icmp_type_name
21
+ attribute :created_at, :type => :time
22
+
23
+ attribute :firewall_policy_id, :aliases => "firewall_policy", :squash => "id"
24
+
25
+ # Sticking with existing Fog behaviour, save does not update but creates a new resource
26
+ def save
27
+ raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
28
+ requires :firewall_policy_id
29
+ options = {
30
+ :firewall_policy => firewall_policy_id,
31
+ :protocol => protocol,
32
+ :description => description,
33
+ :source => source,
34
+ :source_port => source_port,
35
+ :destination => destination,
36
+ :destination_port => destination_port,
37
+ :icmp_type_name => icmp_type_name
38
+ }.delete_if {|k,v| v.nil? || v == "" }
39
+ data = connection.create_firewall_rule(options)
40
+ merge_attributes(data)
41
+ true
42
+ end
43
+
44
+ def destroy
45
+ requires :identity
46
+ connection.destroy_firewall_rule(identity)
47
+ true
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,24 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/brightbox/models/compute/firewall_rule'
3
+
4
+ module Fog
5
+ module Compute
6
+ class Brightbox
7
+
8
+ class FirewallRules < Fog::Collection
9
+
10
+ model Fog::Compute::Brightbox::FirewallRule
11
+
12
+ def get(identifier)
13
+ return nil if identifier.nil? || identifier == ""
14
+ data = connection.get_firewall_rule(identifier)
15
+ new(data)
16
+ rescue Excon::Errors::NotFound
17
+ nil
18
+ end
19
+
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -11,6 +11,7 @@ module Fog
11
11
  attribute :resource_type
12
12
 
13
13
  attribute :name
14
+ attribute :username
14
15
  attribute :status
15
16
  attribute :description
16
17
 
@@ -43,6 +44,7 @@ module Fog
43
44
  :source => source,
44
45
  :arch => arch,
45
46
  :name => name,
47
+ :username => username,
46
48
  :description => description
47
49
  }.delete_if {|k,v| v.nil? || v == "" }
48
50
  data = connection.create_image(options)
@@ -27,17 +27,43 @@ module Fog
27
27
  # Links - to be replaced
28
28
  attribute :account_id, :aliases => "account", :squash => "id"
29
29
  attribute :image_id, :aliases => "image", :squash => "id"
30
- attribute :flavor_id, :aliases => "server_type", :squash => "id"
31
- attribute :zone_id, :aliases => "zone", :squash => "id"
30
+
32
31
  attribute :snapshots
33
32
  attribute :cloud_ips
34
33
  attribute :interfaces
34
+ attribute :server_groups
35
+ attribute :zone
36
+ attribute :server_type
35
37
 
36
38
  def initialize(attributes={})
37
- self.image_id ||= 'img-2ab98' # Ubuntu Lucid 10.04 server (i686)
39
+ self.image_id ||= 'img-4gqhs' # Ubuntu Lucid 10.04 server (i686)
38
40
  super
39
41
  end
40
42
 
43
+ def zone_id
44
+ if t_zone_id = attributes[:zone_id]
45
+ t_zone_id
46
+ elsif zone
47
+ zone[:id] || zone['id']
48
+ end
49
+ end
50
+
51
+ def flavor_id
52
+ if t_flavour_id = attributes[:flavor_id]
53
+ t_flavour_id
54
+ elsif server_type
55
+ server_type[:id] || server_type['id']
56
+ end
57
+ end
58
+
59
+ def zone_id=(incoming_zone_id)
60
+ attributes[:zone_id] = incoming_zone_id
61
+ end
62
+
63
+ def flavor_id=(incoming_flavour_id)
64
+ attributes[:flavor_id] = incoming_flavour_id
65
+ end
66
+
41
67
  def snapshot
42
68
  requires :identity
43
69
  connection.snapshot_server(identity)
@@ -82,11 +108,19 @@ module Fog
82
108
  end
83
109
 
84
110
  def private_ip_address
85
- interfaces.first
111
+ unless interfaces.empty?
112
+ interfaces.first["ipv4_address"]
113
+ else
114
+ nil
115
+ end
86
116
  end
87
117
 
88
118
  def public_ip_address
89
- cloud_ips.first
119
+ unless cloud_ips.empty?
120
+ cloud_ips.first["public_ip"]
121
+ else
122
+ nil
123
+ end
90
124
  end
91
125
 
92
126
  def ready?
@@ -106,7 +140,8 @@ module Fog
106
140
  :image => image_id,
107
141
  :name => name,
108
142
  :zone => zone_id,
109
- :user_data => user_data
143
+ :user_data => user_data,
144
+ :server_groups => server_groups
110
145
  }.delete_if {|k,v| v.nil? || v == "" }
111
146
  unless flavor_id.nil? || flavor_id == ""
112
147
  options.merge!(:server_type => flavor_id)