fog-powerdns 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/CONTRIBUTORS.md +1 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +37 -0
  7. data/Rakefile +11 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +7 -0
  10. data/fog-powerdns.gemspec +28 -0
  11. data/lib/fog/powerdns.rb +2 -0
  12. data/lib/fog/powerdns/core.rb +11 -0
  13. data/lib/fog/powerdns/dns.rb +76 -0
  14. data/lib/fog/powerdns/models/dns/record.rb +31 -0
  15. data/lib/fog/powerdns/models/dns/records.rb +21 -0
  16. data/lib/fog/powerdns/models/dns/zone.rb +40 -0
  17. data/lib/fog/powerdns/models/dns/zones.rb +29 -0
  18. data/lib/fog/powerdns/requests/dns/create_zone.rb +62 -0
  19. data/lib/fog/powerdns/requests/dns/delete_zone.rb +29 -0
  20. data/lib/fog/powerdns/requests/dns/get_cryptokey.rb +37 -0
  21. data/lib/fog/powerdns/requests/dns/get_server.rb +33 -0
  22. data/lib/fog/powerdns/requests/dns/get_server_config.rb +31 -0
  23. data/lib/fog/powerdns/requests/dns/get_server_stats.rb +30 -0
  24. data/lib/fog/powerdns/requests/dns/get_zone.rb +46 -0
  25. data/lib/fog/powerdns/requests/dns/list_cryptokeys.rb +36 -0
  26. data/lib/fog/powerdns/requests/dns/list_server_configs.rb +30 -0
  27. data/lib/fog/powerdns/requests/dns/list_servers.rb +34 -0
  28. data/lib/fog/powerdns/requests/dns/list_zones.rb +47 -0
  29. data/lib/fog/powerdns/requests/dns/notify_zone.rb +50 -0
  30. data/lib/fog/powerdns/requests/dns/retrieve_zone.rb +50 -0
  31. data/lib/fog/powerdns/requests/dns/search_log.rb +28 -0
  32. data/lib/fog/powerdns/requests/dns/update_rrsets.rb +47 -0
  33. data/lib/fog/powerdns/requests/dns/update_server_config.rb +36 -0
  34. data/lib/fog/powerdns/requests/dns/update_zone.rb +54 -0
  35. data/lib/fog/powerdns/version.rb +5 -0
  36. metadata +149 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1569c42b24164df9330240dc63a0b1c98fb2dd30
