fog 0.0.84 → 0.0.85

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/Gemfile +1 -0
  2. data/Gemfile.lock +47 -37
  3. data/bin/fog +9 -10
  4. data/fog.gemspec +23 -4
  5. data/lib/fog.rb +19 -1
  6. data/lib/fog/aws.rb +23 -0
  7. data/lib/fog/aws/bin.rb +4 -0
  8. data/lib/fog/aws/ec2.rb +20 -27
  9. data/lib/fog/aws/elb.rb +115 -0
  10. data/lib/fog/aws/models/ec2/server.rb +7 -1
  11. data/lib/fog/aws/models/s3/directories.rb +4 -4
  12. data/lib/fog/aws/models/s3/directory.rb +13 -11
  13. data/lib/fog/aws/parsers/elb/deregister_instances_from_load_balancer.rb +26 -0
  14. data/lib/fog/aws/parsers/elb/describe_instance_health.rb +30 -0
  15. data/lib/fog/aws/parsers/elb/describe_load_balancers.rb +101 -0
  16. data/lib/fog/aws/parsers/elb/disable_availability_zones_for_load_balancer.rb +26 -0
  17. data/lib/fog/aws/parsers/elb/enable_availability_zones_for_load_balancer.rb +26 -0
  18. data/lib/fog/aws/parsers/elb/register_instances_with_load_balancer.rb +26 -0
  19. data/lib/fog/aws/requests/ec2/detach_volume.rb +2 -2
  20. data/lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb +45 -0
  21. data/lib/fog/aws/requests/elb/describe_instance_health.rb +44 -0
  22. data/lib/fog/aws/requests/elb/describe_load_balancers.rb +57 -0
  23. data/lib/fog/aws/requests/elb/disable_availability_zones_for_load_balancer.rb +44 -0
  24. data/lib/fog/aws/requests/elb/enable_availability_zones_for_load_balancer.rb +44 -0
  25. data/lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb +45 -0
  26. data/lib/fog/aws/s3.rb +8 -1
  27. data/lib/fog/aws/simpledb.rb +9 -18
  28. data/lib/fog/bin.rb +11 -1
  29. data/lib/fog/credentials.rb +1 -0
  30. data/lib/fog/local.rb +72 -0
  31. data/lib/fog/local/bin.rb +34 -0
  32. data/lib/fog/local/models/directories.rb +43 -0
  33. data/lib/fog/local/models/directory.rb +47 -0
  34. data/lib/fog/local/models/file.rb +58 -0
  35. data/lib/fog/local/models/files.rb +74 -0
  36. data/lib/fog/model.rb +2 -8
  37. data/lib/fog/rackspace/models/files/directories.rb +3 -3
  38. data/lib/fog/rackspace/models/files/directory.rb +8 -5
  39. data/lib/fog/rackspace/models/servers/server.rb +7 -3
  40. data/lib/fog/rackspace/requests/servers/create_server.rb +1 -1
  41. data/lib/fog/ssh.rb +91 -25
  42. data/lib/fog/terremark/bin.rb +1 -8
  43. data/lib/fog/terremark/ecloud.rb +14 -5
  44. data/lib/fog/terremark/models/shared/server.rb +54 -3
  45. data/lib/fog/terremark/parsers/shared/vapp.rb +1 -1
  46. data/lib/fog/terremark/requests/shared/get_network.rb +39 -1
  47. data/lib/fog/terremark/requests/shared/get_organization.rb +45 -1
  48. data/lib/fog/terremark/requests/shared/get_organizations.rb +2 -1
  49. data/lib/fog/terremark/requests/shared/get_public_ips.rb +32 -1
  50. data/lib/fog/terremark/requests/shared/get_vdc.rb +83 -1
  51. data/lib/fog/terremark/requests/shared/{reset.rb → power_reset.rb} +1 -1
  52. data/lib/fog/terremark/requests/shared/power_shutdown.rb +32 -0
  53. data/lib/fog/terremark/shared.rb +139 -18
  54. data/lib/fog/terremark/vcloud.rb +14 -5
  55. data/spec/aws/models/ec2/address_spec.rb +1 -3
  56. data/spec/aws/models/ec2/snapshot_spec.rb +25 -49
  57. data/spec/aws/models/ec2/snapshots_spec.rb +25 -31
  58. data/spec/aws/models/ec2/volume_spec.rb +9 -3
  59. data/spec/aws/models/s3/directory_spec.rb +14 -14
  60. data/spec/aws/requests/ec2/associate_address_spec.rb +4 -5
  61. data/spec/aws/requests/ec2/attach_volume_spec.rb +14 -16
  62. data/spec/aws/requests/ec2/create_snapshot_spec.rb +2 -3
  63. data/spec/aws/requests/ec2/delete_snapshot_spec.rb +5 -6
  64. data/spec/aws/requests/ec2/describe_instances_spec.rb +3 -2
  65. data/spec/aws/requests/ec2/describe_snapshots_spec.rb +21 -25
  66. data/spec/aws/requests/ec2/detach_volume_spec.rb +14 -16
  67. data/spec/aws/requests/ec2/disassociate_address_spec.rb +3 -4
  68. data/spec/aws/requests/ec2/get_console_output_spec.rb +1 -0
  69. data/spec/aws/requests/s3/get_service_spec.rb +5 -6
  70. data/spec/spec_helper.rb +0 -20
  71. data/tests/helper.rb +0 -10
  72. data/tests/rackspace/requests/servers/create_image_tests.rb +2 -2
  73. data/tests/rackspace/requests/servers/create_server_tests.rb +3 -2
  74. data/tests/rackspace/requests/servers/delete_image_tests.rb +2 -2
  75. data/tests/rackspace/requests/servers/delete_server_tests.rb +1 -1
  76. data/tests/rackspace/requests/servers/get_server_details_tests.rb +1 -1
  77. data/tests/rackspace/requests/servers/list_addresses_tests.rb +1 -1
  78. data/tests/rackspace/requests/servers/list_private_addresses_tests.rb +1 -1
  79. data/tests/rackspace/requests/servers/list_public_addresses_tests.rb +1 -1
  80. data/tests/rackspace/requests/servers/list_servers_detail_tests.rb +1 -1
  81. data/tests/rackspace/requests/servers/list_servers_tests.rb +1 -1
  82. data/tests/rackspace/requests/servers/reboot_server_tests.rb +3 -3
  83. data/tests/rackspace/requests/servers/update_server_tests.rb +1 -1
  84. data/tests/slicehost/requests/create_slice_tests.rb +1 -1
  85. data/tests/slicehost/requests/delete_slice_tests.rb +1 -1
  86. data/tests/slicehost/requests/get_slice_tests.rb +1 -1
  87. data/tests/slicehost/requests/reboot_slice_tests.rb +2 -2
  88. metadata +24 -5
  89. data/lib/fog/terremark/requests/shared/shutdown.rb +0 -43
