2009-05-18 03:13:06 -04:00
|
|
|
= fog
|
|
|
|
|
2009-09-15 00:32:02 -04:00
|
|
|
fog helps you interact with cloud services. fog is a work in progress.
|
2009-05-18 03:13:06 -04:00
|
|
|
|
2010-01-15 00:31:19 -05:00
|
|
|
== Install
|
2009-09-15 00:32:02 -04:00
|
|
|
|
2010-01-15 00:31:19 -05:00
|
|
|
sudo gem install fog
|
2009-09-15 00:32:02 -04:00
|
|
|
|
2010-01-15 00:31:19 -05:00
|
|
|
== Getting Started
|
2009-09-15 00:32:02 -04:00
|
|
|
|
2010-01-15 00:31:19 -05:00
|
|
|
You can start stumbling around as soon as you install with the fog command line tool.
|
|
|
|
After installing, just type 'fog' to get started.
|
|
|
|
If you don't have credentials setup it will let you know what to do.
|
|
|
|
|
2010-01-15 00:33:48 -05:00
|
|
|
Then just start playing around, fog should let you know if you are forget things.
|
2010-01-15 00:31:19 -05:00
|
|
|
|
2010-01-15 00:33:48 -05:00
|
|
|
For example if you try to create a server but leave out stuff:
|
2010-01-15 00:31:19 -05:00
|
|
|
|
|
|
|
server = AWS.servers.create
|
2009-09-15 00:32:02 -04:00
|
|
|
|
2010-01-15 00:33:48 -05:00
|
|
|
You'll get reminded that things are missing.
|
2010-01-15 00:31:19 -05:00
|
|
|
|
|
|
|
ArgumentError: image_id is required for this operation
|
|
|
|
|
2010-01-15 00:33:48 -05:00
|
|
|
So just add the missing stuff and you are off to the races:
|
2010-01-15 00:31:19 -05:00
|
|
|
|
|
|
|
server = AWS.servers.create(:image_id => 'ami-5ee70037')
|
2010-01-15 00:33:48 -05:00
|
|
|
|
|
|
|
But don't forget to cleanup or you'll regret it when you get the bill:
|
|
|
|
|
2010-01-15 00:31:19 -05:00
|
|
|
server.destroy
|
|
|
|
|
|
|
|
Rinse, repeat, enjoy!
|
|
|
|
|
|
|
|
== Working with Servers
|
2010-01-15 00:19:48 -05:00
|
|
|
|
|
|
|
Lets boot up a server on EC2
|
2009-09-15 00:32:02 -04:00
|
|
|
|
|
|
|
require 'fog'
|
|
|
|
|
2010-01-15 00:19:48 -05:00
|
|
|
# initialize a connection to Amazon Elastic Compute Cloud
|
|
|
|
connection = Fog::AWS::EC2.new(
|
|
|
|
:aws_access_key_id => id,
|
|
|
|
:aws_secret_access_key => key
|
|
|
|
)
|
|
|
|
|
|
|
|
# boot a gentoo server
|
|
|
|
server = connection.servers.new(:image_id => 'ami-5ee70037')
|
|
|
|
|
|
|
|
# wait for it to be ready to do stuff
|
|
|
|
server.wait_for { ready? }
|
|
|
|
|
|
|
|
# DO STUFF
|
|
|
|
|
|
|
|
# shutdown the server
|
|
|
|
server.destroy
|
|
|
|
|
|
|
|
Now we will try again, but with Rackspace
|
|
|
|
|
|
|
|
# initialize a connection to Rackspace Servers
|
|
|
|
connection = Fog::Rackspace::Servers.new(
|
|
|
|
:rackspace_api_key => key,
|
|
|
|
:rackspace_username => username
|
|
|
|
)
|
|
|
|
|
|
|
|
# boot a gentoo server (flavor 1 = 256, image 3 = gentoo 2008.0)
|
|
|
|
server = connection.servers.new(:flavor_id => 1, :image_id => 3, :name => 'my_server')
|
|
|
|
|
|
|
|
# wait for it to be ready to do stuff
|
|
|
|
server.wait_for { ready? }
|
|
|
|
|
|
|
|
# DO STUFF
|
|
|
|
|
|
|
|
# shutdown the server
|
|
|
|
server.destroy
|
|
|
|
|
2010-01-15 00:31:19 -05:00
|
|
|
== Working with Directories and Files
|
2010-01-15 00:19:48 -05:00
|
|
|
|
|
|
|
require 'fog'
|
2009-09-15 00:32:02 -04:00
|
|
|
|
2010-01-15 00:19:48 -05:00
|
|
|
# initialize a connection to Amazon Simple Storage Solution
|
|
|
|
connection = Fog::AWS::S3.new(
|
2009-09-15 00:32:02 -04:00
|
|
|
:aws_access_key_id => id,
|
|
|
|
:aws_secret_access_key => key
|
|
|
|
)
|
|
|
|
|
2010-01-15 00:19:48 -05:00
|
|
|
# create a directory
|
|
|
|
directory = connection.directory.create(:name => 'directoryname')
|
2009-09-15 00:32:02 -04:00
|
|
|
|
2010-01-15 00:19:48 -05:00
|
|
|
# create a new file in your directory
|
|
|
|
directory.files.create(:key => 'filename', :body => 'filebody')
|
2009-09-15 00:32:02 -04:00
|
|
|
|
2010-01-15 00:19:48 -05:00
|
|
|
# connect to your directory
|
|
|
|
directory = connection.directories.get('filename')
|
2009-09-15 00:32:02 -04:00
|
|
|
|
2010-01-15 00:19:48 -05:00
|
|
|
# get your file
|
|
|
|
file = directory.files.get('filename')
|
2009-09-15 00:32:02 -04:00
|
|
|
|
2010-01-15 00:19:48 -05:00
|
|
|
# delete the file
|
|
|
|
file.destroy
|
2009-09-15 00:32:02 -04:00
|
|
|
|
2010-01-15 00:19:48 -05:00
|
|
|
# delete the directory
|
|
|
|
directory.destroy
|
2009-09-15 00:32:02 -04:00
|
|
|
|
|
|
|
== Requirements
|
|
|
|
|
|
|
|
* ruby 1.8 or 1.9
|
|
|
|
* ruby-hmac
|
|
|
|
* mime-types
|
|
|
|
* nokogiri
|
|
|
|
|
2010-01-15 00:31:19 -05:00
|
|
|
== Supports
|
2009-09-15 00:32:02 -04:00
|
|
|
|
2010-01-15 00:31:19 -05:00
|
|
|
* AWS EC2
|
|
|
|
* AWS S3
|
|
|
|
* AWS SimpleDB (no models yet)
|
|
|
|
* Rackspace Files (no models yet, just getting started on requests)
|
|
|
|
* Rackspace Servers (some requests, server model, just getting started)
|
2009-09-15 00:32:02 -04:00
|
|
|
|
2009-09-15 00:40:14 -04:00
|
|
|
== Copyright
|
2009-05-18 03:13:06 -04:00
|
|
|
|
2009-09-15 00:36:20 -04:00
|
|
|
(The MIT License)
|
|
|
|
|
|
|
|
Copyright (c) 2009 {geemus (Wesley Beary)}[http://github.com/geemus]
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
a copy of this software and associated documentation files (the
|
|
|
|
"Software"), to deal in the Software without restriction, including
|
|
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be
|
|
|
|
included in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|