Giter Site home page Giter Site logo

fog-dynect's Introduction

fog

fog is the Ruby cloud services library, top to bottom:

  • Collections provide a simplified interface, making clouds easier to work with and switch between.
  • Requests allow power users to get the most out of the features of each individual cloud.
  • Mocks make testing and integrating a breeze.

Build Status Code Climate Gem Version SemVer

Dependency Notice

Currently all fog providers are getting separated into metagems to lower the load time and dependency count.

If there's a metagem available for your cloud provider, e.g. fog-aws, you should be using it instead of requiring the full fog collection to avoid unnecessary dependencies.

'fog' should be required explicitly only if the provider you use doesn't yet have a metagem available.

Getting Started

The easiest way to learn fog is to install the gem and use the interactive console. Here is an example of wading through server creation for Amazon Elastic Compute Cloud:

$ sudo gem install fog
[...]

$ fog

  Welcome to fog interactive!
  :default provides [...]

>> server = Compute[:aws].servers.create
ArgumentError: image_id is required for this operation

>> server = Compute[:aws].servers.create(:image_id => 'ami-5ee70037')
<Fog::AWS::EC2::Server [...]>

>> server.destroy # cleanup after yourself or regret it, trust me
true

Ruby version

Fog requires Ruby 2.0.0 or later.

Ruby 1.8 and 1.9 support was dropped in fog-v2.0.0 as a backwards incompatible change. Please use the later fog 1.x versions if you require 1.8.7 or 1.9.x support.

Collections

A high level interface to each cloud is provided through collections, such as images and servers. You can see a list of available collections by calling collections on the connection object. You can try it out using the fog command:

>> Compute[:aws].collections
[:addresses, :directories, ..., :volumes, :zones]

Some collections are available across multiple providers:

  • compute providers have flavors, images and servers
  • dns providers have zones and records
  • storage providers have directories and files

Collections share basic CRUD type operations, such as:

  • all - fetch every object of that type from the provider.
  • create - initialize a new record locally and a remote resource with the provider.
  • get - fetch a single object by its identity from the provider.
  • new - initialize a new record locally, but do not create a remote resource with the provider.

As an example, we'll try initializing and persisting a Rackspace Cloud server:

require 'fog'

compute = Fog::Compute.new(
  :provider           => 'Rackspace',
  :rackspace_api_key  => key,
  :rackspace_username => username
)

# boot a gentoo server (flavor 1 = 256, image 3 = gentoo 2008.0)
server = compute.servers.create(:flavor_id => 1, :image_id => 3, :name => 'my_server')
server.wait_for { ready? } # give server time to boot

# DO STUFF

server.destroy # cleanup after yourself or regret it, trust me

Models

Many of the collection methods return individual objects, which also provide common methods:

  • destroy - will destroy the persisted object from the provider
  • save - persist the object to the provider
  • 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)

Mocks

As you might imagine, testing code using Fog can be slow and expensive, constantly turning on and shutting down instances. Mocking allows skipping this overhead by providing an in memory representation of resources as you make requests. Enabling mocking is easy to use: before you run other commands, simply run:

Fog.mock!

Then proceed as usual, if you run into unimplemented mocks, fog will raise an error and as always contributions are welcome!

Requests

Requests allow you to dive deeper when the models just can't cut it. You can see a list of available requests by calling #requests on the connection object.

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:

$ fog
>> Compute[:aws].describe_reserved_instances
#<Excon::Response [...]>

It will return an excon response, which has body, headers and status. Both return nice hashes.

Go forth and conquer

Play around and use the console to explore or check out fog.io and the provider documentation for more details and examples. Once you are ready to start scripting fog, here is a quick hint on how to make connections without the command line thing to help you.

# create a compute connection
compute = Fog::Compute.new(:provider => 'AWS', :aws_access_key_id => ACCESS_KEY_ID, :aws_secret_access_key => SECRET_ACCESS_KEY)
# compute operations go here

# create a storage connection
storage = Fog::Storage.new(:provider => 'AWS', :aws_access_key_id => ACCESS_KEY_ID, :aws_secret_access_key => SECRET_ACCESS_KEY)
# storage operations go here

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!"

Versioning

Fog library aims to adhere to Semantic Versioning 2.0.0, although it does not address challenges of multi-provider libraries. Semantic versioning is only guaranteed for the common API, not any provider-specific extensions. You may also need to update your configuration from time to time (even between Fog releases) as providers update or deprecate services.

However, we still aim for forwards compatibility within Fog major versions. As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision. For example:

