# import os from PLC.Parameter import Parameter class Auth(Parameter): """ Base class for all API authentication methods, as well as a class that can be used to represent all supported API authentication methods. """ def __init__(self, auth = None): if auth is None: auth = {'AuthMethod': Parameter(str, "Authentication method to use", optional = False)} Parameter.__init__(self, auth, "API authentication structure") class PasswordAuth(Auth): """ PlanetLab version 3.x password authentication structure. """ def __init__(self): Auth.__init__(self, { 'AuthMethod': Parameter(str, "Authentication method to use, always 'password' or 'capability'", optional = False), 'Username': Parameter(str, "Username, typically an e-mail address", optional = False), 'AuthString': Parameter(str, "Authentication string, typically a password", optional = False), 'Tenant': Parameter(str, "User Tenant", optional = False), }) path = os.path.dirname(__file__) + "/Auth.d" try: extensions = os.listdir(path) except OSError, e: extensions = [] for extension in extensions: if extension.startswith("."): continue if not extension.endswith(".py"): continue execfile("%s/%s" % (path, extension)) del extensions