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.
28 gi
.require_version('RwTypes', '1.0')
29 gi
.require_version('RwcalYang', '1.0')
30 gi
.require_version('RwSdn', '1.0')
31 from gi
.repository
import (
36 #IetfL2TopologyYang as l2Tl,
37 RwTopologyYang
as RwTl
,
43 from rift
.topmgr
.sdnsim
import SdnSim
46 logger
= logging
.getLogger('rwsdn.sdnsim')
49 class UnknownAccountError(Exception):
53 class MissingFileError(Exception):
57 rwstatus
= rw_status
.rwstatus_from_exc_map({
58 IndexError: RwTypes
.RwStatus
.NOTFOUND
,
59 KeyError: RwTypes
.RwStatus
.NOTFOUND
,
60 UnknownAccountError
: RwTypes
.RwStatus
.NOTFOUND
,
61 MissingFileError
: RwTypes
.RwStatus
.NOTFOUND
,
65 class SdnSimPlugin(GObject
.Object
, RwSdn
.Topology
):
68 GObject
.Object
.__init
__(self
)
69 self
.sdnsim
= SdnSim()
73 def do_init(self
, rwlog_ctx
):
74 if not any(isinstance(h
, rwlogger
.RwLogger
) for h
in logger
.handlers
):
82 @rwstatus(ret_on_failure
=[None])
83 def do_validate_sdn_creds(self
, account
):
85 Validates the sdn account credentials for the specified account.
86 Performs an access to the resources using Keystone API. If creds
87 are not valid, returns an error code & reason string
89 @param account - a SDN account
92 Validation Code and Details String
94 status
= RwsdnYang
.SdnConnectionStatus()
95 print("SDN Successfully connected")
96 status
.status
= "success"
97 status
.details
= "Connection was successful"
98 #logger.debug('Done with validate SDN creds: %s', type(status))
102 @rwstatus(ret_on_failure
=[None])
103 def do_get_network_list(self
, account
):
105 Returns the list of discovered networks
107 @param account - a SDN account
110 logger
.debug('Get network list: ')
111 nwtop
= self
.sdnsim
.get_network_list( account
)
112 logger
.debug('Done with get network list: %s', type(nwtop
))