fog 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/Gemfile.lock +5 -5
- data/README.rdoc +29 -29
- data/fog.gemspec +24 -2
- data/lib/fog.rb +4 -15
- data/lib/fog/aws.rb +2 -2
- data/lib/fog/aws/ec2.rb +64 -101
- data/lib/fog/aws/elb.rb +19 -27
- data/lib/fog/aws/models/ec2/addresses.rb +1 -9
- data/lib/fog/aws/models/ec2/flavors.rb +1 -7
- data/lib/fog/aws/models/ec2/images.rb +1 -7
- data/lib/fog/aws/models/ec2/key_pairs.rb +1 -7
- data/lib/fog/aws/models/ec2/security_groups.rb +1 -7
- data/lib/fog/aws/models/ec2/servers.rb +1 -7
- data/lib/fog/aws/models/ec2/snapshots.rb +1 -9
- data/lib/fog/aws/models/ec2/volumes.rb +1 -9
- data/lib/fog/aws/models/s3/directories.rb +1 -7
- data/lib/fog/aws/models/s3/file.rb +5 -0
- data/lib/fog/aws/requests/ec2/allocate_address.rb +2 -0
- data/lib/fog/aws/requests/ec2/attach_volume.rb +2 -0
- data/lib/fog/aws/requests/ec2/create_key_pair.rb +2 -0
- data/lib/fog/aws/requests/ec2/create_snapshot.rb +2 -0
- data/lib/fog/aws/requests/ec2/create_volume.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_addresses.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_images.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_instances.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_regions.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_reserved_instances.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_security_groups.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_snapshots.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_volumes.rb +2 -0
- data/lib/fog/aws/requests/ec2/detach_volume.rb +2 -0
- data/lib/fog/aws/requests/ec2/get_console_output.rb +2 -0
- data/lib/fog/aws/requests/ec2/run_instances.rb +2 -0
- data/lib/fog/aws/requests/ec2/terminate_instances.rb +2 -0
- data/lib/fog/aws/requests/elb/create_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/delete_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/describe_instance_health.rb +2 -0
- data/lib/fog/aws/requests/elb/describe_load_balancers.rb +2 -0
- data/lib/fog/aws/requests/elb/disable_availability_zones_for_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/enable_availability_zones_for_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/s3/copy_object.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_acl.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_location.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_logging.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_object_versions.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_versioning.rb +2 -0
- data/lib/fog/aws/requests/s3/get_object_acl.rb +2 -0
- data/lib/fog/aws/requests/s3/get_request_payment.rb +2 -0
- data/lib/fog/aws/requests/s3/get_service.rb +2 -0
- data/lib/fog/aws/requests/s3/put_object.rb +2 -2
- data/lib/fog/aws/requests/simpledb/domain_metadata.rb +2 -0
- data/lib/fog/aws/requests/simpledb/get_attributes.rb +2 -0
- data/lib/fog/aws/requests/simpledb/list_domains.rb +2 -0
- data/lib/fog/aws/requests/simpledb/select.rb +2 -0
- data/lib/fog/aws/s3.rb +68 -85
- data/lib/fog/aws/simpledb.rb +15 -29
- data/lib/fog/bluebox.rb +23 -40
- data/lib/fog/bluebox/models/flavors.rb +1 -7
- data/lib/fog/bluebox/models/images.rb +1 -9
- data/lib/fog/bluebox/models/servers.rb +1 -7
- data/lib/fog/credentials.rb +2 -0
- data/lib/fog/errors.rb +20 -0
- data/lib/fog/hmac.rb +48 -0
- data/lib/fog/local.rb +9 -22
- data/lib/fog/local/models/directories.rb +1 -7
- data/lib/fog/rackspace.rb +2 -6
- data/lib/fog/rackspace/files.rb +46 -48
- data/lib/fog/rackspace/models/files/directories.rb +1 -7
- data/lib/fog/rackspace/models/servers/flavors.rb +1 -7
- data/lib/fog/rackspace/models/servers/images.rb +1 -9
- data/lib/fog/rackspace/models/servers/server.rb +37 -1
- data/lib/fog/rackspace/models/servers/servers.rb +8 -7
- data/lib/fog/rackspace/requests/files/put_object.rb +1 -1
- data/lib/fog/rackspace/servers.rb +33 -45
- data/lib/fog/service.rb +82 -0
- data/lib/fog/slicehost.rb +28 -42
- data/lib/fog/slicehost/models/flavors.rb +1 -7
- data/lib/fog/slicehost/models/images.rb +1 -9
- data/lib/fog/slicehost/models/servers.rb +1 -7
- data/lib/fog/ssh.rb +1 -1
- data/lib/fog/vcloud.rb +20 -3
- data/lib/fog/vcloud/collection.rb +25 -5
- data/lib/fog/vcloud/model.rb +4 -0
- data/lib/fog/vcloud/parsers/get_organization.rb +2 -2
- data/lib/fog/vcloud/parsers/get_vdc.rb +2 -2
- data/lib/fog/vcloud/parsers/get_versions.rb +1 -1
- data/lib/fog/vcloud/parsers/login.rb +2 -2
- data/lib/fog/vcloud/parsers/network.rb +53 -0
- data/lib/fog/vcloud/requests/get_network.rb +54 -0
- data/lib/fog/vcloud/requests/get_organization.rb +1 -2
- data/lib/fog/vcloud/terremark/ecloud.rb +17 -4
- data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +35 -0
- data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +9 -9
- data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +18 -0
- data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +36 -0
- data/lib/fog/vcloud/terremark/ecloud/models/network.rb +32 -0
- data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +38 -0
- data/lib/fog/vcloud/terremark/ecloud/models/public_ip.rb +3 -1
- data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +9 -0
- data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +2 -0
- data/lib/fog/vcloud/terremark/ecloud/parsers/network.rb +28 -0
- data/lib/fog/vcloud/terremark/ecloud/parsers/network_ips.rb +31 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +10 -7
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +99 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +54 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +51 -0
- data/spec/aws/models/s3/file_spec.rb +15 -0
- data/spec/vcloud/requests/get_network_spec.rb +55 -0
- data/spec/vcloud/spec_helper.rb +1 -0
- data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +15 -0
- data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +35 -0
- data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +28 -0
- data/spec/vcloud/terremark/ecloud/models/network_spec.rb +65 -0
- data/spec/vcloud/terremark/ecloud/models/networks_spec.rb +26 -0
- data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +0 -2
- data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +44 -0
- data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +54 -0
- data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +63 -0
- data/tests/aws/requests/ec2/volume_tests.rb +2 -2
- data/tests/helper.rb +2 -0
- metadata +25 -3
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -8,7 +8,7 @@ dependencies:
|
|
8
8
|
group:
|
9
9
|
- :default
|
10
10
|
version: ">= 0"
|
11
|
-
|
11
|
+
ruby-hmac:
|
12
12
|
group:
|
13
13
|
- :default
|
14
14
|
version: ">= 0"
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
group:
|
17
17
|
- :default
|
18
18
|
version: ">= 0"
|
19
|
-
|
19
|
+
rspec:
|
20
20
|
group:
|
21
21
|
- :default
|
22
22
|
version: ">= 0"
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
shindo:
|
40
40
|
group:
|
41
41
|
- :default
|
42
|
-
version: ">= 0.1.
|
42
|
+
version: ">= 0.1.5"
|
43
43
|
nokogiri:
|
44
44
|
group:
|
45
45
|
- :default
|
@@ -68,8 +68,8 @@ specs:
|
|
68
68
|
- ruby-hmac:
|
69
69
|
version: 0.4.0
|
70
70
|
- shindo:
|
71
|
-
version: 0.1.
|
72
|
-
hash:
|
71
|
+
version: 0.1.5
|
72
|
+
hash: 12012795f07111bf764cef89d9ba91f521c54956
|
73
73
|
sources:
|
74
74
|
- Rubygems:
|
75
75
|
uri: http://gemcutter.org
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
http://geemus.com/fog.png
|
2
2
|
|
3
|
-
fog
|
3
|
+
fog is the Ruby cloud computing library.
|
4
4
|
|
5
5
|
The quick and dirty, top to bottom:
|
6
6
|
* Models provide a simplified interface, making clouds easier to work with and switch between.
|
@@ -25,21 +25,21 @@ Now just type 'fog' to trying stuff out, confident that fog should let you know
|
|
25
25
|
== Collections
|
26
26
|
|
27
27
|
Nouns like Images and Servers are collections, which form the interface to the cloud.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
* get fetches a single object by its identity.
|
32
|
-
* new initializes a new record locally.
|
28
|
+
Some of these collections are shared across multiple providers.
|
29
|
+
The shared collections for compute resources are flavors, images and servers.
|
30
|
+
Shared collections for storage are directory and file.
|
33
31
|
|
34
|
-
|
32
|
+
Some common methods for all of these collections are:
|
33
|
+
* #all - fetch every object of that type from the provider.
|
34
|
+
* #create initialize a new record locally and then persists it with the provider.
|
35
|
+
* #get - fetch a single object by its identity from the provider.
|
36
|
+
* #new - initialize a new record locally, but do not persist it to the provider.
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
As an example, we'll try initializing and persisting a rackspace server:
|
38
|
+
As an example, we'll try initializing and persisting a Rackspace Cloud server:
|
39
39
|
|
40
40
|
require 'fog'
|
41
41
|
|
42
|
-
# initialize a connection to Rackspace Servers
|
42
|
+
# initialize a connection to Rackspace Cloud Servers
|
43
43
|
connection = Fog::Rackspace::Servers.new(
|
44
44
|
:rackspace_api_key => key,
|
45
45
|
:rackspace_username => username
|
@@ -59,47 +59,47 @@ As an example, we'll try initializing and persisting a rackspace server:
|
|
59
59
|
== Models
|
60
60
|
|
61
61
|
Many of the collection methods return individual objects, which provide destroy, save and wait_for methods.
|
62
|
-
* destroy will destroy the persisted object from the
|
63
|
-
* save
|
64
|
-
* wait_for takes a block and waits for either the block to return true for the object or for a timeout (defaults to 10 minutes)
|
62
|
+
* #destroy - will destroy the persisted object from the provider
|
63
|
+
* #save - persist the object to the provider
|
64
|
+
* #wait_for - takes a block and waits for either the block to return true for the object or for a timeout (defaults to 10 minutes)
|
65
65
|
|
66
66
|
== Mocks
|
67
67
|
|
68
|
-
Mocking provides an in memory representation of
|
69
|
-
|
70
|
-
|
68
|
+
Mocking provides an in memory representation of the state of cloud resources as you make requests.
|
69
|
+
Mocked calls to mimic the behavior of each provider while eliminating the cost and time needed to actually use cloud resources.
|
70
|
+
Enabling mocking easy to use, before you run any other commands run:
|
71
71
|
|
72
72
|
Fog.mock!
|
73
73
|
|
74
|
-
|
75
|
-
|
74
|
+
Then you can run other commands just like you always would.
|
75
|
+
Some mocks are not implemented just yet, but fog will raise an error to let you know and contributions are always welcome!
|
76
76
|
|
77
77
|
== Requests
|
78
78
|
|
79
79
|
Requests allow you to dive deeper when the models just can't cut it.
|
80
|
-
For instance, ec2 provides methods related to reserved instances that don't have any models (yet
|
81
|
-
|
80
|
+
For instance, ec2 provides methods related to reserved instances that don't have any models (yet).
|
81
|
+
Here is how you can lookup your reserved instances:
|
82
82
|
|
83
83
|
$ fog
|
84
84
|
>> AWS[:ec2].describe_reserved_instances
|
85
85
|
#<Excon::Response [...]>
|
86
86
|
|
87
|
-
It will return an excon response, which has headers and body
|
87
|
+
It will return an {excon}[http://github.com/geemus/excon] response, which has #headers and #body. Both return nice hashes.
|
88
88
|
|
89
89
|
== Go forth and conquer
|
90
90
|
|
91
|
-
|
92
|
-
For a more in depth walk through, check out the {getting started guide}[http://wiki.github.com/geemus/fog/getting-started-with-fog].
|
91
|
+
Play around and use the console to explore or check out the {getting started guide}[http://wiki.github.com/geemus/fog/getting-started-with-fog] for more details.
|
93
92
|
|
94
93
|
You should try out the (varying) support fog has for:
|
95
|
-
* AWS [EC2, S3, SimpleDB]
|
96
|
-
* Rackspace [Files, Servers]
|
97
|
-
* Slicehost
|
98
|
-
* Terremark vCloud Express
|
99
|
-
* Blue Box Group [Blocks]
|
94
|
+
* {AWS}[http://aws.amazon.com] [{EC2}[http://aws.amazon.com/ec2], {ELB}[http://aws.amazon.com/elasticloadbalancing], {S3}[http://aws.amazon.com/s3], {SimpleDB}[http://aws.amazon.com/simpledb]]
|
95
|
+
* {Rackspace}[http://www.rackspace.com] [{Files}[http://www.rackspacecloud.com/cloud_hosting_products/files], {Servers}[http://www.rackspacecloud.com/cloud_hosting_products/servers]]
|
96
|
+
* {Slicehost}[http://www.slicehost.com]
|
97
|
+
* {Terremark}[http://www.terremark.com] [{vCloud Express}[http://vcloudexpress.terremark.com]]
|
98
|
+
* {Blue Box Group}[http://www.blueboxgrp.com] [{Blocks}[http://www.blueboxgrp.com/blocks]]
|
100
99
|
|
101
100
|
Enjoy, and let me know what I can do to continue improving fog!
|
102
101
|
|
102
|
+
* Work for {twitter}[http://twitter.com]? I'd love to reclaim the unused {@fog}[http://twitter.com/fog] account!
|
103
103
|
* Follow {@geemus}[http://twitter.com/geemus] on Twitter.
|
104
104
|
* See upcoming work in the {tracker}[http://www.pivotaltracker.com/projects/54635].
|
105
105
|
* Report bugs in {issues}[http://github.com/geemus/fog/issues].
|
data/fog.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
## If your rubyforge_project name is different, then edit it and comment out
|
8
8
|
## the sub! line in the Rakefile
|
9
9
|
s.name = 'fog'
|
10
|
-
s.version = '0.1.
|
11
|
-
s.date = '2010-06-
|
10
|
+
s.version = '0.1.9'
|
11
|
+
s.date = '2010-06-15'
|
12
12
|
s.rubyforge_project = 'fog'
|
13
13
|
|
14
14
|
## Make sure your summary is short. The description may be as long
|
@@ -233,6 +233,8 @@ Gem::Specification.new do |s|
|
|
233
233
|
lib/fog/connection.rb
|
234
234
|
lib/fog/credentials.rb
|
235
235
|
lib/fog/deprecation.rb
|
236
|
+
lib/fog/errors.rb
|
237
|
+
lib/fog/hmac.rb
|
236
238
|
lib/fog/local.rb
|
237
239
|
lib/fog/local/bin.rb
|
238
240
|
lib/fog/local/models/directories.rb
|
@@ -283,6 +285,7 @@ Gem::Specification.new do |s|
|
|
283
285
|
lib/fog/rackspace/requests/servers/reboot_server.rb
|
284
286
|
lib/fog/rackspace/requests/servers/update_server.rb
|
285
287
|
lib/fog/rackspace/servers.rb
|
288
|
+
lib/fog/service.rb
|
286
289
|
lib/fog/slicehost.rb
|
287
290
|
lib/fog/slicehost/bin.rb
|
288
291
|
lib/fog/slicehost/models/flavor.rb
|
@@ -383,6 +386,8 @@ Gem::Specification.new do |s|
|
|
383
386
|
lib/fog/vcloud/parsers/get_vdc.rb
|
384
387
|
lib/fog/vcloud/parsers/get_versions.rb
|
385
388
|
lib/fog/vcloud/parsers/login.rb
|
389
|
+
lib/fog/vcloud/parsers/network.rb
|
390
|
+
lib/fog/vcloud/requests/get_network.rb
|
386
391
|
lib/fog/vcloud/requests/get_organization.rb
|
387
392
|
lib/fog/vcloud/requests/get_vdc.rb
|
388
393
|
lib/fog/vcloud/requests/get_versions.rb
|
@@ -391,6 +396,10 @@ Gem::Specification.new do |s|
|
|
391
396
|
lib/fog/vcloud/terremark/ecloud.rb
|
392
397
|
lib/fog/vcloud/terremark/ecloud/models/internet_service.rb
|
393
398
|
lib/fog/vcloud/terremark/ecloud/models/internet_services.rb
|
399
|
+
lib/fog/vcloud/terremark/ecloud/models/ip.rb
|
400
|
+
lib/fog/vcloud/terremark/ecloud/models/ips.rb
|
401
|
+
lib/fog/vcloud/terremark/ecloud/models/network.rb
|
402
|
+
lib/fog/vcloud/terremark/ecloud/models/networks.rb
|
394
403
|
lib/fog/vcloud/terremark/ecloud/models/public_ip.rb
|
395
404
|
lib/fog/vcloud/terremark/ecloud/models/public_ips.rb
|
396
405
|
lib/fog/vcloud/terremark/ecloud/models/vdc.rb
|
@@ -400,9 +409,14 @@ Gem::Specification.new do |s|
|
|
400
409
|
lib/fog/vcloud/terremark/ecloud/parsers/get_public_ips.rb
|
401
410
|
lib/fog/vcloud/terremark/ecloud/parsers/get_vdc.rb
|
402
411
|
lib/fog/vcloud/terremark/ecloud/parsers/internet_service.rb
|
412
|
+
lib/fog/vcloud/terremark/ecloud/parsers/network.rb
|
413
|
+
lib/fog/vcloud/terremark/ecloud/parsers/network_ips.rb
|
403
414
|
lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb
|
415
|
+
lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb
|
404
416
|
lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb
|
405
417
|
lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb
|
418
|
+
lib/fog/vcloud/terremark/ecloud/requests/get_network.rb
|
419
|
+
lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb
|
406
420
|
lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb
|
407
421
|
lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb
|
408
422
|
lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb
|
@@ -477,6 +491,7 @@ Gem::Specification.new do |s|
|
|
477
491
|
spec/vcloud/bin_spec.rb
|
478
492
|
spec/vcloud/models/vdc_spec.rb
|
479
493
|
spec/vcloud/models/vdcs_spec.rb
|
494
|
+
spec/vcloud/requests/get_network_spec.rb
|
480
495
|
spec/vcloud/requests/get_organization_spec.rb
|
481
496
|
spec/vcloud/requests/get_vdc_spec.rb
|
482
497
|
spec/vcloud/requests/get_versions_spec.rb
|
@@ -484,13 +499,20 @@ Gem::Specification.new do |s|
|
|
484
499
|
spec/vcloud/spec_helper.rb
|
485
500
|
spec/vcloud/terremark/ecloud/models/internet_service_spec.rb
|
486
501
|
spec/vcloud/terremark/ecloud/models/internet_services_spec.rb
|
502
|
+
spec/vcloud/terremark/ecloud/models/ip_spec.rb
|
503
|
+
spec/vcloud/terremark/ecloud/models/ips_spec.rb
|
504
|
+
spec/vcloud/terremark/ecloud/models/network_spec.rb
|
505
|
+
spec/vcloud/terremark/ecloud/models/networks_spec.rb
|
487
506
|
spec/vcloud/terremark/ecloud/models/public_ip_spec.rb
|
488
507
|
spec/vcloud/terremark/ecloud/models/public_ips_spec.rb
|
489
508
|
spec/vcloud/terremark/ecloud/models/vdc_spec.rb
|
490
509
|
spec/vcloud/terremark/ecloud/models/vdcs_spec.rb
|
491
510
|
spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb
|
511
|
+
spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb
|
492
512
|
spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb
|
493
513
|
spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb
|
514
|
+
spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb
|
515
|
+
spec/vcloud/terremark/ecloud/requests/get_network_spec.rb
|
494
516
|
spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb
|
495
517
|
spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb
|
496
518
|
spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb
|
data/lib/fog.rb
CHANGED
@@ -4,8 +4,6 @@ require 'cgi'
|
|
4
4
|
require 'digest/md5'
|
5
5
|
require 'excon'
|
6
6
|
require 'formatador'
|
7
|
-
require 'hmac-sha1'
|
8
|
-
require 'hmac-sha2'
|
9
7
|
require 'json'
|
10
8
|
require 'mime/types'
|
11
9
|
require 'net/ssh'
|
@@ -22,22 +20,13 @@ require 'fog/attributes'
|
|
22
20
|
require 'fog/collection'
|
23
21
|
require 'fog/connection'
|
24
22
|
require 'fog/deprecation'
|
23
|
+
require 'fog/errors'
|
24
|
+
require 'fog/hmac'
|
25
25
|
require 'fog/model'
|
26
26
|
require 'fog/parser'
|
27
|
+
require 'fog/service'
|
27
28
|
require 'fog/ssh'
|
28
29
|
|
29
|
-
module Fog
|
30
|
-
module Errors
|
31
|
-
|
32
|
-
class Error < StandardError; end
|
33
|
-
|
34
|
-
class MockNotImplemented < Fog::Errors::Error; end
|
35
|
-
|
36
|
-
class NotFound < Fog::Errors::Error; end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
30
|
require 'fog/aws'
|
42
31
|
require 'fog/bluebox'
|
43
32
|
require 'fog/local'
|
@@ -49,7 +38,7 @@ require 'fog/vcloud'
|
|
49
38
|
module Fog
|
50
39
|
|
51
40
|
unless const_defined?(:VERSION)
|
52
|
-
VERSION = '0.1.
|
41
|
+
VERSION = '0.1.9'
|
53
42
|
end
|
54
43
|
|
55
44
|
module Mock
|
data/lib/fog/aws.rb
CHANGED
@@ -33,8 +33,8 @@ module Fog
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
string_to_sign = "POST\n#{options[:host]}\n/\n" << body.chop
|
36
|
-
|
37
|
-
body << "Signature=#{CGI.escape(Base64.encode64(
|
36
|
+
signed_string = options[:hmac].sign(string_to_sign)
|
37
|
+
body << "Signature=#{CGI.escape(Base64.encode64(signed_string).chomp!).gsub(/\+/, '%20')}"
|
38
38
|
|
39
39
|
body
|
40
40
|
end
|
data/lib/fog/aws/ec2.rb
CHANGED
@@ -1,101 +1,65 @@
|
|
1
1
|
module Fog
|
2
2
|
module AWS
|
3
3
|
module EC2
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
require 'fog/aws/requests/ec2/describe_availability_zones'
|
61
|
-
require 'fog/aws/requests/ec2/describe_images'
|
62
|
-
require 'fog/aws/requests/ec2/describe_instances'
|
63
|
-
require 'fog/aws/requests/ec2/describe_reserved_instances'
|
64
|
-
require 'fog/aws/requests/ec2/describe_key_pairs'
|
65
|
-
require 'fog/aws/requests/ec2/describe_regions'
|
66
|
-
require 'fog/aws/requests/ec2/describe_security_groups'
|
67
|
-
require 'fog/aws/requests/ec2/describe_snapshots'
|
68
|
-
require 'fog/aws/requests/ec2/describe_volumes'
|
69
|
-
require 'fog/aws/requests/ec2/detach_volume'
|
70
|
-
require 'fog/aws/requests/ec2/disassociate_address'
|
71
|
-
require 'fog/aws/requests/ec2/get_console_output'
|
72
|
-
require 'fog/aws/requests/ec2/modify_image_attributes'
|
73
|
-
require 'fog/aws/requests/ec2/reboot_instances'
|
74
|
-
require 'fog/aws/requests/ec2/release_address'
|
75
|
-
require 'fog/aws/requests/ec2/revoke_security_group_ingress'
|
76
|
-
require 'fog/aws/requests/ec2/run_instances'
|
77
|
-
require 'fog/aws/requests/ec2/terminate_instances'
|
78
|
-
@required = true
|
79
|
-
end
|
80
|
-
|
81
|
-
unless options[:aws_access_key_id]
|
82
|
-
raise ArgumentError.new('aws_access_key_id is required to access ec2')
|
83
|
-
end
|
84
|
-
unless options[:aws_secret_access_key]
|
85
|
-
raise ArgumentError.new('aws_secret_access_key is required to access ec2')
|
86
|
-
end
|
87
|
-
if Fog.mocking?
|
88
|
-
Fog::AWS::EC2::Mock.new(options)
|
89
|
-
else
|
90
|
-
Fog::AWS::EC2::Real.new(options)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def self.reset_data(keys=Mock.data.keys)
|
95
|
-
Mock.reset_data(keys)
|
96
|
-
end
|
4
|
+
extend Fog::Service
|
5
|
+
|
6
|
+
requires :aws_access_key_id, :aws_secret_access_key
|
7
|
+
|
8
|
+
model_path 'fog/aws/models/ec2'
|
9
|
+
model 'address'
|
10
|
+
model 'addresses'
|
11
|
+
model 'flavor'
|
12
|
+
model 'flavors'
|
13
|
+
model 'image'
|
14
|
+
model 'images'
|
15
|
+
model 'key_pair'
|
16
|
+
model 'key_pairs'
|
17
|
+
model 'security_group'
|
18
|
+
model 'security_groups'
|
19
|
+
model 'server'
|
20
|
+
model 'servers'
|
21
|
+
model 'snapshot'
|
22
|
+
model 'snapshots'
|
23
|
+
model 'volume'
|
24
|
+
model 'volumes'
|
25
|
+
|
26
|
+
require 'fog/aws/parsers/ec2/basic'
|
27
|
+
|
28
|
+
request_path 'fog/aws/requests/ec2'
|
29
|
+
request 'allocate_address'
|
30
|
+
request 'associate_address'
|
31
|
+
request 'attach_volume'
|
32
|
+
request 'authorize_security_group_ingress'
|
33
|
+
request 'create_key_pair'
|
34
|
+
request 'create_security_group'
|
35
|
+
request 'create_snapshot'
|
36
|
+
request 'create_volume'
|
37
|
+
request 'delete_key_pair'
|
38
|
+
request 'delete_security_group'
|
39
|
+
request 'delete_snapshot'
|
40
|
+
request 'delete_volume'
|
41
|
+
request 'describe_addresses'
|
42
|
+
request 'describe_availability_zones'
|
43
|
+
request 'describe_images'
|
44
|
+
request 'describe_instances'
|
45
|
+
request 'describe_reserved_instances'
|
46
|
+
request 'describe_key_pairs'
|
47
|
+
request 'describe_regions'
|
48
|
+
request 'describe_security_groups'
|
49
|
+
request 'describe_snapshots'
|
50
|
+
request 'describe_volumes'
|
51
|
+
request 'detach_volume'
|
52
|
+
request 'disassociate_address'
|
53
|
+
request 'get_console_output'
|
54
|
+
request 'modify_image_attributes'
|
55
|
+
request 'reboot_instances'
|
56
|
+
request 'release_address'
|
57
|
+
request 'revoke_security_group_ingress'
|
58
|
+
request 'run_instances'
|
59
|
+
request 'terminate_instances'
|
97
60
|
|
98
61
|
class Mock
|
62
|
+
include Collections
|
99
63
|
|
100
64
|
def self.data
|
101
65
|
@data ||= Hash.new do |hash, key|
|
@@ -158,6 +122,7 @@ module Fog
|
|
158
122
|
end
|
159
123
|
|
160
124
|
class Real
|
125
|
+
include Collections
|
161
126
|
|
162
127
|
# Initialize connection to EC2
|
163
128
|
#
|
@@ -180,7 +145,7 @@ module Fog
|
|
180
145
|
def initialize(options={})
|
181
146
|
@aws_access_key_id = options[:aws_access_key_id]
|
182
147
|
@aws_secret_access_key = options[:aws_secret_access_key]
|
183
|
-
@hmac = HMAC
|
148
|
+
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
|
184
149
|
@host = options[:host] || case options[:region]
|
185
150
|
when 'ap-southeast-1'
|
186
151
|
'ec2.ap-southeast-1.amazonaws.com'
|
@@ -193,8 +158,8 @@ module Fog
|
|
193
158
|
else
|
194
159
|
'ec2.amazonaws.com'
|
195
160
|
end
|
196
|
-
@port
|
197
|
-
@scheme
|
161
|
+
@port = options[:port] || 443
|
162
|
+
@scheme = options[:scheme] || 'https'
|
198
163
|
end
|
199
164
|
|
200
165
|
private
|
@@ -227,14 +192,12 @@ module Fog
|
|
227
192
|
})
|
228
193
|
rescue Excon::Errors::Error => error
|
229
194
|
if match = error.message.match(/<Code>(.*)<\/Code><Message>(.*)<\/Message>/)
|
230
|
-
|
195
|
+
raise case match[1].split('.').last
|
231
196
|
when 'NotFound'
|
232
|
-
Fog::AWS::EC2::NotFound.
|
197
|
+
Fog::AWS::EC2::NotFound.slurp(error, match[2])
|
233
198
|
else
|
234
|
-
Fog::AWS::EC2::Error.
|
199
|
+
Fog::AWS::EC2::Error.slurp(error, "#{match[1]} => #{match[2]}")
|
235
200
|
end
|
236
|
-
new_error.set_backtrace(error.backtrace)
|
237
|
-
raise new_error
|
238
201
|
else
|
239
202
|
raise error
|
240
203
|
end
|