@@ -8,7 +8,7 @@ module Fog
8
8
 
9
9
  identity :id, 'instanceId'
10
10
 
11
- attribute :architecture
11
+ attr_accessor :architecture
12
12
  attribute :ami_launch_index, 'amiLaunchIndex'
13
13
  attribute :availability_zone, 'availabilityZone'
14
14
  attribute :block_device_mapping, 'blockDeviceMapping'
@@ -43,6 +43,12 @@ module Fog
43
43
  connection.addresses(:server => self)
44
44
  end
45
45
 
46
+ def console_output
47
+ requires :id
48
+
49
+ connection.get_console_output(@id)
50
+ end
51
+
46
52
  def destroy
47
53
  requires :id
48
54
 
@@ -26,15 +26,15 @@ module Fog
26
26
  load(data)
27
27
  end
28
28
 
29
- def get(name, options = {})
29
+ def get(key, options = {})
30
30
  remap_attributes(options, {
31
31
  :delimiter => 'delimiter',
32
32
  :marker => 'marker',
33
33
  :max_keys => 'max-keys',
34
34
  :prefix => 'prefix'
35
35
  })
36
- data = connection.get_bucket(name, options).body
37
- directory = new(:name => data['Name'])
36
+ data = connection.get_bucket(key, options).body
37
+ directory = new(:key => data['Name'])
38
38
  options = {}
39
39
  for key, value in data
40
40
  if ['Delimiter', 'IsTruncated', 'Marker', 'MaxKeys', 'Prefix'].include?(key)
@@ -44,7 +44,7 @@ module Fog
44
44
  directory.files.merge_attributes(options)
45
45
  files = data['Contents']
