Merge "NSX|V3: Add user-friendly names for backend DHCP/MDPROXY entities"
This commit is contained in:
commit
53e6cdd275
@ -115,8 +115,12 @@ def add_neutron_nsx_security_group_mapping(session, neutron_id, nsx_id):
|
||||
|
||||
|
||||
def get_nsx_service_binding(session, network_id, service_type):
|
||||
return session.query(nsx_models.NeutronNsxServiceBinding).filter_by(
|
||||
network_id=network_id, nsx_service_type=service_type).one()
|
||||
try:
|
||||
return session.query(nsx_models.NeutronNsxServiceBinding).filter_by(
|
||||
network_id=network_id, nsx_service_type=service_type).one()
|
||||
except exc.NoResultFound:
|
||||
LOG.debug("NSX %s service not enabled on network %s", service_type,
|
||||
network_id)
|
||||
|
||||
|
||||
def add_neutron_nsx_service_binding(session, network_id, port_id,
|
||||
|
@ -51,9 +51,12 @@ def build_dhcp_server_config(network, subnet, port, project_name):
|
||||
'next_hop': gateway_ip})
|
||||
|
||||
options = {'option121': {'static_routes': host_routes}}
|
||||
name = utils.get_name_and_uuid(network['name'] or 'dhcpserver',
|
||||
network['id'])
|
||||
tags = utils.build_v3_tags_payload(
|
||||
network, resource_type='os-neutron-net-id', project_name=project_name)
|
||||
return {'dhcp_profile_id': cfg.CONF.nsx_v3.dhcp_profile_uuid,
|
||||
return {'name': name,
|
||||
'dhcp_profile_id': cfg.CONF.nsx_v3.dhcp_profile_uuid,
|
||||
'server_ip': server_ip,
|
||||
'dns_servers': dns_servers,
|
||||
'domain_name': cfg.CONF.nsx_v3.dns_domain,
|
||||
|
@ -473,8 +473,10 @@ class LogicalDhcpServer(AbstractRESTResource):
|
||||
return 'dhcp/servers'
|
||||
|
||||
def _construct_server(self, body, dhcp_profile_id=None, server_ip=None,
|
||||
dns_servers=None, domain_name=None, gateway_ip=None,
|
||||
options=None, tags=None):
|
||||
name=None, dns_servers=None, domain_name=None,
|
||||
gateway_ip=None, options=None, tags=None):
|
||||
if name:
|
||||
body['display_name'] = name
|
||||
if dhcp_profile_id:
|
||||
body['dhcp_profile_id'] = dhcp_profile_id
|
||||
if server_ip:
|
||||
@ -490,22 +492,24 @@ class LogicalDhcpServer(AbstractRESTResource):
|
||||
if tags:
|
||||
body['tags'] = tags
|
||||
|
||||
def create(self, dhcp_profile_id, server_ip, dns_servers=None,
|
||||
def create(self, dhcp_profile_id, server_ip, name=None, dns_servers=None,
|
||||
domain_name=None, gateway_ip=None, options=None, tags=None):
|
||||
body = {'ipv4_dhcp_server': {}}
|
||||
self._construct_server(body, dhcp_profile_id, server_ip, dns_servers,
|
||||
domain_name, gateway_ip, options, tags)
|
||||
self._construct_server(body, dhcp_profile_id, server_ip, name,
|
||||
dns_servers, domain_name, gateway_ip, options,
|
||||
tags)
|
||||
return self._client.create(body=body)
|
||||
|
||||
@utils.retry_upon_exception_nsxv3(
|
||||
nsx_exc.StaleRevision,
|
||||
max_attempts=cfg.CONF.nsx_v3.retries)
|
||||
def update(self, uuid, dhcp_profile_id=None, server_ip=None,
|
||||
def update(self, uuid, dhcp_profile_id=None, server_ip=None, name=None,
|
||||
dns_servers=None, domain_name=None, gateway_ip=None,
|
||||
options=None, tags=None):
|
||||
body = self._client.get(uuid)
|
||||
self._construct_server(body, dhcp_profile_id, server_ip, dns_servers,
|
||||
domain_name, gateway_ip, options, tags)
|
||||
self._construct_server(body, dhcp_profile_id, server_ip, name,
|
||||
dns_servers, domain_name, gateway_ip, options,
|
||||
tags)
|
||||
return self._client.update(uuid, body=body)
|
||||
|
||||
def create_binding(self, server_uuid, mac, ip, hostname=None,
|
||||
|
@ -674,9 +674,12 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
||||
tags = utils.build_v3_tags_payload(
|
||||
net_data, resource_type='os-neutron-net-id',
|
||||
project_name=context.tenant_name)
|
||||
name = utils.get_name_and_uuid('%s-%s' % (
|
||||
'mdproxy', created_net['name'] or 'network'),
|
||||
created_net['id'])
|
||||
md_port = self._port_client.create(
|
||||
nsx_net_id, cfg.CONF.nsx_v3.metadata_proxy_uuid,
|
||||
tags=tags,
|
||||
tags=tags, name=name,
|
||||
attachment_type=nsx_constants.ATTACHMENT_MDPROXY)
|
||||
LOG.info(_LI("Created MD-Proxy logical port %(port)s "
|
||||
"for network %(network)s"),
|
||||
@ -870,8 +873,9 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
||||
LOG.info(_LI("Created logical DHCP server %(server)s for network "
|
||||
"%(network)s"),
|
||||
{'server': dhcp_server['id'], 'network': network['id']})
|
||||
name = self._get_port_name(context, port_data)
|
||||
nsx_port = self._port_client.create(
|
||||
nsx_net_id, dhcp_server['id'], tags=tags,
|
||||
nsx_net_id, dhcp_server['id'], tags=tags, name=name,
|
||||
attachment_type=nsx_constants.ATTACHMENT_DHCP)
|
||||
LOG.info(_LI("Created DHCP logical port %(port)s for "
|
||||
"network %(network)s"),
|
||||
|
@ -1239,8 +1239,12 @@ class NsxNativeMetadataTestCase(NsxV3PluginTestCaseMixin):
|
||||
tags = utils.build_v3_tags_payload(
|
||||
network['network'], resource_type='os-neutron-net-id',
|
||||
project_name=None)
|
||||
name = utils.get_name_and_uuid('%s-%s' % (
|
||||
'mdproxy', network['network']['name'] or 'network'),
|
||||
network['network']['id'])
|
||||
create_logical_port.assert_called_once_with(
|
||||
nsx_net_id, cfg.CONF.nsx_v3.metadata_proxy_uuid, tags=tags,
|
||||
nsx_net_id, cfg.CONF.nsx_v3.metadata_proxy_uuid,
|
||||
tags=tags, name=name,
|
||||
attachment_type=nsx_constants.ATTACHMENT_MDPROXY)
|
||||
|
||||
def test_metadata_proxy_with_get_subnets(self):
|
||||
|
Loading…
Reference in New Issue
Block a user