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
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'fog/model'
|
1
|
+
require 'fog/core/model'
|
2
2
|
|
3
3
|
module Fog
|
4
4
|
module Bluebox
|
@@ -15,14 +15,15 @@ module Fog
|
|
15
15
|
|
16
16
|
identity :id
|
17
17
|
|
18
|
-
attribute :memory
|
19
|
-
attribute :storage
|
20
|
-
attribute :hostname
|
21
18
|
attribute :cpu
|
22
|
-
attribute :
|
23
|
-
attribute :status
|
19
|
+
attribute :description
|
24
20
|
attribute :flavor_id
|
21
|
+
attribute :hostname
|
25
22
|
attribute :image_id
|
23
|
+
attribute :ips
|
24
|
+
attribute :memory
|
25
|
+
attribute :status
|
26
|
+
attribute :storage
|
26
27
|
attribute :template
|
27
28
|
|
28
29
|
attr_accessor :password
|
@@ -76,6 +77,7 @@ module Fog
|
|
76
77
|
end
|
77
78
|
|
78
79
|
def save
|
80
|
+
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
79
81
|
requires :flavor_id, :image_id
|
80
82
|
options = if !password && !public_key
|
81
83
|
raise(ArgumentError, "password or public_key is required for this operation")
|
data/lib/fog/core.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'fog/core/attributes'
|
2
|
+
require 'fog/core/collection'
|
3
|
+
require 'fog/core/connection'
|
4
|
+
require 'fog/core/deprecation'
|
5
|
+
require 'fog/core/errors'
|
6
|
+
require 'fog/core/hmac'
|
7
|
+
require 'fog/core/model'
|
8
|
+
require 'fog/core/parser'
|
9
|
+
require 'fog/core/provider'
|
10
|
+
require 'fog/core/service'
|
11
|
+
require 'fog/core/ssh'
|
File without changes
|
@@ -17,6 +17,7 @@ module Fog
|
|
17
17
|
|
18
18
|
%w[reject select].each do |method|
|
19
19
|
class_eval <<-RUBY
|
20
|
+
remove_method :#{method}
|
20
21
|
def #{method}(*args)
|
21
22
|
unless @loaded
|
22
23
|
lazy_load
|
@@ -37,6 +38,7 @@ module Fog
|
|
37
38
|
|
38
39
|
attr_accessor :connection
|
39
40
|
|
41
|
+
remove_method :clear
|
40
42
|
def clear
|
41
43
|
@loaded = true
|
42
44
|
super
|
@@ -49,9 +51,11 @@ module Fog
|
|
49
51
|
end
|
50
52
|
|
51
53
|
def initialize(attributes = {})
|
54
|
+
@loaded = false
|
52
55
|
merge_attributes(attributes)
|
53
56
|
end
|
54
57
|
|
58
|
+
remove_method :inspect
|
55
59
|
def inspect
|
56
60
|
Thread.current[:formatador] ||= Formatador.new
|
57
61
|
data = "#{Thread.current[:formatador].indentation}<#{self.class.name}\n"
|
File without changes
|
@@ -34,6 +34,8 @@ module Fog
|
|
34
34
|
:aws_secret_access_key: INTENTIONALLY_LEFT_BLANK
|
35
35
|
:bluebox_api_key: INTENTIONALLY_LEFT_BLANK
|
36
36
|
:bluebox_customer_id: INTENTIONALLY_LEFT_BLANK
|
37
|
+
:go_grid_api_key: INTENTIONALLY_LEFT_BLANK
|
38
|
+
:go_grid_shared_secret: INTENTIONALLY_LEFT_BLANK
|
37
39
|
:local_root: INTENTIONALLY_LEFT_BLANK
|
38
40
|
:new_servers_password: INTENTIONALLY_LEFT_BLANK
|
39
41
|
:new_servers_username: INTENTIONALLY_LEFT_BLANK
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -54,27 +54,27 @@ module Fog
|
|
54
54
|
sudoable_command = command.sub(/^sudo/, %{sudo -p 'fog sudo password:'})
|
55
55
|
escaped_command = sudoable_command.sub(/'/, %{'"'"'})
|
56
56
|
result = Result.new(escaped_command)
|
57
|
-
ssh.open_channel do |
|
58
|
-
|
59
|
-
|
57
|
+
ssh.open_channel do |ssh_channel|
|
58
|
+
ssh_channel.request_pty
|
59
|
+
ssh_channel.exec(%{bash -lc '#{escaped_command}'}) do |channel, success|
|
60
60
|
unless success
|
61
61
|
raise "Could not execute command: #{command.inspect}"
|
62
62
|
end
|
63
63
|
|
64
|
-
channel.on_data do |
|
64
|
+
channel.on_data do |ch, data|
|
65
65
|
result.stdout << data
|
66
66
|
end
|
67
67
|
|
68
|
-
channel.on_extended_data do |
|
68
|
+
channel.on_extended_data do |ch, type, data|
|
69
69
|
next unless type == 1
|
70
70
|
result.stderr << data
|
71
71
|
end
|
72
72
|
|
73
|
-
channel.on_request('exit-status') do |
|
73
|
+
channel.on_request('exit-status') do |ch, data|
|
74
74
|
result.status = data.read_long
|
75
75
|
end
|
76
76
|
|
77
|
-
channel.on_request('exit-signal') do |
|
77
|
+
channel.on_request('exit-signal') do |ch, data|
|
78
78
|
result.status = 255
|
79
79
|
end
|
80
80
|
end
|
data/lib/fog/go_grid.rb
CHANGED
@@ -11,7 +11,7 @@ module Fog
|
|
11
11
|
warning = "[yellow][WARN] Fog::GoGrid#new is deprecated, use Fog::GoGrid::Compute#new instead[/]"
|
12
12
|
warning << " [light_black](" << location << ")[/] "
|
13
13
|
Formatador.display_line(warning)
|
14
|
-
Fog::
|
14
|
+
Fog::GoGrid::Compute.new(attributes)
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
data/lib/fog/go_grid/compute.rb
CHANGED
@@ -6,9 +6,14 @@ module Fog
|
|
6
6
|
requires :go_grid_shared_secret
|
7
7
|
|
8
8
|
model_path 'fog/go_grid/models/compute'
|
9
|
+
model :image
|
10
|
+
collection :images
|
11
|
+
model :server
|
12
|
+
collection :servers
|
9
13
|
|
10
14
|
request_path 'fog/go_grid/requests/compute'
|
11
15
|
request :common_lookup_list
|
16
|
+
request :grid_image_get
|
12
17
|
request :grid_image_list
|
13
18
|
request :grid_ip_list
|
14
19
|
request :grid_loadbalancer_list
|
@@ -67,7 +72,7 @@ module Fog
|
|
67
72
|
'api_key' => @go_grid_api_key,
|
68
73
|
'format' => 'json',
|
69
74
|
'sig' => Digest::MD5.hexdigest("#{@go_grid_api_key}#{@go_grid_shared_secret}#{Time.now.to_i}"),
|
70
|
-
'v' => '1.
|
75
|
+
'v' => '1.5'
|
71
76
|
})
|
72
77
|
|
73
78
|
begin
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module GoGrid
|
5
|
+
class Compute
|
6
|
+
|
7
|
+
class Image < Fog::Model
|
8
|
+
|
9
|
+
identity :id
|
10
|
+
|
11
|
+
attribute :name
|
12
|
+
attribute :description
|
13
|
+
attribute :friendly_name, :aliases => 'friendlyName'
|
14
|
+
attribute :created_at, :aliases => 'createdTime'
|
15
|
+
attribute :updated_at, :aliases => 'updatedTime'
|
16
|
+
attribute :server_id, :aliases => 'id'
|
17
|
+
attribute :state
|
18
|
+
attribute :price
|
19
|
+
attribute :location
|
20
|
+
attribute :billingtokens
|
21
|
+
attribute :os
|
22
|
+
attribute :architecture
|
23
|
+
attribute :type
|
24
|
+
attribute :active, :aliases => 'isActive'
|
25
|
+
attribute :public, :aliases => 'isPublic'
|
26
|
+
attribute :object_type, :aliases => 'object'
|
27
|
+
attribute :owner
|
28
|
+
|
29
|
+
|
30
|
+
def server=(new_server)
|
31
|
+
requires :id
|
32
|
+
|
33
|
+
@server_id = new_server.id
|
34
|
+
end
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
requires :id
|
38
|
+
|
39
|
+
connection.grid_server_delete(@id)
|
40
|
+
true
|
41
|
+
end
|
42
|
+
|
43
|
+
def ready?
|
44
|
+
status == 'Available'
|
45
|
+
end
|
46
|
+
|
47
|
+
def save
|
48
|
+
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
49
|
+
requires :server_id
|
50
|
+
|
51
|
+
data = connection.grid_server_add(@server_id, 'name' => name)
|
52
|
+
merge_attributes(data.body['image'])
|
53
|
+
true
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/go_grid/models/compute/image'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module GoGrid
|
6
|
+
class Compute
|
7
|
+
|
8
|
+
class Images < Fog::Collection
|
9
|
+
|
10
|
+
model Fog::GoGrid::Compute::Image
|
11
|
+
|
12
|
+
attribute :server
|
13
|
+
|
14
|
+
def all
|
15
|
+
data = connection.grid_image_list.body['list']
|
16
|
+
load(data)
|
17
|
+
if server
|
18
|
+
self.replace(self.select {|image| image.server_id == server.id})
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def get(image_id)
|
23
|
+
response = connection.grid_image_get.body['list'][image_id]
|
24
|
+
new(data)
|
25
|
+
rescue Fog::GoGrid::Compute::NotFound
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module GoGrid
|
5
|
+
class Compute
|
6
|
+
|
7
|
+
class BlockInstantiationError < StandardError; end
|
8
|
+
|
9
|
+
class Server < Fog::Model
|
10
|
+
|
11
|
+
identity :id
|
12
|
+
|
13
|
+
attribute :name
|
14
|
+
attribute :image_id # id or name
|
15
|
+
attribute :ip
|
16
|
+
attribute :memory # server.ram
|
17
|
+
attribute :state
|
18
|
+
attribute :description # Optional
|
19
|
+
attribute :sandbox # Optional. Default: False
|
20
|
+
|
21
|
+
def initialize(attributes={})
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def destroy
|
26
|
+
requires :id
|
27
|
+
connection.grid_server_destroy(@id)
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
31
|
+
def image
|
32
|
+
requires :image_id
|
33
|
+
connection.grid_image_get(@image_id)
|
34
|
+
end
|
35
|
+
|
36
|
+
def ready?
|
37
|
+
@state == 'On'
|
38
|
+
end
|
39
|
+
|
40
|
+
def save
|
41
|
+
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
42
|
+
requires :name, :image_id, :ip, :memory
|
43
|
+
options['isSandbox'] = sandbox if sandbox
|
44
|
+
options['server.ram'] = memory
|
45
|
+
options['image'] = image_id
|
46
|
+
data = connection.grid_server_add(name, image, ip, options)
|
47
|
+
merge_attributes(data.body)
|
48
|
+
true
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/go_grid/models/compute/server'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module GoGrid
|
6
|
+
class Compute
|
7
|
+
|
8
|
+
class Servers < Fog::Collection
|
9
|
+
|
10
|
+
model Fog::GoGrid::Compute::Server
|
11
|
+
|
12
|
+
def all
|
13
|
+
data = connection.grid_server_list.body['list']
|
14
|
+
load(data)
|
15
|
+
end
|
16
|
+
|
17
|
+
def bootstrap(new_attributes = {})
|
18
|
+
server = create(new_attributes)
|
19
|
+
server.wait_for { ready? }
|
20
|
+
server
|
21
|
+
end
|
22
|
+
|
23
|
+
def get(server_id)
|
24
|
+
if server_id && server = connection.grid_server_get(server_id).body['list']
|
25
|
+
new(server)
|
26
|
+
end
|
27
|
+
rescue Fog::GoGrid::Compute::NotFound
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Fog
|
2
|
+
module GoGrid
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
|
6
|
+
# List images
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * options<~Hash>:
|
10
|
+
# * 'id'<~String> - ID of the image
|
11
|
+
# * 'name'<~String> - Name of the image
|
12
|
+
# * 'image'<~String> - ID(s) or Name(s) of the images to retrive. Can be speicifed multiple times
|
13
|
+
#
|
14
|
+
# ==== Returns
|
15
|
+
# * response<~Excon::Response>:
|
16
|
+
# * body<~Array>:
|
17
|
+
# TODO: docs
|
18
|
+
def grid_image_get(options={})
|
19
|
+
request(
|
20
|
+
:path => 'grid/image/get',
|
21
|
+
:query => options
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
class Mock
|
28
|
+
|
29
|
+
def grid_image_get(options={})
|
30
|
+
#response = Excon::Response.new
|
31
|
+
|
32
|
+
#images = @data[:list].values
|
33
|
+
#for image in images
|
34
|
+
# case image['state']
|
35
|
+
# when 'Available'
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -30,7 +30,12 @@ module Fog
|
|
30
30
|
class Mock
|
31
31
|
|
32
32
|
def grid_image_list(options={})
|
33
|
-
|
33
|
+
#response = Excon::Response.new
|
34
|
+
|
35
|
+
#images = @data[:list].values
|
36
|
+
#for image in images
|
37
|
+
# case image['state']
|
38
|
+
# when 'Available'
|
34
39
|
end
|
35
40
|
|
36
41
|
end
|