Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zones.create() #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/fog/dns/powerdns/models/zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ class Zone < Fog::Model
identity :zone_id

attribute :zone, aliases: 'name'
attribute :kind
attribute :server_id

DEFAULT_SERVER = 'localhost'

def destroy
service.delete_zone(identity)
true
Expand All @@ -27,8 +30,8 @@ def records
end

def save
requires :zone
data = service.create_zone(zone).body['zone']
requires :zone, :kind
data = service.create_zone(DEFAULT_SERVER, zone, kind)
merge_attributes(data)
true
end
Expand Down
9 changes: 5 additions & 4 deletions lib/fog/dns/powerdns/requests/create_zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ module DNS
class PowerDNS
class Real
# Create a single zone in PowerDNS
# Server, name and nameservers LIST are required
# Server, name and kind are required
#
# ==== Parameters
# * server<~String> - Server ID
# * name<~String> - Name of domain
# * nameservers<~Array> - List of nameservers
# * kind<~String> - Zone kind, one of 'Native', 'Master', 'Slave', 'Producer', 'Consumer'
# * options<~Hash> - Other options
#
# ==== Returns
Expand Down Expand Up @@ -38,10 +38,11 @@ class Real
# * 'comments': <~Array>,
# * status<~Integer> 201 when successful

def create_zone(server, name, nameservers, options = {})
def create_zone(server, name, kind, options = {})
body = {
'name' => name,
'nameservers' => nameservers
'kind' => kind,
'nameservers' => []
}

options.each do |option, value|
Expand Down