4
+ data.tar.gz: 04d60a5ee5f0b3f1acfe26edab13f50fa118a6ae
5
+ SHA512:
6
+ metadata.gz: 8313393e93c1e0590d9c0dbbdc2f3d97f512a6387c2c90ad9a717102a3fc46513ee46548f8a37bd6d919a921e0e185e6f3a0a9192178b5f7ff3a52f292ba51b1
7
+ data.tar.gz: 56b1528d7267d5dc2c9eeb7549d64a1f57f2a94fdb810814f1305e5f1ae7c7baea08fd92e877bad5943e0d5efc4870d4e4d3e5e7dd2fb10e91dbd8869297e16a
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /.idea/
data/CONTRIBUTORS.md ADDED
@@ -0,0 +1 @@
1
+ * Chris Luo <luo_christopher@bah.com>
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fog-dns.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Fog::PowerDNS
2
+
3
+ Module for the 'fog' gem to support PowerDNS
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'fog-powerdns'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install fog-powerdns
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( https://github.com/[my-github-username]/fog-powerdns/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ def name
4
+ @name ||= Dir['*.gemspec'].first.split('.').first
5
+ end
6
+
7
+ desc "Open an irb session preloaded with this library"
8
+ task :console do
9
+ puts "#{name}"
10
+ sh "irb -rubygems -r ./lib/fog/powerdns.rb"
11
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fog/powerdns"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fog/powerdns/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fog-powerdns"
8
+ spec.version = Fog::PowerDNS::VERSION
9
+ spec.authors = ["Chris Luo"]
10
+ spec.email = ["luo_christopher@bah.com"]
11
+
12
+ spec.summary = %q{Module for the 'fog' gem to support PowerDNS DNS services.}
13
+ spec.description = %q{This library can be used as a module for 'fog' or as a standalone provider to use PowerDNS DNS services in applications.}
14
+ spec.homepage = "http://github.com/cluobah/fog-powerdns"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.8"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+
25
+ spec.add_dependency 'fog-core', '~> 1.27'
26
+ spec.add_dependency 'fog-json', '~>1.0'
27
+ spec.add_dependency 'fog-xml', '~>0.1'
28
+ end
@@ -0,0 +1,2 @@
1
+ require 'fog/powerdns'
2
+ require 'fog/powerdns/dns'
@@ -0,0 +1,11 @@
1
+ require 'fog/core'
2
+ require 'fog/json'
3
+ require 'fog/xml'
4
+
5
+ module Fog
6
+ module PowerDNS
7
+ extend Fog::Provider
8
+
9
+ service(:dns, 'DNS')
10
+ end
11
+ end
@@ -0,0 +1,76 @@
1
+ require 'fog/powerdns/core'
2
+
3
+ module Fog
4
+ module DNS
5
+ class PowerDNS < Fog::Service
6
+ requires :pdns_api_key
7
+ recognizes :host, :port, :persistent, :scheme, :timeout
8
+
9
+ model_path 'fog/powerdns/models/dns'
10
+ model :zone
11
+ collection :zones
12
+ # collection :rrsets
13
+
14
+ request_path 'fog/powerdns/requests/dns'
15
+ request :list_servers
16
+ request :get_server
17
+ request :list_server_configs
18
+ request :get_server_config
19
+ request :update_server_config
20
+ request :list_zones
21
+ request :create_zone
22
+ request :get_zone
23
+ request :delete_zone
24
+ request :update_rrsets
25
+ request :update_zone
26
+ request :notify_zone
27
+ request :retrieve_zone
28
+ request :list_cryptokeys
29
+ request :get_cryptokey
30
+ request :search_log
31
+ request :get_server_stats
32
+
33
+ class Mock
34
+ end
35
+
36
+ class Real
37
+ def initialize(options={})
38
+
39
+ @pdns_api_key = options[:pdns_api_key]
40
+ @connection_options = options[:connection_options] || {}
41
+ @host = options[:host] || "127.0.0.1"
42
+ @persistent = options[:persistent]|| false
43
+ @port = options[:port] || 8081
44
+ @scheme = options[:scheme] || 'http'
45
+ puts @api_key
46
+ puts @persistent
47
+ puts @connection_options
48
+ puts @scheme
49
+ puts @host
50
+ puts @port
51
+ @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
52
+ end
53
+
54
+ def reload
55
+ @connection.reset
56
+ end
57
+
58
+ def request(params)
59
+ params[:headers] ||= {}
60
+ params[:headers].merge!("X-API-key" => "#{@pdns_api_key}")
61
+ params[:headers].merge!(
62
+ "Accept" => "application/json",
63
+ "Content-Type" => "application/json"
64
+ )
65
+
66
+ response = @connection.request(params)
67
+
68
+ unless response.body.empty?
69
+ response.body = Fog::JSON.decode(response.body)
70
+ end
71
+ response
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,31 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module DNS
5
+ class PowerDNS
6
+ class Record < Fog::Model
7
+ # TODO: Needs work to comply with powerdns api
8
+ identity :name
9
+
10
+ attribute :content
11
+ attribute :ttl
12
+ attribute :type
13
+ attribute :disabled
14
+ attribute :set_ptr
15
+
16
+ def initialize(attributes={})
17
+ super
18
+ end
19
+ def domain
20
+ name
21
+ end
22
+ def destroy
23
+ # service.delete_record(id)
24
+ # TODO: maybe hack our own delete? this does nothing for now
25
+ true
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/rage4/models/dns/record'
3
+ module Fog
4
+ module DNS
5
+ class PowerDNS
6
+ class Records < Fog::Collection
7
+ attribute :zone
8
+ model Fog::DNS::PowerDNS::Record
9
+
10
+ def all
11
+ requires :zone
12
+ clear
13
+ data = service.get_zone(zone)[:records]
14
+ load(data)
15
+ end
16
+
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,40 @@
1
+ require 'fog/core/model'
2
+ # require 'fog/powerdns/models/dns/rrsets'
3
+
4
+ module Fog
5
+ module DNS
6
+ class PowerDNS
7
+ class Zone < Fog::Model
8
+ identity :zone_id
9
+
10
+ attribute :zone, :aliases => 'name'
11
+ attribute :server_id
12
+
13
+ def destroy
14
+ service.delete_zone(identity)
15
+ true
16
+ end
17
+
18
+
19
+ def records
20
+ # TODO: Should rewrite this
21
+ @records ||= begin
22
+ Fog::DNS::PowerDNS::Records.new(
23
+ :zone => self,
24
+ :service => service
25
+ )
26
+ end
27
+ end
28
+
29
+
30
+ def save
31
+ requires :zone
32
+ data = service.create_zone(zone).body["zone"]
33
+ merge_attributes(data)
34
+ true
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,29 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/powerdns/models/dns/zone'
3
+
4
+ module Fog
5
+ module DNS
6
+ class PowerDNS
7
+ class Zones < Fog::Collection
8
+ model Fog::DNS::PowerDNS::Zone
9
+
10
+ # attribute :zone, :aliases => 'name'
11
+
12
+ def all
13
+ clear
14
+ data = service.list_zones.body
15
+ load(data)
16
+ end
17
+
18
+ def get(zone)
19
+ data = service.get_zone(zone).body['zone']
20
+ zone = new(data)
21
+ zone
22
+ rescue Fog::Service::NotFound
23
+ puts 'help!'
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,62 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Create a single zone in PowerDNS
6
+ # Server, name and nameservers LIST are required
7
+ #
8
+ # ==== Parameters
9
+ # * server<~String> - Server ID
10
+ # * name<~String> - Name of domain
11
+ # * nameservers<~Array> - List of nameservers
12
+ # * options<~Hash> - Other options
13
+ #
14
+ # ==== Returns
15
+ # * response<~Excon::Response>:
16
+ # * body<~Hash>:
17
+ # * 'id': <~String>,
18
+ # * "name": <~String>,
19
+ # * 'type': <~String>,
20
+ # * 'url': <~String>,
21
+ # * 'kind': <~String>,
22
+ # * 'serial': <~Integer>,
23
+ # * 'notified_serial': <~Int>,
24
+ # * 'masters': <~Array,
25
+ # * 'dnssec': <~Boolean>,
26
+ # * 'nsec3param': <~String>,
27
+ # * 'nsec3narrow': <~Boolean>,
28
+ # * 'presigned': <~Boolean>,
29
+ # * 'soa_edit': '<~String>',
30
+ # * 'soa_edit_api': '<~String>',
31
+ # * 'account': '<~String>',
32
+ # * 'nameservers': <~Array>,
33
+ # * 'servers': <~Array>,
34
+ # * 'recursion_desired': <~Boolean>,
35
+ # * 'records': <~Array>,
36
+ # * 'comments': <~Array>,
37
+ # * status<~Integer> 201 when successful
38
+
39
+ def create_zone(server, name, nameservers, options = {})
40
+ body = {
41
+ "name" => name,
42
+ "nameservers" => nameservers
43
+ }
44
+
45
+ options.each { |option, value|
46
+ body[option] = value;
47
+ }
48
+
49
+ request(
50
+ :body => Fog::JSON.encode(body),
51
+ :expects => 201,
52
+ :method => 'POST',
53
+ :path => "/servers/#{server}/zones"
54
+ ).body
55
+ end
56
+ end
57
+ class Mock
58
+ # TODO: Write this
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Delete the zone from the server
6
+ # Reference the zone to delete with server id and zone id
7
+
8
+ # ==== Parameters
9
+ # * server<~String> - server id
10
+ # * zone<~String> - zone id
11
+ #
12
+ #
13
+ # ==== Returns
14
+ # * response<~Excon::Response>:
15
+ # * body<~Hash>:
16
+ # * status<~Integer> - 204 when successful
17
+ #
18
+
19
+ def delete_zone(server, zone)
20
+ request(
21
+ :expects => 204,
22
+ :method => 'DELETE',
23
+ :path => "/servers/#{server}/zones/#{zone}"
24
+ )
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Get details of a cryptokey
6
+ #
7
+ # ==== Parameters
8
+ # * server<~String> - server id
9
+ # * zone<~String> - zone id
10
+ # * cryptokey<~String> - cryptokey id
11
+
12
+ #
13
+ # ==== Returns
14
+ # * response<~Excon::Response>:
15
+ # * body<~Hash>:
16
+ # * 'type': <~String>,
17
+ # * 'id': <~Integer>,
18
+ # * 'active': <~Boolean>,
19
+ # * 'keytype': <~String>,
20
+ # * 'dnskey': <~String>,
21
+ # * 'content': <~String>,
22
+ # * 'ds': <~Array>
23
+ # * status<~Integer> - 200 when successful
24
+ #
25
+
26
+ def get_cryptokey(server, zone, cryptokey)
27
+ request(
28
+ :expects => 200,
29
+ :method => 'GET',
30
+ :path => "/servers/#{server}/zones/#{zone}/cryptokeys/#{cryptokey}"
31
+ ).body
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,33 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Get details of a DNS server
6
+ #
7
+ # ==== Parameters
8
+ # * server<~String> - server id
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * 'type': <~String>,
14
+ # * 'id': <~String>,
15
+ # * 'url': <~String>,
16
+ # * 'daemon_type': <~String>,
17
+ # * 'version': <~String>,
18
+ # * 'config_url': <~String>,
19
+ # * 'zones_url': <~String>,
20
+ # * status<~String> - 200 when successful
21
+
22
+ def get_server(server)
23
+ request(
24
+ :expects => 200,
25
+ :method => 'GET',
26
+ :path => "/servers/#{server}"
27
+ ).body
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,31 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Get a specific config setting of one server
6
+ # TODO: Can only get / retrieve recursor's allow_from
7
+ #
8
+ # ==== Parameters
9
+ # * server<~String> - server id
10
+ # * config<~String> - config name
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response>:
14
+ # * body<~Hash>:
15
+ # * 'type': <~String>,
16
+ # * 'name': <~String>,
17
+ # * 'value': <~String>
18
+ # * status<~String> - 200 when successful
19
+
20
+ def get_server_config(server, config)
21
+ request(
22
+ :expects => 200,
23
+ :method => 'GET',
24
+ :path => "/servers/#{server}/config/#{config}"
25
+ ).body
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Retrieves server stats
6
+ #
7
+ # ==== Parameters
8
+ # * server<~String> - server id
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Array>:
13
+ # * statistics<~Hash>:
14
+ # * 'type': <~String>,
15
+ # * 'name': <~String>,
16
+ # * 'value': <~String>
17
+ # * status<~Integer> - 200 when successful
18
+
19
+ def get_server_stats(server)
20
+ request(
21
+ :expects => 200,
22
+ :method => 'GET',
23
+ :path => "/servers/#{server}/statistics"
24
+ ).body
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,46 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Get details of a DNS zone
6
+ #
7
+ # ==== Parameters
8
+ # * zone<~String> - Zone id
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * 'id': <~String>,
14
+ # * "name": <~String>,
15
+ # * 'type': <~String>,
16
+ # * 'url': <~String>,
17
+ # * 'kind': <~String>,
18
+ # * 'serial': <~Integer>,
19
+ # * 'notified_serial': <~Int>,
20
+ # * 'masters': <~Array,
21
+ # * 'dnssec': <~Boolean>,
22
+ # * 'nsec3param': <~String>,
23
+ # * 'nsec3narrow': <~Boolean>,
24
+ # * 'presigned': <~Boolean>,
25
+ # * 'soa_edit': '<~String>',
26
+ # * 'soa_edit_api': '<~String>',
27
+ # * 'account': '<~String>',
28
+ # * 'nameservers': <~Array>,
29
+ # * 'servers': <~Array>,
30
+ # * 'recursion_desired': <~Boolean>,
31
+ # * 'records': <~Array>,
32
+ # * 'comments': <~Array>,
33
+ # * status<~Integer> 200 when successful
34
+
35
+ def get_zone(server, zone)
36
+ request(
37
+ :expects => 200,
38
+ :method => 'GET',
39
+ :path => "/servers/#{server}/zones/#{zone}"
40
+ ).body
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,36 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Get details of all public cryptokeys
6
+ #
7
+ # ==== Parameters
8
+ # server<~String> - server id
9
+ # zone<~String> - zone id
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>:
13
+ # * body<~Array>:
14
+ # * Cryptokey<~Hash>:
15
+ # * 'type': <~String>,
16
+ # * 'id': <~Integer>,
17
+ # * 'active': <~Boolean>,
18
+ # * 'keytype': <~String>,
19
+ # * 'dnskey': <~String>,
20
+ # * 'content': <~String>,
21
+ # * 'ds': <~Array>
22
+ # * status<~Integer> - 200 when successful
23
+ #
24
+
25
+ def list_cryptokeys(server, zone)
26
+ request(
27
+ :expects => 200,
28
+ :method => 'GET',
29
+ :path => "/servers/#{server}/zones/#{zone}/cryptokeys"
30
+ ).body
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Get all of a DNS server's config settings
6
+ #
7
+ # ==== Parameters
8
+ # * server<~String> - server id
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Array>:
13
+ # * Config<~Hash>:
14
+ # * 'type': <~String>,
15
+ # * 'name': <~String>,
16
+ # * 'value': <~String>
17
+ # * status<~String> - 200 when successful
18
+
19
+ def list_server_configs(server)
20
+ request(
21
+ :expects => 200,
22
+ :method => 'GET',
23
+ :path => "/servers/#{server}/config"
24
+ ).body
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,34 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Get details of all powerdns servers
6
+ #
7
+ # ==== Parameters
8
+ #
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * server<~Array>:
14
+ # * 'type': <~String>,
15
+ # * 'id': <~String>,
16
+ # * 'url': <~String>,
17
+ # * 'daemon_type': <~String>,
18
+ # * 'version': <~String>,
19
+ # * 'config_url': <~String>,
20
+ # * 'zones_url': <~String>,
21
+ # * status<~String> - 200 when successful
22
+
23
+ def list_servers
24
+ request(
25
+ :expects => 200,
26
+ :method => 'GET',
27
+ :path => "/servers"
28
+ ).body
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,47 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Get details of a server's DNS zones
6
+ #
7
+ # ==== Parameters
8
+ # * server<~String> - server id
9
+ #
10
+ # ==== Returns
11
+ # * response<~Excon::Response>:
12
+ # * body<~Hash>:
13
+ # * zone<~Hash>:
14
+ # * 'id': <~String>,
15
+ # * "name": <~String>,
16
+ # * 'type': <~String>,
17
+ # * 'url': <~String>,
18
+ # * 'kind': <~String>,
19
+ # * 'serial': <~Integer>,
20
+ # * 'notified_serial': <~Int>,
21
+ # * 'masters': <~Array,
22
+ # * 'dnssec': <~Boolean>,
23
+ # * 'nsec3param': <~String>,
24
+ # * 'nsec3narrow': <~Boolean>,
25
+ # * 'presigned': <~Boolean>,
26
+ # * 'soa_edit': '<~String>',
27
+ # * 'soa_edit_api': '<~String>',
28
+ # * 'account': '<~String>',
29
+ # * 'nameservers': <~Array>,
30
+ # * 'servers': <~Array>,
31
+ # * 'recursion_desired': <~Boolean>,
32
+ # * 'records': <~Array>,
33
+ # * 'comments': <~Array>,
34
+ # * status<~Integer> 200 when successful
35
+
36
+ def list_zones(server)
37
+ request(
38
+ :expects => 200,
39
+ :method => 'GET',
40
+ :path => "/servers/#{server}/zones"
41
+ ).body
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,50 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # DNS Notify all slaves of the zone
6
+ # Authoritative only, zone must be set up as master
7
+ # or slave (fails otherwise)
8
+ #
9
+ # ==== Parameters
10
+ # * server<~String> - server id
11
+ # * zone<~String> - zone name
12
+ #
13
+ # ==== Returns
14
+ # TODO: Untested
15
+ # * response<~Excon::Response>:
16
+ # * body<~Hash>:
17
+ # * 'id': <~String>,
18
+ # * "name": <~String>,
19
+ # * 'type': <~String>,
20
+ # * 'url': <~String>,
21
+ # * 'kind': <~String>,
22
+ # * 'serial': <~Integer>,
23
+ # * 'notified_serial': <~Int>,
24
+ # * 'masters': <~Array,
25
+ # * 'dnssec': <~Boolean>,
26
+ # * 'nsec3param': <~String>,
27
+ # * 'nsec3narrow': <~Boolean>,
28
+ # * 'presigned': <~Boolean>,
29
+ # * 'soa_edit': '<~String>',
30
+ # * 'soa_edit_api': '<~String>',
31
+ # * 'account': '<~String>',
32
+ # * 'nameservers': <~Array>,
33
+ # * 'servers': <~Array>,
34
+ # * 'recursion_desired': <~Boolean>,
35
+ # * 'records': <~Array>,
36
+ # * 'comments': <~Array>,
37
+ # * status<~Integer> 200 when successful
38
+
39
+ def notify_zone(server, zone)
40
+ request(
41
+ :expects => 200,
42
+ :method => 'PUT',
43
+ :path => "/servers/#{server}/zones/#{zone}/notify"
44
+ )
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,50 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Retrieves master
6
+ # Authoritative only, zone must be set up as slave
7
+ # (fails otherwise)
8
+ #
9
+ # ==== Parameters
10
+ # * server<~String> - server id
11
+ # * zone<~String> - zone name
12
+ #
13
+ # ==== Returns
14
+ # TODO: Untested
15
+ # * response<~Excon::Response>:
16
+ # * body<~Hash>:
17
+ # * 'id': <~String>,
18
+ # * "name": <~String>,
19
+ # * 'type': <~String>,
20
+ # * 'url': <~String>,
21
+ # * 'kind': <~String>,
22
+ # * 'serial': <~Integer>,
23
+ # * 'notified_serial': <~Int>,
24
+ # * 'masters': <~Array,
25
+ # * 'dnssec': <~Boolean>,
26
+ # * 'nsec3param': <~String>,
27
+ # * 'nsec3narrow': <~Boolean>,
28
+ # * 'presigned': <~Boolean>,
29
+ # * 'soa_edit': '<~String>',
30
+ # * 'soa_edit_api': '<~String>',
31
+ # * 'account': '<~String>',
32
+ # * 'nameservers': <~Array>,
33
+ # * 'servers': <~Array>,
34
+ # * 'recursion_desired': <~Boolean>,
35
+ # * 'records': <~Array>,
36
+ # * 'comments': <~Array>,
37
+ # * status<~Integer> 201 when successful
38
+
39
+ def retrieve_zone(server, zone)
40
+ request(
41
+ :expects => 200,
42
+ :method => 'PUT',
43
+ :path => "/servers/#{server}/zones/#{zone}/axfr-retrieve"
44
+ )
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Searches for term in server logs
6
+ #
7
+ # ==== Parameters
8
+ # * server<~String> - server id
9
+ # * term<~String> - search term
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>:
13
+ # * body<~Array>:
14
+ # * log-line<~String>
15
+ # * status<~Integer> - 200 when successful
16
+
17
+ def search_log(server, term)
18
+ request(
19
+ :expects => 200,
20
+ :method => 'GET',
21
+ :path => "/servers/#{server}/search-log?q=#{term}"
22
+ ).body
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,47 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Modify existing RRset's of a zone
6
+ #
7
+ # ==== Parameters
8
+ # server<~String> - server id
9
+ # zone<~String> - zone id
10
+ # options<~Hash> - see pdns api for rules
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response>:
14
+ # * body<~Hash>:
15
+ # * 'rrsets'<~Hash> The representation of the rrsets:
16
+ # * 'name': <~String>,
17
+ # * 'type': <~String>,
18
+ # * 'changetype': <~String>,
19
+ # * 'records' <~Hash> domain records:
20
+ # * 'content': <~String>,
21
+ # * 'name': <~String>,
22
+ # * 'ttl': <~Integer>,
23
+ # * 'type': <~String>,
24
+ # * 'disabled': <~Boolean>,
25
+ # * 'set-ptr': <~Boolean>
26
+ # * 'comments' <~Hash> comments:
27
+ # * 'account': <~String>,
28
+ # * 'content': <~String>,
29
+ # * 'modfied_at': <~Integer>
30
+
31
+
32
+ def update_rrsets(server, zone, options = {})
33
+ options.each { |option, value|
34
+ body[option] = value;
35
+ }
36
+
37
+ request(
38
+ :body => Fog::JSON.encode(body),
39
+ :expects => 200,
40
+ :method => 'PATCH',
41
+ :path => "/servers/#{server}/zones/#{zone}/"
42
+ )
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,36 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Update a specific config setting of one server
6
+ # TODO: Can only get / retrieve recursor's allow_from
7
+ #
8
+ # ==== Parameters
9
+ # * server<~String> - server id
10
+ # * config<~String> - config name
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response>:
14
+ # * body<~Hash>:
15
+ # * 'type': <~String>,
16
+ # * 'name': <~String>,
17
+ # * 'value': <~String>
18
+ # * status<~String> - 200 when successful
19
+
20
+ def update_server_config(server, config, body)
21
+ if config == 'allows_from'
22
+ request(
23
+ :body => body,
24
+ :expects => 200,
25
+ :method => 'PUT',
26
+ :path => "/servers/#{server}/config/#{config}"
27
+ ).body
28
+ else
29
+ puts 'Only allows_from config is allowed.'
30
+ end
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,54 @@
1
+ module Fog
2
+ module DNS
3
+ class PowerDNS
4
+ class Real
5
+ # Modify a single zone in PowerDNS
6
+ #
7
+ # ==== Parameters
8
+ # server<~String> - server id
9
+ # zone<~String> - zone id
10
+ # options<~Hash> - pairs enumerated below
11
+ #
12
+ #
13
+ # ==== Returns
14
+ # * response<~Excon::Response>:
15
+ # * body<~Hash>:
16
+ # * 'id': <~String>,
17
+ # * "name": <~String>,
18
+ # * 'type': <~String>,
19
+ # * 'url': <~String>,
20
+ # * 'kind': <~String>,
21
+ # * 'serial': <~Integer>,
22
+ # * 'notified_serial': <~Int>,
23
+ # * 'masters': <~Array,
24
+ # * 'dnssec': <~Boolean>,
25
+ # * 'nsec3param': <~String>,
26
+ # * 'nsec3narrow': <~Boolean>,
27
+ # * 'presigned': <~Boolean>,
28
+ # * 'soa_edit': '<~String>',
29
+ # * 'soa_edit_api': '<~String>',
30
+ # * 'account': '<~String>',
31
+ # * 'nameservers': <~Array>,
32
+ # * 'servers': <~Array>,
33
+ # * 'recursion_desired': <~Boolean>,
34
+ # * 'records': <~Array>,
35
+ # * 'comments': <~Array>,
36
+ # * status<~Integer> 200 when successful
37
+
38
+ def update_zone(server, zone, options = {})
39
+
40
+ options.each { |option, value|
41
+ body[option] = value;
42
+ }
43
+
44
+ request(
45
+ :body => Fog::JSON.encode(body),
46
+ :expects => 200,
47
+ :method => 'PUT',
48
+ :path => "/servers/#{server}/zones/#{zone}"
49
+ ).body
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ module Fog
2
+ module PowerDNS
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fog-powerdns
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Luo
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-03-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fog-core
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.27'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.27'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fog-json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: fog-xml
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.1'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.1'
83
+ description: This library can be used as a module for 'fog' or as a standalone provider
84
+ to use PowerDNS DNS services in applications.
85
+ email:
86
+ - luo_christopher@bah.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - CONTRIBUTORS.md
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - fog-powerdns.gemspec
100
+ - lib/fog/powerdns.rb
101
+ - lib/fog/powerdns/core.rb
102
+ - lib/fog/powerdns/dns.rb
103
+ - lib/fog/powerdns/models/dns/record.rb
104
+ - lib/fog/powerdns/models/dns/records.rb
105
+ - lib/fog/powerdns/models/dns/zone.rb
106
+ - lib/fog/powerdns/models/dns/zones.rb
107
+ - lib/fog/powerdns/requests/dns/create_zone.rb
108
+ - lib/fog/powerdns/requests/dns/delete_zone.rb
109
+ - lib/fog/powerdns/requests/dns/get_cryptokey.rb
110
+ - lib/fog/powerdns/requests/dns/get_server.rb
111
+ - lib/fog/powerdns/requests/dns/get_server_config.rb
112
+ - lib/fog/powerdns/requests/dns/get_server_stats.rb
113
+ - lib/fog/powerdns/requests/dns/get_zone.rb
114
+ - lib/fog/powerdns/requests/dns/list_cryptokeys.rb
115
+ - lib/fog/powerdns/requests/dns/list_server_configs.rb
116
+ - lib/fog/powerdns/requests/dns/list_servers.rb
117
+ - lib/fog/powerdns/requests/dns/list_zones.rb
118
+ - lib/fog/powerdns/requests/dns/notify_zone.rb
119
+ - lib/fog/powerdns/requests/dns/retrieve_zone.rb
120
+ - lib/fog/powerdns/requests/dns/search_log.rb
121
+ - lib/fog/powerdns/requests/dns/update_rrsets.rb
122
+ - lib/fog/powerdns/requests/dns/update_server_config.rb
123
+ - lib/fog/powerdns/requests/dns/update_zone.rb
124
+ - lib/fog/powerdns/version.rb
125
+ homepage: http://github.com/cluobah/fog-powerdns
126
+ licenses:
127
+ - MIT
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 2.4.6
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: Module for the 'fog' gem to support PowerDNS DNS services.
149
+ test_files: []