fog-maestrodev 1.14.0.20130806165225 → 1.15.0.20130829165835

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. data/changelog.txt +296 -0
  2. data/fog.gemspec +2 -2
  3. data/lib/fog/atmos/storage.rb +0 -3
  4. data/lib/fog/aws/cdn.rb +1 -2
  5. data/lib/fog/aws/compute.rb +52 -2
  6. data/lib/fog/aws/dns.rb +0 -1
  7. data/lib/fog/aws/models/auto_scaling/groups.rb +6 -3
  8. data/lib/fog/aws/models/compute/address.rb +1 -0
  9. data/lib/fog/aws/models/compute/flavors.rb +19 -0
  10. data/lib/fog/aws/models/compute/route_table.rb +69 -0
  11. data/lib/fog/aws/models/compute/route_tables.rb +92 -0
  12. data/lib/fog/aws/models/rds/instance_option.rb +21 -0
  13. data/lib/fog/aws/models/rds/instance_options.rb +30 -0
  14. data/lib/fog/aws/parsers/compute/associate_route_table.rb +20 -0
  15. data/lib/fog/aws/parsers/compute/create_route_table.rb +75 -0
  16. data/lib/fog/aws/parsers/compute/describe_account_attributes.rb +42 -0
  17. data/lib/fog/aws/parsers/compute/describe_route_tables.rb +85 -0
  18. data/lib/fog/aws/parsers/rds/describe_orderable_db_instance_options.rb +47 -0
  19. data/lib/fog/aws/rds.rb +5 -0
  20. data/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_groups.rb +9 -1
  21. data/lib/fog/aws/requests/auto_scaling/describe_policies.rb +15 -1
  22. data/lib/fog/aws/requests/compute/associate_dhcp_options.rb +2 -2
  23. data/lib/fog/aws/requests/compute/associate_route_table.rb +75 -0
  24. data/lib/fog/aws/requests/compute/attach_internet_gateway.rb +2 -2
  25. data/lib/fog/aws/requests/compute/create_route.rb +89 -0
  26. data/lib/fog/aws/requests/compute/create_route_table.rb +70 -0
  27. data/lib/fog/aws/requests/compute/create_vpc.rb +16 -1
  28. data/lib/fog/aws/requests/compute/delete_dhcp_options.rb +2 -2
  29. data/lib/fog/aws/requests/compute/delete_internet_gateway.rb +2 -2
  30. data/lib/fog/aws/requests/compute/delete_network_interface.rb +2 -2
  31. data/lib/fog/aws/requests/compute/delete_route.rb +60 -0
  32. data/lib/fog/aws/requests/compute/delete_route_table.rb +51 -0
  33. data/lib/fog/aws/requests/compute/delete_subnet.rb +2 -2
  34. data/lib/fog/aws/requests/compute/delete_vpc.rb +2 -2
  35. data/lib/fog/aws/requests/compute/describe_account_attributes.rb +49 -0
  36. data/lib/fog/aws/requests/compute/describe_route_tables.rb +87 -0
  37. data/lib/fog/aws/requests/compute/detach_internet_gateway.rb +2 -2
  38. data/lib/fog/aws/requests/compute/detach_network_interface.rb +2 -2
  39. data/lib/fog/aws/requests/compute/disassociate_route_table.rb +57 -0
  40. data/lib/fog/aws/requests/compute/reset_network_interface_attribute.rb +2 -1
  41. data/lib/fog/aws/requests/elb/create_load_balancer.rb +23 -9
  42. data/lib/fog/aws/requests/iam/upload_server_certificate.rb +1 -1
  43. data/lib/fog/aws/requests/rds/describe_orderable_db_instance_options.rb +76 -0
  44. data/lib/fog/aws/storage.rb +0 -2
  45. data/lib/fog/brightbox/models/compute/collaboration.rb +10 -2
  46. data/lib/fog/brightbox/models/compute/collaborations.rb +26 -2
  47. data/lib/fog/brightbox/models/compute/user_collaboration.rb +16 -1
  48. data/lib/fog/brightbox/models/compute/user_collaborations.rb +10 -2
  49. data/lib/fog/cloudstack/models/compute/server.rb +4 -0
  50. data/lib/fog/core/collection.rb +18 -0
  51. data/lib/fog/core/credentials.rb +6 -1
  52. data/lib/fog/google/compute.rb +17 -0
  53. data/lib/fog/google/examples/get_list_images.rb +27 -0
  54. data/lib/fog/google/examples/get_list_snapshots.rb +20 -0
  55. data/lib/fog/google/examples/image_create.rb +18 -0
  56. data/lib/fog/google/examples/launch_micro_instance.rb +10 -5
  57. data/lib/fog/google/examples/network.rb +21 -0
  58. data/lib/fog/google/models/compute/disk.rb +16 -5
  59. data/lib/fog/google/models/compute/image.rb +36 -18
  60. data/lib/fog/google/models/compute/images.rb +36 -10
  61. data/lib/fog/google/models/compute/server.rb +41 -11
  62. data/lib/fog/google/models/compute/servers.rb +1 -1
  63. data/lib/fog/google/models/compute/snapshot.rb +36 -0
  64. data/lib/fog/google/models/compute/snapshots.rb +28 -0
  65. data/lib/fog/google/requests/compute/delete_disk.rb +5 -1
  66. data/lib/fog/google/requests/compute/get_disk.rb +2 -1
  67. data/lib/fog/google/requests/compute/get_snapshot.rb +34 -0
  68. data/lib/fog/google/requests/compute/insert_disk.rb +23 -7
  69. data/lib/fog/google/requests/compute/insert_image.rb +16 -9
  70. data/lib/fog/google/requests/compute/insert_server.rb +22 -10
  71. data/lib/fog/google/requests/compute/list_disks.rb +1 -1
  72. data/lib/fog/google/requests/compute/list_snapshots.rb +30 -0
  73. data/lib/fog/google/storage.rb +1 -3
  74. data/lib/fog/hp/storage.rb +0 -2
  75. data/lib/fog/internet_archive/storage.rb +0 -2
  76. data/lib/fog/local/storage.rb +0 -2
  77. data/lib/fog/ninefold/storage.rb +0 -1
  78. data/lib/fog/openstack/models/storage/file.rb +2 -0
  79. data/lib/fog/openstack/requests/compute/add_flavor_access.rb +1 -1
  80. data/lib/fog/openstack/requests/compute/create_volume.rb +8 -7
  81. data/lib/fog/openstack/requests/compute/list_tenants_with_flavor_access.rb +1 -1
  82. data/lib/fog/openstack/requests/compute/remove_flavor_access.rb +1 -1
  83. data/lib/fog/openstack/requests/image/create_image.rb +23 -23
  84. data/lib/fog/openstack/requests/image/update_image.rb +31 -33
  85. data/lib/fog/openstack/requests/storage/get_object_https_url.rb +3 -3
  86. data/lib/fog/openstack/requests/storage/post_set_meta_temp_url_key.rb +1 -1
  87. data/lib/fog/openstack/storage.rb +10 -11
  88. data/lib/fog/openstack.rb +10 -1
  89. data/lib/fog/rackspace/cdn.rb +13 -0
  90. data/lib/fog/rackspace/compute.rb +8 -4
  91. data/lib/fog/rackspace/compute_v2.rb +2 -0
  92. data/lib/fog/rackspace/databases.rb +4 -4
  93. data/lib/fog/rackspace/dns.rb +6 -6
  94. data/lib/fog/rackspace/examples/compute_v2/bootstrap_server.rb +98 -0
  95. data/lib/fog/rackspace/load_balancers.rb +5 -4
  96. data/lib/fog/rackspace/models/compute_v2/flavors.rb +1 -2
  97. data/lib/fog/rackspace/models/compute_v2/images.rb +35 -3
  98. data/lib/fog/rackspace/models/compute_v2/metadatum.rb +2 -2
  99. data/lib/fog/rackspace/models/identity/service_catalog.rb +34 -16
  100. data/lib/fog/rackspace/models/load_balancers/load_balancer.rb +8 -3
  101. data/lib/fog/rackspace/models/monitoring/alarm.rb +16 -8
  102. data/lib/fog/rackspace/models/monitoring/base.rb +2 -8
  103. data/lib/fog/rackspace/monitoring.rb +14 -6
  104. data/lib/fog/rackspace/requests/compute_v2/list_flavors_detail.rb +39 -0
  105. data/lib/fog/rackspace/requests/compute_v2/list_images.rb +15 -5
  106. data/lib/fog/rackspace/requests/compute_v2/list_images_detail.rb +53 -0
  107. data/lib/fog/rackspace/requests/identity/create_token.rb +1 -1
  108. data/lib/fog/rackspace/requests/load_balancers/create_load_balancer.rb +12 -0
  109. data/lib/fog/rackspace/requests/load_balancers/get_stats.rb +31 -0
  110. data/lib/fog/rackspace/requests/monitoring/get_entity.rb +33 -0
  111. data/lib/fog/rackspace/service.rb +7 -0
  112. data/lib/fog/rackspace/storage.rb +6 -3
  113. data/lib/fog/rackspace.rb +8 -5
  114. data/lib/fog/riakcs/provisioning.rb +0 -1
  115. data/lib/fog/riakcs/usage.rb +2 -3
  116. data/lib/fog/storage.rb +2 -0
  117. data/lib/fog/vcloud/examples/README.md +54 -0
  118. data/lib/fog/vcloud/examples/creating_a_connection.md +20 -0
  119. data/lib/fog/vcloud/examples/creating_a_vapp.md +17 -0
  120. data/lib/fog/vcloud/examples/get_network_information.md +10 -0
  121. data/lib/fog/vcloud/examples/get_vapp_information.md +10 -0
  122. data/lib/fog/vcloud/examples/more_on_vapps.md +23 -0
  123. data/lib/fog/version.rb +1 -1
  124. data/lib/tasks/changelog_task.rb +1 -0
  125. data/tests/aws/models/elb/model_tests.rb +5 -0
  126. data/tests/aws/models/rds/instance_option_tests.rb +14 -0
  127. data/tests/aws/requests/compute/client_tests.rb +25 -0
  128. data/tests/aws/requests/compute/route_tests.rb +277 -0
  129. data/tests/aws/requests/rds/helper.rb +22 -0
  130. data/tests/aws/requests/rds/instance_option_tests.rb +21 -0
  131. data/tests/core/credential_tests.rb +21 -0
  132. data/tests/core/service_tests.rb +26 -0
  133. data/tests/openstack/authenticate_tests.rb +22 -0
  134. data/tests/openstack/models/storage/file_tests.rb +20 -1
  135. data/tests/openstack/requests/compute/flavor_tests.rb +27 -12
  136. data/tests/openstack/requests/compute/volume_tests.rb +10 -12
  137. data/tests/openstack/requests/image/image_tests.rb +30 -15
  138. data/tests/rackspace/block_storage_tests.rb +9 -4
  139. data/tests/rackspace/cdn_tests.rb +14 -0
  140. data/tests/rackspace/compute_tests.rb +10 -4
  141. data/tests/rackspace/compute_v2_tests.rb +9 -4
  142. data/tests/rackspace/databases_tests.rb +9 -4
  143. data/tests/rackspace/dns_tests.rb +9 -4
  144. data/tests/rackspace/helper.rb +21 -2
  145. data/tests/rackspace/identity_tests.rb +9 -4
  146. data/tests/rackspace/load_balancer_tests.rb +8 -4
  147. data/tests/rackspace/models/compute_v2/server_tests.rb +18 -21
  148. data/tests/rackspace/models/identity/service_catalog_tests.rb +54 -29
  149. data/tests/rackspace/models/load_balancers/load_balancer_tests.rb +5 -0
  150. data/tests/rackspace/models/monitoring/alarm_examples_tests.rb +1 -1
  151. data/tests/rackspace/models/monitoring/alarm_tests.rb +2 -2
  152. data/tests/rackspace/monitoring_tests.rb +9 -4
  153. data/tests/rackspace/requests/compute_v2/flavor_tests.rb +6 -0
  154. data/tests/rackspace/requests/compute_v2/image_tests.rb +4 -0
  155. data/tests/rackspace/requests/compute_v2/server_tests.rb +2 -2
  156. data/tests/rackspace/requests/load_balancers/get_stats_tests.rb +13 -0
  157. data/tests/rackspace/requests/load_balancers/helper.rb +9 -0
  158. data/tests/rackspace/requests/monitoring/alarm_tests.rb +4 -5
  159. data/tests/rackspace/requests/monitoring/entity_tests.rb +9 -1
  160. data/tests/rackspace/requests/storage/large_object_tests.rb +12 -4
  161. data/tests/rackspace/storage_tests.rb +23 -4
  162. data/tests/rackspace/url_encoding_tests.rb +3 -1
  163. metadata +117 -133
  164. checksums.yaml +0 -15
  165. data/lib/fog/aws/parsers/compute/associate_dhcp_options.rb +0 -24
  166. data/lib/fog/aws/parsers/compute/attach_internet_gateway.rb +0 -24
  167. data/lib/fog/aws/parsers/compute/delete_dhcp_options.rb +0 -24
  168. data/lib/fog/aws/parsers/compute/delete_internet_gateway.rb +0 -24
  169. data/lib/fog/aws/parsers/compute/delete_network_interface.rb +0 -24
  170. data/lib/fog/aws/parsers/compute/delete_subnet.rb +0 -24
  171. data/lib/fog/aws/parsers/compute/delete_vpc.rb +0 -24
  172. data/lib/fog/aws/parsers/compute/detach_internet_gateway.rb +0 -24
  173. data/lib/fog/aws/parsers/compute/detach_network_interface.rb +0 -24
