Add 'symmetrical' as property of a forwarding path

When Network Service (NS) is supported in Tacker, we can launch
multiple VNFFGs by initiating NS. Because each VNFFG can have
different 'symmetrical' value, we should support dynamic 'symmetrical'
parameter for each VNFFG in VNFFG descriptor.

This feature will add 'symmetrical' as a property of forwarding path,
so users can set 'symmetrical' value to 'true' or 'false' to change
symmetrical value of a port chain in networking-sfc.

Change-Id: Ie9a6abe96141954e95902cd426abafa10d744236
This commit is contained in:
Cong Phuoc Hoang 2018-07-25 15:29:08 +09:00
parent 210d8f93bb
commit df8be52ac7
15 changed files with 102 additions and 46 deletions

View File

@ -12,11 +12,13 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
echo "Deleting network service NS1" echo "Deleting network service NS1, NS2"
network_service_id=$(openstack ns list | grep NS1 | awk '{print $2}') for ns in NS1 NS2; do
if [ -n "$network_service_id" ]; then network_service_id=$(openstack ns list | grep $ns | awk '{print $2}')
openstack ns delete $network_service_id if [ -n "$network_service_id" ]; then
fi openstack ns delete $network_service_id
fi
done
sleep 5 sleep 5

View File

@ -31,6 +31,7 @@ sleep 15
client_ip=$(openstack server list | grep http_client | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+') client_ip=$(openstack server list | grep http_client | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')
network_source_port_id=$(openstack port list | grep $client_ip | awk '{print $2}') network_source_port_id=$(openstack port list | grep $client_ip | awk '{print $2}')
ip_dst=$(openstack server list | grep http_server | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+') ip_dst=$(openstack server list | grep http_server | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')
network_dest_port_id=$(openstack port list | grep $ip_dst | awk '{print $2}')
echo "Creating/ Updating ns_param.yaml file" echo "Creating/ Updating ns_param.yaml file"
cat > ../../samples/tosca-templates/vnffg-nsd/ns_param.yaml << EOL cat > ../../samples/tosca-templates/vnffg-nsd/ns_param.yaml << EOL
@ -39,6 +40,7 @@ nsd:
vl2_name: net0 vl2_name: net0
net_src_port_id: ${network_source_port_id} net_src_port_id: ${network_source_port_id}
ip_dest_prefix: ${ip_dst}/24 ip_dest_prefix: ${ip_dst}/24
net_dst_port_id: ${network_dest_port_id}
EOL EOL
vim_default=$(openstack vim list | grep openstack | awk '{print $10}') vim_default=$(openstack vim list | grep openstack | awk '{print $10}')

View File

@ -326,6 +326,7 @@ VNFFG.
description: creates path inside ns (src_port->CP12->CP22->dst_port) description: creates path inside ns (src_port->CP12->CP22->dst_port)
properties: properties:
id: 51 id: 51
symmetrical: true
policy: policy:
type: ACL type: ACL
criteria: criteria:
@ -346,6 +347,7 @@ VNFFG.
description: creates path inside ns (src_port->CP12->CP22->dst_port) description: creates path inside ns (src_port->CP12->CP22->dst_port)
properties: properties:
id: 52 id: 52
symmetrical: false
policy: policy:
type: ACL type: ACL
criteria: criteria:

View File