46
46
  while data['IsTruncated']
47
- data = connection.get_bucket(name, options.merge!('marker' => files.last['Key'])).body
47
+ data = connection.get_bucket(key, options.merge!('marker' => files.last['Key'])).body
48
48
  files.concat(data['Contents'])
49
49
  end
50
50
  directory.files.load(files)
@@ -6,22 +6,24 @@ module Fog
6
6
  module S3
7
7
 
8
8
  class Directory < Fog::Model
9
+ extend Fog::Deprecation
10
+ deprecate(:name, :key)
9
11
 
10
- identity :name, 'Name'
12
+ identity :key, 'Name'
11
13
 
12
14
  attribute :creation_date, 'CreationDate'
13
15
 
14
16
  def destroy
15
- requires :name
16
- connection.delete_bucket(@name)
17
+ requires :key
18
+ connection.delete_bucket(key)
17
19
  true
18
20
  rescue Excon::Errors::NotFound
19
21
  false
20
22
  end
21
23
 
22
24
  def location
23
- requires :name
24
- data = connection.get_bucket_location(@name)
25
+ requires :key
26
+ data = connection.get_bucket_location(key)
25
27
  data.body['LocationConstraint']
26
28
  end
27
29
 
@@ -39,24 +41,24 @@ module Fog
39
41
  end
40
42
 
41
43
  def payer
42
- requires :name
43
- data = connection.get_request_payment(@name)
44
+ requires :key
45
+ data = connection.get_request_payment(key)
44
46
  data.body['Payer']
45
47
  end
46
48
 
47
49
  def payer=(new_payer)
48
- requires :name
49
- connection.put_request_payment(@name, new_payer)
50
+ requires :key
51
+ connection.put_request_payment(key, new_payer)
50
52
  @payer = new_payer
51
53
  end
52
54
 
53
55
  def save
54
- requires :name
56
+ requires :key
55
57
  options = {}
56
58
  if @location
57
59
  options['LocationConstraint'] = @location
58
60
  end
59
- connection.put_bucket(@name, options)
61
+ connection.put_bucket(key, options)
60
62
  true
61
63
  end