@@ -91,19 +91,19 @@ module Fog
91
91
 
92
92
  def enable_content_caching
93
93
  requires :identity
94
- connection.set_content_caching identity, true
94
+ service.set_content_caching identity, true
95
95
  true
96
96
  end
97
97
 
98
98
  def disable_content_caching
99
99
  requires :identity
100
- connection.set_content_caching identity, false
100
+ service.set_content_caching identity, false
101
101
  true
102
102
  end
103
103
 
104
104
  def content_caching
105
105
  requires :identity
106
- connection.get_content_caching(identity).body['contentCaching']['enabled']
106
+ service.get_content_caching(identity).body['contentCaching']['enabled']
107
107
  end
108
108
 
109
109
  def enable_connection_logging
@@ -196,6 +196,11 @@ module Fog
196
196
  service.get_load_balancer_usage(identity, options).body
197
197
  end
198
198
 
199
+ def stats
200
+ requires :identity
201
+ service.get_stats(identity).body
202
+ end
203
+
199
204
  def error_page
200
205
  requires :identity
201
206
  service.get_error_page(identity).body['errorpage']['content']
@@ -7,15 +7,22 @@ module Fog
7
7
  class Alarm < Fog::Rackspace::Monitoring::Base
8
8
 
9
9
  identity :id
