Merge "Refactor neutron tag resources for macvlan driver."

This commit is contained in:
Zuul
2020-02-06 16:30:25 +00:00
committed by Gerrit Code Review

View File

@@ -45,7 +45,7 @@ class NestedMacvlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
if not container_port: if not container_port:
container_port = neutron.create_port(req).get('port') container_port = neutron.create_port(req).get('port')
_tag_neutron_resources('ports', [container_port['id']]) _tag_neutron_port(container_port['id'])
container_mac = container_port['mac_address'] container_mac = container_port['mac_address']
container_ips = frozenset(entry['ip_address'] for entry in container_ips = frozenset(entry['ip_address'] for entry in
@@ -179,14 +179,15 @@ class NestedMacvlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
return attempts return attempts
def _tag_neutron_resources(resource, res_ids): def _tag_neutron_port(res_id):
tags = CONF.neutron_defaults.resource_tags tags = CONF.neutron_defaults.resource_tags
if tags:
neutron = clients.get_neutron_client() if not tags:
for res_id in res_ids: return
try:
neutron.replace_tag(resource, res_id, body={"tags": tags}) neutron = clients.get_neutron_client()
except n_exc.NeutronClientException: try:
LOG.warning("Failed to tag %s %s with %s. Ignoring, but this " neutron.replace_tag('ports', res_id, body={"tags": tags})
"is still unexpected.", resource, res_id, tags, except n_exc.NeutronClientException:
exc_info=True) LOG.warning("Failed to tag port %s with %s. Ignoring, but this is "
"still unexpected.", res_id, tags, exc_info=True)