@ -123,14 +123,32 @@ without "symmetrical", you can ommit "network_dst_port_id" and "ip_dst_prefix".
.. code-block:: yaml .. code-block:: yaml
policy: Forwarding_path1:
type: ACL type: tosca.nodes.nfv.FP.TackerV2
criteria: description: creates path (CP12->CP22)
- network_src_port_id: 640dfd77-c92b-45a3-b8fc-22712de480e1 properties:
network_dst_port_id: ea206bba-7083-4364-a9f1-c0b7fdf61b6e id: 51
destination_port_range: 80-1024 symmetrical: true
ip_proto: 6 policy:
ip_dst_prefix: 192.168.1.2/24 type: ACL
criteria:
- name: block_tcp
classifier:
network_src_port_id: 640dfd77-c92b-45a3-b8fc-22712de480e1
network_dst_port_id: ea206bba-7083-4364-a9f1-c0b7fdf61b6e
ip_dst_prefix: 192.168.1.2/24
destination_port_range: 80-1024
ip_proto: 6
path:
- forwarder: VNFD1
capability: CP12
- forwarder: VNFD2
capability: CP22
In above template, users can set **symmetrical** in properties of a forwarding
path create symmetrical VNFFG. If this property is not set, **symmetrical**
will be specified by **--symmetrical** in create VNFFG command (default value
is False).
You can use the sample VNFFGD template for symmetrical feature (in port chain) You can use the sample VNFFGD template for symmetrical feature (in port chain)
such as this `link <https://github.com/openstack/tacker/tree/master/samples/ such as this `link <https://github.com/openstack/tacker/tree/master/samples/
@ -196,7 +214,7 @@ Here,
* param-file - Parameter file in Yaml. * param-file - Parameter file in Yaml.
* vnf-mapping - Allows a list of logical VNFD to VNF instance mapping * vnf-mapping - Allows a list of logical VNFD to VNF instance mapping
* symmetrical - If --symmetrical is present, symmetrical is True * symmetrical - If --symmetrical is present, symmetrical is True
(default: False) (default: False - The **symmectical** is set in template has higher priority)
VNF Mapping is used to declare which exact VNF instance to be used for VNF Mapping is used to declare which exact VNF instance to be used for
each VNF in the Forwarding Path. The following command would list VNFs each VNF in the Forwarding Path. The following command would list VNFs
@ -281,12 +299,12 @@ Using the below command query the list of existing VNFFG templates.
openstack vnf graph list openstack vnf graph list
+--------------------+--------+------- +-------------------------------------+ +--------------------+---------+--------+-------------------------------------+
| ID | Name | Status | VNFFGD ID | | ID | Name | Status | VNFFGD ID |
+--------------------+-----------------+-------------------------------------+ +--------------------+------------------+-------------------------------------+
| f4438511-e33d-43df-| | | | | f4438511-e33d-43df-| | | |
| 95d9-0199253db72e | myvnffg| ACTIVE | bd7829bf-85de-4f3b-960a-8482028bfb34| | 95d9-0199253db72e | myvnffg | ACTIVE | bd7829bf-85de-4f3b-960a-8482028bfb34|
+--------------------+---------+-------+-------------+--------+--------------+ +--------------------+---------+--------+-------------+--------+--------------+
After the user located the VNFFG the subsequent action is to update it. After the user located the VNFFG the subsequent action is to update it.
@ -341,6 +359,7 @@ derived from the following VNFFGD template.
description: creates path (CP1) description: creates path (CP1)
properties: properties:
id: 51 id: 51
symmetrical: false
policy: policy:
type: ACL type: ACL
criteria: criteria:
@ -382,6 +401,7 @@ By using the below VNFFGD template we can update the exisitng VNFFG.
description: creates path (CP1->CP2) description: creates path (CP1->CP2)
properties: properties:
id: 52 id: 52
symmetrical: false
policy: policy:
type: ACL type: ACL
criteria: criteria:

View File

@ -0,0 +1,6 @@
---
features:
- |
This feature adds 'symmetrical' as a property of forwarding path,
so users can set 'symmetrical' value to 'true' or 'false' to change
the symmetrical value of a port chain in networking-sfc.

View File

@ -1,5 +1,6 @@
nsd: nsd:
vl1_name: net_mgmt vl1_name: net_mgmt
vl2_name: net0 vl2_name: net0
net_src_port_id: 22566484-6585-483b-9f70-0c2811895f96 net_src_port_id: 5610a59a-68d3-431b-aa11-843744e81041
ip_dest_prefix: 10.10.0.11/24 ip_dest_prefix: 10.10.0.5/24
net_dst_port_id: 0eed8399-6c51-4eee-b037-0999c93ac898

View File

@ -48,12 +48,14 @@ topology_template:
description: creates path inside ns (src_port->CP12->CP22->dst_port) description: creates path inside ns (src_port->CP12->CP22->dst_port)
properties: properties:
id: 51 id: 51
symmetrical: true
policy: policy:
type: ACL type: ACL
criteria: criteria:
- name: block_tcp - name: block_tcp
classifier: classifier:
network_src_port_id: {get_input: net_src_port_id} network_src_port_id: {get_input: net_src_port_id}
network_dst_port_id: {get_input: net_dst_port_id}
destination_port_range: 80-1024 destination_port_range: 80-1024
ip_proto: 6 ip_proto: 6
ip_dst_prefix: {get_input: ip_dest_prefix} ip_dst_prefix: {get_input: ip_dest_prefix}
@ -68,6 +70,7 @@ topology_template:
description: creates path inside ns (src_port->CP12->dst_port) description: creates path inside ns (src_port->CP12->dst_port)
properties: properties:
id: 52 id: 52
symmetrical: false
policy: policy:
type: ACL type: ACL
criteria: criteria:

