fog 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/Rakefile +43 -0
- data/changelog.txt +39 -0
- data/docs/_config.yml +39 -0
- data/docs/_layouts/default.html +96 -0
- data/docs/_posts/2011-01-01-cdn.markdown +82 -0
- data/docs/_posts/2011-01-01-contributing.markdown +228 -0
- data/docs/_posts/2011-01-01-dns.markdown +79 -0
- data/docs/_posts/2011-01-01-press.markdown +32 -0
- data/docs/_posts/2011-01-01-start.markdown +21 -0
- data/docs/_posts/2011-01-01-storage.markdown +145 -0
- data/docs/_posts/2011-01-01-structure.markdown +78 -0
- data/docs/_posts/2011-01-01-users.markdown +33 -0
- data/docs/index.markdown +94 -0
- data/docs/public/crossdomain.xml +25 -0
- data/docs/public/css/fog.css +129 -0
- data/docs/public/css/handheld.css +8 -0
- data/docs/public/css/style.css +129 -0
- data/docs/public/images/.gitignore +3 -0
- data/docs/public/js/libs/dd_belatedpng.js +13 -0
- data/docs/public/js/libs/jquery-1.4.2.js +6240 -0
- data/docs/public/js/libs/jquery-1.4.2.min.js +154 -0
- data/docs/public/js/libs/modernizr-1.6.min.js +30 -0
- data/docs/public/js/mylibs/.gitignore +3 -0
- data/docs/public/js/plugins.js +34 -0
- data/docs/public/js/profiling/config.js +59 -0
- data/docs/public/js/profiling/yahoo-profiling.css +7 -0
- data/docs/public/js/profiling/yahoo-profiling.min.js +39 -0
- data/docs/public/js/script.js +26 -0
- data/docs/public/robots.txt +5 -0
- data/fog.gemspec +6 -5
- data/lib/fog.rb +1 -1
- data/lib/fog/aws/cloud_formation.rb +1 -1
- data/lib/fog/compute/aws.rb +24 -0
- data/lib/fog/compute/models/aws/key_pair.rb +19 -1
- data/lib/fog/compute/models/aws/server.rb +6 -12
- data/lib/fog/compute/models/rackspace/server.rb +7 -7
- data/lib/fog/compute/requests/aws/attach_volume.rb +4 -0
- data/lib/fog/compute/requests/aws/create_security_group.rb +3 -3
- data/lib/fog/compute/requests/aws/create_tags.rb +2 -0
- data/lib/fog/compute/requests/aws/create_volume.rb +4 -0
- data/lib/fog/compute/requests/aws/delete_tags.rb +43 -0
- data/lib/fog/compute/requests/aws/describe_instances.rb +3 -7
- data/lib/fog/compute/requests/aws/describe_snapshots.rb +4 -6
- data/lib/fog/compute/requests/aws/describe_volumes.rb +2 -6
- data/lib/fog/core.rb +1 -0
- data/lib/fog/core/connection.rb +1 -1
- data/lib/fog/core/credentials.rb +5 -1
- data/lib/fog/core/parser.rb +1 -2
- data/lib/fog/core/ssh.rb +2 -3
- data/lib/fog/dns/models/aws/record.rb +1 -1
- data/lib/fog/dns/models/bluebox/zone.rb +1 -0
- data/lib/fog/storage/models/rackspace/directory.rb +8 -2
- data/lib/fog/storage/rackspace.rb +3 -1
- data/lib/fog/storage/requests/rackspace/delete_container.rb +1 -1
- data/lib/fog/storage/requests/rackspace/delete_object.rb +1 -1
- data/lib/fog/storage/requests/rackspace/get_container.rb +1 -1
- data/lib/fog/storage/requests/rackspace/get_object.rb +1 -1
- data/lib/fog/storage/requests/rackspace/head_container.rb +1 -1
- data/lib/fog/storage/requests/rackspace/head_object.rb +2 -2
- data/lib/fog/storage/requests/rackspace/put_container.rb +1 -1
- data/lib/fog/storage/requests/rackspace/put_object.rb +1 -1
- data/spec/spec_helper.rb +0 -4
- data/tests/aws/requests/cloud_formation/stack_tests.rb +16 -5
- data/tests/aws/requests/rds/instance_tests.rb +4 -2
- data/tests/compute/models/aws/address_tests.rb +16 -0
- data/tests/compute/models/aws/addresses_tests.rb +5 -0
- data/tests/compute/models/aws/key_pair_tests.rb +27 -0
- data/tests/compute/models/aws/key_pairs_tests.rb +5 -0
- data/tests/compute/models/aws/security_group_tests.rb +5 -0
- data/tests/compute/models/aws/security_groups.rb +5 -0
- data/tests/compute/models/aws/server_tests.rb +39 -0
- data/tests/compute/models/aws/snapshot_tests.rb +10 -0
- data/tests/compute/models/aws/snapshots_tests.rb +10 -0
- data/tests/compute/models/aws/volume_tests.rb +26 -0
- data/tests/compute/models/aws/volumes_tests.rb +5 -0
- data/tests/core/credential_tests.rb +36 -0
- data/tests/storage/requests/aws/object_tests.rb +1 -1
- data/tests/storage/requests/google/object_tests.rb +1 -1
- data/tests/storage/requests/rackspace/object_tests.rb +8 -0
- metadata +118 -75
- data/spec/aws/models/compute/address_spec.rb +0 -103
- data/spec/aws/models/compute/addresses_spec.rb +0 -70
- data/spec/aws/models/compute/key_pair_spec.rb +0 -86
- data/spec/aws/models/compute/key_pairs_spec.rb +0 -71
- data/spec/aws/models/compute/security_group_spec.rb +0 -88
- data/spec/aws/models/compute/security_groups_spec.rb +0 -71
- data/spec/aws/models/compute/server_spec.rb +0 -105
- data/spec/aws/models/compute/snapshot_spec.rb +0 -79
- data/spec/aws/models/compute/snapshots_spec.rb +0 -85
- data/spec/aws/models/compute/volume_spec.rb +0 -174
- data/spec/aws/models/compute/volumes_spec.rb +0 -71
- data/tests/compute/models/aws/server_monitor_tests.rb +0 -47
@@ -0,0 +1,79 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
title: dns
|
4
|
+
---
|
5
|
+
|
6
|
+
The power and flexibility of the cloud are amazing. But sometimes it can be a pain to chase your resources around and keep everything up to date. This is especially true of keeping track of addresses for DNS, but thankfully more and more API driven options are available, allowing you to automate your DNS to keep up with your hardware changes.
|
7
|
+
|
8
|
+
## Setup
|
9
|
+
|
10
|
+
First, make sure you have fog installed:
|
11
|
+
|
12
|
+
gem install fog
|
13
|
+
|
14
|
+
For this first example we will use Zerigo (see below for how to use other providers). You can signup for Zerigo DNS <a href="https://www.zerigo.com/signup/dns">here</a>. Gather up your new credentials to initialize a connection to the service:
|
15
|
+
|
16
|
+
require 'rubygems'
|
17
|
+
require 'fog'
|
18
|
+
|
19
|
+
# create a connection to the service
|
20
|
+
dns = Fog::DNS.new({
|
21
|
+
:provider => 'Zerigo',
|
22
|
+
:zerigo_email => ZERIGO_EMAIL,
|
23
|
+
:zerigo_token => ZERIGO_TOKEN
|
24
|
+
}
|
25
|
+
|
26
|
+
## Getting in the Zone
|
27
|
+
|
28
|
+
The first thing you need to do to prepare for your DNS excursion is create a zone for your domain. The zone will contain all of the more specific records that you will create later. You will just need to specify the domain, which should be your url without the 'http' or 'www' parts, and an email address. Then you can create the zone with your DNS connection:<!--more-->
|
29
|
+
|
30
|
+
zone = @dns.zones.create(
|
31
|
+
:domain => 'example.com',
|
32
|
+
:email => 'admin@example.com'
|
33
|
+
)
|
34
|
+
|
35
|
+
Now that you have a zone you will need to update your registrar to let them know what DNS servers are responsible for your domain. You can ask the zone what values to use:
|
36
|
+
|
37
|
+
zone.nameservers
|
38
|
+
|
39
|
+
## Spinning Records
|
40
|
+
|
41
|
+
With your new zone in hand you can add records as needed. First and foremost you will probably want the 'www' version of your site to point to whatever your ip might be:
|
42
|
+
|
43
|
+
record = @zone.records.create(
|
44
|
+
:ip => '1.2.3.4',
|
45
|
+
:name => 'example.com',
|
46
|
+
:type => 'A'
|
47
|
+
)
|
48
|
+
|
49
|
+
Adding other records is similarly easy, for instance if we want 'www.example.com' to go to the same place, we can use a cname record:
|
50
|
+
|
51
|
+
record = @zone.records.create(
|
52
|
+
:ip => 'example.com',
|
53
|
+
:name => 'www',
|
54
|
+
:type => 'CNAME'
|
55
|
+
)
|
56
|
+
|
57
|
+
Or, similarly you might want to have your blog elsewhere:
|
58
|
+
|
59
|
+
record = @zone.records.create(
|
60
|
+
:ip => '4.3.2.1',
|
61
|
+
:name => 'blog.example.com',
|
62
|
+
:type => 'A'
|
63
|
+
)
|
64
|
+
|
65
|
+
You can add more specifics if you need to, but reasonable defaults make it just that easy. You can also add any other kind of DNS record you might need for mail or other purposes, you can find a nice overview of record options and types <a href="http://en.wikipedia.org/wiki/Domain_Name_System#DNS_resource_records">on Wikipedia</a>.
|
66
|
+
|
67
|
+
## No Zerigo? No Problem
|
68
|
+
|
69
|
+
If you already have an account with another service you can just as easily use this same code with different credentials. fog currently supports <a href="http://aws.amazon.com/route53/">AWS Route 53</a>, <a href="http://bluebox.net">Blue Box</a>, <a href="http://dnsimple.com">DNSimple</a>, <a href="http://www.linode.com">Linode</a>, <a href="http://www.slicehost.com">Slicehost</a> and <a href="http://www.zerigo.com/managed-dns">Zerigo</a>; so you can have your pick. As an example you can connect to AWS instead of Zerigo:
|
70
|
+
|
71
|
+
dns = Fog::DNS.new(
|
72
|
+
:provider => 'AWS',
|
73
|
+
:aws_access_key_id => AWS_ACCESS_KEY_ID,
|
74
|
+
:aws_secret_access_key => AWS_SECRET_ACCESS_KEY
|
75
|
+
)
|
76
|
+
|
77
|
+
## Go Forth and Resolve
|
78
|
+
|
79
|
+
You can see an example of reusing code like this in the <a href="https://github.com/geemus/fog/blob/master/examples/dns_tests.rb">examples folder</a>. Using this makes it easier to give yourself shortcuts to your cloud servers and manage how clients and users access them as well. It is great to have this flexibility so that you can modify your cloud infrastructure as needed while keeping everything ship shape. It also provides a nice way to create custom subdomains for users and just generally round out your cloud solution.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
title: Press
|
4
|
+
---
|
5
|
+
|
6
|
+
Mentions and blog posts from elsewhere in reverse chronological order by day (and alphasorted for same days).
|
7
|
+
|
8
|
+
**March 9th, 2011**
|
9
|
+
|
10
|
+
* [Offsite Backups with fog](http://www.engineyard.com/blog/2011/offsite-backups-with-fog/)
|
11
|
+
|
12
|
+
**March 2nd, 2011**
|
13
|
+
|
14
|
+
* [Better AWS Access Control with IAM and Fog](http://blog.zerosum.org/2011/03/02/better-aws-access-control-with-iam-and-fog.html)
|
15
|
+
* [Using Amazon's CloudFormation, cloud-init, chef and fog to automate infrastructure](http://allanfeid.com/content/using-amazons-cloudformation-cloud-init-chef-and-fog-automate-infrastructure)
|
16
|
+
|
17
|
+
**January 6th, 2011**
|
18
|
+
|
19
|
+
* [Happy New Year (and 0.4.0) from fog!](http://www.engineyard.com/blog/2011/happy-new-year-and-0-4-0-from-fog/)
|
20
|
+
|
21
|
+
**November 30th, 2010**
|
22
|
+
|
23
|
+
* [Getting Hired: fog Edition](http://www.engineyard.com/blog/2010/getting-hired-fog-edition/)
|
24
|
+
|
25
|
+
**October 13, 2010**
|
26
|
+
|
27
|
+
* [Engine Yard Announces Formal Support for ‘fog’ to Ensure Application Portability in the Cloud](http://www.engineyard.com/company/press/2010-10-13-engine-yard-announces-formal-support-for-%E2%80%98fog%E2%80%99-to-ensure-application-portability-in-the-cloud)
|
28
|
+
* [Wesley Beary and fog Promoted to the Engine Yard Open Source Program](http://www.engineyard.com/blog/2010/wesley-beary-and-fog-promoted-to-the-engine-yard-open-source-program/)
|
29
|
+
|
30
|
+
**September 28, 2010**
|
31
|
+
|
32
|
+
* [The Curious Tale of the Humble Micro](http://www.engineyard.com/blog/2010/the-curious-tale-of-the-humble-micro/)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
title: Getting Started
|
4
|
+
---
|
5
|
+
|
6
|
+
First off, install the gem:
|
7
|
+
|
8
|
+
$ gem install fog
|
9
|
+
|
10
|
+
## Setting Up Local Storage
|
11
|
+
|
12
|
+
We will be using local storage in the example, so first off make a local directory that things can go in.
|
13
|
+
|
14
|
+
$ mkdir ~/fog
|
15
|
+
|
16
|
+
Now We can start building out our script to play with. First thing is first, we will setup a storage connection.
|
17
|
+
|
18
|
+
Fog::Storage.new(
|
19
|
+
:local_root => '~/fog',
|
20
|
+
:provider => 'Local',
|
21
|
+
)
|
@@ -0,0 +1,145 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
title: storage
|
4
|
+
---
|
5
|
+
|
6
|
+
Having Ruby experience makes you hirable; but how can you stand out? You need to demonstrate your abilities. What better way than using Ruby and "the cloud" to store and serve your resume!
|
7
|
+
|
8
|
+
In this blog post you will learn to use <a href="http://github.com/geemus/fog">fog</a> - the cloud computing library - to upload your resume to Amazon's <a href="http://aws.amazon.com/s3/">Simple Storage Service</a> (S3), Rackspace's <a href="http://www.rackspacecloud.com/cloud_hosting_products/files">CloudFiles</a> or Google's <a href="http://code.google.com/apis/storage/">Storage for Developers</a>.
|
9
|
+
|
10
|
+
Here's my out of date resume stored on <a href="http://geemus.s3.amazonaws.com/resume.html">S3</a>, <a href="http://c0023559.cdn2.cloudfiles.rackspacecloud.com/resume.html">CloudFiles</a> and <a href="https://geemus.commondatastorage.googleapis.com/resume.html">Google Storage</a>; programmatically stored in the cloud using this tutorial. NOTE: my boss would like me to add that I'm not currently looking for a new gig ;)
|
11
|
+
|
12
|
+
Check out those cloud-specific URLs! You could put all three in your job application, add the Ruby source for how you did it, and have your choice of Ruby jobs for being so awesome!
|
13
|
+
|
14
|
+
How? The all-clouds-in-one library of choice is <a href="https://github.com/geemus/fog">fog</a>.
|
15
|
+
|
16
|
+
## Installing fog
|
17
|
+
|
18
|
+
fog is distributed as a RubyGem:
|
19
|
+
|
20
|
+
gem install fog
|
21
|
+
|
22
|
+
Or add it in your application's Gemfile:
|
23
|
+
|
24
|
+
gem "fog"
|
25
|
+
|
26
|
+
## Using Amazon S3 and fog
|
27
|
+
|
28
|
+
Sign up for an account <a href="http://aws-portal.amazon.com/gp/aws/developer/subscription/index.html?productCode=AmazonS3">here</a> and copy down your secret access key and access key id from <a href="http://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key">here</a>. We are about to get into the code samples, so be sure to fill in anything in ALL_CAPS with your own values!
|
29
|
+
|
30
|
+
First, create a connection with your new account:
|
31
|
+
|
32
|
+
require 'rubygems'
|
33
|
+
require 'fog'
|
34
|
+
|
35
|
+
# create a connection
|
36
|
+
connection = Fog::Storage.new(
|
37
|
+
:provider => 'AWS',
|
38
|
+
:aws_secret_access_key => YOUR_SECRET_ACCESS_KEY,
|
39
|
+
:aws_access_key_id => YOUR_SECRET_ACCESS_KEY_ID
|
40
|
+
)
|
41
|
+
|
42
|
+
# First, a place to contain the glorious details
|
43
|
+
directory = connection.directories.create(
|
44
|
+
:key => "fog-demo-#{Time.now.to_i}", # globally unique name
|
45
|
+
:public => true
|
46
|
+
)
|
47
|
+
|
48
|
+
# list directories
|
49
|
+
p connection.directories
|
50
|
+
|
51
|
+
# upload that resume
|
52
|
+
file = directory.files.create(
|
53
|
+
:key => 'resume.html',
|
54
|
+
:body => File.open("/path/to/my/resume.html"),
|
55
|
+
:public => true
|
56
|
+
)
|
57
|
+
|
58
|
+
If you are anything like me, you will continually tweak your resume. Pushing updates is easy:
|
59
|
+
|
60
|
+
file.body = File.open("/path/to/my/resume.html")
|
61
|
+
file.save
|
62
|
+
|
63
|
+
As you can see, cloud storage files in fog are a lot like an ActiveRecord model. Attributes that can be changed and a `#save` method that creates or updates the stored file in the cloud.
|
64
|
+
|
65
|
+
But if it took you longer to realize the mistake you might not still have file around, but you've got options.
|
66
|
+
|
67
|
+
directory = connection.directories.get("proclamations1234567890")
|
68
|
+
|
69
|
+
# get the resume file
|
70
|
+
file = directory.files.get('resume.html')
|
71
|
+
file.body = File.open("/path/to/my/resume.html")
|
72
|
+
file.save
|
73
|
+
|
74
|
+
# also, create(attributes) is just new(attributes).save, so you can also do:
|
75
|
+
file = directory.files.new(
|
76
|
+
:key => 'resume.html',
|
77
|
+
:body => 'improvements',
|
78
|
+
:public => true
|
79
|
+
)
|
80
|
+
file.save
|
81
|
+
|
82
|
+
Alright, so you (eventually) become satisfied enough to send it off, what is the URL endpoint to your resume?
|
83
|
+
|
84
|
+
puts file.public_url
|
85
|
+
|
86
|
+
Pop that link in an email and you should be ready to cruise job ads and send your resume far and wide (Engine Yard is <a href="http://www.engineyard.com/company/careers/wanted-head-in-the-clouds-engineer">hiring</a>, so check us out!). Now you are set, unless you are interviewing for Google, or Rackspace... Both of these companies have their own cloud storage services, so using Amazon S3 might not be the foot in the door you hoped for.
|
87
|
+
|
88
|
+
More clouds? How much extra stuff will you have to do for these services!?! Hardly anything needs to change, you just have to pass slightly different credentials in, but I'm getting ahead of myself.
|
89
|
+
|
90
|
+
## Google Storage for Developers
|
91
|
+
|
92
|
+
Sign up <a href="http://gs-signup-redirect.appspot.com/">here</a> and get your credentials <a href="https://sandbox.google.com/storage/m/">here</a>.
|
93
|
+
|
94
|
+
connection = Fog::Storage.new(
|
95
|
+
:provider => 'Google',
|
96
|
+
:google_storage_secret_access_key => YOUR_SECRET_ACCESS_KEY,
|
97
|
+
:google_storage_access_key_id => YOUR_SECRET_ACCESS_KEY_ID
|
98
|
+
)
|
99
|
+
|
100
|
+
## Rackspace CloudFiles
|
101
|
+
|
102
|
+
Rackspace has <a href="http://www.rackspacecloud.com/cloud_hosting_products/files">Cloud Files</a> and you can sign up <a href="https://www.rackspacecloud.com/signup">here</a> and get your credentials <a href="https://manage.rackspacecloud.com/APIAccess.do">here</a>.
|
103
|
+
|
104
|
+
connection = Fog::Storage.new(
|
105
|
+
:provider => 'Rackspace',
|
106
|
+
:rackspace_username => RACKSPACE_USERNAME,
|
107
|
+
:rackspace_api_key => RACKSPACE_API_KEY
|
108
|
+
)
|
109
|
+
|
110
|
+
Then create, save, destroy as per fog-for-AWS. The `:public => true` option when creating directories (see above) is important for Rackspace; your folder and files won't be shared to Rackspace's CDN and hence your users without it. Similarly the `:public => true` on files is important for AWS and Google or they will be private.
|
111
|
+
|
112
|
+
## Local Storage
|
113
|
+
|
114
|
+
While you are working out the kinks you might not want to do everything live though, ditto for while you are running tests, so you have a couple options to try before you buy. First, you can use a local provider to store things in a directory on your machine.
|
115
|
+
|
116
|
+
connection = Fog::Storage.new(
|
117
|
+
:provider => 'Local',
|
118
|
+
:local_root => '~/fog'
|
119
|
+
)
|
120
|
+
|
121
|
+
## Mocking out Cloud Storage
|
122
|
+
|
123
|
+
Of course when you are testing or developing you can always just use the mocks (at least for AWS and Google, Rackspace still needs mocks implemented if you are looking for somewhere to contribute). They emulate the behavior of the external systems without actually using them. It is as simple as:
|
124
|
+
|
125
|
+
Fog.mock!
|
126
|
+
connection = Fog::Storage.new(config_hash)
|
127
|
+
|
128
|
+
## Cleaning up
|
129
|
+
|
130
|
+
Fog takes care of the rest so you can focus on your cover letter. And with the awesome cover letter and cloud delivered resume you are probably a shoe-in. So all that is left is to cleanup that leftover job hunt residue.
|
131
|
+
|
132
|
+
file.destroy
|
133
|
+
directory.destroy
|
134
|
+
|
135
|
+
## Summary
|
136
|
+
|
137
|
+
All done. Try out all the different options and let me know if you have any bugs or issues. I also wrote up a more <a href="https://gist.github.com/710869">consolidated example as a script</a> that you can use for reference.
|
138
|
+
|
139
|
+
Bonus, note the `Fog.mock!` command. In your tests you can easily mock out calls to cloud providers.
|
140
|
+
|
141
|
+
Please let me know in the comments if you got a new Ruby job because you hosted your CV on 3 different Cloud Stores without getting your hands dirty.
|
142
|
+
|
143
|
+
Have questions or comments? Hop into <a href="irc://irc.freenode.net/">#ruby-fog</a> on freenode, ping <a href="http://twitter.com/fog">@fog</a> or <a href="http://twitter.com/geemus">@geemus</a>.
|
144
|
+
|
145
|
+
And please always remember that I accept high fives and contributions!
|
@@ -0,0 +1,78 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
title: Structure
|
4
|
+
---
|
5
|
+
|
6
|
+
fog is the Ruby cloud computing library, top to bottom:
|
7
|
+
|
8
|
+
* Collections provide a simplified interface, making clouds easier to work with and switch between.
|
9
|
+
* Requests allow power users to get the most out of the features of each individual cloud.
|
10
|
+
* Mocks make testing and integrating a breeze.
|
11
|
+
|
12
|
+
## Collections
|
13
|
+
|
14
|
+
A high level interface to each cloud is provided through collections, such as `images` and `servers`.
|
15
|
+
You can see a list of available collections by calling `collections` on the connection object. You can try it out using the `fog` command:
|
16
|
+
|
17
|
+
>> AWS.collections
|
18
|
+
[:addresses, :directories, ..., :volumes, :zones]
|
19
|
+
|
20
|
+
Some collections are available across multiple providers:
|
21
|
+
|
22
|
+
* compute providers have `flavors`, `images` and `servers`
|
23
|
+
* dns providers have `zones` and `records`
|
24
|
+
* storage providers have `directories` and `files`
|
25
|
+
|
26
|
+
Collections share basic CRUD type operations, such as:
|
27
|
+
* `all` - fetch every object of that type from the provider.
|
28
|
+
* `create` - initialize a new record locally and a remote resource with the provider.
|
29
|
+
* `get` - fetch a single object by it's identity from the provider.
|
30
|
+
* `new` - initialize a new record locally, but do not create a remote resource with the provider.
|
31
|
+
|
32
|
+
As an example, we'll try initializing and persisting a Rackspace Cloud server:
|
33
|
+
|
34
|
+
require 'fog'
|
35
|
+
|
36
|
+
compute = Fog::Compute.new(
|
37
|
+
:provider => 'Rackspace',
|
38
|
+
:rackspace_api_key => key,
|
39
|
+
:rackspace_username => username
|
40
|
+
)
|
41
|
+
|
42
|
+
# boot a gentoo server (flavor 1 = 256, image 3 = gentoo 2008.0)
|
43
|
+
server = compute.servers.create(:flavor_id => 1, :image_id => 3, :name => 'my_server')
|
44
|
+
server.wait_for { ready? } # give server time to boot
|
45
|
+
|
46
|
+
# DO STUFF
|
47
|
+
|
48
|
+
server.destroy # cleanup after yourself or regret it, trust me
|
49
|
+
|
50
|
+
## Models
|
51
|
+
|
52
|
+
Many of the collection methods return individual objects, which also provide common methods:
|
53
|
+
* `destroy` - will destroy the persisted object from the provider
|
54
|
+
* `save` - persist the object to the provider
|
55
|
+
* `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)
|
56
|
+
|
57
|
+
## Requests
|
58
|
+
|
59
|
+
Requests allow you to dive deeper when the models just can't cut it.
|
60
|
+
You can see a list of available requests by calling #requests on the connection object.
|
61
|
+
|
62
|
+
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:
|
63
|
+
|
64
|
+
$ fog
|
65
|
+
>> AWS[:ec2].describe_reserved_instances
|
66
|
+
#<Excon::Response [...]>
|
67
|
+
|
68
|
+
It will return an [excon](http://github.com/geemus/excon) response, which has `body`, `headers` and `status`. Both return nice hashes.
|
69
|
+
|
70
|
+
## Mocks
|
71
|
+
|
72
|
+
As you might imagine, testing code using Fog can be slow and expensive, constantly turning on and and shutting down instances.
|
73
|
+
Mocking allows skipping this overhead by providing an in memory representation resources as you make requests.
|
74
|
+
Enabling mocking easy to use, before you run other commands, simply run:
|
75
|
+
|
76
|
+
Fog.mock!
|
77
|
+
|
78
|
+
Then proceed as usual, if you run into unimplemented mocks fog will raise an error and as always contributions are welcome!
|
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
title: Users
|
4
|
+
---
|
5
|
+
|
6
|
+
Here lies a listing of projects and products that are using fog.
|
7
|
+
|
8
|
+
Please feel free to add your own, just please follow these rules for consistency and readability.
|
9
|
+
|
10
|
+
1. Listings should be in alphabetical order and should have a link and list of services used.
|
11
|
+
2. Projects that are open source should link to where the source code can be found.
|
12
|
+
3. Products that are not open source should link to where more information about the product can be found.
|
13
|
+
|
14
|
+
Thanks for following these rules to keep the quality high and and the content useful!
|
15
|
+
|
16
|
+
## Projects
|
17
|
+
|
18
|
+
* [carrierwave](http://github.com/jnicklas/carrierwave) = AWS => Storage
|
19
|
+
* [chef](http://github.com/opscode/chef) = AWS => Compute, Slicehost => Compute, Terremark => vCloud, Rackspace => Compute
|
20
|
+
* [deckard](http://github.com/joewilliams/deckard) = AWS => Compute
|
21
|
+
* [gaff](http://github.com/joewilliams/gaff) = AWS => Compute, Slicehost => Compute
|
22
|
+
* [gemcutter](http://github.com/rubygems/gemcutter) = AWS => Storage
|
23
|
+
* [plover](http://github.com/railsmachine/plover) = AWS => Compute
|
24
|
+
|
25
|
+
## Products
|
26
|
+
|
27
|
+
* [DevStructure](http://devstructure.com/) = AWS => Compute, Rackspace => Compute, Slicehost => Compute
|
28
|
+
* [Engine Yard AppCloud](http://www.engineyard.com/cloud) = AWS => \[Compute, Storage\]
|
29
|
+
* [iSwifter](http://iswifter.youwebinc.com/) = BlueBox => Compute
|
30
|
+
* [OpenFeint](http://openfeint.com) = BlueBox => Compute
|
31
|
+
* [PHPFog](https://phpfog.com) = AWS => Compute
|
32
|
+
* [RowFeeder](https://rowfeeder.com) = Blue Box Group => Compute
|
33
|
+
* [Viximo](http://viximo.com) = AWS => Compute
|
data/docs/index.markdown
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
---
|
2
|
+
layout: default
|
3
|
+
title: The Ruby cloud services library
|
4
|
+
---
|
5
|
+
|
6
|
+
Whether you need compute, dns, storage, or a multitude of other services, fog provides an accessible entry point and facilitates cross service compatibility.
|
7
|
+
|
8
|
+
Just getting started working with cloud resources? You are not alone, and having so many complicated options makes it hard to know where to start. fog delivers the knowledge of cloud experts to you, helping you to bootstrap your cloud usage and guiding you as your own expertise develops.
|
9
|
+
|
10
|
+
By coding with fog from the start you avoid vendor lock-in and give yourself more flexibility to provide value. Whether you are writing a library, designing a software as a service product or just hacking on the weekend this flexibility is a huge boon.
|
11
|
+
|
12
|
+
With a rapidly expanding community and codebase the advantages of fog just keep coming. Join us and together we will realize the future of cloud computing.
|
13
|
+
|
14
|
+
## Getting Started
|
15
|
+
|
16
|
+
sudo gem install fog
|
17
|
+
|
18
|
+
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:
|
19
|
+
|
20
|
+
>> server = AWS.servers.create
|
21
|
+
ArgumentError: image_id is required for this operation
|
22
|
+
|
23
|
+
>> server = AWS.servers.create(:image_id => 'ami-5ee70037')
|
24
|
+
<Fog::AWS::EC2::Server [...]>
|
25
|
+
|
26
|
+
>> server.destroy # cleanup after yourself or regret it, trust me
|
27
|
+
true
|
28
|
+
|
29
|
+
## Go forth and conquer
|
30
|
+
|
31
|
+
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. Once you are reading to start scripting fog, here is a quick hint on how to make connections without the command line thing to help you.
|
32
|
+
|
33
|
+
# create a compute connection
|
34
|
+
compute = Fog::Compute.new(:provider => 'AWS', :aws_access_key_id => ACCESS_KEY_ID, :aws_secret_access_key => SECRET_ACCESS_KEY)
|
35
|
+
# compute operations go here
|
36
|
+
|
37
|
+
# create a storage connection
|
38
|
+
storage = Fog::Storage.new(:provider => 'AWS', :aws_access_key_id => ACCESS_KEY_ID, :aws_secret_access_key => SECRET_ACCESS_KEY)
|
39
|
+
# storage operations go here
|
40
|
+
|
41
|
+
geemus says: "That should give you everything you need to get started, but let me know if there is anything I can do to help!"
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
* Find something you would like to work on. For suggestions look for the `easy`, `medium` and `hard` tags in the [issues](http://github.com/geemus/fog/issues)
|
46
|
+
* Fork the project and do your work in a topic branch.
|
47
|
+
* Add shindo tests to prove your code works and run all the tests using `bundle exec rake`.
|
48
|
+
* Rebase your branch against geemus/fog to make sure everything is up to date.
|
49
|
+
* Commit your changes and send a pull request.
|
50
|
+
|
51
|
+
## T-Shirts
|
52
|
+
|
53
|
+
Wonder how you can get a lovely fog shirt? Look no further!
|
54
|
+
|
55
|
+
* Blue shirts go to people who have contributed indirectly, great examples are writing blog posts or giving lightning talks.
|
56
|
+
* Grey shirts and a follow from @fog go to people who have made it on to the [contributors list](https://github.com/geemus/fog/contributors) by submitting code.
|
57
|
+
* Black shirts go to people who have made it on to the [collaborators list](https://github.com/api/v2/json/repos/show/geemus/fog/collaborators) by coercing geemus into adding them (geemus is currently the only member of this list).
|
58
|
+
|
59
|
+
## Resources
|
60
|
+
|
61
|
+
Enjoy, and let me know what I can do to continue improving fog!
|
62
|
+
|
63
|
+
* Stay up to date by following [@fog](http://twitter.com/fog) and/or [@geemus](http://twitter.com/geemus) on Twitter.
|
64
|
+
* Get and give help on the [#ruby-fog](irc://irc.freenode.net/ruby-fog) irc channel on Freenode
|
65
|
+
* Follow release notes and discussions on the [mailing list](http://groups.google.com/group/ruby-fog)
|
66
|
+
* Report bugs or find tasks to help with in the [issues](http://github.com/geemus/fog/issues)
|
67
|
+
* Learn about [contributing](http://github.com/geemus/fog/wiki/contributor-guide)
|
68
|
+
* See where fog is used and let the world know how you use it [in the wild](http://wiki.github.com/geemus/fog/in-the-wild)
|
69
|
+
* Check out blog posts and other mentions in the [press](http://wiki.github.com/geemus/fog/press)
|
70
|
+
|
71
|
+
## Copyright
|
72
|
+
|
73
|
+
(The MIT License)
|
74
|
+
|
75
|
+
Copyright (c) 2010 [geemus (Wesley Beary)](http://github.com/geemus)
|
76
|
+
|
77
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
78
|
+
a copy of this software and associated documentation files (the
|
79
|
+
"Software"), to deal in the Software without restriction, including
|
80
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
81
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
82
|
+
permit persons to whom the Software is furnished to do so, subject to
|
83
|
+
the following conditions:
|
84
|
+
|
85
|
+
The above copyright notice and this permission notice shall be
|
86
|
+
included in all copies or substantial portions of the Software.
|
87
|
+
|
88
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
89
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
90
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
91
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
92
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
93
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
94
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|