3 # Copyright 2017 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.
25 gi
.require_version('RwTypes', '1.0')
26 from gi
.repository
import RwsdnalYang
27 from gi
.repository
.RwTypes
import RwStatus
30 logger
= logging
.getLogger('sdnopenstack')
34 'password' : 'mypasswd',
35 'auth_url' : 'http://10.66.4.17:5000/v2.0/',
36 'project_name' : 'demo',
37 'user_domain_name' : 'default',
38 'project_domain_name': 'default'
42 def get_sdn_account():
44 Creates an object for class RwsdnalYang.SdnAccount()
46 account
= RwsdnalYang
.SDNAccount()
47 account
.name
= "grunt17"
48 account
.account_type
= "openstack"
49 account
.openstack
.plugin_name
= "rwsdn_openstack"
50 account
.openstack
.key
= openstack_info
['username']
51 account
.openstack
.secret
= openstack_info
['password']
52 account
.openstack
.auth_url
= openstack_info
['auth_url']
53 account
.openstack
.tenant
= openstack_info
['project_name']
54 account
.openstack
.user_domain
= openstack_info
['user_domain_name']
55 account
.openstack
.project_domain
= openstack_info
['project_domain_name']
61 Loads rw.sdn plugin via libpeas
63 plugin
= rw_peas
.PeasPlugin('rwsdn_openstack', 'RwSdn-1.0')
64 engine
, info
, extension
= plugin()
66 # Get the RwLogger context
67 rwloggerctx
= rwlogger
.RwLog
.Ctx
.new("SDN-Log")
69 sdn
= plugin
.get_interface("Topology")
71 rc
= sdn
.init(rwloggerctx
)
72 assert rc
== RwStatus
.SUCCESS
74 logger
.error("ERROR:SDN openstack plugin instantiation failed. Aborting tests")
76 logger
.info("SDN openstack plugin successfully instantiated")
81 class SdnOpenstackTest(unittest
.TestCase
):
84 Initialize test plugins
86 self
._acct
= get_sdn_account()
87 logger
.info("SDN-Openstack-Test: setUp")
88 self
.sdn
= get_sdn_plugin()
89 logger
.info("SDN-Openstack-Test: setUpEND")
92 logger
.info("SDN-Openstack-Test: Done with tests")
94 def test_validate_sdn_creds(self
):
98 logger
.debug("SDN-Openstack-Test: Starting validate creds ")
99 rc
, status
= self
.sdn
.validate_sdn_creds(self
._acct
)
100 logger
.debug("SDN-Openstack-Test: SDN return code %s resp %s", rc
, status
)
101 self
.assertEqual(rc
, RwStatus
.SUCCESS
)
102 logger
.info("SDN-Openstack-Test: Passed validate creds")
105 if __name__
== "__main__":
106 logging
.basicConfig(level
=logging
.DEBUG
)