62
64
 
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module ELB
5
+
6
+ class DeregisterInstancesFromLoadBalancer < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = { 'DeregisterInstancesFromLoadBalancerResult' => { 'Instances' => [] }, 'ResponseMetadata' => {} }
10
+ end
11
+
12
+ def end_element(name)
13
+ case name
14
+ when 'InstanceId'
15
+ @response['DeregisterInstancesFromLoadBalancerResult']['Instances'] << {name => @value}
16
+ when 'RequestId'
17
+ @response['ResponseMetadata'][name] = @value
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module ELB
5
+
6
+ class DescribeInstanceHealth < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = { 'DescribeInstanceHealthResult' => { 'InstanceStates' => [] }, 'ResponseMetadata' => {} }
10
+ @instance_state = {}
11
+ end
12
+
13
+ def end_element(name)
14
+ case name
15
+ when 'Description', 'State', 'InstanceId', 'ReasonCode'
16
+ @instance_state[name] = @value
17
+ when 'member'
18
+ @response['DescribeInstanceHealthResult']['InstanceStates'] << @instance_state
19
+ @instance_state = {}
20
+ when 'RequestId'
21
+ @response['ResponseMetadata'][name] = @value
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,101 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module ELB
5
+
6
+ class DescribeLoadBalancers < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @load_balancer = { 'ListenerDescriptions' => [], 'Instances' => [], 'AvailabilityZones' => [], 'Policies' => {'AppCookieStickinessPolicies' => [], 'LBCookieStickinessPolicies' => [] }, 'HealthCheck' => {} }
10
+ @listener_description = { 'PolicyNames' => [], 'Listener' => {} }
11
+ @results = { 'LoadBalancerDescriptions' => [] }
12
+ @response = { 'DescribeLoadBalancersResult' => {}, 'ResponseMetadata' => {} }
13
+ end
14
+
15
+ def start_element(name, attrs = [])
16
+ case name
17
+ when 'ListenerDescriptions'
18
+ @in_listeners = true
19
+ when 'Instances'
20
+ @in_instances = true
21
+ when 'AvailabilityZones'
22
+ @in_availability_zones = true
23
+ when 'PolicyNames'
24
+ @in_policy_names = true
25
+ when 'Policies'
26
+ @in_policies = true
27
+ when 'LBCookieStickinessPolicies'
28
+ @in_lb_cookies = true
29
+ when 'AppCookieStickinessPolicies'
30
+ @in_app_cookies = true
31
+ end
32
+ @value = ''
33
+ end
34
+
35
+ def end_element(name)
36
+ case name
37
+ when 'member'
38
+ if @in_policy_names
39
+ @listener_description['PolicyNames'] << @value
40
+ elsif @in_availability_zones
41
+ @load_balancer['AvailabilityZones'] << @value
42
+ elsif @in_listeners
43
+ @load_balancer['ListenerDescriptions'] << @listener_description
44
+ @listener_description = { 'PolicyNames' => [], 'Listener' => {} }
45
+ elsif @in_app_cookies
46
+ @load_balancer['Policies']['AppCookieStickinessPolicies'] << @value
47
+ elsif @in_lb_cookies
48
+ @load_balancer['Policies']['LBCookieStickinessPolicies'] << @value
49
+ elsif !@in_instances && !@in_policies
50
+ @results['LoadBalancerDescriptions'] << @load_balancer
51
+ @load_balancer = { 'ListenerDescriptions' => [], 'Instances' => [], 'AvailabilityZones' => [], 'Policies' => {'AppCookieStickinessPolicies' => [], 'LBCookieStickinessPolicies' => [] }, 'HealthCheck' => {} }
52
+ end
53
+
54
+ when 'LoadBalancerName', 'DNSName'
55
+ @load_balancer[name] = @value
56
+ when 'CreatedTime'
57
+ @load_balancer[name] = Time.parse(@value)
58
+
59
+ when 'ListenerDescriptions'
60
+ @in_listeners = false
61
+ when 'PolicyNames'
62
+ @in_policy_names = false
63
+ when 'Protocol'
64
+ @listener_description['Listener'][name] = @value
65
+ when 'LoadBalancerPort', 'InstancePort'
66
+ @listener_description['Listener'][name] = @value.to_i
67
+
68
+ when 'Instances'
69
+ @in_instances = false
70
+ when 'InstanceId'
71
+ @load_balancer['Instances'] << @value
72
+
73
+ when 'AvailabilityZones'
74
+ @in_availability_zones = false
75
+
76
+ when 'Policies'
77
+ @in_policies = false
78
+ when 'AppCookieStickinessPolicies'
79
+ @in_app_cookies = false
80
+ when 'LBCookieStickinessPolicies'
81
+ @in_lb_cookies = false
82
+
83
+ when 'Interval', 'HealthyThreshold', 'Timeout', 'UnhealthyThreshold'
84
+ @load_balancer['HealthCheck'][name] = @value.to_i
85
+ when 'Target'
86
+ @load_balancer['HealthCheck'][name] = @value
87
+
88
+ when 'RequestId'
89
+ @response['ResponseMetadata'][name] = @value
90
+
91
+ when 'DescribeLoadBalancersResponse'
92
+ @response['DescribeLoadBalancersResult'] = @results
93
+ end
94
+ end
95
+
96
+ end
97
+
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module ELB
5
+
6
+ class DisableAvailabilityZonesForLoadBalancer < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = { 'DisableAvailabilityZonesForLoadBalancerResult' => { 'AvailabilityZones' => [] }, 'ResponseMetadata' => {} }
10
+ end
11
+
12
+ def end_element(name)
13
+ case name
14
+ when 'member'
15
+ @response['DisableAvailabilityZonesForLoadBalancerResult']['AvailabilityZones'] << @value
16
+ when 'RequestId'
17
+ @response['ResponseMetadata'][name] = @value
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module ELB
5
+
6
+ class EnableAvailabilityZonesForLoadBalancer < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = { 'EnableAvailabilityZonesForLoadBalancerResult' => { 'AvailabilityZones' => [] }, 'ResponseMetadata' => {} }
10
+ end
11
+
12
+ def end_element(name)
13
+ case name
14
+ when 'member'
15
+ @response['EnableAvailabilityZonesForLoadBalancerResult']['AvailabilityZones'] << @value
16
+ when 'RequestId'
17
+ @response['ResponseMetadata'][name] = @value
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module ELB
5
+
6
+ class RegisterInstancesWithLoadBalancer < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = { 'RegisterInstancesWithLoadBalancerResult' => { 'Instances' => [] }, 'ResponseMetadata' => {} }
10
+ end
11
+
12
+ def end_element(name)
13
+ case name
14
+ when 'InstanceId'
15
+ @response['RegisterInstancesWithLoadBalancerResult']['Instances'] << {name => @value}
16
+ when 'RequestId'
17
+ @response['ResponseMetadata'][name] = @value
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -36,9 +36,9 @@ module Fog
36
36
  def detach_volume(volume_id, options = {})
