1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
The Ruby cloud services library.
Find a file
2010-03-17 21:00:23 -07:00
benchs move connection benchmarks to excon 2009-10-25 18:45:27 -07:00
bin more cleanup around interactive formatting 2010-02-15 20:18:52 -08:00
lib [terremark] cleaner mocking/dependencies 2010-03-17 21:00:23 -07:00
spec [ec2] add specs/mocks for named ingresses 2010-03-16 17:34:06 -07:00
.document fix .document paths 2009-11-27 15:39:00 -08:00
.gitignore move config to saner place, only parse it once 2009-07-13 19:25:44 -07:00
fog.gemspec Version bump to 0.0.58 2010-03-17 16:08:11 -07:00
Rakefile fix email address in rakefile 2010-03-16 23:32:38 -07:00
README.rdoc fix error in README, thanks JEG2 2010-02-01 11:18:59 -08:00
VERSION.yml Version bump to 0.0.58 2010-03-17 16:08:11 -07:00

= fog

fog helps you interact with cloud services. fog is a work in progress.

== Install

  sudo gem install fog

== Getting Started

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.

Then just start playing around, fog should let you know if you are forget things.

For example if you try to create a server but leave out stuff:

  server = AWS.servers.create

You'll get reminded that things are missing.

  ArgumentError: image_id is required for this operation

So just add the missing stuff and you are off to the races:

  server = AWS.servers.create(:image_id => 'ami-5ee70037')

But don't forget to cleanup or you'll regret it when you get the bill:

  server.destroy

Rinse, repeat, enjoy!

== Working with Servers

Lets boot up a server on EC2

  require 'fog'

  # 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')
  # you might also want to add the server to security groups, which goes like this:
  # AWS.servers.create(:image_id => 'ami-5ee70037', :groups => ['web', 'db'])

  # 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

== Working with Directories and Files

  require 'fog'

  # initialize a connection to Amazon Simple Storage Solution
  connection = Fog::AWS::S3.new(
    :aws_access_key_id => id,
    :aws_secret_access_key => key
  )

  # create a directory
  directory = connection.directory.create(:name => 'directoryname')

  # create a new file in your directory
  directory.files.create(:key => 'filename', :body => 'filebody')

  # connect to your directory
  directory = connection.directories.get('directoryname')

  # get your file
  file = directory.files.get('filename')

  # delete the file
  file.destroy

  # delete the directory
  directory.destroy

== More info

* Follow {@geemus}[http://twitter.com/geemus] on Twitter.
* See upcoming work in the {tracker}[http://www.pivotaltracker.com/projects/54635].
* Report bugs in {issues}[http://github.com/geemus/fog/issues].

== Supports

* 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)

== Copyright

(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.