View File

@ -18,6 +18,9 @@ topology_template:
net_src_port_id: net_src_port_id:
type: string type: string
description: neutron port id of source port description: neutron port id of source port
net_dst_port_id:
type: string
description: neutron port id of destination port
ip_dest_prefix: ip_dest_prefix:
type: string type: string
description: IP prefix of destination port description: IP prefix of destination port
@ -48,12 +51,14 @@ topology_template:
description: creates path inside ns (src_port->CP12->CP22->dst_port) description: creates path inside ns (src_port->CP12->CP22->dst_port)
properties: properties:
id: 51 id: 51
symmetrical: true
policy: policy:
type: ACL type: ACL
criteria: criteria:
- name: block_tcp - name: block_tcp
classifier: classifier:
network_src_port_id: {get_input: net_src_port_id} network_src_port_id: {get_input: net_src_port_id}
network_dst_port_id: {get_input: net_dst_port_id}
destination_port_range: 80-1024 destination_port_range: 80-1024
ip_proto: 6 ip_proto: 6
ip_dst_prefix: {get_input: ip_dest_prefix} ip_dst_prefix: {get_input: ip_dest_prefix}
@ -64,7 +69,6 @@ topology_template:
capability: CP22 capability: CP22
groups: groups:
VNFFG1: VNFFG1:
type: tosca.groups.nfv.VNFFG type: tosca.groups.nfv.VNFFG
description: HTTP to Corporate Net description: HTTP to Corporate Net

View File

@ -11,6 +11,7 @@ topology_template:
description: creates path (CP12->CP22) description: creates path (CP12->CP22)
properties: properties:
id: 51 id: 51
symmetrical: true
policy: policy:
type: ACL type: ACL
criteria: criteria:

View File

@ -11,6 +11,7 @@ topology_template:
description: creates path (CP12->CP22) description: creates path (CP12->CP22)
properties: properties:
id: 51 id: 51
symmetrical: true
policy: policy:
type: ACL type: ACL
criteria: criteria:

View File

@ -1,6 +1,3 @@
{ net_src_port_id: 640dfd77-c92b-45a3-b8fc-22712de480e1
net_src_port_id: 640dfd77-c92b-45a3-b8fc-22712de480e1 dst_port_range: 80-1024
dst_port_range: 80-1024 ip_dst_pre: 192.168.1.2/24
ip_dst_pre:
- 192.168.1.2/24
}

View File

