3 # Copyright 2016 RIFT.IO Inc
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.
21 gi
.require_version('RwTypes', '1.0')
22 gi
.require_version('RwSdn', '1.0')
23 from gi
.repository
import (
34 logger
= logging
.getLogger('rwsdn')
36 rwstatus
= rw_status
.rwstatus_from_exc_map({
37 IndexError: RwTypes
.RwStatus
.NOTFOUND
,
38 KeyError: RwTypes
.RwStatus
.NOTFOUND
,
43 class TopologyPlugin(GObject
.Object
, RwSdn
.Topology
):
45 GObject
.Object
.__init
__(self
)
49 def do_init(self
, rwlog_ctx
):
51 "sdnsim": rift
.sdn
.SdnSim
,
52 "mock": rift
.sdn
.Mock
,
63 for name
, impl
in providers
.items():
65 self
._impl
[name
] = impl()
68 msg
= "unable to load SDN implementation for {}"
69 logger
.exception(msg
.format(name
))
72 def do_get_network_list(self
, account
, network_top
):
73 obj
= self
._impl
[account
.account_type
]
74 return obj
.get_network_list(account
, network_top
)
82 assert(a
== RwTypes
.RwStatus
.NOTFOUND
)
84 @rwstatus({IndexError: RwTypes
.RwStatus
.NOTCONNECTED
})
90 assert(a
== RwTypes
.RwStatus
.NOTCONNECTED
)
91 assert(blah2
.__doc__
== "Some function")
93 if __name__
== '__main__':