~markmc/nova/flat-dhcp-without-bridge-iface

« back to all changes in this revision

Viewing changes to bin/nova-dhcpbridge

  • Committer: Tarmac
  • Author(s): Dan Wendlandt
  • Date: 2011-08-19 02:14:17 UTC
  • mfrom: (1450.5.3 nova)
  • Revision ID: tarmac-20110819021417-4ha3nrwrf2amiq60
Bugfix for lp 828429.  Its still not clear to me exactly how this code path is actually invoked when nova is used, so I'm looking for input on whether we should be adding a test case for this, removing the code as unused, etc.  Thanks.  

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
LOG = logging.getLogger('nova.dhcpbridge')
53
53
 
54
54
 
55
 
def add_lease(mac, ip_address, _interface):
 
55
def add_lease(mac, ip_address):
56
56
    """Set the IP that was assigned by the DHCP server."""
57
57
    if FLAGS.fake_rabbit:
58
58
        LOG.debug(_("leasing ip"))
66
66
                  "args": {"address": ip_address}})
67
67
 
68
68
 
69
 
def old_lease(mac, ip_address, interface):
 
69
def old_lease(mac, ip_address):
70
70
    """Update just as add lease."""
71
71
    LOG.debug(_("Adopted old lease or got a change of mac"))
72
 
    add_lease(mac, ip_address, interface)
73
 
 
74
 
 
75
 
def del_lease(mac, ip_address, _interface):
 
72
    add_lease(mac, ip_address)
 
73
 
 
74
 
 
75
def del_lease(mac, ip_address):
76
76
    """Called when a lease expires."""
77
77
    if FLAGS.fake_rabbit:
78
78
        LOG.debug(_("releasing ip"))
99
99
    utils.default_flagfile(flagfile)
100
100
    argv = FLAGS(sys.argv)
101
101
    logging.setup()
102
 
    # check ENV first so we don't break any older deploys
103
 
    network_id = int(os.environ.get('NETWORK_ID'))
104
102
 
105
103
    if int(os.environ.get('TESTING', '0')):
106
104
        from nova.tests import fake_flags
115
113
    if action in ['add', 'del', 'old']:
116
114
        mac = argv[2]
117
115
        ip = argv[3]
118
 
        msg = _("Called %(action)s for mac %(mac)s with ip %(ip)s"
119
 
                " on interface %(interface)s") % locals()
 
116
        msg = _("Called '%(action)s' for mac '%(mac)s' with ip '%(ip)s'") % \
 
117
                    {"action": action,
 
118
                     "mac": mac,
 
119
                     "ip": ip}
120
120
        LOG.debug(msg)
121
 
        globals()[action + '_lease'](mac, ip, interface)
 
121
        globals()[action + '_lease'](mac, ip)
122
122
    else:
 
123
        try:
 
124
            network_id = int(os.environ.get('NETWORK_ID'))
 
125
        except TypeError:
 
126
            LOG.error(_("Environment variable 'NETWORK_ID' must be set."))
 
127
            sys.exit(1)
 
128
 
123
129
        print init_leases(network_id)
124
130
 
125
131
if __name__ == "__main__":