spec.add_dependency 'fog', '~> 1.0'

This means your project is compatible with Fog 1.0 up until 2.0. You can also set a higher minimum version:

spec.add_dependency 'fog', '~> 1.16'

Getting Help

Contributing

Please refer to CONTRIBUTING.md.

License

Please refer to LICENSE.md.

fog-dynect's People

Contributors

amatsuda avatar bensonk avatar blentz avatar blkperl avatar brianhartsock avatar cainlevy avatar danp avatar dependabot[bot] avatar dje avatar dylanegan avatar fcheung avatar geemus avatar ggoodale avatar glennpratt avatar icco avatar jblancett avatar keoven avatar ktheory avatar lanej avatar luqman avatar mikehale avatar nirvdrum avatar pdrakeweb avatar plribeiro3000 avatar prozsolt avatar rb2k avatar sbfaulkner avatar shawncatz avatar stormsilver avatar tokengeek avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fog-dynect's Issues

Job is still incomplete

I have got too many records in the zone, so it printed out the below message. Is there a way to paginate the output or with cursor?

/usr/local/lib/ruby/gems/2.2.0/gems/fog-dynect-0.0.2/lib/fog/dynect/dns.rb:144:in `rescue in poll_job': Job 2094586824 is still incomplete (Fog::DNS::Dynect::JobIncomplete)
    from /usr/local/lib/ruby/gems/2.2.0/gems/fog-dynect-0.0.2/lib/fog/dynect/dns.rb:131:in `poll_job'
    from /usr/local/lib/ruby/gems/2.2.0/gems/fog-dynect-0.0.2/lib/fog/dynect/dns.rb:105:in `request'
    from /usr/local/lib/ruby/gems/2.2.0/gems/fog-dynect-0.0.2/lib/fog/dynect/requests/dns/get_all_records.rb:14:in `get_all_records'
    from /usr/local/lib/ruby/gems/2.2.0/gems/fog-dynect-0.0.2/lib/fog/dynect/models/dns/records.rb:14:in `all'
    from tpn_dns.rb:39:in `<main>'

TLL is missing when retreiving zone or records

Hi @geemus,
Sorry for hammering you, please point me to the right person if needed.

I've read the code and tried to patch the gem to populate the TTL field of retrieved records, but no success to do so.

I saw a get_record request but there's a comment in records.rb that some arguments are missing at that location.

Thought about adding an options argument that will hold the record type and fqdn but that would be the opposite of the options argument in get_record method(in dynect/requests/dns/get_record.rb)

Can you throw a tip or two on how to get the TTL field populated?

Rake beaker is failing due to json gem requiring Ruby '~> 2.0' on Debian debian-78-x64 box

Hi,
I'm getting the following error when running rake beaker:
json requires Ruby version ~> 2.0.

The issue is with the fog gem installation, full trace:

Warning! PATH is not properly set up, '$USER_HOME/.rvm/gems/ruby-2.3.1/bin' is not at first place,
         usually this is caused by shell initialization files - check them for 'PATH=...' entries,
         it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
         to fix temporarily in this shell session run: 'rvm use ruby-2.3.1'.
$USER_HOME/.rvm/rubies/ruby-2.0.0-p648/bin/ruby -I$DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib:$DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-support-3.5.0/lib $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/exe/rspec spec/acceptance --color
$DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/beaker-rspec-5.6.0/lib/beaker-rspec/helpers/serverspec.rb:43: warning: already initialized constant Module::VALID_OPTIONS_KEYS
$DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/specinfra-2.61.1/lib/specinfra/configuration.rb:4: warning: previous definition of VALID_OPTIONS_KEYS was here
Beaker::Hypervisor, found some vagrant boxes to create
Bringing machine 'debian-78-x64' up with 'virtualbox' provider...
==> debian-78-x64: Importing base box 'puppetlabs/debian-7.8-64-nocm'...
Progress: 10%Progress: 20%Progress: 30%Progress: 40%Progress: 50%Progress: 60%Progress: 70%Progress: 80%Progress: 90%==> debian-78-x64: Matching MAC address for NAT networking...
==> debian-78-x64: Checking if box 'puppetlabs/debian-7.8-64-nocm' is up to date...
==> debian-78-x64: Setting the name of the VM: defaultyml_debian-78-x64_1477758759012_41151
==> debian-78-x64: Fixed port collision for 22 => 2222. Now on port 2200.
==> debian-78-x64: Clearing any previously set network interfaces...
==> debian-78-x64: Preparing network interfaces based on configuration...
    debian-78-x64: Adapter 1: nat
    debian-78-x64: Adapter 2: hostonly