@ -358,7 +358,9 @@ class VnffgPluginDbMixin(vnffg.VNFFGPluginBase, db_base.CommonDbMixin):
vnffg_id = vnffg.get('id') or uuidutils.generate_uuid() vnffg_id = vnffg.get('id') or uuidutils.generate_uuid()
template_id = vnffg['vnffgd_id'] template_id = vnffg['vnffgd_id']
ns_id = vnffg.get('ns_id', None) ns_id = vnffg.get('ns_id', None)
symmetrical = vnffg['symmetrical'] symmetrical_in_temp = self._get_symmetrical_template(context, vnffg)
symmetrical = symmetrical_in_temp if symmetrical_in_temp is not None \
else vnffg.get('symmetrical')
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
template_db = self._get_resource(context, VnffgTemplate, template_db = self._get_resource(context, VnffgTemplate,
@ -1336,6 +1338,19 @@ class VnffgPluginDbMixin(vnffg.VNFFGPluginBase, db_base.CommonDbMixin):
if template_db.get('template_source') == 'inline': if template_db.get('template_source') == 'inline':
self.delete_vnffgd(context, vnffgd_id) self.delete_vnffgd(context, vnffgd_id)
def _get_symmetrical_template(self, context, vnffg):
vnffgd_topo = None
if vnffg.get('vnffgd_template'):
vnffgd_topo = vnffg['vnffgd_template']['topology_template']
elif vnffg.get('vnffgd_id'):
vnffgd_template = self.get_vnffgd(context, vnffg.get('vnffgd_id'))
vnffgd_topo = vnffgd_template['template']['vnffgd'][
'topology_template']
vnffg_name = list(vnffgd_topo['groups'].keys())[0]
nfp_name = vnffgd_topo['groups'][vnffg_name]['members'][0]
fp_prop = vnffgd_topo['node_templates'][nfp_name]['properties']
return fp_prop.get('symmetrical', None)
def _make_template_dict(self, template, fields=None): def _make_template_dict(self, template, fields=None):
res = {} res = {}
key_list = ('id', 'tenant_id', 'name', 'description', 'template', key_list = ('id', 'tenant_id', 'name', 'description', 'template',

View File

@ -256,10 +256,11 @@ def get_dummy_vnffg_param_obj():
'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437',
'name': 'dummy_vnffg', 'name': 'dummy_vnffg',
u'attributes': { u'attributes': {
u'template': vnffgd_tosca_param_template}, u'template': vnffgd_tosca_param_template,
u'param_values':
yaml.safe_load(vnffg_params)
},
'vnf_mapping': {}, 'vnf_mapping': {},
u'attributes': {u'param_values':
yaml.safe_load(vnffg_params)},
'symmetrical': False}} 'symmetrical': False}}
@ -269,10 +270,9 @@ def get_dummy_vnffg_str_param_obj():
'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437',
'name': 'dummy_vnffg', 'name': 'dummy_vnffg',
u'attributes': { u'attributes': {
u'template': vnffgd_tosca_param_template}, u'template': vnffgd_tosca_param_template,
'vnf_mapping': {},
u'attributes': {
u'param_values': 'value not dict format'}, u'param_values': 'value not dict format'},
'vnf_mapping': {},
'symmetrical': False}} 'symmetrical': False}}
@ -282,10 +282,11 @@ def get_dummy_vnffg_multi_param_obj():
'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437', 'tenant_id': u'ad7ebc56538745a08ef7c5e97f8bd437',
'name': 'dummy_vnffg', 'name': 'dummy_vnffg',
u'attributes': { u'attributes': {
u'template': vnffgd_tosca_multi_param_template}, u'template': vnffgd_tosca_multi_param_template,
u'param_values':
yaml.safe_load(vnffg_multi_params)
},
'vnf_mapping': {}, 'vnf_mapping': {},
u'attributes': {u'param_values':
yaml.safe_load(vnffg_multi_params)},
'symmetrical': False}} 'symmetrical': False}}

View File

@ -81,10 +81,6 @@ def get_by_name():
return False return False
def get_by_id():
return False
def dummy_get_vim_auth(*args, **kwargs): def dummy_get_vim_auth(*args, **kwargs):
return {'vim_auth': {u'username': u'admin', 'password': 'devstack', return {'vim_auth': {u'username': u'admin', 'password': 'devstack',
u'project_name': u'nfv', u'user_id': u'', u'project_name': u'nfv', u'user_id': u'',
@ -757,12 +753,11 @@ class TestNfvoPlugin(db_base.SqlTestCase):
symmetrical=mock.ANY symmetrical=mock.ANY
) )
@mock.patch.object(nfvo_plugin.NfvoPlugin, '_get_by_id') def test_create_vnffg_param_value_format_error(self):
def test_create_vnffg_param_value_format_error(self, mock_get_by_id):
with patch.object(TackerManager, 'get_service_plugins') as \ with patch.object(TackerManager, 'get_service_plugins') as \
mock_plugins: mock_plugins:
mock_plugins.return_value = {'VNFM': FakeVNFMPlugin()} mock_plugins.return_value = {'VNFM': FakeVNFMPlugin()}
mock_get_by_id.value = get_by_id() self._insert_dummy_vnffg_param_template()
vnffg_obj = utils.get_dummy_vnffg_str_param_obj() vnffg_obj = utils.get_dummy_vnffg_str_param_obj()
self.assertRaises(nfvo.VnffgParamValueFormatError, self.assertRaises(nfvo.VnffgParamValueFormatError,
self.nfvo_plugin.create_vnffg, self.nfvo_plugin.create_vnffg,

View File

@ -305,6 +305,9 @@ node_types:
id: id:
type: integer type: integer
required: false required: false
symmetrical:
type: boolean
required: false
policy: policy:
type: tosca.nfv.datatypes.policyTypeV2 type: tosca.nfv.datatypes.policyTypeV2
required: false required: false
@ -321,6 +324,9 @@ node_types:
id: id:
type: integer type: integer
required: false required: false
symmetrical:
type: boolean
required: false
policy: policy:
type: tosca.nfv.datatypes.policyType type: tosca.nfv.datatypes.policyType
required: true required: true