1 # Copyright 2016 ZTE Corporation.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
16 import neutronclient.v2_0.client as neutronclient
18 logger = logging.getLogger(__name__)
21 def get_neutron(funname, auth_info, tenant_name):
22 username = auth_info["user"]
23 passwd = auth_info["passwd"]
24 url = auth_info["url"]
25 cacert = auth_info["cacert"]
26 insecure = auth_info["insecure"]
27 logger.info("[%s]call neutronclient.Client(auth_url='%s',"
28 "username='%s',password='%s',tenant_name='%s',insecure=%s,ca_cert='%s')"
29 % (funname, url, username, passwd, tenant_name, insecure, cacert))
30 return neutronclient.Client(username=username, password=passwd, tenant_name=tenant_name,
31 insecure=insecure, auth_url=url, ca_cert=cacert)
34 def get_neutron_by_tenant_id(funname, auth_info, tenant_id):
35 username = auth_info["user"]
36 passwd = auth_info["passwd"]
37 url = auth_info["url"]
38 cacert = auth_info["cacert"]
39 logger.info("[%s]call neutronclient.Client(auth_url='%s',"
40 "username='%s',password='%s',tenant_id='%s',ca_cert='%s')"
41 % (funname, url, username, passwd, tenant_id, cacert))
42 return neutronclient.Client(username=username, password=passwd, tenant_id=tenant_id, auth_url=url, ca_cert=cacert)
45 def get_neutron_default(funname, auth_info):
46 return get_neutron(funname, auth_info, auth_info["tenant"])