diff options
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/dhcpleasor.py | 92 | ||||
| -rwxr-xr-x | bin/nova-api | 8 | ||||
| -rwxr-xr-x | bin/nova-compute | 5 | ||||
| -rwxr-xr-x | bin/nova-manage | 4 |
4 files changed, 101 insertions, 8 deletions
diff --git a/bin/dhcpleasor.py b/bin/dhcpleasor.py new file mode 100755 index 000000000..30f8fbdc3 --- /dev/null +++ b/bin/dhcpleasor.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# 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 linux_net +from nova.compute import network +from nova import rpc + +from nova import flags +FLAGS = flags.FLAGS + + +def add_lease(mac, ip, hostname, interface): + if FLAGS.fake_rabbit: + network.lease_ip(ip) + else: + rpc.cast(FLAGS.cloud_topic, {"method": "lease_ip", + "args" : {"address": ip}}) + +def old_lease(mac, ip, hostname, interface): + logging.debug("Adopted old lease or got a change of mac/hostname") + +def del_lease(mac, ip, hostname, interface): + if FLAGS.fake_rabbit: + network.release_ip(ip) + else: + rpc.cast(FLAGS.cloud_topic, {"method": "release_ip", + "args" : {"address": ip}}) + +def init_leases(interface): + net = network.get_network_by_interface(interface) + res = "" + for host_name in net.hosts: + res += "%s\n" % linux_net.hostDHCP(net, host_name, net.hosts[host_name]) + return res + + +def main(argv=None): + if argv is None: + argv = sys.argv + interface = environ.get('DNSMASQ_INTERFACE', 'br0') + if int(environ.get('TESTING', '0')): + FLAGS.fake_rabbit = True + FLAGS.redis_db = 8 + FLAGS.network_size = 32 + FLAGS.fake_libvirt=True + FLAGS.fake_network=True + FLAGS.fake_users = True + 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) + exit(0) + +if __name__ == "__main__": + sys.exit(main()) diff --git a/bin/nova-api b/bin/nova-api index f0f79a236..1bef778c5 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -20,7 +20,7 @@ # under the License. """ -Tornado daemon for the main API endpoint. +Tornado daemon for the main API endpoint. """ import logging @@ -43,13 +43,11 @@ FLAGS = flags.FLAGS def main(_argv): - user_manager = users.UserManager() - host_manager = model.Host controllers = { 'Cloud': cloud.CloudController(), - 'Admin': admin.AdminController(user_manager, host_manager) + 'Admin': admin.AdminController() } - _app = api.APIServerApplication(user_manager, controllers) + _app = api.APIServerApplication(controllers) conn = rpc.Connection.instance() consumer = rpc.AdapterConsumer(connection=conn, diff --git a/bin/nova-compute b/bin/nova-compute index ed829ecc8..1b438f6a7 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -75,7 +75,8 @@ def main(): topic='%s.%s' % (FLAGS.compute_topic, FLAGS.node_name), proxy=n) - pulse = task.LoopingCall(n.report_state, FLAGS.node_name, 'nova-compute') + bin_name = os.path.basename(__file__) + pulse = task.LoopingCall(n.report_state, FLAGS.node_name, bin_name) pulse.start(interval=FLAGS.node_report_state_interval, now=False) injected = consumer_all.attach_to_twisted() @@ -83,7 +84,7 @@ def main(): # This is the parent service that twistd will be looking for when it # parses this file, return it so that we can get it into globals below - application = service.Application('nova-compute') + application = service.Application(bin_name) n.setServiceParent(application) return application diff --git a/bin/nova-manage b/bin/nova-manage index f418e162b..12e4c9324 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -62,6 +62,8 @@ class VpnCommands(object): net = 'up' else: net = 'down' + print vpn['private_dns_name'], + print vpn['node_name'], print vpn['instance_id'], print vpn['state_description'], print net @@ -218,7 +220,7 @@ def methods_of(obj): if __name__ == '__main__': - utils.default_flagfile() + utils.default_flagfile('/etc/nova/nova-manage.conf') argv = FLAGS(sys.argv) script_name = argv.pop(0) if len(argv) < 1: |
