vagrant-powerdns 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b98ac2809c2093b13f504075eec9735f4481722
4
- data.tar.gz: 3cda97d2e2071e4dc42c72f7a03c4cc431ec1d18
3
+ metadata.gz: acb0cb8a88a2a042926f73b8413195f26f54296b
4
+ data.tar.gz: a9884828fe4222180e4e60bc4d85ab499a2ef8b6
5
5
  SHA512:
6
- metadata.gz: 6fe362fb842a4b5502f5c53e049d968048f216e48f5d3dd85190c94bbe4799d57fef412b5b977ca25b4d85655bae4edb1246d6ab1d30c70cf12219637ba2b3d2
7
- data.tar.gz: 71767572bba48605415ffd2febc5b56a09e5bf7fab432e8d186013337ca606d08295ffdc58b2f7ce583fcce0a177b48bc0bcf76c09d4dea5bdf00c9f1d310d9a
6
+ metadata.gz: e85525301d3762ae8eeb431a70d567e7e49363c14a942820db88cbad19339c7212609cc24c0e158ec3113e3377bfbce2fbf5fe5dea33321ddc4ce3b9c6b183f7
7
+ data.tar.gz: 7fe9fc614097755d8af7b5e9243bcf0531ce7f5b820e658b2ea89da832f0082e9022af301bd823f2f1fff2ec2b25efa64da4a3e34a05ad38be107d83f695966d
@@ -28,10 +28,11 @@ module Vagrant
28
28
  p = PdnsRestApiClient.new(env[:machine].config.powerdns.api_url,
29
29
  env[:machine].config.powerdns.api_key)
30
30
 
31
- # Only update if IP changed
32
- if p.zone(@zone)["records"].select { |v| v["type"] == "A" and
33
- v["name"] == @domain and v["content"] == ip}.empty?
31
+ # Only update if IP changed or inactive
32
+ record_not_found = p.zone(@zone)["records"].select {|v| v["type"] == "A" and v["name"] == @domain and v["content"] == ip}.empty?
33
+ record_disabled = p.zone(@zone)["records"].select { |v| v["type"] == "A" and v["name"] == @domain and v["disable"]}.empty?
34
34
 
35
+ if record_not_found or record_disabled
35
36
  env[:ui].info "PowerDNS action..."
36
37
  # Append new comment
37
38
  new_comment = {
@@ -22,57 +22,39 @@ module Vagrant
22
22
  @default_zone = Zone.new @default_zone;
23
23
  end
24
24
 
25
+ @api_url = nil if @api_url == UNSET_VALUE
26
+ @api_key = nil if @api_key == UNSET_VALUE
25
27
  @disable = false if @disable == UNSET_VALUE
26
28
 
27
- # default way to obtain ip address
28
- if @ip == UNSET_VALUE
29
- @ip = proc do |guest_machine|
30
- ips = nil
31
- puts "SUDO SUUUUUU............"
32
- guest_machine.communicate.sudo("hostname -I") do |type, data|
33
- ips = data.scan /[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/
34
- end
35
- ips
36
- end
37
- end
38
-
39
29
  end
40
30
 
41
31
  def enabled?
42
- not @disable and not @api_url.nil? and not @api_key.nil?
32
+ @api_url.is_a?(String) or @api_key.is_a?(String) or @default_zone.is_a?(String)
43
33
  end
44
34
 
45
35
  def validate(machine)
46
- return unless enabled?
36
+ if enabled?
37
+ #return if not @api_url.nil? and not @api_key.nil? and not @default_zone.nil?
47
38
 
48
- errors = []
39
+ errors = []
49
40
 
50
- # verify @disable
51
- if @disable != true and @disable != false then errors << 'invalid disable setting' end
41
+ # verify @disable
42
+ if @disable != true and @disable != false then errors << 'invalid disable setting' end
52
43
 
53
- # verify zone
54
- begin @default_zone = Zone.new @default_zone; rescue => e; errors << e.message end
44
+ # verify zone
45
+ begin @default_zone = Zone.new @default_zone; rescue => e; errors << e.message end
55
46
 
56
- # verify ip
57
- if @ip.is_a? Array
58
- @ip.map!{|ip| begin Ip.new(ip); rescue => e; errors << e.message end}
47
+ # verify api_url
48
+ begin @api_url = String.new @api_url; rescue => e; errors << "powerdns.api_url: Invalid URL. It should be like `http://ns.example.com:8081'" end
59
49
 
60
- elsif @ip.is_a? String
61
- begin @ip = Ip.new(@ip); rescue => e; errors << e.message end
62
- @ip = [@ip]
50
+ # verify api_key
51
+ begin @api_key = String.new @api_key; rescue => e; errors << "powerdns.api_key: Invalid API Key. It should be like `api_key_of_powerdns'" end
63
52
 
64
- elsif @ip.is_a? Proc
65
- # okay, there is nothing to verify at the moment
66
- else
67
- @ip = nil
68
- end
53
+ # verify zone
54
+ #begin @default_zone = Zone.new @default_zone; rescue => e; errors << "config.powerdns.default_zone: Invalid Zone #{@default_zone}. It should be like: `dev.example.com'" end
69
55
 
70
- # verify API URL/key
71
- #if @resolver
72
- # errors << "file '#{@dnsmasqconf}' does not exist" unless File.exists? @dnsmasqconf
73
- #end
74
-
75
- return { 'PowerDNS configuration' => errors }
56
+ return { 'PowerDNS configuration' => errors }
57
+ end
76
58
  end
77
59
 
78
60
  end
@@ -12,7 +12,8 @@ class Zone
12
12
  name = name.dotted
13
13
  end
14
14
 
15
- raise ArgumentError, "no domain name given" if name.empty?
15
+ raise ArgumentError, "Invalid Zone: #{name.to_s}" if !name.is_a?(String)
16
+ raise ArgumentError, "no zone name given" if name.empty?
16
17
 
17
18
  # parse domain name ...
18
19
  name = name.to_s
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module PowerDNS
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -12,20 +12,20 @@ module Vagrant
12
12
  description "A PowerDNS Vagrant plugin that manages the zone record via vagrant up/destroy"
13
13
 
14
14
  inc_path = Pathname.new(File.expand_path("../vagrant-powerdns/includes", __FILE__))
15
- require inc_path.join("Zone.class.rb")
16
- require inc_path.join("Ip.class.rb")
17
-
15
+ lib_path = Pathname.new(File.expand_path("../vagrant-powerdns", __FILE__))
18
16
  util_path = Pathname.new(File.expand_path("../vagrant-powerdns/util", __FILE__))
19
- require util_path.join("pdns_api")
20
17
 
21
- lib_path = Pathname.new(File.expand_path("../vagrant-powerdns", __FILE__))
22
- require lib_path.join("action")
18
+ require inc_path.join("Zone.class.rb")
19
+ require inc_path.join("Ip.class.rb")
23
20
 
24
21
  config "powerdns" do
25
22
  require lib_path.join("config")
26
23
  Config
27
24
  end
28
25
 
26
+ require util_path.join("pdns_api")
27
+ require lib_path.join("action")
28
+
29
29
  action_hook(:powerdns, :machine_action_up) do |hook|
30
30
  hook.append(Vagrant::Action::Up)
31
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-powerdns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sayid Munawar