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. " "Error point %(error_point)s. "
"Cannot %(action)s while the vnf is in this state " "Cannot %(action)s while the vnf is in this state "
"with this error point.") "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 copy
import eventlet import eventlet
import importlib import importlib
import ipaddress
import os import os
import re
import sys import sys
import time import time
import yaml import yaml
@ -1558,8 +1558,8 @@ class OpenStack(abstract_driver.VnfAbstractDriver,
vnfc_cp.cp_protocol_info = [] vnfc_cp.cp_protocol_info = []
cp_protocol_info = objects.CpProtocolInfo() cp_protocol_info = objects.CpProtocolInfo()
cp_protocol_info.layer_protocol = '\ cp_protocol_info.layer_protocol = \
IP_OVER_ETHERNET' 'IP_OVER_ETHERNET'
ip_over_ethernet = objects.\ ip_over_ethernet = objects.\
IpOverEthernetAddressInfo() IpOverEthernetAddressInfo()
ip_over_ethernet.mac_address = rsc_info.\ ip_over_ethernet.mac_address = rsc_info.\
@ -1573,15 +1573,19 @@ class OpenStack(abstract_driver.VnfAbstractDriver,
ip_addresses.addresses = [] ip_addresses.addresses = []
for fixed_ip in rsc_info.attributes.get( for fixed_ip in rsc_info.attributes.get(
'fixed_ips'): 'fixed_ips'):
ip_addr = fixed_ip.get('ip_address') try:
if re.match( ip_addr = fixed_ip.get(
r'^\d{1,3}\ 'ip_address')
(\.\d{1,3}){3}\ ip_addresses.type = \
(/\d{1,2})?$', 'IPV{}'.format(
ip_addr): ipaddress.ip_address(
ip_addresses.type = 'IPV4' ip_addr).version)
else: except ValueError:
ip_addresses.type = 'IPV6' 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.addresses.append(ip_addr)
ip_addresses.subnet_id = fixed_ip.get( ip_addresses.subnet_id = fixed_ip.get(
'subnet_id') 'subnet_id')
@ -1599,8 +1603,8 @@ class OpenStack(abstract_driver.VnfAbstractDriver,
vim_connection_info.id vim_connection_info.id
resource.resource_id =\ resource.resource_id =\
rsc_info.physical_resource_id rsc_info.physical_resource_id
resource.vim_level_resource_type = '\ resource.vim_level_resource_type =\
OS::Neutron::Port' 'OS::Neutron::Port'
if not vl.vnf_link_ports: if not vl.vnf_link_ports:
vl.vnf_link_ports = [] vl.vnf_link_ports = []
link_port_info = objects.\ link_port_info = objects.\