Fix display bugs of vnflcm show command

When running openstack vnflcm show command in CLI,
some over intended bugs and ip version error will happen.

This patch fixes vnfm/infra_driver/openstack.py
in order to fix these bugs.

Closes-Bug: #1922544
Change-Id: Ie3b95c3bf2c62056dfd6ac659e32825c75d21fac
This commit is contained in:
LiangLu 2021-04-05 17:10:14 +08:00
parent 6fc64560e2
commit d471377772
2 changed files with 22 additions and 14 deletions

View File

@ -423,3 +423,7 @@ class VnfConflictStateWithErrorPoint(Conflict):
"Error point %(error_point)s. "
"Cannot %(action)s while the vnf is in this state "
"with this error point.")
class InvalidIpAddr(TackerException):
message = _('Invalid ip address value in resource %(id)s.')

View File

@ -17,8 +17,8 @@
import copy
import eventlet
import importlib
import ipaddress
import os
import re
import sys
import time
import yaml
@ -1558,8 +1558,8 @@ class OpenStack(abstract_driver.VnfAbstractDriver,
vnfc_cp.cp_protocol_info = []
cp_protocol_info = objects.CpProtocolInfo()
cp_protocol_info.layer_protocol = '\
IP_OVER_ETHERNET'
cp_protocol_info.layer_protocol = \
'IP_OVER_ETHERNET'
ip_over_ethernet = objects.\
IpOverEthernetAddressInfo()
ip_over_ethernet.mac_address = rsc_info.\
@ -1573,15 +1573,19 @@ class OpenStack(abstract_driver.VnfAbstractDriver,
ip_addresses.addresses = []
for fixed_ip in rsc_info.attributes.get(
'fixed_ips'):
ip_addr = fixed_ip.get('ip_address')
if re.match(
r'^\d{1,3}\
(\.\d{1,3}){3}\
(/\d{1,2})?$',
ip_addr):
ip_addresses.type = 'IPV4'
else:
ip_addresses.type = 'IPV6'
try:
ip_addr = fixed_ip.get(
'ip_address')
ip_addresses.type = \
'IPV{}'.format(
ipaddress.ip_address(
ip_addr).version)
except ValueError:
LOG.error("Invalid ip address %s"
" in resource %s.",
ip_addr, vnfc_rsc.id)
raise exceptions.InvalidIpAddr(
id=vnfc_rsc.id)
ip_addresses.addresses.append(ip_addr)
ip_addresses.subnet_id = fixed_ip.get(
'subnet_id')
@ -1599,8 +1603,8 @@ class OpenStack(abstract_driver.VnfAbstractDriver,
vim_connection_info.id
resource.resource_id =\
rsc_info.physical_resource_id
resource.vim_level_resource_type = '\
OS::Neutron::Port'
resource.vim_level_resource_type =\
'OS::Neutron::Port'
if not vl.vnf_link_ports:
vl.vnf_link_ports = []
link_port_info = objects.\