37
37
  response = Excon::Response.new
38
38
  response.status = 200
39
- if volume = @data[:volumes][volume_id]
39
+ if (volume = @data[:volumes][volume_id]) && !volume['attachmentSet'].empty?
40
40
  data = volume['attachmentSet'].pop
41
- @data[:volumes][volume_id]['status'] = 'available'
41
+ volume['status'] = 'available'
42
42
  response.status = 200
43
43
  response.body = {
44
44
  'requestId' => Fog::AWS::Mock.request_id
@@ -0,0 +1,45 @@
1
+ module Fog
2
+ module AWS
3
+ module ELB
4
+ class Real
5
+
6
+ # Deregister an instance from an existing ELB
7
+ #
8
+ # ==== Parameters
9
+ # * instance_ids<~Array> - List of instance IDs to remove from ELB
10
+ # * lb_name<~String> - Load balancer to remove instances from
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response>:
14
+ # * body<~Hash>:
15
+ # * 'ResponseMetadata'<~Hash>:
16
+ # * 'RequestId'<~String> - Id of request
17
+ # * 'DeregisterInstancesFromLoadBalancerResult'<~Hash>:
18
+ # * 'Instances'<~Array> - array of hashes describing instances currently enabled
19
+ # * 'InstanceId'<~String>
20
+ def deregister_instances_from_load_balancer(instance_ids, lb_name)
21
+ params = ELB.indexed_param('Instances.member.%.InstanceId', [*instance_ids], 1)
22
+ request({
23
+ 'Action' => 'DeregisterInstancesFromLoadBalancer',
24
+ 'LoadBalancerName' => lb_name,
25
+ :parser => Fog::Parsers::AWS::ELB::DeregisterInstancesFromLoadBalancer.new
26
+ }.merge!(params))
27
+ end
28
+
29
+ alias :deregister_instances :deregister_instances_from_load_balancer
30
+
31
+ end
32
+
33
+ class Mock
34
+
35
+ def deregister_instances_from_load_balancer(instance_ids, lb_name)
36
+ raise MockNotImplemented.new("Contributions welcome!")
37
+ end
38
+
39
+ alias :deregister_instances :deregister_instances_from_load_balancer
40
+
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,44 @@
1
+ module Fog
2
+ module AWS
3
+ module ELB
4
+ class Real
5
+
6
+ # Get health status for one or more instances on an existing ELB
7
+ #
8
+ # ==== Parameters
9
+ # * lb_name<~String> - Load balancer to check instances health on
10
+ # * instance_ids<~Array> - Optional list of instance IDs to check
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response>:
14
+ # * body<~Hash>:
15
+ # * 'ResponseMetadata'<~Hash>:
16
+ # * 'RequestId'<~String> - Id of request
17
+ # * 'DescribeInstanceHealthResult'<~Hash>:
18
+ # * 'InstanceStates'<~Array> - array of hashes describing instance health
19
+ # * 'Description'<~String>
20
+ # * 'State'<~String>
21
+ # * 'InstanceId'<~String>
22
+ # * 'ReasonCode'<~String>
23
+ def describe_instance_health(lb_name, instance_ids = [])
24
+ params = ELB.indexed_param('Instances.member.%.InstanceId', [*instance_ids], 1)
25
+ request({
26
+ 'Action' => 'DescribeInstanceHealth',
27
+ 'LoadBalancerName' => lb_name,
28
+ :parser => Fog::Parsers::AWS::ELB::DescribeInstanceHealth.new
29
+ }.merge!(params))
30
+ end
31
+
32
+ end
33
+
34
+ class Mock
35
+
36
+ def describe_instance_health(lb_name, instance_ids = [])
37
+ raise MockNotImplemented.new("Contributions welcome!")
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+ end
44
+ end