diff options
author | Manuel Buil <mbuil@suse.com> | 2017-09-14 18:56:18 +0200 |
---|---|---|
committer | Manuel Buil <mbuil@suse.com> | 2017-09-19 07:53:18 +0000 |
commit | 9c11d59035ff1741c5e6d935aa7c2ed23d15f485 (patch) | |
tree | 69f8f206735a661722b00254ad925ad78d214c64 /sfc/lib/utils.py | |
parent | 2aa0c27a5d4b0b0d31a9cc0c9dc07321538860f0 (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>
Diffstat (limited to 'sfc/lib/utils.py')
-rw-r--r-- | sfc/lib/utils.py | 38 |
1 files changed, 38 insertions, 0 deletions
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 |