),
http_code=HTTPStatus.UNPROCESSABLE_ENTITY,
)
+ vnf_ip_list = set()
+ for ma in get_iterable(position.get("match-attributes")):
+ ma_source_ip = ma.get("source-ip-address")
+ ma_dest_ip = ma.get("destination-ip-address")
+ ma_vp_id = ""
+ if ma_source_ip and ma_dest_ip:
+ if ma_source_ip == ma_dest_ip:
+ raise EngineException(
+ "Error at vnffgd match-attributes:source-ip-address and destination-ip-address should not match",
+ http_code=HTTPStatus.UNPROCESSABLE_ENTITY,
+ )
+ if ma_source_ip:
+ for df in get_iterable(indata.get("df")):
+ for vp in get_iterable(df.get("vnf-profile")):
+ for vlc in get_iterable(
+ vp.get("virtual-link-connectivity")
+ ):
+ for cpd in get_iterable(
+ vlc.get("constituent-cpd-id")
+ ):
+ vnf_ip_list.add(cpd.get("ip-address"))
+ if ma_source_ip == cpd.get("ip-address"):
+ ma_vp_id = vp.get("id")
+ if ma_source_ip not in vnf_ip_list:
+ raise EngineException(
+ "Error at vnffgd match-attributes:source-ip-address='{}' "
+ "does not match any ip-address".format(ma_source_ip),
+ http_code=HTTPStatus.UNPROCESSABLE_ENTITY,
+ )
+ if ma_dest_ip not in vnf_ip_list:
+ raise EngineException(
+ "Error at vnffgd match-attributes:destination-ip-address='{}' "
+ "does not match any ip-address".format(ma_dest_ip),
+ http_code=HTTPStatus.UNPROCESSABLE_ENTITY,
+ )
+ constituent_base_element_id = ma.get("constituent-base-element-id")
+ if (
+ constituent_base_element_id
+ and constituent_base_element_id not in ma_vp_id
+ ):
+ raise EngineException(
+ "Error at vnffgd match-attributes:vnfd-id='{}' "
+ "does not match source constituent-base-element-id".format(
+ constituent_base_element_id
+ ),
+ http_code=HTTPStatus.UNPROCESSABLE_ENTITY,
+ )
@staticmethod
def validate_vnf_profiles_vnfd_id(indata):
destination-ip-address: 20.20.3.5
source-port: 0
destination-port: 80
+ constituent-base-element-id: '1'
nfp-position-element-id:
- test
nfp-position-element:
- constituent-cpd-id:
- constituent-base-element-id: '1'
constituent-cpd-id: eth0-ext
+ ip-address: 20.20.1.2
virtual-link-profile-id: osm-ext
vnfd-id: cirros_vnffg-vnf
+ - id: '2'
+ virtual-link-connectivity:
+ - constituent-cpd-id:
+ - constituent-base-element-id: '2'
+ constituent-cpd-id: eth0-ext
+ ip-address: 20.20.3.5
+ virtual-link-profile-id: osm-ext
+ vnfd-id: cirros_vnffg-vnf2
description: Simple NS example with vnffgd
"""