~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to bin/nova-dhcpbridge

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
gettext.install('nova', unicode=1)
37
37
 
 
38
from nova import config
38
39
from nova import context
39
40
from nova import db
40
 
from nova import flags
41
41
from nova.network import linux_net
 
42
from nova.network import rpcapi as network_rpcapi
 
43
from nova.openstack.common import cfg
42
44
from nova.openstack.common import importutils
43
45
from nova.openstack.common import log as logging
44
46
from nova.openstack.common import rpc
45
47
from nova import utils
46
48
 
47
 
FLAGS = flags.FLAGS
48
 
 
 
49
CONF = cfg.CONF
 
50
CONF.import_opt('host', 'nova.config')
 
51
CONF.import_opt('network_manager', 'nova.config')
49
52
LOG = logging.getLogger('nova.dhcpbridge')
50
53
 
51
54
 
52
55
def add_lease(mac, ip_address):
53
56
    """Set the IP that was assigned by the DHCP server."""
54
 
    if FLAGS.fake_rabbit:
 
57
    if CONF.fake_rabbit:
55
58
        LOG.debug(_("leasing ip"))
56
 
        network_manager = importutils.import_object(FLAGS.network_manager)
 
59
        network_manager = importutils.import_object(CONF.network_manager)
57
60
        network_manager.lease_fixed_ip(context.get_admin_context(),
58
61
                                       ip_address)
59
62
    else:
60
 
        rpc.cast(context.get_admin_context(),
61
 
                 "%s.%s" % (FLAGS.network_topic, FLAGS.host),
62
 
                 {"method": "lease_fixed_ip",
63
 
                  "args": {"address": ip_address}})
 
63
        api = network_rpcapi.NetworkAPI()
 
64
        api.lease_fixed_ip(context.get_admin_context(), ip_address, CONF.host)
64
65
 
65
66
 
66
67
def old_lease(mac, ip_address):
73
74
 
74
75
def del_lease(mac, ip_address):
75
76
    """Called when a lease expires."""
76
 
    if FLAGS.fake_rabbit:
 
77
    if CONF.fake_rabbit:
77
78
        LOG.debug(_("releasing ip"))
78
 
        network_manager = importutils.import_object(FLAGS.network_manager)
 
79
        network_manager = importutils.import_object(CONF.network_manager)
79
80
        network_manager.release_fixed_ip(context.get_admin_context(),
80
81
                                         ip_address)
81
82
    else:
82
 
        rpc.cast(context.get_admin_context(),
83
 
                 "%s.%s" % (FLAGS.network_topic, FLAGS.host),
84
 
                 {"method": "release_fixed_ip",
85
 
                  "args": {"address": ip_address}})
 
83
        api = network_rpcapi.NetworkAPI()
 
84
        api.release_fixed_ip(context.get_admin_context(), ip_address,
 
85
                             CONF.host)
86
86
 
87
87
 
88
88
def init_leases(network_id):
89
89
    """Get the list of hosts for a network."""
90
90
    ctxt = context.get_admin_context()
91
91
    network_ref = db.network_get(ctxt, network_id)
92
 
    network_manager = importutils.import_object(FLAGS.network_manager)
 
92
    network_manager = importutils.import_object(CONF.network_manager)
93
93
    return network_manager.get_dhcp_leases(ctxt, network_ref)
94
94
 
95
95
 
96
96
def main():
97
97
    """Parse environment and arguments and call the approproate action."""
98
 
    flagfile = os.environ.get('FLAGFILE', FLAGS.dhcpbridge_flagfile)
99
 
    argv = flags.parse_args(sys.argv)
 
98
    flagfile = os.environ.get('FLAGFILE', CONF.dhcpbridge_flagfile)
 
99
    argv = config.parse_args(sys.argv, default_config_files=[flagfile])
100
100
    logging.setup("nova")
101
101
 
102
102
    if int(os.environ.get('TESTING', '0')):