blob: c1becc8d74e7e08909e600a644f6077134999a3e [file] [log] [blame]
Mike Marchetti08f04282017-05-04 16:43:09 -04001# Copyright 2017 Sandvine
2#
3# All Rights Reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16
17import pytest
18import json
19
20
21def osm_add_options(parser):
22 parser.addoption("--osmhost", default="", help="osm hostname")
Mike Marchettiaa245142018-08-17 13:54:21 -040023 parser.addoption("--sol005",action="store_true", help="enable sol005 API")
Mike Marchettif94dd8a2017-11-06 11:04:38 -050024 parser.addoption("--osm_ro_host", default="", help="osm ro_host")
Mike Marchetti08f04282017-05-04 16:43:09 -040025 parser.addoption("--osm-descriptor-packages", default="", help="location of descriptor packages")
26 parser.addoption("--osm-vnfd-descriptor-packages", default="", help="vnfd packages to test")
27 parser.addoption("--osm-nsd-descriptor-packages", default="", help="nsd package to test")
28 parser.addoption("--osmfile", action="store", default="", help="osm json data file")
29 parser.addoption("--osm-ns-name-prefix", action="store", default="", help="ns name prefix to apply")
30
31'''
32@pytest.fixture
33def osm(request):
34 from osmclient.common import OsmAPI
35 with open(request.config.getoption("--osm")) as json_data:
36 osmdict=json.load(json_data)
37 return OsmAPI.OsmAPI(osmdict['ip'])
38
39'''
40
41@pytest.fixture
42def osm(request):
43 from lib.osm import osm
44 osmhost=request.config.getoption("--osmhost")
Mike Marchettidbada222018-08-14 12:13:48 -040045 sol005=request.config.getoption("--sol005")
Mike Marchettif94dd8a2017-11-06 11:04:38 -050046 osm_ro_host=request.config.getoption("--osm_ro_host")
Mike Marchetti08f04282017-05-04 16:43:09 -040047 descriptors_dir=request.config.getoption("--osm-descriptor-packages")
48 vnfd_descriptors_list=request.config.getoption("--osm-vnfd-descriptor-packages").split(',')
49 nsd_descriptors_list=request.config.getoption("--osm-nsd-descriptor-packages").split(',')
50 ns_name_prefix=request.config.getoption("--osm-ns-name-prefix")
51 return osm.Osm(osmhost,
Mike Marchettif94dd8a2017-11-06 11:04:38 -050052 ro_host=osm_ro_host,
Mike Marchettiaa245142018-08-17 13:54:21 -040053 sol005=sol005,
Mike Marchetti08f04282017-05-04 16:43:09 -040054 descriptors_dir=descriptors_dir,
55 vnfd_descriptors_list=vnfd_descriptors_list,
56 nsd_descriptors_list=nsd_descriptors_list,
57 ns_name_prefix=ns_name_prefix)