10
- attribute :entity
11
- attribute :entity_id
10
+ attribute :entity, :aliases => 'entity_id'
11
+ attribute :check, :aliases => 'check_id'
12
12
 
13
13
  attribute :label
14
14
  attribute :criteria
15
15
  attribute :check_type
16
- attribute :check_id
17
16
  attribute :notification_plan_id
18
17
 
18
+ def entity=(obj)
19
+ attributes[:entity] = obj.is_a?(String) ? Entity.new(:id => obj) : obj
20
+ end
21
+
22
+ def check=(obj)
23
+ attributes[:check] = obj.is_a?(String) ? Check.new(:id => obj) : obj
24
+ end
25
+
19
26
  def params(options={})
20
27
  h = {
21
28
  'label' => label,
@@ -27,13 +34,14 @@ module Fog
27
34
 
28
35
  def save
29
36
  requires :notification_plan_id
30
- requires :entity_id
37
+ requires :entity
38
+ requires :check
31
39
 
32
40
  if identity
33
- data = service.update_alarm(entity_id, identity, params)
41
+ data = service.update_alarm(entity.id, identity, params)
34
42
  else
35
- options = params('check_type' => check_type, 'check_id' => check_id)
36
- data = service.create_alarm(entity_id, options)
43
+ options = params('check_type' => check_type, 'check_id' => check.id)
44
+ data = service.create_alarm(entity.id, options)
37
45
  self.id = data.headers['X-Object-ID']
38
46
  end
39
47
  true
@@ -41,7 +49,7 @@ module Fog
41
49
 
42
50
  def destroy
43
51
  requires :id
44
- service.delete_alarm(entity.id,id)
52
+ service.delete_alarm(entity.id, id)
45
53
  end
46
54
 
47
55
  end
@@ -19,17 +19,11 @@ module Fog
19
19
  end
20
20
 
21
21
  def compare?(b)
22
- a_o = prep
23
- b_o = b.prep
22
+ a_o = params
23
+ b_o = b.params
24
24
  remain = a_o.reject {|key, value| b_o[key] === value}
25
25
  remain.empty?
26
26
  end
27
-
28
- def entity_id
29
- raise(ArgumentError, "entity with id is required for this operation") unless entity && entity.identity
30
- entity.identity
31
- end
32
-
33
27
  end
34
28
  end
35
29
  end
@@ -77,6 +77,10 @@ module Fog
77
77
 
78
78
 
79
79
  class Mock < Fog::Rackspace::Service
80
+
81
+ def initialize(options={})
82
+ end
83
+
80
84
  def request(params)
81
85
  Fog::Mock.not_implemented
82
86
  end
@@ -112,22 +116,26 @@ module Fog
112
116
  @uri = super(@rackspace_endpoint || service_endpoint_url, :rackspace_monitoring_url)
113
117
  end
114
118
 
119
+ def request_id_header
120
+ "X-Response-Id"
121
+ end
122
+
115
123
  private
116
124
 
117
125
  def request(params, parse_json = true, &block)
118
126
  super(params, parse_json, &block)
119
127
  rescue Excon::Errors::BadRequest => error
120
- raise BadRequest.slurp error
128
+ raise BadRequest.slurp(error, self)
121
129
  rescue Excon::Errors::Conflict => error
122
- raise Conflict.slurp error
130
+ raise Conflict.slurp(error, self)
123
131
  rescue Excon::Errors::NotFound => error
124
- raise NotFound.slurp(error, region)
132
+ raise NotFound.slurp(error, self)
125
133
  rescue Excon::Errors::ServiceUnavailable => error
126
- raise ServiceUnavailable.slurp error
134
+ raise ServiceUnavailable.slurp(error, self)
127
135
  rescue Excon::Errors::InternalServerError => error
128
- raise InternalServerError.slurp error
136
+ raise InternalServerError.slurp(error, self)
129
137
  rescue Excon::Errors::HTTPStatusError => error
130
- raise ServiceError.slurp error
138
+ raise ServiceError.slurp(error, self)
131
139
  end
132
140
 
133
141
  def authenticate
@@ -0,0 +1,39 @@
1
+ module Fog
2
+ module Compute
3
+ class RackspaceV2
4
+ class Real
5
+
6
+ # Retrieves a list of flavors
7
+ # @return [Excon::Response] response:
8
+ # * body [Hash]:
9
+ # * flavors [Array]:
10
+ # * [Hash]:
11
+ # * id [String] - flavor id
12
+ # * links [Array] - flavor links
13
+ # * name [String] - flavor name
14
+ # * ram [Fixnum] - flavor ram
15
+ # * disk [Fixnum] - flavor disk
16
+ # * vcpus [Fixnum] - flavor vcpus
17
+ # @raise [Fog::Compute::RackspaceV2::NotFound] - HTTP 404
18
+ # @raise [Fog::Compute::RackspaceV2::BadRequest] - HTTP 400
19
+ # @raise [Fog::Compute::RackspaceV2::InternalServerError] - HTTP 500
20
+ # @raise [Fog::Compute::RackspaceV2::ServiceError]
21
+ # @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/List_Flavors-d1e4188.html
22
+ def list_flavors_detail
23
+ request(
24
+ :expects => [200, 203],
25
+ :method => 'GET',
26
+ :path => 'flavors/detail'
27
+ )
28
+ end
29
+ end
30
+
31
+ class Mock
32
+ def list_flavors_detail
33
+ flavors = self.data[:flavors].values.map { |f| Fog::Rackspace::MockData.keep(f, 'id', 'name', 'links') }
34
+ response(:body => {"flavors" => flavors})
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -4,29 +4,39 @@ module Fog
4
4
  class Real
5
5
 
6
6
  # Retrieves a list of images
7
+ # ==== Parameters
8
+ # * options<~String>:
9
+ # * 'name'<~String> - Filters the list of images by image name
10
+ # * 'limit'<~String> - Maximum number of objects to return
11
+ # * 'marker'<~String> - Only return objects whose name is greater than marker
12
+ # * 'status'<~String> - Filters the list of images by status
13
+ # * 'type'<~String> - Filters base Rackspace images or anyn custom server images that have been created
14
+ #
7
15
  # @return [Excon::Response] response:
8
16
  # * body [Hash]:
9
17
  # * images [Array]:
10
18
  # * [Hash]:
11
- # * id [String] - flavor id
19
+ # * id [String] - image id
12
20
  # * links [Array] - image links
13
21
  # * name [String] - image name
14
22
  # @raise [Fog::Compute::RackspaceV2::NotFound] - HTTP 404
15
23
  # @raise [Fog::Compute::RackspaceV2::BadRequest] - HTTP 400
16
24
  # @raise [Fog::Compute::RackspaceV2::InternalServerError] - HTTP 500
17
25
  # @raise [Fog::Compute::RackspaceV2::ServiceError]
18
- # @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/List_Flavors-d1e4188.html
19
- def list_images
26
+ # @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/List_Images-d1e4435.html
27
+ def list_images(options = {})
28
+ options = options.reject {|key, value| value.nil?}
20
29
  request(
21
30
  :expects => [200, 203],
22
31
  :method => 'GET',
23
- :path => 'images'
32
+ :path => 'images',
33
+ :query => {'format' => 'json'}.merge!(options)
24
34
  )
25
35
  end
26
36
  end
27
37
 
28
38
  class Mock
29
- def list_images
39
+ def list_images(options = {})
30
40
  images = self.data[:images].values
31
41
  response(:body => {"images" => images})
32
42
  end
@@ -0,0 +1,53 @@
1
+ module Fog
2
+ module Compute
3
+ class RackspaceV2
4
+ class Real
5
+
6
+ # Retrieves a list of images
7
+ # ==== Parameters
8
+ # * options<~String>:
9
+ # * 'name'<~String> - Filters the list of images by image name
10
+ # * 'limit'<~String> - Maximum number of objects to return
11
+ # * 'marker'<~String> - Only return objects whose name is greater than marker
12
+ # * 'status'<~String> - Filters the list of images by status
13
+ # * 'type'<~String> - Filters base Rackspace images or anyn custom server images that have been created
14
+ #
15
+ # @return [Excon::Response] response:
16
+ # * body [Hash]:
17
+ # * images [Array]:
18
+ # * [Hash]:
19
+ # * id [String] - image id
20
+ # * links [Array] - image links
21
+ # * name [String] - image name
22
+ # * minDisk [Fixnum] - image minimum disk required
23
+ # * minRam [Fixnum] - image minimum ram required
24
+ # * created [String] - image creation date (ISO 8601 format)
25
+ # * updated [String] - date of most recent image update
26
+ # * state [String] - image status (e.g. ACTIVE, SAVING, ERROR)
27
+ # * progress [Fixnum] - image saving progress
28
+ #
29
+ # @raise [Fog::Compute::RackspaceV2::NotFound] - HTTP 404
30
+ # @raise [Fog::Compute::RackspaceV2::BadRequest] - HTTP 400
31
+ # @raise [Fog::Compute::RackspaceV2::InternalServerError] - HTTP 500
32
+ # @raise [Fog::Compute::RackspaceV2::ServiceError]
33
+ # @see http://docs.rackspace.com/servers/api/v2/cs-devguide/content/List_Images-d1e4435.html
34
+ def list_images_detail(options = {})
35
+ options = options.reject {|key, value| value.nil?}
36
+ request(
37
+ :expects => [200, 203],
38
+ :method => 'GET',
39
+ :path => 'images/detail',
40
+ :query => {'format' => 'json'}.merge!(options)
41
+ )
42
+ end
43
+ end
44
+
45
+ class Mock
46
+ def list_images_detail(options = {})
47
+ images = self.data[:images].values
48
+ response(:body => {"images" => images})
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -12,7 +12,7 @@ module Fog
12
12
  }
