fog 0.3.31 → 0.3.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +3 -0
- data/.gitignore +10 -0
- data/Gemfile.lock +1 -4
- data/README.rdoc +29 -37
- data/Rakefile +5 -25
- data/bin/fog +1 -3
- data/examples/dns_methods.rb +389 -0
- data/examples/storage.rb +103 -0
- data/fog.gemspec +4 -778
- data/lib/fog.rb +5 -66
- data/lib/fog/aws.rb +3 -0
- data/lib/fog/aws/bin.rb +7 -2
- data/lib/fog/aws/cdn.rb +2 -2
- data/lib/fog/aws/compute.rb +2 -2
- data/lib/fog/aws/dns.rb +101 -0
- data/lib/fog/aws/elb.rb +2 -2
- data/lib/fog/aws/iam.rb +2 -2
- data/lib/fog/aws/models/compute/image.rb +1 -0
- data/lib/fog/aws/models/compute/server.rb +1 -1
- data/lib/fog/aws/models/compute/servers.rb +1 -13
- data/lib/fog/aws/parsers/compute/describe_images.rb +36 -34
- data/lib/fog/aws/parsers/dns/change_resource_record_sets.rb +26 -0
- data/lib/fog/aws/parsers/dns/create_hosted_zone.rb +55 -0
- data/lib/fog/aws/parsers/dns/delete_hosted_zone.rb +25 -0
- data/lib/fog/aws/parsers/dns/get_change.rb +26 -0
- data/lib/fog/aws/parsers/dns/get_hosted_zone.rb +43 -0
- data/lib/fog/aws/parsers/dns/list_hosted_zones.rb +35 -0
- data/lib/fog/aws/parsers/dns/list_resource_record_sets.rb +46 -0
- data/lib/fog/aws/requests/compute/describe_images.rb +1 -0
- data/lib/fog/aws/requests/dns/change_resource_record_sets.rb +90 -0
- data/lib/fog/aws/requests/dns/create_hosted_zone.rb +68 -0
- data/lib/fog/aws/requests/dns/delete_hosted_zone.rb +48 -0
- data/lib/fog/aws/requests/dns/get_change.rb +47 -0
- data/lib/fog/aws/requests/dns/get_hosted_zone.rb +51 -0
- data/lib/fog/aws/requests/dns/list_hosted_zones.rb +63 -0
- data/lib/fog/aws/requests/dns/list_resource_record_sets.rb +68 -0
- data/lib/fog/aws/requests/storage/get_object_url.rb +2 -2
- data/lib/fog/aws/requests/storage/put_object_url.rb +2 -2
- data/lib/fog/aws/requests/storage/sync_clock.rb +28 -0
- data/lib/fog/aws/simpledb.rb +2 -2
- data/lib/fog/aws/storage.rb +5 -3
- data/lib/fog/bluebox.rb +2 -0
- data/lib/fog/bluebox/compute.rb +2 -2
- data/lib/fog/brightbox.rb +2 -0
- data/lib/fog/brightbox/compute.rb +2 -2
- data/lib/fog/core.rb +21 -1
- data/lib/fog/core/bin.rb +3 -1
- data/lib/fog/core/compute.rb +1 -0
- data/lib/fog/core/credentials.rb +72 -50
- data/lib/fog/core/deprecation.rb +11 -5
- data/lib/fog/core/mock.rb +34 -0
- data/lib/fog/core/model.rb +9 -1
- data/lib/fog/core/service.rb +40 -26
- data/lib/fog/core/storage.rb +1 -0
- data/lib/fog/core/time.rb +21 -0
- data/lib/fog/core/wait_for.rb +17 -0
- data/lib/fog/go_grid.rb +2 -0
- data/lib/fog/go_grid/compute.rb +2 -2
- data/lib/fog/google.rb +2 -0
- data/lib/fog/google/requests/storage/get_bucket.rb +6 -5
- data/lib/fog/google/requests/storage/get_object_url.rb +4 -4
- data/lib/fog/google/requests/storage/put_object_url.rb +4 -4
- data/lib/fog/google/storage.rb +4 -3
- data/lib/fog/linode.rb +3 -0
- data/lib/fog/linode/bin.rb +5 -3
- data/lib/fog/linode/compute.rb +6 -2
- data/lib/fog/linode/dns.rb +80 -0
- data/lib/fog/linode/requests/dns/domain_create.rb +52 -0
- data/lib/fog/linode/requests/dns/domain_delete.rb +35 -0
- data/lib/fog/linode/requests/dns/domain_list.rb +50 -0
- data/lib/fog/linode/requests/dns/domain_resource_create.rb +53 -0
- data/lib/fog/linode/requests/dns/domain_resource_delete.rb +36 -0
- data/lib/fog/linode/requests/dns/domain_resource_list.rb +48 -0
- data/lib/fog/linode/requests/dns/domain_resource_update.rb +54 -0
- data/lib/fog/linode/requests/dns/domain_update.rb +48 -0
- data/lib/fog/local.rb +2 -0
- data/lib/fog/local/storage.rb +3 -3
- data/lib/fog/new_servers.rb +2 -0
- data/lib/fog/new_servers/compute.rb +2 -2
- data/lib/fog/rackspace.rb +2 -0
- data/lib/fog/rackspace/cdn.rb +2 -2
- data/lib/fog/rackspace/compute.rb +2 -2
- data/lib/fog/rackspace/storage.rb +2 -2
- data/lib/fog/slicehost.rb +3 -0
- data/lib/fog/slicehost/bin.rb +2 -0
- data/lib/fog/slicehost/compute.rb +2 -2
- data/lib/fog/slicehost/dns.rb +84 -0
- data/lib/fog/slicehost/parsers/dns/create_record.rb +26 -0
- data/lib/fog/slicehost/parsers/dns/create_zone.rb +26 -0
- data/lib/fog/slicehost/parsers/dns/get_record.rb +26 -0
- data/lib/fog/slicehost/parsers/dns/get_records.rb +30 -0
- data/lib/fog/slicehost/parsers/dns/get_zone.rb +26 -0
- data/lib/fog/slicehost/parsers/dns/get_zones.rb +30 -0
- data/lib/fog/slicehost/requests/compute/create_slice.rb +2 -2
- data/lib/fog/slicehost/requests/compute/delete_slice.rb +3 -17
- data/lib/fog/slicehost/requests/dns/create_record.rb +61 -0
- data/lib/fog/slicehost/requests/dns/create_zone.rb +54 -0
- data/lib/fog/slicehost/requests/dns/delete_record.rb +31 -0
- data/lib/fog/slicehost/requests/dns/delete_zone.rb +31 -0
- data/lib/fog/slicehost/requests/dns/get_record.rb +40 -0
- data/lib/fog/slicehost/requests/dns/get_records.rb +41 -0
- data/lib/fog/slicehost/requests/dns/get_zone.rb +40 -0
- data/lib/fog/slicehost/requests/dns/get_zones.rb +38 -0
- data/lib/fog/terremark.rb +2 -0
- data/lib/fog/terremark/ecloud.rb +2 -4
- data/lib/fog/vcloud.rb +4 -2
- data/lib/fog/vcloud/bin.rb +3 -1
- data/lib/fog/vcloud/mock_data_classes.rb +77 -11
- data/lib/fog/vcloud/terremark/ecloud.rb +22 -7
- data/lib/fog/vcloud/terremark/ecloud/models/backup_internet_service.rb +60 -0
- data/lib/fog/vcloud/terremark/ecloud/models/backup_internet_services.rb +36 -0
- data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +28 -13
- data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +2 -2
- data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/network.rb +4 -1
- data/lib/fog/vcloud/terremark/ecloud/models/server.rb +5 -5
- data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +6 -2
- data/lib/fog/vcloud/terremark/ecloud/requests/add_backup_internet_service.rb +111 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +2 -4
- data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +1 -3
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +39 -27
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb +1 -2
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb +21 -6
- data/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +2 -1
- data/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +34 -17
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +12 -10
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +15 -10
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +1 -12
- data/lib/fog/zerigo.rb +15 -0
- data/lib/fog/zerigo/bin.rb +25 -0
- data/lib/fog/zerigo/dns.rb +96 -0
- data/lib/fog/zerigo/parsers/dns/count_hosts.rb +24 -0
- data/lib/fog/zerigo/parsers/dns/count_zones.rb +24 -0
- data/lib/fog/zerigo/parsers/dns/create_host.rb +26 -0
- data/lib/fog/zerigo/parsers/dns/create_zone.rb +26 -0
- data/lib/fog/zerigo/parsers/dns/find_hosts.rb +30 -0
- data/lib/fog/zerigo/parsers/dns/get_host.rb +26 -0
- data/lib/fog/zerigo/parsers/dns/get_zone.rb +56 -0
- data/lib/fog/zerigo/parsers/dns/get_zone_stats.rb +26 -0
- data/lib/fog/zerigo/parsers/dns/list_hosts.rb +30 -0
- data/lib/fog/zerigo/parsers/dns/list_zones.rb +30 -0
- data/lib/fog/zerigo/requests/dns/count_hosts.rb +36 -0
- data/lib/fog/zerigo/requests/dns/count_zones.rb +36 -0
- data/lib/fog/zerigo/requests/dns/create_host.rb +70 -0
- data/lib/fog/zerigo/requests/dns/create_zone.rb +97 -0
- data/lib/fog/zerigo/requests/dns/delete_host.rb +32 -0
- data/lib/fog/zerigo/requests/dns/delete_zone.rb +33 -0
- data/lib/fog/zerigo/requests/dns/find_hosts.rb +63 -0
- data/lib/fog/zerigo/requests/dns/get_host.rb +47 -0
- data/lib/fog/zerigo/requests/dns/get_zone.rb +57 -0
- data/lib/fog/zerigo/requests/dns/get_zone_stats.rb +44 -0
- data/lib/fog/zerigo/requests/dns/list_hosts.rb +48 -0
- data/lib/fog/zerigo/requests/dns/list_zones.rb +53 -0
- data/lib/fog/zerigo/requests/dns/update_host.rb +60 -0
- data/lib/fog/zerigo/requests/dns/update_zone.rb +78 -0
- data/spec/spec_helper.rb +0 -5
- data/spec/vcloud/spec_helper.rb +3 -2
- data/spec/vcloud/terremark/ecloud/models/backup_internet_service_spec.rb +49 -0
- data/spec/vcloud/terremark/ecloud/models/backup_internet_services_spec.rb +29 -0
- data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +32 -13
- data/spec/vcloud/terremark/ecloud/models/network_spec.rb +7 -4
- data/spec/vcloud/terremark/ecloud/models/server_spec.rb +20 -0
- data/spec/vcloud/terremark/ecloud/requests/add_backup_internet_service_spec.rb +60 -0
- data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +3 -0
- data/spec/vcloud/terremark/ecloud/requests/configure_network_ip_spec.rb +55 -0
- data/spec/vcloud/terremark/ecloud/requests/delete_vapp_spec.rb +9 -0
- data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +60 -14
- data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +2 -0
- data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +3 -3
- data/tests/aws/requests/compute/image_tests.rb +15 -14
- data/tests/aws/requests/dns/dns_tests.rb +276 -0
- data/tests/brightbox/requests/compute/account_tests.rb +20 -9
- data/tests/brightbox/requests/compute/api_client_tests.rb +12 -4
- data/tests/brightbox/requests/compute/cloud_ip_tests.rb +20 -6
- data/tests/brightbox/requests/compute/image_tests.rb +9 -4
- data/tests/brightbox/requests/compute/interface_tests.rb +8 -2
- data/tests/brightbox/requests/compute/server_tests.rb +17 -5
- data/tests/brightbox/requests/compute/server_type_tests.rb +8 -4
- data/tests/brightbox/requests/compute/user_tests.rb +13 -5
- data/tests/brightbox/requests/compute/zone_tests.rb +8 -4
- data/tests/core/attribute_tests.rb +45 -0
- data/tests/helper.rb +0 -2
- data/tests/linode/requests/dns/dns_tests.rb +262 -0
- data/tests/rackspace/requests/compute/address_tests.rb +1 -1
- data/tests/rackspace/requests/compute/image_tests.rb +1 -1
- data/tests/slicehost/requests/dns_tests/dns_tests.rb +279 -0
- data/tests/zerigo/helper.rb +0 -0
- data/tests/zerigo/requests/dns/dns_tests.rb +374 -0
- metadata +280 -36
- data/spec/compact_progress_bar_formatter.rb +0 -195
- data/spec/core/attributes_spec.rb +0 -52
- data/spec/lorem.txt +0 -1
data/.document
ADDED
data/.gitignore
ADDED
data/Gemfile.lock
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
fog (0.3.
|
|
4
|
+
fog (0.3.32)
|
|
5
5
|
builder
|
|
6
6
|
excon (>= 0.3.3)
|
|
7
7
|
formatador (>= 0.0.16)
|
|
8
8
|
json
|
|
9
9
|
mime-types
|
|
10
|
-
named-parameters (>= 0.0.17)
|
|
11
10
|
net-ssh (>= 2.0.23)
|
|
12
11
|
nokogiri (>= 1.4.4)
|
|
13
12
|
ruby-hmac
|
|
@@ -22,7 +21,6 @@ GEM
|
|
|
22
21
|
formatador (>= 0.0.12)
|
|
23
22
|
json (1.4.6)
|
|
24
23
|
mime-types (1.16)
|
|
25
|
-
named-parameters (0.0.18)
|
|
26
24
|
net-ssh (2.0.23)
|
|
27
25
|
nokogiri (1.4.4)
|
|
28
26
|
rake (0.8.7)
|
|
@@ -42,7 +40,6 @@ DEPENDENCIES
|
|
|
42
40
|
formatador (>= 0.0.16)
|
|
43
41
|
json
|
|
44
42
|
mime-types
|
|
45
|
-
named-parameters (>= 0.0.17)
|
|
46
43
|
net-ssh (>= 2.0.23)
|
|
47
44
|
nokogiri (>= 1.4.4)
|
|
48
45
|
rake
|
data/README.rdoc
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
http://geemus.s3.amazonaws.com/fog.png
|
|
2
2
|
|
|
3
|
-
fog is the Ruby cloud computing library
|
|
4
|
-
|
|
5
|
-
The quick and dirty, top to bottom:
|
|
3
|
+
fog is the Ruby cloud computing library, top to bottom:
|
|
6
4
|
|
|
7
5
|
* Collections provide a simplified interface, making clouds easier to work with and switch between.
|
|
8
6
|
* Requests allow power users to get the most out of the features of each individual cloud.
|
|
9
7
|
* Mocks make testing and integrating a breeze.
|
|
10
8
|
|
|
11
|
-
Put them together and you get a great cloud computing experience, but we are getting ahead of ourselves...
|
|
12
|
-
|
|
13
9
|
== Getting Started
|
|
14
10
|
|
|
15
11
|
sudo gem install fog
|
|
16
12
|
|
|
17
|
-
Now
|
|
13
|
+
Now type 'fog' to try stuff, confident that fog will let you know what to do. Here is an example of wading through server creation for Amazon Elastic Compute Cloud:
|
|
18
14
|
|
|
19
15
|
>> server = AWS.servers.create
|
|
20
16
|
ArgumentError: image_id is required for this operation
|
|
@@ -27,73 +23,67 @@ Now just type 'fog' to trying stuff out, confident that fog should let you know
|
|
|
27
23
|
|
|
28
24
|
== Collections
|
|
29
25
|
|
|
30
|
-
A high level interface to each cloud is provided through collections, such as images and servers
|
|
31
|
-
You can see a list of available collections by calling
|
|
26
|
+
A high level interface to each cloud is provided through collections, such as `images` and `servers`.
|
|
27
|
+
You can see a list of available collections by calling `collections` on the connection object. You can try it out using the `fog` command:
|
|
32
28
|
|
|
33
|
-
>>
|
|
29
|
+
>> AWS.collections
|
|
34
30
|
[:addresses, :directories, :files, :flavors, :images, :key_pairs, :security_groups, :servers, :snapshots, :volumes]
|
|
35
31
|
|
|
36
|
-
Some
|
|
32
|
+
Some collections are available across multiple providers. For example, compute providers have +flavors+, +images+ and +servers+, and storage providers have +directory+ and +file+.
|
|
37
33
|
|
|
38
|
-
Collections share
|
|
34
|
+
Collections share basic CRUD type operations, such as:
|
|
39
35
|
* +all+ - fetch every object of that type from the provider.
|
|
40
|
-
* +create+ - initialize a new record locally and
|
|
41
|
-
* +get+ - fetch a single object by
|
|
42
|
-
* +new+ - initialize a new record locally, but do not
|
|
36
|
+
* +create+ - initialize a new record locally and a remote resource with the provider.
|
|
37
|
+
* +get+ - fetch a single object by it's identity from the provider.
|
|
38
|
+
* +new+ - initialize a new record locally, but do not create a remote resource with the provider.
|
|
43
39
|
|
|
44
40
|
As an example, we'll try initializing and persisting a Rackspace Cloud server:
|
|
45
41
|
|
|
46
42
|
require 'fog'
|
|
47
43
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
:rackspace_api_key
|
|
44
|
+
compute = Fog::Compute.new(
|
|
45
|
+
:provider => 'Rackspace',
|
|
46
|
+
:rackspace_api_key => key,
|
|
51
47
|
:rackspace_username => username
|
|
52
48
|
)
|
|
53
49
|
|
|
54
50
|
# boot a gentoo server (flavor 1 = 256, image 3 = gentoo 2008.0)
|
|
55
|
-
server =
|
|
56
|
-
|
|
57
|
-
# wait for it to be ready to do stuff
|
|
58
|
-
server.wait_for { ready? }
|
|
51
|
+
server = compute.servers.create(:flavor_id => 1, :image_id => 3, :name => 'my_server')
|
|
52
|
+
server.wait_for { ready? } # give server time to boot
|
|
59
53
|
|
|
60
54
|
# DO STUFF
|
|
61
55
|
|
|
62
|
-
#
|
|
63
|
-
server.destroy
|
|
56
|
+
server.destroy # cleanup after yourself or regret it, trust me
|
|
64
57
|
|
|
65
58
|
== Models
|
|
66
59
|
|
|
67
|
-
Many of the collection methods return individual objects, which also provide
|
|
60
|
+
Many of the collection methods return individual objects, which also provide common methods:
|
|
68
61
|
* +destroy+ - will destroy the persisted object from the provider
|
|
69
62
|
* +save+ - persist the object to the provider
|
|
70
63
|
* +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)
|
|
71
64
|
|
|
72
65
|
== Mocks
|
|
73
66
|
|
|
74
|
-
As you might imagine, testing code using Fog
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
Mocked calls to mimic the behavior of each provider while eliminating the cost and time needed to actually use cloud resources.
|
|
78
|
-
Enabling mocking easy to use, before you run any other commands run:
|
|
67
|
+
As you might imagine, testing code using Fog can be slow and expensive, constantly turning on and and shutting down instances.
|
|
68
|
+
Mocking allows skipping this overhead by providing an in memory representation resources as you make requests.
|
|
69
|
+
Enabling mocking easy to use, before you run other commands, simply run:
|
|
79
70
|
|
|
80
71
|
Fog.mock!
|
|
81
72
|
|
|
82
|
-
Then you
|
|
83
|
-
Some mocks are not implemented just yet, but fog will raise an error to let you know and contributions are always welcome!
|
|
73
|
+
Then proceed as usual, if you run into unimplemented mocks fog will raise an error and as always contributions are welcome!
|
|
84
74
|
|
|
85
75
|
== Requests
|
|
86
76
|
|
|
87
77
|
Requests allow you to dive deeper when the models just can't cut it.
|
|
88
78
|
You can see a list of available requests by calling #requests on the connection object.
|
|
89
|
-
|
|
90
|
-
Here is how you can lookup your reserved instances:
|
|
79
|
+
|
|
80
|
+
For instance, ec2 provides methods related to reserved instances that don't have any models (yet). Here is how you can lookup your reserved instances:
|
|
91
81
|
|
|
92
82
|
$ fog
|
|
93
83
|
>> AWS[:ec2].describe_reserved_instances
|
|
94
84
|
#<Excon::Response [...]>
|
|
95
85
|
|
|
96
|
-
It will return an {excon}[http://github.com/geemus/excon] response, which has
|
|
86
|
+
It will return an {excon}[http://github.com/geemus/excon] response, which has `body`, `headers` and `status`. Both return nice hashes.
|
|
97
87
|
|
|
98
88
|
== Go forth and conquer
|
|
99
89
|
|
|
@@ -114,15 +104,16 @@ You should try out the (varying) support fog has for:
|
|
|
114
104
|
* {Blue Box Group}[http://www.blueboxgrp.com] [{Compute}[http://www.blueboxgrp.com/blocks]]
|
|
115
105
|
* {Brightbox}[http://www.brightbox.co.uk] [{Compute}[http://beta.brightbox.com/]]
|
|
116
106
|
* {Google}[http://www.google.com] [{Storage}[http://code.google.com/apis/storage]]
|
|
107
|
+
* Local [Storage]
|
|
117
108
|
* {Rackspace}[http://www.rackspace.com] [{Compute}[http://www.rackspacecloud.com/cloud_hosting_products/servers], {Storage}[http://www.rackspacecloud.com/cloud_hosting_products/files]]
|
|
118
|
-
* {Slicehost}[http://www.slicehost.com] [{Compute}[http://www.slicehost.com]]
|
|
109
|
+
* {Slicehost}[http://www.slicehost.com] [{Compute}[http://www.slicehost.com], {DNS}[http://www.slicehost.com]]
|
|
119
110
|
* {Terremark}[http://www.terremark.com] [{vCloud Express}[http://vcloudexpress.terremark.com]]
|
|
120
111
|
|
|
121
112
|
There are also the basics of these providers (that could use your love):
|
|
122
113
|
* {GoGrid}[http://www.gogrid.com] [{Compute}[http://www.gogrid.com]]
|
|
123
|
-
* {Linode}[http://www.linode.com] [{Compute}[http://www.linode.com]]
|
|
124
|
-
* Local [Storage]
|
|
114
|
+
* {Linode}[http://www.linode.com] [{Compute}[http://www.linode.com], {DNS}[http://www.linode.com]]
|
|
125
115
|
* {New Servers}[http://www.newservers.com] [{Compute}[http://www.newservers.com]]
|
|
116
|
+
* {Zerigo}[http://www.zerigo.com] [{DNS}[http://www.zerigo.com/managed-dns]]
|
|
126
117
|
|
|
127
118
|
Enjoy, and let me know what I can do to continue improving fog!
|
|
128
119
|
|
|
@@ -132,6 +123,7 @@ Enjoy, and let me know what I can do to continue improving fog!
|
|
|
132
123
|
* Report bugs or find stuff to work on in {issues}[http://github.com/geemus/fog/issues]
|
|
133
124
|
* Learn about {contributing}[http://github.com/geemus/fog/wiki/contributor-guide] or find more info about the {Providers}[http://github.com/geemus/fog/wiki/Providers] (including some todo items)
|
|
134
125
|
* See what already uses fog and add your own stuff to {the list}[http://wiki.github.com/geemus/fog/in-the-wild]
|
|
126
|
+
* Check out blog posts and other mentions from elsewhere {press}[http://wiki.github.com/geemus/fog/press]
|
|
135
127
|
|
|
136
128
|
== Sponsorship
|
|
137
129
|
|
data/Rakefile
CHANGED
|
@@ -46,13 +46,6 @@ end
|
|
|
46
46
|
task :default => :test
|
|
47
47
|
|
|
48
48
|
task :test do
|
|
49
|
-
sh("export FOG_MOCK=true && bundle exec spec -cfs spec") &&
|
|
50
|
-
sh("export FOG_MOCK=true && bundle exec shindo tests") &&
|
|
51
|
-
sh("export FOG_MOCK=false && bundle exec spec -cfs spec") &&
|
|
52
|
-
sh("export FOG_MOCK=false && bundle exec shindo tests")
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
task :ci do
|
|
56
49
|
sh("export FOG_MOCK=true && bundle exec spec spec") &&
|
|
57
50
|
sh("export FOG_MOCK=true && bundle exec shindont tests") &&
|
|
58
51
|
sh("export FOG_MOCK=false && bundle exec spec spec") &&
|
|
@@ -108,27 +101,14 @@ end
|
|
|
108
101
|
task :gemspec => :validate do
|
|
109
102
|
# read spec file and split out manifest section
|
|
110
103
|
spec = File.read(gemspec_file)
|
|
111
|
-
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
|
112
104
|
|
|
113
105
|
# replace name version and date
|
|
114
|
-
replace_header(
|
|
115
|
-
replace_header(
|
|
116
|
-
replace_header(
|
|
106
|
+
replace_header(spec, :name)
|
|
107
|
+
replace_header(spec, :version)
|
|
108
|
+
replace_header(spec, :date)
|
|
117
109
|
#comment this out if your rubyforge_project has a different name
|
|
118
|
-
replace_header(
|
|
119
|
-
|
|
120
|
-
# determine file list from git ls-files
|
|
121
|
-
files = `git ls-files`.
|
|
122
|
-
split("\n").
|
|
123
|
-
sort.
|
|
124
|
-
reject { |file| file =~ /^\./ }.
|
|
125
|
-
reject { |file| file =~ /^(rdoc|pkg)/ }.
|
|
126
|
-
map { |file| " #{file}" }.
|
|
127
|
-
join("\n")
|
|
128
|
-
|
|
129
|
-
# piece file back together and write
|
|
130
|
-
manifest = " s.files = %w[\n#{files}\n ]\n"
|
|
131
|
-
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
|
110
|
+
replace_header(spec, :rubyforge_project)
|
|
111
|
+
|
|
132
112
|
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
|
133
113
|
puts "Updated #{gemspec_file}"
|
|
134
114
|
end
|
data/bin/fog
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'fog'))
|
|
3
3
|
require 'irb'
|
|
4
4
|
require 'yaml'
|
|
5
|
-
require File.join('fog', 'core', 'credentials')
|
|
6
5
|
Fog.credential = ARGV.first ? ARGV.first.to_sym : nil
|
|
7
|
-
Fog.bin = true
|
|
8
6
|
Fog.mock! if ENV['FOG_MOCK']
|
|
9
7
|
unless Fog.credentials
|
|
10
8
|
exit
|
|
@@ -35,7 +33,7 @@ else
|
|
|
35
33
|
@irb.context.workspace = IRB::WorkSpace.new(binding)
|
|
36
34
|
|
|
37
35
|
Formatador.display_line('Welcome to fog interactive!')
|
|
38
|
-
Formatador.display_line(":#{Fog.credential
|
|
36
|
+
Formatador.display_line(":#{Fog.credential} provides #{providers}")
|
|
39
37
|
providers = Fog.providers
|
|
40
38
|
Fog.modules.each do |_module_|
|
|
41
39
|
if _module_.respond_to?(:startup_notice)
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require File.join(File.dirname(File.expand_path(__FILE__)), '..', 'lib', 'fog')
|
|
5
|
+
require 'fog/core/bin'
|
|
6
|
+
|
|
7
|
+
#mark true for each cloud you wish to enable/run the sample for
|
|
8
|
+
RUN_AWS_SAMPLE = true
|
|
9
|
+
RUN_LINODE_SAMPLE = false
|
|
10
|
+
RUN_SLICEHOST_SAMPLE = false
|
|
11
|
+
RUN_ZERIGO_SAMPLE = false
|
|
12
|
+
|
|
13
|
+
#domain to use in examples
|
|
14
|
+
TEST_DOMAIN = 'test-343246324434.com'
|
|
15
|
+
|
|
16
|
+
# example of how to use AWS Route 53 DNS calls
|
|
17
|
+
def show_aws_dns_usage
|
|
18
|
+
|
|
19
|
+
begin
|
|
20
|
+
|
|
21
|
+
#use to keep track of zone we create
|
|
22
|
+
zone_id= nil
|
|
23
|
+
|
|
24
|
+
# see if domain is already hosted on AWS
|
|
25
|
+
# important to check as AWS will let you create multiple zones with the same domain name
|
|
26
|
+
options= { :max_items => 200 }
|
|
27
|
+
response = AWS[:dns].list_hosted_zones( options)
|
|
28
|
+
if response.status == 200
|
|
29
|
+
zones = response.body['HostedZones']
|
|
30
|
+
zones.each { |zone|
|
|
31
|
+
domain_name = zone['Name']
|
|
32
|
+
if domain_name.chop == TEST_DOMAIN
|
|
33
|
+
zone_id = zone['Id'].sub('/hostedzone/', '')
|
|
34
|
+
end
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
#if domain not yet created, do so now
|
|
39
|
+
if zone_id.nil?
|
|
40
|
+
options= { :comment => 'test domain - not for production use' }
|
|
41
|
+
response = AWS[:dns].create_hosted_zone( TEST_DOMAIN, options)
|
|
42
|
+
if response.status == 201
|
|
43
|
+
zone_id = response.body['HostedZone']['Id']
|
|
44
|
+
change_id = response.body['ChangeInfo']['Id']
|
|
45
|
+
status = response.body['ChangeInfo']['Status']
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
#get details about zone including name servers (which AWS adds automatically)
|
|
50
|
+
response = AWS[:dns].get_hosted_zone( zone_id)
|
|
51
|
+
if response.status == 200
|
|
52
|
+
zone_info = response.body['HostedZone']
|
|
53
|
+
name_servers = response.body['NameServers']
|
|
54
|
+
num_ns_servers = name_servers.count
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
#add an A record for www
|
|
58
|
+
change_batch = []
|
|
59
|
+
host = 'www.' + TEST_DOMAIN
|
|
60
|
+
ip_addr = '1.2.3.4'
|
|
61
|
+
record = { :name => host, :type => 'A', :resource_records => [ip_addr], :ttl => 3600 }
|
|
62
|
+
|
|
63
|
+
resource_record_set = record.merge( :action => 'CREATE' )
|
|
64
|
+
change_batch << resource_record_set
|
|
65
|
+
options = { :comment => 'add A record for www'}
|
|
66
|
+
response = AWS[:dns].change_resource_record_sets( zone_id, change_batch, options)
|
|
67
|
+
if response.status == 200
|
|
68
|
+
change_id = response.body['Id']
|
|
69
|
+
status = response.body['Status']
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
debugger
|
|
73
|
+
|
|
74
|
+
#wait until new zone is live across all name servers
|
|
75
|
+
while status == 'PENDING'
|
|
76
|
+
sleep 2
|
|
77
|
+
response = AWS[:dns].get_change( change_id)
|
|
78
|
+
if response.status == 200
|
|
79
|
+
change_id = response.body['Id']
|
|
80
|
+
status = response.body['Status']
|
|
81
|
+
end
|
|
82
|
+
puts "your changes are #{status}"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# get resource records for zone
|
|
86
|
+
response = AWS[:dns].list_resource_record_sets( zone_id)
|
|
87
|
+
if response.status == 200
|
|
88
|
+
record_sets= response.body['ResourceRecordSets']
|
|
89
|
+
num_records= record_sets.count
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
#now delete record for www
|
|
93
|
+
resource_record_set = record.merge( :action => 'DELETE' )
|
|
94
|
+
change_batch = []
|
|
95
|
+
change_batch << resource_record_set
|
|
96
|
+
options = { :comment => 'remove A record for www'}
|
|
97
|
+
response = AWS[:dns].change_resource_record_sets( zone_id, change_batch, options)
|
|
98
|
+
if response.status == 200
|
|
99
|
+
change_id = response.body['Id']
|
|
100
|
+
status = response.body['Status']
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
#delete the zone
|
|
104
|
+
response = AWS[:dns].delete_hosted_zone( zone_id)
|
|
105
|
+
if response.status == 200
|
|
106
|
+
change_id = response.body['ChangeInfo']['Id']
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
rescue
|
|
111
|
+
#opps, ran into a problem
|
|
112
|
+
puts $!.message
|
|
113
|
+
return false
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
true
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# example of how to use Linode DNS calls
|
|
121
|
+
def show_linode_dns_usage
|
|
122
|
+
|
|
123
|
+
begin
|
|
124
|
+
|
|
125
|
+
#create a zone for a domain
|
|
126
|
+
type = 'master'
|
|
127
|
+
options = { :SOA_email => 'netops@sample-domain.com', :description => "Sample-Domain Inc", :status => 0}
|
|
128
|
+
response = Linode[:compute].domain_create( TEST_DOMAIN, type, options)
|
|
129
|
+
if response.status == 200
|
|
130
|
+
master_zone_id = response.body['DATA']['DomainID']
|
|
131
|
+
puts "created zone for #{TEST_DOMAIN} - ID: #{master_zone_id}"
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
#create a slave zone
|
|
135
|
+
domain = 'sample-slave-domain.com'
|
|
136
|
+
type = 'slave'
|
|
137
|
+
options = { :master_ips => '1.2.3.4; 1.2.3.5'}
|
|
138
|
+
response = Linode[:compute].domain_create( domain, type, options)
|
|
139
|
+
if response.status == 200
|
|
140
|
+
slave_zone_id = response.body['DATA']['DomainID']
|
|
141
|
+
puts "created slave zone for #{domain} - ID: #{slave_zone_id}"
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
#get a list of zones Linode hosted for account
|
|
145
|
+
response = Linode[:compute].domain_list()
|
|
146
|
+
if response.status == 200
|
|
147
|
+
zones = response.body['DATA']
|
|
148
|
+
num_zones = zones.count
|
|
149
|
+
puts "Linode is hosting #{num_zones} DNS zones for this account:"
|
|
150
|
+
zones.each { |zone|
|
|
151
|
+
puts " #{zone['DOMAIN']}\n"
|
|
152
|
+
}
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
#add an A and a MX record
|
|
156
|
+
domain= 'www.' + TEST_DOMAIN
|
|
157
|
+
options = { :name => domain, :target => '4.5.6.7', :ttl_sec => 7200 }
|
|
158
|
+
response = Linode[:compute].domain_resource_create( master_zone_id, 'A', options)
|
|
159
|
+
if response.status == 200
|
|
160
|
+
resource_id = response.body['DATA']['ResourceID']
|
|
161
|
+
puts "added an A record for #{domain} - ID: #{resource_id}"
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
domain= 'mail.' + TEST_DOMAIN
|
|
165
|
+
options = { :target => domain, :priority => 1 }
|
|
166
|
+
response = Linode[:compute].domain_resource_create( master_zone_id, 'MX', options)
|
|
167
|
+
if response.status == 200
|
|
168
|
+
resource_id = response.body['DATA']['ResourceID']
|
|
169
|
+
puts "added a MX record for #{TEST_DOMAIN} - ID: #{resource_id}"
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
#change MX to have a lower priority
|
|
173
|
+
options = { :priority => 5 }
|
|
174
|
+
response = Linode[:compute].domain_resource_update( master_zone_id, resource_id, options)
|
|
175
|
+
if response.status == 200
|
|
176
|
+
resource_id = response.body['DATA']['ResourceID']
|
|
177
|
+
puts "updated MX record for #{TEST_DOMAIN} with new priority - ID: #{resource_id}"
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
#get the list of resource records for the domain
|
|
181
|
+
response = Linode[:compute].domain_resource_list( master_zone_id)
|
|
182
|
+
if response.status == 200
|
|
183
|
+
num_records = response.body['DATA'].count
|
|
184
|
+
puts "#{TEST_DOMAIN} zone has #{num_records} resource records"
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
#finally cleanup by deleting the zone we created
|
|
188
|
+
response = Linode[:compute].domain_delete( master_zone_id)
|
|
189
|
+
if response.status == 200
|
|
190
|
+
puts "deleted #{TEST_DOMAIN} zone"
|
|
191
|
+
end
|
|
192
|
+
response = Linode[:compute].domain_delete( slave_zone_id)
|
|
193
|
+
if response.status == 200
|
|
194
|
+
puts "deleted slave zone"
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
rescue
|
|
198
|
+
#opps, ran into a problem
|
|
199
|
+
puts $!.message
|
|
200
|
+
return false
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
true
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
# example of how to use Slicehost DNS calls
|
|
208
|
+
def show_slicehost_dns_usage
|
|
209
|
+
|
|
210
|
+
begin
|
|
211
|
+
#create a zone for a domain
|
|
212
|
+
zone_id = 0
|
|
213
|
+
options = { :ttl => 1800, :active => 'N' }
|
|
214
|
+
response= Slicehost[:compute].create_zone( TEST_DOMAIN, options)
|
|
215
|
+
if response.status == 201
|
|
216
|
+
zone_id= response.body['id']
|
|
217
|
+
puts "created zone for #{TEST_DOMAIN} - ID: #{zone_id}"
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
#add an A record for website
|
|
221
|
+
record_id = 0
|
|
222
|
+
options = { :ttl => 3600, :active => 'N' }
|
|
223
|
+
host = "www.#{TEST_DOMAIN}"
|
|
224
|
+
response= Slicehost[:compute].create_record( 'A', zone_id, host, "1.2.3.4", options)
|
|
225
|
+
if response.status == 201
|
|
226
|
+
record_id= response.body['id']
|
|
227
|
+
puts "created 'A' record for #{host} - ID: #{record_id}"
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
#get a list of zones Slicehost hosted for account
|
|
231
|
+
response = Slicehost[:compute].get_zones()
|
|
232
|
+
if response.status == 200
|
|
233
|
+
zones = response.body['zones']
|
|
234
|
+
num_zones= zones.count
|
|
235
|
+
puts "Slicehost is hosting #{num_zones} DNS zones for this account"
|
|
236
|
+
zones.each { |zone|
|
|
237
|
+
puts " #{zone['origin']}\n"
|
|
238
|
+
}
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
#now get details on www record for the zone
|
|
242
|
+
if record_id > 0
|
|
243
|
+
response = Slicehost[:compute].get_record( record_id)
|
|
244
|
+
if response.status == 200
|
|
245
|
+
record = response.body['records'][0]
|
|
246
|
+
name = record['name']
|
|
247
|
+
type = record['record-type']
|
|
248
|
+
puts "got details on record #{record_id} -is an #{type} record for #{name} domain"
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
#finally cleanup by deleting the zone we created
|
|
253
|
+
if zone_id > 0
|
|
254
|
+
response = Slicehost[:compute].delete_zone( zone_id)
|
|
255
|
+
if response.status == 200
|
|
256
|
+
puts "#{TEST_DOMAIN} removed from Slicehost DNS"
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
rescue
|
|
261
|
+
#opps, ran into a problem
|
|
262
|
+
puts $!.message
|
|
263
|
+
return false
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
true
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
# example of how to use Zerigo DNS calls
|
|
270
|
+
def show_zerigo_dns_usage
|
|
271
|
+
|
|
272
|
+
begin
|
|
273
|
+
#create a domain
|
|
274
|
+
options = { :nx_ttl => 1800 }
|
|
275
|
+
response = Zerigo[:compute].create_zone( "sample-domain.com", 3600, 'pri_sec', options)
|
|
276
|
+
if response.status == 201
|
|
277
|
+
zone_id = response.body['id']
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
#update zone
|
|
281
|
+
options = { :notes => "domain for client ABC"}
|
|
282
|
+
response = Zerigo[:compute].update_zone( zone_id, options)
|
|
283
|
+
if response.status == 200
|
|
284
|
+
puts "update of zone #{zone_id} worked"
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
#get details on the zone
|
|
288
|
+
response = Zerigo[:compute].get_zone( zone_id)
|
|
289
|
+
if response.status == 200
|
|
290
|
+
domain = response.body['domain']
|
|
291
|
+
hosts = response.body['hosts']
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
#get zone stats
|
|
295
|
+
response = Zerigo[:compute].get_zone_stats( zone_id)
|
|
296
|
+
if response.status == 200
|
|
297
|
+
queries = response.body['queries']
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
#list all domains on this accont
|
|
301
|
+
response= Zerigo[:compute].list_zones()
|
|
302
|
+
if response.status == 200
|
|
303
|
+
zone_count = response.headers['X-Query-Count'].to_i
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
#add an A record to the zone
|
|
307
|
+
options = { :hostname => 'www' }
|
|
308
|
+
response = Zerigo[:compute].create_host( zone_id, 'A', '1.2.3.4', options )
|
|
309
|
+
if response.status == 201
|
|
310
|
+
host_id = response.body['id']
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
#add an MX record to the zone
|
|
314
|
+
options = { :priority => 5 }
|
|
315
|
+
response = Zerigo[:compute].create_host( zone_id, 'MX', 'mail.sample-domain.com', options)
|
|
316
|
+
if response.status == 201
|
|
317
|
+
mail_host_id = response.body['id']
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
#update the record
|
|
321
|
+
options = { :priority => 10 }
|
|
322
|
+
response = Zerigo[:compute].update_host( mail_host_id, options)
|
|
323
|
+
if response.status == 200
|
|
324
|
+
#updated priority
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
#find a specific record
|
|
328
|
+
response = Zerigo[:compute].find_hosts( "sample-domain.com" )
|
|
329
|
+
if response.status == 200
|
|
330
|
+
hosts= response.body['hosts']
|
|
331
|
+
num_records = hosts.count
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
#get host record
|
|
335
|
+
response = Zerigo[:compute].get_host( host_id)
|
|
336
|
+
if response.status == 200
|
|
337
|
+
fqdn = response.body['fqdn']
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
#list hosts
|
|
341
|
+
response = Zerigo[:compute].list_hosts( zone_id)
|
|
342
|
+
if response.status == 200
|
|
343
|
+
hosts = response.body['hosts']
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
#delete the host record
|
|
347
|
+
response = Zerigo[:compute].delete_host( host_id)
|
|
348
|
+
if response.status == 200
|
|
349
|
+
puts "host record #{host_id} deleted from zone"
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
#delete the zone we created
|
|
353
|
+
response = Zerigo[:compute].delete_zone( zone_id)
|
|
354
|
+
if response.status == 200
|
|
355
|
+
puts "deleted zone #{zone_id}"
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
rescue
|
|
359
|
+
#opps, ran into a problem
|
|
360
|
+
puts $!.message
|
|
361
|
+
return false
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
######################################
|
|
367
|
+
|
|
368
|
+
# make sure Fog credentials file has been setup
|
|
369
|
+
# (will throw exception if not)
|
|
370
|
+
Fog::credentials
|
|
371
|
+
|
|
372
|
+
# AWS Route 53
|
|
373
|
+
if RUN_AWS_SAMPLE and Fog::credentials[:aws_access_key_id] and Fog::credentials[:aws_secret_access_key]
|
|
374
|
+
show_aws_dns_usage
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
# Linode
|
|
378
|
+
if RUN_LINODE_SAMPLE and Fog::credentials[:linode_api_key]
|
|
379
|
+
show_linode_dns_usage
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
# Slicehost
|
|
383
|
+
if RUN_SLICEHOST_SAMPLE and Fog::credentials[:slicehost_password]
|
|
384
|
+
show_slicehost_dns_usage
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
if RUN_ZERIGO_SAMPLE and Fog::credentials[:zerigo_email] and Fog::credentials[:zerigo_password]
|
|
388
|
+
show_zerigo_dns_usage
|
|
389
|
+
end
|