You are viewing a plain text version of this content. The canonical link for it is here.
Posted to tashi-commits@incubator.apache.org by st...@apache.org on 2012/02/18 03:58:09 UTC
svn commit: r1245860 -
/incubator/tashi/branches/stroucki-irpbugs/src/tashi/agents/dhcpdns.py
Author: stroucki
Date: Sat Feb 18 03:58:08 2012
New Revision: 1245860
URL: http://svn.apache.org/viewvc?rev=1245860&view=rev
Log:
dhcpdns: IRP uses a dns key file, would need to be integrated into mainline
Modified:
incubator/tashi/branches/stroucki-irpbugs/src/tashi/agents/dhcpdns.py
Modified: incubator/tashi/branches/stroucki-irpbugs/src/tashi/agents/dhcpdns.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-irpbugs/src/tashi/agents/dhcpdns.py?rev=1245860&r1=1245859&r2=1245860&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-irpbugs/src/tashi/agents/dhcpdns.py (original)
+++ incubator/tashi/branches/stroucki-irpbugs/src/tashi/agents/dhcpdns.py Sat Feb 18 03:58:08 2012
@@ -28,8 +28,7 @@ from tashi import boolean
class DhcpDns(InstanceHook):
def __init__(self, config, client, post=False):
InstanceHook.__init__(self, config, client, post)
- self.dnsKeyName = self.config.get('DhcpDns', 'dnsKeyName')
- self.dnsSecretKey = self.config.get('DhcpDns', 'dnsSecretKey')
+ self.dnsKeyFile = self.config.get('DhcpDns', 'dnsKeyFile')
self.dnsServer = self.config.get('DhcpDns', 'dnsServer')
self.dnsDomain = self.config.get('DhcpDns', 'dnsDomain')
self.dnsExpire = int(self.config.get('DhcpDns', 'dnsExpire'))
@@ -114,7 +113,6 @@ class DhcpDns(InstanceHook):
except:
pass
cmd = "omshell"
-# XXXpipe: open omshell session
(stdin, stdout) = os.popen2(cmd)
stdin.write("server %s\n" % (self.dhcpServer))
if (self.dhcpSecretKey != ""):
@@ -132,7 +130,6 @@ class DhcpDns(InstanceHook):
def removeDhcp(self, name, ipaddr=None):
cmd = "omshell"
-# XXXpipe: open omshell session
(stdin, stdout) = os.popen2(cmd)
stdin.write("server %s\n" % (self.dhcpServer))
if (self.dhcpSecretKey != ""):
@@ -154,12 +151,14 @@ class DhcpDns(InstanceHook):
self.removeDns(name)
except:
pass
- cmd = "nsupdate"
+ if (self.dnsKeyFile != ""):
+ cmd = "nsupdate -k %s" % (self.dnsKeyFile)
+ else:
+ cmd = "nsupdate"
child = subprocess.Popen(args=cmd.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE)
try:
(stdin, stdout) = (child.stdin, child.stdout)
stdin.write("server %s\n" % (self.dnsServer))
- stdin.write("key %s %s\n" % (self.dnsKeyName, self.dnsSecretKey))
stdin.write("update add %s.%s %d A %s\n" % (name, self.dnsDomain, self.dnsExpire, ip))
stdin.write("\n")
if (self.reverseDns):
@@ -180,12 +179,14 @@ class DhcpDns(InstanceHook):
(pid, status) = os.waitpid(child.pid, os.WNOHANG)
def removeDns(self, name):
- cmd = "nsupdate"
+ if (self.dnsKeyFile != ""):
+ cmd = "nsupdate -k %s" % (self.dnsKeyFile)
+ else:
+ cmd = "nsupdate"
child = subprocess.Popen(args=cmd.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE)
try:
(stdin, stdout) = (child.stdin, child.stdout)
stdin.write("server %s\n" % (self.dnsServer))
- stdin.write("key %s %s\n" % (self.dnsKeyName, self.dnsSecretKey))
if (self.reverseDns):
ip = socket.gethostbyname(name)
ipSegments = map(int, ip.split("."))