13
13
  }
14
14
 
15
- request(
15
+ request_without_retry(
16
16
  :body => Fog::JSON.encode(data),
17
17
  :expects => [200, 203],
18
18
  :method => 'POST',
@@ -24,6 +24,18 @@ module Fog
24
24
  )
25
25
  end
26
26
  end
27
+
28
+ class Mock
29
+ def create_load_balancer(name, protocol, port, virtual_ips, nodes, options = {})
30
+ data = {"loadBalancer"=>{"name"=>name, "id"=>uniq_id, "protocol"=>protocol, "port"=>port, "algorithm"=>"RANDOM", "status"=>"BUILD",
31
+ "cluster"=>{"name"=>"ztm-n13.dfw1.lbaas.rackspace.net"}, "timeout"=>30, "created"=>{"time"=>"2013-08-20T20:52:44Z"},
32
+ "updated"=>{"time"=>"2013-08-20T20:52:44Z"}, "halfClosed"=>false, "connectionLogging"=>{"enabled"=>false}, "contentCaching"=>{"enabled"=>false}}}
33
+ data["virtual_ips"] = virtual_ips.collect {|n| {"virtualIps"=>[{"address"=>"192.237.192.152", "id"=>uniq_id, "type"=>n[:type], "ipVersion"=>"IPV4"}, {"address"=>"2001:4800:7901:0000:ba81:a6a5:0000:0002", "id"=>9153169, "type"=>"PUBLIC", "ipVersion"=>"IPV6"}], "sourceAddresses"=>{"ipv6Public"=>"2001:4800:7901::13/64", "ipv4Servicenet"=>"10.189.254.5", "ipv4Public"=>"166.78.44.5"}}
34
+ data["nodes"] = nodes.collect {|n| {"address"=>n[:address], "id"=>uniq_id, "type"=>"PRIMARY", "port"=>n[:port], "status"=>"ONLINE", "condition"=>"ENABLED", "weight"=>1}}
35
+ data = Excon::Response.new(:body => data, :status => 202)
36
+ }
37
+ end
38
+ end
27
39
  end
28
40
  end
29
41
  end
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module Rackspace
3
+ class LoadBalancers
4
+ class Real
5
+ def get_stats(load_balancer_id)
6
+
7
+ request(
8
+ :expects => 200,
9
+ :path => "loadbalancers/#{load_balancer_id}/stats",
10
+ :method => 'GET'
11
+ )
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def get_stats(load_balancer_id)
17
+ mock_data = {
18
+ 'connectTimeOut' => 0,
19
+ 'connectError' => 1,
20
+ 'connectFailure' => 2,
21
+ 'dataTimedOut' => 3,
22
+ 'keepAliveTimedOut' => 4,
23
+ 'maxConn' => 5
24
+ }
25
+
26
+ Excon::Response.new(:body => mock_data, :status => 200)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -12,6 +12,39 @@ module Fog
12
12
  end
13
13
 
14
14
  end
15
+
16
+ class Mock
17
+ def get_entity(entity_id)
18
+ response = Excon::Response.new
19
+ response.status = 200
20
+ response.body = {
21
+ "id" => entity_id,
22
+ "label"=>"mocked_fog_entitiy",
23
+ "ip_addresses"=>{
24
+ "private0_v4"=>"10.0.0.1"
25
+ },
26
+ "metadata"=>nil,
27
+ "managed"=>false,
28
+ "uri"=>"https://ord.servers.api.rackspacecloud.com/5555/servers/23kj2q4hk234",
29
+ "agent_id"=>nil,
30
+ "created_at"=> Time.now.to_i - 5000,
31
+ "updated_at"=> Time.now.to_i
32
+ }
33
+ response.headers = {
34
+ "Date"=> Time.now.utc.to_s,
35
+ "Content-Type"=>"application/json; charset=UTF-8",
36
+ "X-RateLimit-Limit"=>"50000",
37
+ "X-RateLimit-Remaining"=>"49627",
38
+ "X-RateLimit-Window"=>"24 hours",
39
+ "X-RateLimit-Type"=>"global",
40
+ "X-Response-Id"=>"j23jlk234jl2j34j",
41
+ "X-LB"=>"dfw1-maas-prod-api0",
42
+ "Vary"=>"Accept-Encoding",
43
+ "Transfer-Encoding"=>"chunked"
44
+ }
45
+ response
46
+ end
47
+ end
15
48
  end
16
49
  end
17
50
  end
@@ -30,6 +30,13 @@ module Fog
30
30
  self.send authentication_method, options
31
31
  end
32
32
 
33
+ def request_without_retry(params, parse_json = true, &block)
34
+ response = @connection.request(request_params(params), &block)
35
+
36
+ process_response(response) if parse_json
37
+ response
38
+ end
39
+
33
40
  def request(params, parse_json = true, &block)
34
41
  first_attempt = true
35
42
  begin
@@ -74,9 +74,9 @@ module Fog
74
74
  end
75
75
 
76
76
  def initialize(options={})
77
- require 'mime/types'
78
77
  @rackspace_api_key = options[:rackspace_api_key]
79
78
  @rackspace_username = options[:rackspace_username]
79
+ @rackspace_cdn_ssl = options[:rackspace_cdn_ssl]
80
80
  end
81
81
 
82
82
  def data
@@ -95,6 +95,10 @@ module Fog
95
95
  @rackspace_region
96
96
  end
97
97
 
98
+ def ssl?
99
+ !!@rackspace_cdn_ssl
100
+ end
101
+
98
102
  end
99
103
 
100
104
  class Real < Fog::Rackspace::Service
@@ -103,7 +107,6 @@ module Fog
103
107
  attr_reader :rackspace_cdn_ssl
104
108
 
105
109
  def initialize(options={})
106
- require 'mime/types'
107
110
  @rackspace_api_key = options[:rackspace_api_key]
108
111
  @rackspace_username = options[:rackspace_username]
109
112
  @rackspace_cdn_ssl = options[:rackspace_cdn_ssl]
@@ -134,7 +137,7 @@ module Fog
134
137
  # @return [Boolean] return true if service is returning SSL-Secured URLs in public_url methods
135
138
  # @see Directory#public_url
136
139
  def ssl?
137
- !rackspace_cdn_ssl.nil?
140
+ !!rackspace_cdn_ssl
138
141
  end
139
142
 
140
143
  # Resets presistent service connections
data/lib/fog/rackspace.rb CHANGED
@@ -19,7 +19,7 @@ module Fog
19
19
  "[#{status} | #{transaction_id}] #{super}"
20
20
  end
21
21
 
22
- def self.slurp(error)
22
+ def self.slurp(error, service=nil)
23
23
  data = nil
24
24
  message = nil
25
25
  status_code = nil
@@ -45,8 +45,6 @@ module Fog
45
45
  new_error
46
46
  end
47
47
 
48
- private
49
-
50
48
  def set_transaction_id(error, service)
51
49
  return unless service && service.respond_to?(:request_id_header) && error.response
52
50
  @transaction_id = error.response.headers[service.request_id_header]
@@ -69,14 +67,16 @@ module Fog
69
67
  #TODO - Need to find a better way to print out these validation errors when they are thrown
70
68
  attr_reader :validation_errors
71
69
 
72
- def self.slurp(error)
70
+ def self.slurp(error, service=nil)
73
71
  new_error = super(error)
74
72
  unless new_error.response_data.nil? or new_error.response_data['badRequest'].nil?
75
73
  new_error.instance_variable_set(:@validation_errors, new_error.response_data['badRequest']['validationErrors'])
76
74
  end
77
75
 
76
+ status_code = error.response ? error.response.status : nil
78
77
  new_error.instance_variable_set(:@status_code, status_code)
79
78
  new_error.set_transaction_id(error, service)
79
+ new_error
80
80
  end
81
81
  end
82
82
  end
@@ -130,7 +130,10 @@ module Fog
130
130
 
131
131
  # CGI.escape, but without special treatment on spaces
132
132
  def self.escape(str,extra_exclude_chars = '')
133
- str.gsub(/([^a-zA-Z0-9_.-#{extra_exclude_chars}]+)/) do
133
+ # '-' is a special character inside a regex class so it must be first or last.
134
+ # Add extra excludes before the final '-' so it always remains trailing, otherwise
135
+ # an unwanted range is created by mistake.
136
+ str.gsub(/([^a-zA-Z0-9_.#{extra_exclude_chars}-]+)/) do
134
137
  '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
135
138
  end
136
139
  end
@@ -47,7 +47,6 @@ module Fog
47
47
  include Utils
48
48
 
49
49
  def initialize(options = {})
50
- require 'mime/types'
51
50
  require 'multi_json'
52
51
 
53
52
  configure_uri_options(options)
@@ -15,7 +15,7 @@ module Fog
15
15
  include Utils
16
16
 
17
17
  def self.data
18
- @data ||= Hash.new do |hash, key|
18
+ @data ||= Hash.new do |hash, key|
19
19
  hash[key] = {}
20
20
  end
21
21
  end
@@ -24,7 +24,7 @@ module Fog
24
24
  @data = nil
25
25
  end
26
26
 
27
- def initialize(options = {})
27
+ def initialize(options = {})
28
28
  configure_uri_options(options)
29
29
  end
30
30
 
@@ -41,7 +41,6 @@ module Fog
41
41
  include Utils
42
42
 
43
43
  def initialize(options = {})
44
- require 'mime/types'
45
44
  require 'multi_json'
46
45
 
47
46
  configure_uri_options(options)
data/lib/fog/storage.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'mime/types'
2
+
1
3
  module Fog
2
4
  module Storage
3
5
 
@@ -0,0 +1,54 @@
1
+ # Using vCloud API via fog
2
+ _contributor @singhgarima_
3
+
4
+ For more information about fog [README](/README.md), or visit their website
5
+ [fog.io](www.fog.io).
6
+
7
+ ## Vcloud API
8
+
9
+ Some useful links to get started on the vCloud API:
10
+
11
+ - [http://www.vmware.com/pdf/vcd_15_api_guide.pdf](http://www.vmware.com/pdf/vcd_15_api_guide.pdf)
12
+ - [vCloud API Programming Guide](http://pubs.vmware.com/vcd-51/index.jsp?topic=%2Fcom.vmware.vcloud.api.doc_51%2FGUID-86CA32C2-3753-49B2-A471-1CE460109ADB.html)
13
+
14
+ ## Terminology
15
+
16
+ - Organization: An Organization is the fundamental vCloud Director grouping
17
+ that contains users, the vApps that they create, and the resources the vApps
18
+ use. It is a top-level container in a cloud that contains one or more
19
+ Organization Virtual Data Centers (Org vDCs) and Catalog entities. It owns
20
+ all the virtual resources for a cloud instance and can have many Org vDCs.[1]
21
+
22
+ - vApp: VMware vApp is a format for packaging and managing applications. A vApp
23
+ can contain multiple virtual machines.[2]
24
+
25
+ - VM: A virtualized personal computer environment in which a guest
26
+ operating system and associated application software can run. Multiple virtual
27
+ machines can operate on the same managed host machine concurrently.[3]
28
+
29
+ - Catalogs & Catalog-Items: Catalog is used in organizations for storing content.
30
+ Example: base images. Each item stored in catalog is referred as catalog item.
31
+
32
+ - vDC: Virtual Data Center. These are of two kinds provider vDCs (accessible to
33
+ multiple organizations), and organization vDCs (accessible only by a given
34
+ organization). In fog we refer to organization vDCs.
35
+
36
+ - Networks: You can setup various internal networks and assign various internal
37
+ ip ranges to them
38
+
39
+ ## What is the difference between a virtual appliance and a virtual machine?
40
+
41
+ A virtual machine is a tightly isolated software container created to run on
42
+ virtualized platforms. It has four key virtualized resources (CPU, RAM,
43
+ Storage, and Networking); but requires the installation of an Operating System
44
+ and runs on one or more applications. A virtual appliance functions very much
45
+ like a virtual machine, possessing the four key characteristics of
46
+ compatibility, isolation, encapsulation, and hardware independence. However, a
47
+ virtual appliance contains a pre-installed, pre-configured Operating System
48
+ and an application stack optimized to provide a specific set of services.[3]
49
+
50
+ **References**
51
+
52
+ - [1] http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1026316
53
+ - [2] http://www.vmware.com/pdf/vsphere4/r40/vsp_40_admin_guide.pdf
54
+ - [3] http://www.vmware.com/technical-resources/virtualization-topics/virtual-appliances/faqs
@@ -0,0 +1,20 @@
1
+ # Creating a connection
2
+
3
+ connection = Fog::Compute.new(
4
+ :provider => :vcloud,
5
+ :vcloud_username => "username@org-name",
6
+ :vcloud_password => password,
7
+ :vcloud_host => vendor-api-endpoint-host,
8
+ :vcloud_default_vdc => default_vdc_uri,
9
+ :connection_options => {
10
+ :ssl_verify_peer => false,
11
+ :omit_default_port => true
12
+ }
13
+ )
14
+
15
+ - Refer to links in [vcloud/examples/README.md](/lib/fog/vcloud/examples/REAME.md)
16
+ for find various different uris
17
+ - connection_options are passed down to `excon`, which is used by fog to make
18
+ http requests.
19
+ - We using `omit_default_port`, as currently excon adds port to host entry
20
+ in headers, which might not be compatible with various vendors.
@@ -0,0 +1,17 @@
1
+ # Creating a vApp
2
+
3
+ connection.servers.create(
4
+ :vdc_uri => vdc-uuid,
5
+ :catalog_item_uri => catalog-uuid,
6
+ :name => vApp-name,
7
+ :network_uri => network-uri,
8
+ :network_name => network-name,
9
+ :connection_options => {
10
+ :ssl_verify_peer => false,
11
+ :omit_default_port => true
12
+ }
13
+ )
14
+
15
+ - Not most of the uris can be found by understanding the vcloud api
16
+ eg various network information can be retrieved by
17
+ `connection.servers.service.networks`
@@ -0,0 +1,10 @@
1
+ # Get network information
2
+
3
+ - To see all networks list
4
+
5
+ connection.servers.service.networks
6
+
7
+ - To see details of a particular network
8
+
9
+ selected_nw = connection.servers.service.networks.detect { |n| n.name == 'Default' }
10
+ connection.servers.service.get_network(selected_nw.href)
@@ -0,0 +1,10 @@
1
+ # Get network information
2
+
3
+ - To see all vApps list
4
+
5
+ connection.servers.service.vapps
6
+
7
+ - To see details of a particular vApp
8
+
9
+ selected_vapp = connection.servers.service.vapps.detect { |n| n.name == 'vapp-name' }
10
+ connection.servers.service.get_vapp(selected_vapp.href)