aboutsummaryrefslogtreecommitdiffstats
path: root/sfc
diff options
context:
space:
mode:
authorManuel Buil <mbuil@suse.com>2017-09-14 18:56:18 +0200
committerManuel Buil <mbuil@suse.com>2017-09-20 07:11:41 +0000
commit2ce3eccae3de3f97c2ad8b2041d1b068d070a6e3 (patch)
tree69f8f206735a661722b00254ad925ad78d214c64 /sfc
parent3cea8f88d68e71e22be478beab8ce94a0d352392 (diff)
Create vnffg providing the neutron_port
JIRA: SFC-107 We are submitting the vnffgd with a variable for the neutron_port. Before creating the vnffg, we must provide a file with the neutron_port value Change-Id: I9994e2baa53f323df17434448d372598c0d94c72 Signed-off-by: Manuel Buil <mbuil@suse.com> (cherry picked from commit 9c11d59035ff1741c5e6d935aa7c2ed23d15f485)
Diffstat (limited to 'sfc')
-rw-r--r--sfc/lib/openstack_tacker.py13
-rw-r--r--sfc/lib/utils.py38
-rw-r--r--sfc/tests/functest/sfc_one_chain_two_service_functions.py8
-rw-r--r--sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py15
-rw-r--r--sfc/tests/functest/vnffgd-templates/test2-vnffgd1.yaml5
-rw-r--r--sfc/tests/functest/vnffgd-templates/test2-vnffgd2.yaml6
6 files changed, 70 insertions, 15 deletions
diff --git a/sfc/lib/openstack_tacker.py b/sfc/lib/openstack_tacker.py
index 93649e32..a4077744 100644
--- a/sfc/lib/openstack_tacker.py
+++ b/sfc/lib/openstack_tacker.py
@@ -241,7 +241,7 @@ def create_vnffgd(tacker_client, tosca_file=None, vnffgd_name=None):
vnffgd_body = {}
if tosca_file is not None:
with open(tosca_file) as tosca_fd:
- vnffgd_body = yaml.load(tosca_fd)
+ vnffgd_body = yaml.safe_load(tosca_fd)
logger.info('VNFFGD template:\n{0}'.format(vnffgd_body))
return tacker_client.create_vnffgd(
body={'vnffgd': {'name': vnffgd_name,
@@ -253,10 +253,9 @@ def create_vnffgd(tacker_client, tosca_file=None, vnffgd_name=None):
def create_vnffg(tacker_client, vnffg_name=None, vnffgd_id=None,
- vnffgd_name=None):
+ vnffgd_name=None, param_file=None):
'''
- Tacker doesn't support Symmetrical chain and parameter file
- in Openstack/Ocata
+ Creates the vnffg which will provide the RSP and the classifier
'''
try:
vnffg_body = {
@@ -265,6 +264,12 @@ def create_vnffg(tacker_client, vnffg_name=None, vnffgd_id=None,
'name': vnffg_name
}
}
+ if param_file is not None:
+ params = None
+ with open(param_file) as f:
+ params = f.read()
+ params_dict = yaml.safe_load(params)
+ vnffg_body['vnffg']['attributes']['param_values'] = params_dict
if vnffgd_id is not None:
vnffg_body['vnffg']['vnffgd_id'] = vnffgd_id
else:
diff --git a/sfc/lib/utils.py b/sfc/lib/utils.py
index 392f1db5..9d44b3eb 100644
--- a/sfc/lib/utils.py
+++ b/sfc/lib/utils.py
@@ -117,6 +117,25 @@ def create_vnf_in_av_zone(
param_file=param_file)
+def create_vnffg_with_param_file(tacker_client, vnffgd_name, vnffg_name,
+ default_param_file, neutron_port):
+ param_file = default_param_file
+
+ if neutron_port is not None:
+ param_file = os.path.join(
+ '/tmp',
+ 'param_{0}.json'.format(neutron_port))
+ data = {
+ 'net_src_port_id': neutron_port
+ }
+ with open(param_file, 'w+') as f:
+ json.dump(data, f)
+ os_tacker.create_vnffg(tacker_client,
+ vnffgd_name=vnffgd_name,
+ vnffg_name=vnffg_name,
+ param_file=param_file)
+
+
def setup_neutron(neutron_client, net, subnet, router, subnet_cidr):
n_dict = os_utils.create_network_full(neutron_client,
net,
@@ -647,3 +666,22 @@ def register_vim(tacker_client, vim_file=None):
json.dump(json_dict, open(tmp_file, 'w'))
os_tacker.create_vim(tacker_client, vim_file=tmp_file)
+
+
+def get_neutron_interfaces(vm):
+ '''
+ Get the interfaces of an instance
+ '''
+ nova_client = os_utils.get_nova_client()
+ interfaces = nova_client.servers.interface_list(vm.id)
+ return interfaces
+
+
+def get_client_port_id(vm):
+ '''
+ Get the neutron port id of the client
+ '''
+ interfaces = get_neutron_interfaces(vm)
+ if len(interfaces) > 1:
+ raise Exception("Client has more than one interface. Not expected!")
+ return interfaces[0].id
diff --git a/sfc/tests/functest/sfc_one_chain_two_service_functions.py b/sfc/tests/functest/sfc_one_chain_two_service_functions.py
index 0f4d6aa9..2125f3e1 100644
--- a/sfc/tests/functest/sfc_one_chain_two_service_functions.py
+++ b/sfc/tests/functest/sfc_one_chain_two_service_functions.py
@@ -191,9 +191,11 @@ def main():
tosca_file=tosca_file,
vnffgd_name='red')
- os_tacker.create_vnffg(tacker_client,
- vnffgd_name='red',
- vnffg_name='red_http')
+ neutron_port = test_utils.get_client_port_id(client_instance)
+ test_utils.create_vnffg_with_param_file(tacker_client, 'red',
+ 'red_http',
+ default_param_file,
+ neutron_port)
# Start measuring the time it takes to implement the classification rules
t1 = threading.Thread(target=test_utils.wait_for_classification_rules,
diff --git a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
index 22249c25..031fc005 100644
--- a/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
+++ b/sfc/tests/functest/sfc_two_chains_SSH_and_HTTP.py
@@ -185,9 +185,11 @@ def main():
tosca_file=tosca_file,
vnffgd_name='red')
- os_tacker.create_vnffg(tacker_client,
- vnffgd_name='red',
- vnffg_name='red_http_works')
+ neutron_port = test_utils.get_client_port_id(client_instance)
+ test_utils.create_vnffg_with_param_file(tacker_client, 'red',
+ 'red_http',
+ default_param_file,
+ neutron_port)
# Start measuring the time it takes to implement the classification rules
t1 = threading.Thread(target=test_utils.wait_for_classification_rules,
@@ -270,9 +272,10 @@ def main():
tosca_file=tosca_file,
vnffgd_name='blue')
- os_tacker.create_vnffg(tacker_client,
- vnffgd_name='blue',
- vnffg_name='blue_ssh_works')
+ test_utils.create_vnffg_with_param_file(tacker_client, 'blue',
+ 'blue_ssh',
+ default_param_file,
+ neutron_port)
# Start measuring the time it takes to implement the classification rules
t2 = threading.Thread(target=test_utils.wait_for_classification_rules,
diff --git a/sfc/tests/functest/vnffgd-templates/test2-vnffgd1.yaml b/sfc/tests/functest/vnffgd-templates/test2-vnffgd1.yaml
index 24a32db4..f0615e4e 100644
--- a/sfc/tests/functest/vnffgd-templates/test2-vnffgd1.yaml
+++ b/sfc/tests/functest/vnffgd-templates/test2-vnffgd1.yaml
@@ -4,6 +4,9 @@ description: test-case2_HTTP Test
topology_template:
description: topology-template-test2
+ inputs:
+ net_src_port_id:
+ type: string
node_templates:
Forwarding_path1:
@@ -14,7 +17,7 @@ topology_template:
policy:
type: ACL
criteria:
- - source_port_range: 0-0
+ - network_src_port_id: {get_input: net_src_port_id}
- destination_port_range: 22-80
- ip_proto: 6
path:
diff --git a/sfc/tests/functest/vnffgd-templates/test2-vnffgd2.yaml b/sfc/tests/functest/vnffgd-templates/test2-vnffgd2.yaml
index 401a4272..ec18c9d6 100644
--- a/sfc/tests/functest/vnffgd-templates/test2-vnffgd2.yaml
+++ b/sfc/tests/functest/vnffgd-templates/test2-vnffgd2.yaml
@@ -4,6 +4,10 @@ description: test-case2_SSH Test
topology_template:
description: topology-template-test2
+ inputs:
+ net_src_port_id:
+ type: string
+
node_templates:
Forwarding_path1:
@@ -14,7 +18,7 @@ topology_template:
policy:
type: ACL
criteria:
- - source_port_range: 0-0
+ - network_src_port_id: {get_input: net_src_port_id}
- destination_port_range: 22-80
- ip_proto: 6
path: