initial commit of vif-plugging for network-service interfaces
This commit is contained in:
@@ -48,12 +48,11 @@ flags.DECLARE('auth_driver', 'nova.auth.manager')
|
|||||||
flags.DECLARE('network_size', 'nova.network.manager')
|
flags.DECLARE('network_size', 'nova.network.manager')
|
||||||
flags.DECLARE('num_networks', 'nova.network.manager')
|
flags.DECLARE('num_networks', 'nova.network.manager')
|
||||||
flags.DECLARE('update_dhcp_on_disassociate', 'nova.network.manager')
|
flags.DECLARE('update_dhcp_on_disassociate', 'nova.network.manager')
|
||||||
flags.DEFINE_string('dnsmasq_interface', 'br0', 'Default Dnsmasq interface')
|
|
||||||
|
|
||||||
LOG = logging.getLogger('nova.dhcpbridge')
|
LOG = logging.getLogger('nova.dhcpbridge')
|
||||||
|
|
||||||
|
|
||||||
def add_lease(mac, ip_address, _hostname, _interface):
|
def add_lease(mac, ip_address, _hostname):
|
||||||
"""Set the IP that was assigned by the DHCP server."""
|
"""Set the IP that was assigned by the DHCP server."""
|
||||||
if FLAGS.fake_rabbit:
|
if FLAGS.fake_rabbit:
|
||||||
LOG.debug(_("leasing ip"))
|
LOG.debug(_("leasing ip"))
|
||||||
@@ -67,13 +66,13 @@ def add_lease(mac, ip_address, _hostname, _interface):
|
|||||||
"args": {"address": ip_address}})
|
"args": {"address": ip_address}})
|
||||||
|
|
||||||
|
|
||||||
def old_lease(mac, ip_address, hostname, interface):
|
def old_lease(mac, ip_address, hostname):
|
||||||
"""Update just as add lease."""
|
"""Update just as add lease."""
|
||||||
LOG.debug(_("Adopted old lease or got a change of mac/hostname"))
|
LOG.debug(_("Adopted old lease or got a change of mac/hostname"))
|
||||||
add_lease(mac, ip_address, hostname, interface)
|
add_lease(mac, ip_address, hostname)
|
||||||
|
|
||||||
|
|
||||||
def del_lease(mac, ip_address, _hostname, _interface):
|
def del_lease(mac, ip_address, _hostname):
|
||||||
"""Called when a lease expires."""
|
"""Called when a lease expires."""
|
||||||
if FLAGS.fake_rabbit:
|
if FLAGS.fake_rabbit:
|
||||||
LOG.debug(_("releasing ip"))
|
LOG.debug(_("releasing ip"))
|
||||||
@@ -87,10 +86,10 @@ def del_lease(mac, ip_address, _hostname, _interface):
|
|||||||
"args": {"address": ip_address}})
|
"args": {"address": ip_address}})
|
||||||
|
|
||||||
|
|
||||||
def init_leases(interface):
|
def init_leases(network_id):
|
||||||
"""Get the list of hosts for an interface."""
|
"""Get the list of hosts for a network."""
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
network_ref = db.network_get_by_bridge(ctxt, interface)
|
network_ref = db.network_get(ctxt, network_id)
|
||||||
return linux_net.get_dhcp_leases(ctxt, network_ref)
|
return linux_net.get_dhcp_leases(ctxt, network_ref)
|
||||||
|
|
||||||
|
|
||||||
@@ -101,7 +100,8 @@ def main():
|
|||||||
argv = FLAGS(sys.argv)
|
argv = FLAGS(sys.argv)
|
||||||
logging.setup()
|
logging.setup()
|
||||||
# check ENV first so we don't break any older deploys
|
# check ENV first so we don't break any older deploys
|
||||||
interface = os.environ.get('DNSMASQ_INTERFACE', FLAGS.dnsmasq_interface)
|
network_id = int(os.environ.get('NETWORK_ID'))
|
||||||
|
|
||||||
if int(os.environ.get('TESTING', '0')):
|
if int(os.environ.get('TESTING', '0')):
|
||||||
from nova.tests import fake_flags
|
from nova.tests import fake_flags
|
||||||
|
|
||||||
@@ -117,11 +117,11 @@ def main():
|
|||||||
ip = argv[3]
|
ip = argv[3]
|
||||||
hostname = argv[4]
|
hostname = argv[4]
|
||||||
msg = _("Called %(action)s for mac %(mac)s with ip %(ip)s and"
|
msg = _("Called %(action)s for mac %(mac)s with ip %(ip)s and"
|
||||||
" hostname %(hostname)s on interface %(interface)s") % locals()
|
" hostname %(hostname)s on network %(network_id)s") % locals()
|
||||||
LOG.debug(msg)
|
LOG.debug(msg)
|
||||||
globals()[action + '_lease'](mac, ip, hostname, interface)
|
globals()[action + '_lease'](mac, ip, hostname)
|
||||||
else:
|
else:
|
||||||
print init_leases(interface)
|
print init_leases(network_id)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user