# API authentication method
method = None,
# Password authentication
- role = None, user = None, password = None,
+ role = None, user = None, password = None, tenant = None,
# Session authentication
session = None):
"""
try:
# If any XML-RPC options have been specified, do not try
# connecting directly to the DB.
- if (url, method, user, password, role, cacert, xmlrpc) != \
- (None, None, None, None, None, None, False):
+ if (url, method, user, password, role, tenant, cacert, xmlrpc) != \
+ (None, None, None, None, None, None, None, False):
raise Exception
# Otherwise, first try connecting directly to the DB. This
if self.config is None:
raise Exception, "Must specify API URL"
- url = "https://" + self.config.PLC_API_HOST + \
- ":" + str(self.config.PLC_API_PORT) + \
- "/" + self.config.PLC_API_PATH + "/"
+ url = "https://" + self.config.api_host + \
+ ":" + str(self.config.api_port) #+ \
+ #"/" + self.config.PI_PATH + "/"
if cacert is None:
- cacert = self.config.PLC_API_CA_SSL_CRT
+ cacert = self.config.api_ca_ssl_cert
self.url = url
if cacert is not None:
self.server = xmlrpclib.ServerProxy(url, allow_none = 1)
# Set up authentication structure
-
# Default is to use session or capability authentication
- if (method, user, password) == (None, None, None):
- if session is not None or os.path.exists("/etc/planetlab/session"):
- method = "session"
- if session is None:
- session = "/etc/planetlab/session"
- else:
- method = "capability"
-
- if method == "capability":
+ if not method or method == "capability":
# Load defaults from configuration file if using capability
# authentication.
if user is None and self.config is not None:
- user = self.config.PLC_API_MAINTENANCE_USER
+ user = self.config.nova_admin_user
if password is None and self.config is not None:
- password = self.config.PLC_API_MAINTENANCE_PASSWORD
- if role is None:
- role = "admin"
- elif method is None:
- # Otherwise, default to password authentication
- method = "password"
-
+ password = self.config.nova_admin_password
+ if tenant is None and self.config is not None:
+ tenant = self.config.nova_admin_tenant
+
if role == "anonymous" or method == "anonymous":
self.auth = {'AuthMethod': "anonymous"}
- elif method == "session":
- if session is None:
- raise Exception, "Must specify session"
-
- if os.path.exists(session):
- session = file(session).read()
-
- self.auth = {'AuthMethod': "session", 'session': session}
else:
if user is None:
raise Exception, "Must specify username"
self.auth = {'AuthMethod': method,
'Username': user,
- 'AuthString': password}
+ 'AuthString': password,
+ 'Tenant': tenant}
if role is not None:
self.auth['Role'] = role