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.
18 from emuvim
.api
.openstack
.openstack_api_endpoint
import OpenstackApiEndpoint
19 from emuvim
.api
.osm
.osm
import OSM
20 from emuvim
.dcemulator
.net
import DCNetwork
22 net
= DCNetwork(monitor
=False, enable_learning
=True)
23 dc1
= net
.addDatacenter("dc1")
24 api
= OpenstackApiEndpoint("0.0.0.0", 6001)
25 api
.connect_datacenter(dc1
)
26 api
.connect_dc_network(net
)
29 s1
= net
.addSwitch('s1')
30 s2
= net
.addSwitch('s2')
31 osm1
= OSM(net
, s1
, name
='1')
32 osm2
= OSM(net
, s2
, name
='2')
41 vim_id1
= osm1
.register_emulated_api('vim', api
)
42 osm1
.onboard_vnfd('vnfs/ping_vnf')
43 osm1
.onboard_vnfd('vnfs/pong_vnf')
44 nsd_id1
= osm1
.onboard_nsd('services/pingpong_ns')
45 ns_id1
= osm1
.ns_create('pingpong-test1', nsd_id1
, vim_id1
)
47 vim_id2
= osm2
.register_emulated_api('vim', api
)
48 osm2
.onboard_vnfd('vnfs/ping_vnf')
49 osm2
.onboard_vnfd('vnfs/pong_vnf')
50 nsd_id2
= osm2
.onboard_nsd('services/pingpong_ns')
51 ns_id2
= osm2
.ns_create('pingpong-test2', nsd_id2
, vim_id2
)
53 osm1
.ns_wait_until_all_in_status('running')
54 osm2
.ns_wait_until_all_in_status('running')
57 osm1
.ns_delete(ns_id1
)
58 osm2
.ns_delete(ns_id2
)
60 osm1
.ns_wait_until_all_in_status('terminated')
61 osm2
.ns_wait_until_all_in_status('terminated')