fog 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -6
- data/README.rdoc +7 -1
- data/bin/fog +4 -3
- data/fog.gemspec +39 -24
- data/lib/fog.rb +4 -12
- data/lib/fog/aws.rb +14 -5
- data/lib/fog/aws/compute.rb +26 -9
- data/lib/fog/aws/elb.rb +3 -2
- data/lib/fog/aws/models/compute/address.rb +2 -1
- data/lib/fog/aws/models/compute/addresses.rb +11 -9
- data/lib/fog/aws/models/compute/flavor.rb +1 -1
- data/lib/fog/aws/models/compute/flavors.rb +13 -11
- data/lib/fog/aws/models/compute/image.rb +2 -1
- data/lib/fog/aws/models/compute/images.rb +7 -9
- data/lib/fog/aws/models/compute/key_pair.rb +1 -1
- data/lib/fog/aws/models/compute/key_pairs.rb +10 -8
- data/lib/fog/aws/models/compute/security_group.rb +1 -1
- data/lib/fog/aws/models/compute/security_groups.rb +11 -9
- data/lib/fog/aws/models/compute/server.rb +10 -3
- data/lib/fog/aws/models/compute/servers.rb +14 -8
- data/lib/fog/aws/models/compute/snapshot.rb +3 -2
- data/lib/fog/aws/models/compute/snapshots.rb +11 -16
- data/lib/fog/aws/models/compute/tag.rb +36 -0
- data/lib/fog/aws/models/compute/tags.rb +34 -0
- data/lib/fog/aws/models/compute/volume.rb +11 -10
- data/lib/fog/aws/models/compute/volumes.rb +11 -9
- data/lib/fog/aws/models/storage/directories.rb +1 -1
- data/lib/fog/aws/models/storage/directory.rb +1 -1
- data/lib/fog/aws/models/storage/file.rb +3 -2
- data/lib/fog/aws/models/storage/files.rb +1 -7
- data/lib/fog/aws/parsers/compute/describe_availability_zones.rb +4 -2
- data/lib/fog/aws/parsers/compute/describe_images.rb +23 -13
- data/lib/fog/aws/parsers/compute/describe_instances.rb +34 -8
- data/lib/fog/aws/parsers/compute/describe_security_groups.rb +4 -3
- data/lib/fog/aws/parsers/compute/describe_snapshots.rb +33 -13
- data/lib/fog/aws/parsers/compute/describe_tags.rb +30 -0
- data/lib/fog/aws/parsers/compute/describe_volumes.rb +17 -3
- data/lib/fog/aws/parsers/compute/run_instances.rb +4 -4
- data/lib/fog/aws/parsers/storage/get_bucket.rb +1 -1
- data/lib/fog/aws/parsers/storage/get_bucket_logging.rb +1 -1
- data/lib/fog/aws/parsers/storage/get_bucket_object_versions.rb +3 -3
- data/lib/fog/aws/requests/compute/create_snapshot.rb +1 -0
- data/lib/fog/aws/requests/compute/create_tags.rb +78 -0
- data/lib/fog/aws/requests/compute/delete_tags.rb +45 -0
- data/lib/fog/aws/requests/compute/describe_addresses.rb +27 -19
- data/lib/fog/aws/requests/compute/describe_availability_zones.rb +31 -25
- data/lib/fog/aws/requests/compute/describe_images.rb +11 -18
- data/lib/fog/aws/requests/compute/describe_instances.rb +125 -53
- data/lib/fog/aws/requests/compute/describe_key_pairs.rb +29 -21
- data/lib/fog/aws/requests/compute/describe_regions.rb +28 -23
- data/lib/fog/aws/requests/compute/describe_reserved_instances.rb +8 -4
- data/lib/fog/aws/requests/compute/describe_security_groups.rb +48 -19
- data/lib/fog/aws/requests/compute/describe_snapshots.rb +72 -35
- data/lib/fog/aws/requests/compute/describe_tags.rb +42 -0
- data/lib/fog/aws/requests/compute/describe_volumes.rb +67 -36
- data/lib/fog/aws/requests/compute/run_instances.rb +10 -3
- data/lib/fog/aws/simpledb.rb +3 -1
- data/lib/fog/aws/storage.rb +17 -8
- data/lib/fog/bluebox/models/compute/flavor.rb +1 -1
- data/lib/fog/bluebox/models/compute/flavors.rb +1 -1
- data/lib/fog/bluebox/models/compute/image.rb +1 -1
- data/lib/fog/bluebox/models/compute/images.rb +1 -1
- data/lib/fog/bluebox/models/compute/server.rb +8 -6
- data/lib/fog/bluebox/models/compute/servers.rb +1 -1
- data/lib/fog/bluebox/requests/compute/get_blocks.rb +1 -1
- data/lib/fog/core.rb +11 -0
- data/lib/fog/{attributes.rb → core/attributes.rb} +0 -0
- data/lib/fog/{bin.rb → core/bin.rb} +1 -1
- data/lib/fog/{collection.rb → core/collection.rb} +4 -0
- data/lib/fog/{connection.rb → core/connection.rb} +0 -0
- data/lib/fog/{credentials.rb → core/credentials.rb} +2 -0
- data/lib/fog/{deprecation.rb → core/deprecation.rb} +0 -0
- data/lib/fog/{errors.rb → core/errors.rb} +0 -0
- data/lib/fog/{hmac.rb → core/hmac.rb} +0 -0
- data/lib/fog/{model.rb → core/model.rb} +0 -0
- data/lib/fog/{parser.rb → core/parser.rb} +0 -0
- data/lib/fog/{provider.rb → core/provider.rb} +0 -0
- data/lib/fog/{service.rb → core/service.rb} +1 -0
- data/lib/fog/{ssh.rb → core/ssh.rb} +7 -7
- data/lib/fog/go_grid.rb +1 -1
- data/lib/fog/go_grid/compute.rb +6 -1
- data/lib/fog/go_grid/models/compute/image.rb +60 -0
- data/lib/fog/go_grid/models/compute/images.rb +33 -0
- data/lib/fog/go_grid/models/compute/server.rb +56 -0
- data/lib/fog/go_grid/models/compute/servers.rb +35 -0
- data/lib/fog/go_grid/requests/compute/grid_image_get.rb +41 -0
- data/lib/fog/go_grid/requests/compute/grid_image_list.rb +6 -1
- data/lib/fog/go_grid/requests/compute/grid_server_power.rb +2 -2
- data/lib/fog/google/models/storage/directories.rb +1 -1
- data/lib/fog/google/models/storage/directory.rb +1 -1
- data/lib/fog/google/models/storage/file.rb +3 -2
- data/lib/fog/google/models/storage/files.rb +1 -7
- data/lib/fog/google/parsers/storage/get_bucket.rb +1 -1
- data/lib/fog/linode/requests/compute/avail_linodeplans.rb +2 -2
- data/lib/fog/local/models/storage/directories.rb +1 -1
- data/lib/fog/local/models/storage/directory.rb +1 -1
- data/lib/fog/local/models/storage/file.rb +2 -2
- data/lib/fog/local/models/storage/files.rb +2 -5
- data/lib/fog/local/storage.rb +1 -1
- data/lib/fog/new_servers/compute.rb +1 -1
- data/lib/fog/rackspace/models/compute/flavor.rb +1 -3
- data/lib/fog/rackspace/models/compute/flavors.rb +1 -1
- data/lib/fog/rackspace/models/compute/image.rb +2 -1
- data/lib/fog/rackspace/models/compute/images.rb +1 -1
- data/lib/fog/rackspace/models/compute/server.rb +12 -11
- data/lib/fog/rackspace/models/compute/servers.rb +1 -1
- data/lib/fog/rackspace/models/storage/directories.rb +1 -1
- data/lib/fog/rackspace/models/storage/directory.rb +1 -1
- data/lib/fog/rackspace/models/storage/file.rb +4 -4
- data/lib/fog/rackspace/models/storage/files.rb +1 -1
- data/lib/fog/rackspace/requests/compute/create_image.rb +2 -2
- data/lib/fog/rackspace/requests/compute/delete_image.rb +1 -1
- data/lib/fog/rackspace/requests/compute/delete_server.rb +1 -1
- data/lib/fog/rackspace/requests/compute/get_server_details.rb +1 -1
- data/lib/fog/rackspace/requests/compute/list_addresses.rb +1 -1
- data/lib/fog/rackspace/requests/compute/list_images_detail.rb +2 -2
- data/lib/fog/rackspace/requests/compute/list_private_addresses.rb +1 -1
- data/lib/fog/rackspace/requests/compute/list_public_addresses.rb +1 -1
- data/lib/fog/rackspace/requests/compute/update_server.rb +1 -1
- data/lib/fog/rackspace/requests/storage/put_object.rb +4 -3
- data/lib/fog/slicehost/models/compute/flavor.rb +1 -1
- data/lib/fog/slicehost/models/compute/flavors.rb +1 -1
- data/lib/fog/slicehost/models/compute/image.rb +1 -1
- data/lib/fog/slicehost/models/compute/images.rb +1 -1
- data/lib/fog/slicehost/models/compute/server.rb +3 -1
- data/lib/fog/slicehost/models/compute/servers.rb +1 -1
- data/lib/fog/terremark/ecloud.rb +34 -33
- data/lib/fog/terremark/models/shared/address.rb +1 -1
- data/lib/fog/terremark/models/shared/network.rb +1 -1
- data/lib/fog/terremark/models/shared/server.rb +1 -1
- data/lib/fog/terremark/models/shared/servers.rb +1 -1
- data/lib/fog/terremark/models/shared/task.rb +1 -1
- data/lib/fog/terremark/models/shared/tasks.rb +1 -1
- data/lib/fog/terremark/models/shared/vdc.rb +1 -1
- data/lib/fog/terremark/parser.rb +1 -0
- data/lib/fog/terremark/vcloud.rb +4 -4
- data/lib/fog/vcloud.rb +15 -7
- data/lib/fog/vcloud/terremark/ecloud.rb +15 -3
- data/lib/fog/vcloud/terremark/ecloud/models/firewall_acls.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +55 -49
- data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +19 -15
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +8 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +17 -12
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +29 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +38 -2
- data/lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb +8 -2
- data/lib/fog/vcloud/terremark/ecloud/requests/instantiate_vapp_template.rb +46 -4
- data/spec/aws/models/compute/server_spec.rb +2 -0
- data/spec/aws/requests/simpledb/select_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/vcloud/spec_helper.rb +1 -1
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_item_spec.rb +62 -0
- data/spec/vcloud/terremark/ecloud/requests/get_catalog_spec.rb +44 -0
- data/spec/vcloud/terremark/ecloud/requests/get_customization_options_spec.rb +39 -0
- data/spec/vcloud/terremark/ecloud/requests/instantiate_vapp_template_spec.rb +73 -0
- data/tests/aws/requests/compute/address_tests.rb +2 -6
- data/tests/aws/requests/compute/availability_zone_tests.rb +3 -10
- data/tests/aws/requests/compute/image_tests.rb +4 -9
- data/tests/aws/requests/compute/instance_tests.rb +7 -8
- data/tests/aws/requests/compute/key_pair_tests.rb +2 -6
- data/tests/aws/requests/compute/region_tests.rb +2 -9
- data/tests/aws/requests/compute/security_group_tests.rb +3 -7
- data/tests/aws/requests/compute/snapshot_tests.rb +4 -7
- data/tests/aws/requests/compute/tag_tests.rb +49 -0
- data/tests/aws/requests/compute/volume_tests.rb +2 -6
- data/tests/aws/requests/storage/bucket_tests.rb +48 -0
- data/tests/aws/requests/storage/object_tests.rb +63 -0
- data/tests/bluebox/requests/compute/block_tests.rb +24 -11
- data/tests/bluebox/requests/compute/product_tests.rb +3 -0
- data/tests/bluebox/requests/compute/template_tests.rb +3 -0
- data/tests/go_grid/helper.rb +0 -0
- data/tests/go_grid/requests/compute/image_tests.rb +0 -0
- data/tests/helper.rb +5 -1
- data/tests/linode/requests/compute/datacenter_tests.rb +1 -0
- data/tests/linode/requests/compute/distribution_tests.rb +2 -0
- data/tests/linode/requests/compute/linode_tests.rb +6 -0
- data/tests/linode/requests/compute/linodeplans_tests.rb +2 -0
- data/tests/lorem.txt +1 -0
- data/tests/rackspace/requests/compute/flavor_tests.rb +4 -0
- data/tests/rackspace/requests/compute/image_tests.rb +12 -4
- data/tests/rackspace/requests/compute/server_tests.rb +9 -0
- data/tests/slicehost/requests/compute/backup_tests.rb +1 -0
- data/tests/slicehost/requests/compute/flavor_tests.rb +3 -0
- data/tests/slicehost/requests/compute/image_tests.rb +3 -0
- data/tests/slicehost/requests/compute/slice_tests.rb +14 -2
- metadata +42 -27
- data/spec/aws/requests/storage/delete_bucket_spec.rb +0 -35
- data/spec/aws/requests/storage/delete_object_spec.rb +0 -36
- data/spec/aws/requests/storage/get_object_spec.rb +0 -58
- data/spec/aws/requests/storage/get_service_spec.rb +0 -32
- data/spec/aws/requests/storage/head_object_spec.rb +0 -26
- data/spec/aws/requests/storage/put_bucket_spec.rb +0 -19
- data/spec/aws/requests/storage/put_object_spec.rb +0 -43
data/lib/fog/aws/elb.rb
CHANGED
@@ -17,7 +17,6 @@ module Fog
|
|
17
17
|
class Mock
|
18
18
|
|
19
19
|
def initialize(options={})
|
20
|
-
Fog::Mock.not_implemented
|
21
20
|
end
|
22
21
|
|
23
22
|
end
|
@@ -59,9 +58,10 @@ module Fog
|
|
59
58
|
else
|
60
59
|
raise ArgumentError, "Unknown region: #{options[:region].inspect}"
|
61
60
|
end
|
61
|
+
@path = options[:path] || '/'
|
62
62
|
@port = options[:port] || 443
|
63
63
|
@scheme = options[:scheme] || 'https'
|
64
|
-
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
64
|
+
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
|
65
65
|
end
|
66
66
|
|
67
67
|
def reload
|
@@ -80,6 +80,7 @@ module Fog
|
|
80
80
|
:aws_access_key_id => @aws_access_key_id,
|
81
81
|
:hmac => @hmac,
|
82
82
|
:host => @host,
|
83
|
+
:path => @path,
|
83
84
|
:version => '2009-11-25'
|
84
85
|
}
|
85
86
|
)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fog/model'
|
1
|
+
require 'fog/core/model'
|
2
2
|
|
3
3
|
module Fog
|
4
4
|
module AWS
|
@@ -32,6 +32,7 @@ module Fog
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def save
|
35
|
+
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
35
36
|
data = connection.allocate_address
|
36
37
|
@public_ip = data.body['publicIp']
|
37
38
|
if @server
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fog/collection'
|
1
|
+
require 'fog/core/collection'
|
2
2
|
require 'fog/aws/models/compute/address'
|
3
3
|
|
4
4
|
module Fog
|
@@ -7,19 +7,23 @@ module Fog
|
|
7
7
|
|
8
8
|
class Addresses < Fog::Collection
|
9
9
|
|
10
|
-
attribute :
|
10
|
+
attribute :filters
|
11
11
|
attribute :server
|
12
12
|
|
13
13
|
model Fog::AWS::Compute::Address
|
14
14
|
|
15
15
|
def initialize(attributes)
|
16
|
-
@
|
16
|
+
@filters ||= {}
|
17
17
|
super
|
18
18
|
end
|
19
19
|
|
20
|
-
def all(
|
21
|
-
|
22
|
-
|
20
|
+
def all(filters = @filters)
|
21
|
+
unless filters.is_a?(Hash)
|
22
|
+
Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('public-ip' => []) instead[/] [light_black](#{caller.first})[/]")
|
23
|
+
filters = {'public-ip' => [*filters]}
|
24
|
+
end
|
25
|
+
@filters = filters
|
26
|
+
data = connection.describe_addresses(filters).body
|
23
27
|
load(
|
24
28
|
data['addressesSet'].map do |address|
|
25
29
|
address.reject {|key, value| value.nil? || value.empty? }
|
@@ -33,10 +37,8 @@ module Fog
|
|
33
37
|
|
34
38
|
def get(public_ip)
|
35
39
|
if public_ip
|
36
|
-
all(public_ip).first
|
40
|
+
self.class.new(:connection => connection).all('public-ip' => public_ip).first
|
37
41
|
end
|
38
|
-
rescue Fog::Errors::NotFound
|
39
|
-
nil
|
40
42
|
end
|
41
43
|
|
42
44
|
def new(attributes = {})
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fog/collection'
|
1
|
+
require 'fog/core/collection'
|
2
2
|
require 'fog/aws/models/compute/flavor'
|
3
3
|
|
4
4
|
module Fog
|
@@ -11,25 +11,27 @@ module Fog
|
|
11
11
|
|
12
12
|
def all
|
13
13
|
data = [
|
14
|
-
{ :bits => 0, :cores =>
|
14
|
+
{ :bits => 0, :cores => 2, :disk => 0, :id => 't1.micro', :name => 'Micro Instance', :ram => 613},
|
15
15
|
|
16
|
-
{ :bits => 32, :cores =>
|
17
|
-
{ :bits => 64, :cores =>
|
18
|
-
{ :bits => 64, :cores =>
|
16
|
+
{ :bits => 32, :cores => 1, :disk => 160, :id => 'm1.small', :name => 'Small Instance', :ram => 1740.8},
|
17
|
+
{ :bits => 64, :cores => 4, :disk => 850, :id => 'm1.large', :name => 'Large Instance', :ram => 7680},
|
18
|
+
{ :bits => 64, :cores => 8, :disk => 1690, :id => 'm1.xlarge', :name => 'Extra Large Instance', :ram => 15360},
|
19
19
|
|
20
|
-
{ :bits => 32, :cores =>
|
21
|
-
{ :bits => 64, :cores =>
|
20
|
+
{ :bits => 32, :cores => 5, :disk => 350, :id => 'c1.medium', :name => 'High-CPU Medium', :ram => 1740.8},
|
21
|
+
{ :bits => 64, :cores => 20, :disk => 1690, :id => 'c1.xlarge', :name => 'High-CPU Extra Large', :ram => 7168},
|
22
22
|
|
23
|
-
{ :bits => 64, :cores =>
|
24
|
-
{ :bits => 64, :cores =>
|
25
|
-
{ :bits => 64, :cores =>
|
23
|
+
{ :bits => 64, :cores => 6.5, :disk => 420, :id => 'm2.xlarge', :name => 'High-Memory Extra Large', :ram => 17510.4},
|
24
|
+
{ :bits => 64, :cores => 13, :disk => 850, :id => 'm2.2xlarge', :name => 'High Memory Double Extra Large', :ram => 35020.8},
|
25
|
+
{ :bits => 64, :cores => 26, :disk => 1690, :id => 'm2.4xlarge', :name => 'High Memory Quadruple Extra Large', :ram => 70041.6},
|
26
|
+
|
27
|
+
{ :bits => 64, :cores => 33.5, :disk => 1690, :id => 'cc1.4xlarge', :name => 'Cluster Compute Quadruple Extra Large', :ram => 23552}
|
26
28
|
]
|
27
29
|
load(data)
|
28
30
|
self
|
29
31
|
end
|
30
32
|
|
31
33
|
def get(flavor_id)
|
32
|
-
all.detect {|flavor| flavor.id == flavor_id}
|
34
|
+
self.class.new(:connection => connection).all.detect {|flavor| flavor.id == flavor_id}
|
33
35
|
end
|
34
36
|
|
35
37
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fog/model'
|
1
|
+
require 'fog/core/model'
|
2
2
|
|
3
3
|
module Fog
|
4
4
|
module AWS
|
@@ -21,6 +21,7 @@ module Fog
|
|
21
21
|
attribute :ramdisk_id, :aliases => 'ramdiskId'
|
22
22
|
attribute :root_device_type, :aliases => 'rootDeviceType'
|
23
23
|
attribute :root_device_name, :aliases => 'rootDeviceName'
|
24
|
+
attribute :tags, :aliases => 'tagSet'
|
24
25
|
|
25
26
|
def deregister(delete_snapshot = false)
|
26
27
|
connection.deregister_image(@id)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fog/collection'
|
1
|
+
require 'fog/core/collection'
|
2
2
|
require 'fog/aws/models/compute/image'
|
3
3
|
|
4
4
|
module Fog
|
@@ -7,27 +7,25 @@ module Fog
|
|
7
7
|
|
8
8
|
class Images < Fog::Collection
|
9
9
|
|
10
|
-
attribute :
|
10
|
+
attribute :filters
|
11
11
|
|
12
12
|
model Fog::AWS::Compute::Image
|
13
13
|
|
14
14
|
def initialize(attributes)
|
15
|
-
@
|
15
|
+
@filters ||= {}
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
19
|
-
def all(
|
20
|
-
@
|
21
|
-
data = connection.describe_images(
|
19
|
+
def all(filters = @filters)
|
20
|
+
@filters = filters
|
21
|
+
data = connection.describe_images(@filters).body
|
22
22
|
load(data['imagesSet'])
|
23
23
|
end
|
24
24
|
|
25
25
|
def get(image_id)
|
26
26
|
if image_id
|
27
|
-
all(image_id).first
|
27
|
+
self.class.new(:connection => connection).all('image-id' => image_id).first
|
28
28
|
end
|
29
|
-
rescue Fog::Errors::NotFound
|
30
|
-
nil
|
31
29
|
end
|
32
30
|
end
|
33
31
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fog/collection'
|
1
|
+
require 'fog/core/collection'
|
2
2
|
require 'fog/aws/models/compute/key_pair'
|
3
3
|
|
4
4
|
module Fog
|
@@ -12,22 +12,24 @@ module Fog
|
|
12
12
|
model Fog::AWS::Compute::KeyPair
|
13
13
|
|
14
14
|
def initialize(attributes)
|
15
|
-
@
|
15
|
+
@filters ||= {}
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
19
|
-
def all(
|
20
|
-
|
21
|
-
|
19
|
+
def all(filters = @filters)
|
20
|
+
unless filters.is_a?(Hash)
|
21
|
+
Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('key-name' => []) instead[/] [light_black](#{caller.first})[/]")
|
22
|
+
filters = {'key-name' => [*filters]}
|
23
|
+
end
|
24
|
+
@filters = filters
|
25
|
+
data = connection.describe_key_pairs(filters).body
|
22
26
|
load(data['keySet'])
|
23
27
|
end
|
24
28
|
|
25
29
|
def get(key_name)
|
26
30
|
if key_name
|
27
|
-
all(key_name).first
|
31
|
+
self.class.new(:connection => connection).all('key-name' => key_name).first
|
28
32
|
end
|
29
|
-
rescue Fog::Errors::NotFound
|
30
|
-
nil
|
31
33
|
end
|
32
34
|
|
33
35
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fog/collection'
|
1
|
+
require 'fog/core/collection'
|
2
2
|
require 'fog/aws/models/compute/security_group'
|
3
3
|
|
4
4
|
module Fog
|
@@ -7,27 +7,29 @@ module Fog
|
|
7
7
|
|
8
8
|
class SecurityGroups < Fog::Collection
|
9
9
|
|
10
|
-
attribute :
|
10
|
+
attribute :filters
|
11
11
|
|
12
12
|
model Fog::AWS::Compute::SecurityGroup
|
13
13
|
|
14
14
|
def initialize(attributes)
|
15
|
-
@
|
15
|
+
@filters ||= {}
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
19
|
-
def all(
|
20
|
-
|
21
|
-
|
19
|
+
def all(filters = @filters)
|
20
|
+
unless filters.is_a?(Hash)
|
21
|
+
Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('group-name' => []) instead[/] [light_black](#{caller.first})[/]")
|
22
|
+
filters = {'group-name' => [*filters]}
|
23
|
+
end
|
24
|
+
@filters = filters
|
25
|
+
data = connection.describe_security_groups(@filters).body
|
22
26
|
load(data['securityGroupInfo'])
|
23
27
|
end
|
24
28
|
|
25
29
|
def get(group_name)
|
26
30
|
if group_name
|
27
|
-
all(group_name).first
|
31
|
+
self.class.new(:connection => connection).all('group-name' => group_name).first
|
28
32
|
end
|
29
|
-
rescue Fog::Errors::NotFound
|
30
|
-
nil
|
31
33
|
end
|
32
34
|
|
33
35
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fog/model'
|
1
|
+
require 'fog/core/model'
|
2
2
|
|
3
3
|
module Fog
|
4
4
|
module AWS
|
@@ -12,6 +12,7 @@ module Fog
|
|
12
12
|
attribute :ami_launch_index, :aliases => 'amiLaunchIndex'
|
13
13
|
attribute :availability_zone, :aliases => 'availabilityZone'
|
14
14
|
attribute :block_device_mapping, :aliases => 'blockDeviceMapping'
|
15
|
+
attribute :client_token, :aliases => 'clientToken'
|
15
16
|
attribute :dns_name, :aliases => 'dnsName'
|
16
17
|
attribute :groups
|
17
18
|
attribute :flavor_id, :aliases => 'instanceType'
|
@@ -29,10 +30,12 @@ module Fog
|
|
29
30
|
attribute :root_device_name, :aliases => 'rootDeviceName'
|
30
31
|
attribute :root_device_type, :aliases => 'rootDeviceType'
|
31
32
|
attribute :state, :aliases => 'instanceState'
|
33
|
+
attribute :state_reason, :aliases => 'stateReason'
|
32
34
|
attribute :subnet_id, :aliases => 'subnetId'
|
35
|
+
attribute :tags, :aliases => 'tagSet'
|
33
36
|
attribute :user_data
|
34
37
|
|
35
|
-
attr_accessor :password
|
38
|
+
attr_accessor :password
|
36
39
|
attr_writer :private_key, :private_key_path, :public_key, :public_key_path
|
37
40
|
|
38
41
|
def initialize(attributes={})
|
@@ -60,6 +63,7 @@ module Fog
|
|
60
63
|
true
|
61
64
|
end
|
62
65
|
|
66
|
+
remove_method :flavor_id
|
63
67
|
def flavor_id
|
64
68
|
@flavor && @flavor.id || @flavor_id
|
65
69
|
end
|
@@ -82,6 +86,7 @@ module Fog
|
|
82
86
|
@key_name = new_keypair && new_keypair.name
|
83
87
|
end
|
84
88
|
|
89
|
+
remove_method :monitoring=
|
85
90
|
def monitoring=(new_monitoring)
|
86
91
|
if new_monitoring.is_a?(Hash)
|
87
92
|
@monitoring = new_monitoring['state']
|
@@ -124,10 +129,12 @@ module Fog
|
|
124
129
|
end
|
125
130
|
|
126
131
|
def save
|
132
|
+
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
127
133
|
requires :image_id
|
128
134
|
|
129
135
|
options = {
|
130
136
|
'BlockDeviceMapping' => block_device_mapping,
|
137
|
+
'ClientToken' => client_token,
|
131
138
|
'InstanceType' => flavor_id,
|
132
139
|
'KernelId' => kernel_id,
|
133
140
|
'KeyName' => key_name,
|
@@ -191,12 +198,12 @@ module Fog
|
|
191
198
|
|
192
199
|
def volumes
|
193
200
|
requires :id
|
194
|
-
|
195
201
|
connection.volumes(:server => self)
|
196
202
|
end
|
197
203
|
|
198
204
|
private
|
199
205
|
|
206
|
+
remove_method :state=
|
200
207
|
def state=(new_state)
|
201
208
|
if new_state.is_a?(Hash)
|
202
209
|
@state = new_state['name']
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fog/collection'
|
1
|
+
require 'fog/core/collection'
|
2
2
|
require 'fog/aws/models/compute/server'
|
3
3
|
|
4
4
|
module Fog
|
@@ -7,18 +7,24 @@ module Fog
|
|
7
7
|
|
8
8
|
class Servers < Fog::Collection
|
9
9
|
|
10
|
+
attribute :filters
|
11
|
+
|
10
12
|
attribute :server_id
|
11
13
|
|
12
14
|
model Fog::AWS::Compute::Server
|
13
15
|
|
14
16
|
def initialize(attributes)
|
15
|
-
@
|
17
|
+
@filters ||= {}
|
16
18
|
super
|
17
19
|
end
|
18
20
|
|
19
|
-
def all(
|
20
|
-
|
21
|
-
|
21
|
+
def all(filters = @filters)
|
22
|
+
unless filters.is_a?(Hash)
|
23
|
+
Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('instance-id' => []) instead[/] [light_black](#{caller.first})[/]")
|
24
|
+
filters = {'instance-id' => [*filters]}
|
25
|
+
end
|
26
|
+
@filters = filters
|
27
|
+
data = connection.describe_instances(filters).body
|
22
28
|
load(
|
23
29
|
data['reservationSet'].map do |reservation|
|
24
30
|
reservation['instancesSet'].map do |instance|
|
@@ -42,13 +48,13 @@ module Fog
|
|
42
48
|
|
43
49
|
# make sure port 22 is open in the first security group
|
44
50
|
security_group = connection.security_groups.get(server.groups.first)
|
45
|
-
|
51
|
+
authorized = security_group.ip_permissions.detect do |ip_permission|
|
46
52
|
ip_permission['ipRanges'].first && ip_permission['ipRanges'].first['cidrIp'] == '0.0.0.0/0' &&
|
47
53
|
ip_permission['fromPort'] == 22 &&
|
48
54
|
ip_permission['ipProtocol'] == 'tcp' &&
|
49
55
|
ip_permission['toPort'] == 22
|
50
56
|
end
|
51
|
-
unless
|
57
|
+
unless authorized
|
52
58
|
security_group.authorize_port_range(22..22)
|
53
59
|
end
|
54
60
|
|
@@ -60,7 +66,7 @@ module Fog
|
|
60
66
|
|
61
67
|
def get(server_id)
|
62
68
|
if server_id
|
63
|
-
all(server_id).first
|
69
|
+
self.class.new(:connection => connection).all('instance-id' => server_id).first
|
64
70
|
end
|
65
71
|
rescue Fog::Errors::NotFound
|
66
72
|
nil
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fog/model'
|
1
|
+
require 'fog/core/model'
|
2
2
|
|
3
3
|
module Fog
|
4
4
|
module AWS
|
@@ -15,6 +15,7 @@ module Fog
|
|
15
15
|
attribute :created_at, :aliases => 'startTime'
|
16
16
|
attribute :owner_id, :aliases => 'ownerId'
|
17
17
|
attribute :state, :aliases => 'status'
|
18
|
+
attribute :tags, :aliases => 'tagSet'
|
18
19
|
attribute :volume_id, :aliases => 'volumeId'
|
19
20
|
attribute :volume_size, :aliases => 'volumeSize'
|
20
21
|
|
@@ -30,6 +31,7 @@ module Fog
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def save
|
34
|
+
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
33
35
|
requires :volume_id
|
34
36
|
|
35
37
|
data = connection.create_snapshot(@volume_id, @description).body
|
@@ -40,7 +42,6 @@ module Fog
|
|
40
42
|
|
41
43
|
def volume
|
42
44
|
requires :id
|
43
|
-
|
44
45
|
connection.describe_volumes(@volume_id)
|
45
46
|
end
|
46
47
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fog/collection'
|
1
|
+
require 'fog/core/collection'
|
2
2
|
require 'fog/aws/models/compute/snapshot'
|
3
3
|
|
4
4
|
module Fog
|
@@ -7,26 +7,23 @@ module Fog
|
|
7
7
|
|
8
8
|
class Snapshots < Fog::Collection
|
9
9
|
|
10
|
-
attribute :
|
11
|
-
attribute :restorable_by, :aliases => 'RestorableBy'
|
12
|
-
attribute :snapshot_id
|
10
|
+
attribute :filters
|
13
11
|
attribute :volume
|
14
12
|
|
15
13
|
model Fog::AWS::Compute::Snapshot
|
16
14
|
|
17
15
|
def initialize(attributes)
|
18
|
-
@
|
16
|
+
@filters ||= { 'RestorableBy' => 'self' }
|
19
17
|
super
|
20
18
|
end
|
21
19
|
|
22
|
-
def all(
|
23
|
-
|
24
|
-
'
|
25
|
-
'
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
data = connection.describe_snapshots(snapshot_id).body
|
20
|
+
def all(filters = @filters, options = {})
|
21
|
+
unless filters.is_a?(Hash)
|
22
|
+
Formatador.display_line("[yellow][WARN] all with #{filters.class} param is deprecated, use all('snapshot-id' => []) instead[/] [light_black](#{caller.first})[/]")
|
23
|
+
filters = {'snapshot-id' => [*filters]}
|
24
|
+
end
|
25
|
+
@filters = filters
|
26
|
+
data = connection.describe_snapshots(filters.merge!(options)).body
|
30
27
|
load(data['snapshotSet'])
|
31
28
|
if volume
|
32
29
|
self.replace(self.select {|snapshot| snapshot.volume_id == volume.id})
|
@@ -36,10 +33,8 @@ module Fog
|
|
36
33
|
|
37
34
|
def get(snapshot_id)
|
38
35
|
if snapshot_id
|
39
|
-
all(snapshot_id).first
|
36
|
+
self.class.new(:connection => connection).all('snapshot-id' => snapshot_id).first
|
40
37
|
end
|
41
|
-
rescue Fog::Errors::NotFound
|
42
|
-
nil
|
43
38
|
end
|
44
39
|
|
45
40
|
def new(attributes = {})
|