From d3fdfebd4ca835ebbc35410f96c5a1247243c773 Mon Sep 17 00:00:00 2001 From: Chris Luo Date: Fri, 13 Mar 2015 13:42:56 -0400 Subject: [PATCH] Initial integration of powerdns --- fog.gemspec | 1 + lib/fog.rb | 1 + lib/fog/bin.rb | 1 + lib/fog/bin/powerdns.rb | 28 ++++++++++++++++++++++++++++ spec/fog/bin/powerdns_spec.rb | 8 ++++++++ spec/fog/bin_spec.rb | 3 +++ 6 files changed, 42 insertions(+) create mode 100644 lib/fog/bin/powerdns.rb create mode 100644 spec/fog/bin/powerdns_spec.rb diff --git a/fog.gemspec b/fog.gemspec index 023683385..fb9f1fea8 100644 --- a/fog.gemspec +++ b/fog.gemspec @@ -57,6 +57,7 @@ Gem::Specification.new do |s| s.add_dependency("fog-brightbox", "~> 0.4") s.add_dependency("fog-ecloud") s.add_dependency("fog-local") + s.add_dependency("fog-powerdns", ">= 0.1.1") s.add_dependency("fog-profitbricks") s.add_dependency("fog-radosgw", ">= 0.0.2") s.add_dependency("fog-riakcs") diff --git a/lib/fog.rb b/lib/fog.rb index 06ffeac5f..8ccfa3ee2 100644 --- a/lib/fog.rb +++ b/lib/fog.rb @@ -49,6 +49,7 @@ require 'fog/rage4' require 'fog/riakcs' require 'fog/openstack' require 'fog/ovirt' +require 'fog/powerdns' require 'fog/profitbricks' require 'fog/sakuracloud' require 'fog/serverlove' diff --git a/lib/fog/bin.rb b/lib/fog/bin.rb index 156ffc32e..0abdda1d2 100644 --- a/lib/fog/bin.rb +++ b/lib/fog/bin.rb @@ -81,6 +81,7 @@ require 'fog/bin/rage4' require 'fog/bin/riakcs' require 'fog/bin/openstack' require 'fog/bin/ovirt' +require 'fog/bin/powerdns' require 'fog/bin/profitbricks' require 'fog/bin/sakuracloud' require 'fog/bin/serverlove' diff --git a/lib/fog/bin/powerdns.rb b/lib/fog/bin/powerdns.rb new file mode 100644 index 000000000..88e544770 --- /dev/null +++ b/lib/fog/bin/powerdns.rb @@ -0,0 +1,28 @@ +class Softlayer < Fog::Bin + class << self + def class_for(key) + case key + + when :dns + Fog::DNS::PowerDNS + else + raise ArgumentError, "Unsupported #{self} service: #{key}" + end + end + def [](service) + @@connections ||= Hash.new do |hash, key| + hash[key] = case key + when :dns + Fog::Logger.warning("PowerDNS[:dns] is not recommended, use DNS[:powerdns] for portability") + Fog::DNS.new(:provider => :powerdns) + else + raise ArgumentError, "Unrecognized service: #{key.inspect}" + end + end + @@connections[service] + end + def services + Fog::PowerDNS.services + end + end +end \ No newline at end of file diff --git a/spec/fog/bin/powerdns_spec.rb b/spec/fog/bin/powerdns_spec.rb new file mode 100644 index 000000000..708c708d2 --- /dev/null +++ b/spec/fog/bin/powerdns_spec.rb @@ -0,0 +1,8 @@ +require "minitest/autorun" +require "fog" +require "fog/bin" +require "helpers/bin" +describe PowerDNS do + include Fog::BinSpec + let(:subject) { PowerDNS } +end \ No newline at end of file diff --git a/spec/fog/bin_spec.rb b/spec/fog/bin_spec.rb index 265a577f0..55c0acd9d 100644 --- a/spec/fog/bin_spec.rb +++ b/spec/fog/bin_spec.rb @@ -34,6 +34,7 @@ describe Fog do assert_equal "OpenStack", Fog.providers[:openstack] assert_equal "Openvz", Fog.providers[:openvz] assert_equal "Ovirt", Fog.providers[:ovirt] + assert_equal "PowerDNS", Fog.providers[:powerdns] assert_equal "ProfitBricks", Fog.providers[:profitbricks] assert_equal "Rackspace", Fog.providers[:rackspace] assert_equal "Rage4", Fog.providers[:rage4] @@ -84,6 +85,7 @@ describe Fog do assert_includes Fog.registered_providers, "OpenStack" assert_includes Fog.registered_providers, "Openvz" assert_includes Fog.registered_providers, "Ovirt" + assert_includes Fog.registered_providers, "PowerDNS" assert_includes Fog.registered_providers, "ProfitBricks" assert_includes Fog.registered_providers, "Rackspace" assert_includes Fog.registered_providers, "Rage4" @@ -134,6 +136,7 @@ describe Fog do assert_includes Fog.available_providers, "OpenStack" if OpenStack.available? assert_includes Fog.available_providers, "Openvz" if Openvz.available? assert_includes Fog.available_providers, "Ovirt" if Ovirt.available? + assert_includes Fog.available_providers, "ProfitBricks" if PowerDNS.available? assert_includes Fog.available_providers, "ProfitBricks" if ProfitBricks.available? assert_includes Fog.available_providers, "Rackspace" if Rackspace.available? assert_includes Fog.available_providers, "Rage4" if Rage4.available?