Merge "NSXv3: Fix DHCP upgrade script"
This commit is contained in:
commit
78838243a9
@ -118,7 +118,8 @@ def nsx_update_dhcp_bindings(resource, event, trigger, **kwargs):
|
|||||||
lswitch_id = neutron_client.net_id_to_lswitch_id(network_id)
|
lswitch_id = neutron_client.net_id_to_lswitch_id(network_id)
|
||||||
bindings = port_bindings.get(lswitch_id, [])
|
bindings = port_bindings.get(lswitch_id, [])
|
||||||
bindings.append((port['id'], port['mac_address'],
|
bindings.append((port['id'], port['mac_address'],
|
||||||
fixed_ip['ip_address']))
|
fixed_ip['ip_address'],
|
||||||
|
fixed_ip['subnet_id']))
|
||||||
port_bindings[lswitch_id] = bindings
|
port_bindings[lswitch_id] = bindings
|
||||||
break # process only the first IPv4 address
|
break # process only the first IPv4 address
|
||||||
|
|
||||||
@ -127,14 +128,17 @@ def nsx_update_dhcp_bindings(resource, event, trigger, **kwargs):
|
|||||||
dhcp_server_id = server_bindings.get(lswitch_id)
|
dhcp_server_id = server_bindings.get(lswitch_id)
|
||||||
if not dhcp_server_id:
|
if not dhcp_server_id:
|
||||||
continue
|
continue
|
||||||
for (port_id, mac, ip) in bindings:
|
for (port_id, mac, ip, subnet_id) in bindings:
|
||||||
hostname = 'host-%s' % ip.replace('.', '-')
|
hostname = 'host-%s' % ip.replace('.', '-')
|
||||||
options = {'option121': {'static_routes': [
|
options = {'option121': {'static_routes': [
|
||||||
{'network': '%s' % cfg.CONF.nsx_v3.native_metadata_route,
|
{'network': '%s' % cfg.CONF.nsx_v3.native_metadata_route,
|
||||||
'next_hop': ip}]}}
|
'next_hop': ip}]}}
|
||||||
dhcp_server_resource.create_binding(
|
binding = dhcp_server_resource.create_binding(
|
||||||
dhcp_server_id, mac, ip, hostname,
|
dhcp_server_id, mac, ip, hostname,
|
||||||
cfg.CONF.nsx_v3.dhcp_lease_time, options)
|
cfg.CONF.nsx_v3.dhcp_lease_time, options)
|
||||||
|
# Add DHCP static binding in neutron DB.
|
||||||
|
neutron_client.add_dhcp_static_binding(
|
||||||
|
port_id, subnet_id, ip, dhcp_server_id, binding['id'])
|
||||||
LOG.info(_LI("Added DHCP binding (mac: %(mac)s, ip: %(ip)s) "
|
LOG.info(_LI("Added DHCP binding (mac: %(mac)s, ip: %(ip)s) "
|
||||||
"for neutron port %(port)s"),
|
"for neutron port %(port)s"),
|
||||||
{'mac': mac, 'ip': ip, 'port': port_id})
|
{'mac': mac, 'ip': ip, 'port': port_id})
|
||||||
|
@ -66,6 +66,12 @@ class NeutronDbClient(db_base_plugin_v2.NeutronDbPluginV2):
|
|||||||
self.context.session, network_id, port_id,
|
self.context.session, network_id, port_id,
|
||||||
nsx_constants.SERVICE_DHCP, server_id)
|
nsx_constants.SERVICE_DHCP, server_id)
|
||||||
|
|
||||||
|
def add_dhcp_static_binding(self, port_id, subnet_id, ip_address,
|
||||||
|
server_id, binding_id):
|
||||||
|
return nsx_db.add_neutron_nsx_dhcp_binding(
|
||||||
|
self.context.session, port_id, subnet_id, ip_address, server_id,
|
||||||
|
binding_id)
|
||||||
|
|
||||||
|
|
||||||
class NsxV3PluginWrapper(plugin.NsxV3Plugin):
|
class NsxV3PluginWrapper(plugin.NsxV3Plugin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user