==> debian-78-x64: Forwarding ports...
    debian-78-x64: 22 (guest) => 2200 (host) (adapter 1)
==> debian-78-x64: Running 'pre-boot' VM customizations...
==> debian-78-x64: Booting VM...
==> debian-78-x64: Waiting for machine to boot. This may take a few minutes...
    debian-78-x64: SSH address: 127.0.0.1:2200
    debian-78-x64: SSH username: vagrant
    debian-78-x64: SSH auth method: private key
==> debian-78-x64: Machine booted and ready!
==> debian-78-x64: Checking for guest additions in VM...
==> debian-78-x64: Setting hostname...
==> debian-78-x64: Configuring and enabling network interfaces...
==> debian-78-x64: Mounting shared folders...
    debian-78-x64: /vagrant => $DEV_PATH/puppetlabs-dns/.vagrant/beaker_vagrant_files/default.yml
Disabling updates.puppetlabs.com by modifying hosts file to resolve updates to 127.0.0.1 on debian-78-x64
localhost $ scp $DEV_PATH/puppetlabs-dns debian-78-x64:/etc/puppet/modules {:ignore => [".bundle", ".git", ".idea", ".vagrant", ".vendor", "vendor", "acceptance", "bundle", "spec", "tests", "log", ".svn", "junit", "pkg", "example", ".", ".."]}
Destroying vagrant boxes
==> debian-78-x64: Forcing shutdown of VM...
==> debian-78-x64: Destroying VM and associated drives...

Finished in 3 minutes 10.3 seconds (files took 1 minute 32.03 seconds to load)
0 examples, 0 failures

$DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/beaker-2.50.0/lib/beaker/host.rb:351:in `exec': Host 'debian-78-x64' exited with 1 running: (Beaker::Host::CommandFailure)
 gem install fog --no-ri --no-rdoc
Last 10 lines of output were:
        Building native extensions.  This could take a while...
        ERROR:  Error installing fog:
                json requires Ruby version ~> 2.0.
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/beaker-2.50.0/lib/beaker/dsl/helpers/host_helpers.rb:83:in `block in on'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/beaker-2.50.0/lib/beaker/shared/host_manager.rb:127:in `run_block_on'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/beaker-2.50.0/lib/beaker/dsl/patterns.rb:37:in `block_on'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/beaker-2.50.0/lib/beaker/dsl/helpers/host_helpers.rb:63:in `on'
        from $DEV_PATH/puppetlabs-dns/spec/spec_helper_acceptance.rb:17:in `block (3 levels) in <top (required)>'
        from $DEV_PATH/puppetlabs-dns/spec/spec_helper_acceptance.rb:12:in `each'
        from $DEV_PATH/puppetlabs-dns/spec/spec_helper_acceptance.rb:12:in `block (2 levels) in <top (required)>'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib/rspec/core/example.rb:443:in `instance_exec'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib/rspec/core/example.rb:443:in `instance_exec'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib/rspec/core/hooks.rb:350:in `run'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1879:in `block in run_hooks_with'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1879:in `each'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1879:in `run_hooks_with'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib/rspec/core/configuration.rb:1835:in `with_suite_hooks'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:112:in `block in run_specs'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib/rspec/core/reporter.rb:77:in `report'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:111:in `run_specs'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:87:in `run'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:71:in `run'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib/rspec/core/runner.rb:45:in `invoke'
        from $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/exe/rspec:4:in `<main>'
$USER_HOME/.rvm/rubies/ruby-2.0.0-p648/bin/ruby -I$DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/lib:$DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-support-3.5.0/lib $DEV_PATH/puppetlabs-dns/vendor/gems/ruby/2.0.0/gems/rspec-core-3.5.2/exe/rspec spec/acceptance --color failed

We have the fog gem installed on Ubuntu Wily 15.10, maybe the issue is with the debian image in use?

Thank you,
Yarden

Unable load gem failing back to deprecated constant

I'm seeing the following error. Running ruby 2.6.6 and bundler 2.1.4.

[fog][DEPRECATION] Unable to load Fog::Dynect::DNS
[fog][DEPRECATION] Falling back to deprecated constant Fog::DNS::Dynect. The preferred format of service provider constants has changed from service::provider to provider::service. Please update this service provider to use the preferred format.

Has something changed with Dynect API?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.