summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorJoshua McKenty <jmckenty@joshua-mckentys-macbook-pro.local>2010-07-07 12:06:34 -0700
committerVishvananda Ishaya <vishvananda@gmail.com>2010-07-07 12:06:34 -0700
commitb7ea2f70581f6acd927ea7b65adaffeeb4b8d2ba (patch)
tree6f00bf4a6207486478b0142f0297081ebcf85d8d /bin
parent5e8337aec03f5a697c90779eb66a457aae4e7ae0 (diff)
downloadnova-b7ea2f70581f6acd927ea7b65adaffeeb4b8d2ba.tar.gz
nova-b7ea2f70581f6acd927ea7b65adaffeeb4b8d2ba.tar.xz
nova-b7ea2f70581f6acd927ea7b65adaffeeb4b8d2ba.zip
Capture signals from dnsmasq and use them to update network state.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/dhcpleasor.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/bin/dhcpleasor.py b/bin/dhcpleasor.py
new file mode 100755
index 000000000..07e63884f
--- /dev/null
+++ b/bin/dhcpleasor.py
@@ -0,0 +1,68 @@
+#!/opt/local/bin/python
+
+# Copyright [2010] [Anso Labs, LLC]
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""
+dhcpleasor.py
+
+Handle lease database updates from DHCP servers.
+"""
+
+import sys
+import os
+import logging
+sys.path.append(os.path.abspath(os.path.join(__file__, "../../")))
+
+logging.debug(sys.path)
+import getopt
+from os import environ
+from nova.compute import network
+from nova import flags
+FLAGS = flags.FLAGS
+
+
+def add_lease(mac, ip, hostname, interface):
+ pass
+
+def old_lease(mac, ip, hostname, interface):
+ pass
+
+def del_lease(mac, ip, hostname, interface):
+ # TODO - get net from interface instead
+ net = network.get_network_by_address(ip)
+ net.release_ip(ip)
+
+def init_leases(interface):
+ return ""
+
+
+def main(argv=None):
+ if argv is None:
+ argv = sys.argv
+ interface = environ.get('DNSMASQ_INTERFACE', 'br0')
+ old_redis_db = FLAGS.redis_db
+ FLAGS.redis_db = int(environ.get('REDIS_DB', '0'))
+ action = argv[1]
+ if action in ['add','del','old']:
+ mac = argv[2]
+ ip = argv[3]
+ hostname = argv[4]
+ logging.debug("Called %s for mac %s with ip %s and hostname %s on interface %s" % (action, mac, ip, hostname, interface))
+ globals()[action+'_lease'](mac, ip, hostname, interface)
+ else:
+ print init_leases(interface)
+ FLAGS.redis_db = old_redis_db
+
+if __name__ == "__main__":
+ sys.exit(main())