2 # Copyright (c) 2019 Erik Schilling
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
19 from emuvim
.api
.openstack
.openstack_api_endpoint
import OpenstackApiEndpoint
20 from emuvim
.api
.osm
.osm
import OSM
21 from emuvim
.dcemulator
.net
import DCNetwork
24 class PreConfiguredOSM
:
26 vca_host
=os
.environ
.get('VCA_HOST'),
27 vca_secret
=os
.environ
.get('VCA_SECRET'),
28 osm_version
='releasefive-daily'):
29 self
.net
= DCNetwork(monitor
=False, enable_learning
=True)
30 dc1
= self
.net
.addDatacenter("dc1")
31 self
.api
= OpenstackApiEndpoint("0.0.0.0", 6001)
32 self
.api
.connect_datacenter(dc1
)
33 self
.api
.connect_dc_network(self
.net
)
35 s1
= self
.net
.addSwitch('s1')
36 self
.osm
= OSM(self
.net
, s1
, vca_host
=vca_host
, vca_secret
=vca_secret
, osm_version
=osm_version
)
37 self
.vim_emu_id
= None
43 def __exit__(self
, exc_type
, exc_val
, exc_tb
):
50 self
.vim_emu_id
= self
.osm
.register_emulated_api('emu-vim1', self
.api
)
56 def ns_create(self
, ns_name
, nsd_id
):
57 return self
.osm
.ns_create(ns_name
, nsd_id
, self
.vim_emu_id
)
59 # forward api related calls
60 def onboard_vnfd(self
, *args
, **kwargs
):
61 return self
.osm
.onboard_vnfd(*args
, **kwargs
)
63 def onboard_nsd(self
, *args
, **kwargs
):
64 return self
.osm
.onboard_nsd(*args
, **kwargs
)
67 return self
.osm
.ns_list()
69 def ns_delete(self
, *args
, **kwargs
):
70 return self
.osm
.ns_delete(*args
, **kwargs
)
72 def ns_get(self
, *args
, **kwargs
):
73 return self
.osm
.ns_get(*args
, **kwargs
)
75 def ns_action(self
, *args
, **kwargs
):
76 return self
.osm
.ns_action(*args
, **kwargs
)
78 def ns_wait_until_all_in_status(self
, *args
, **kwargs
):
79 return self
.osm
.ns_wait_until_all_in_status(*args
, **kwargs
)