本文整理汇总了Python中Authentication类的典型用法代码示例。如果您正苦于以下问题:Python Authentication类的具体用法?Python Authentication怎么用?Python Authentication使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Authentication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
class InstancePreReq:
def __init__(self):
self.aObj = Authentication("yess");
self.nova = self.aObj.getComputeClient();
self.neutron = self.aObj.getNeutronClient();
self.keystone= self.aObj.getKeystoneClient();
self.glance = self.aObj.getGlanceClient();
self.cclient = self.aObj.getCeilometerClient();
def getAllFlavours(self):
obj= self.nova.flavors.list();
flvrs=[];
for each in obj:
flvrs.append(each.name);
return flvrs;
def getAllImages(self):
obj= self.nova.images.list();
imgz=[];
for each in obj:
imgz.append(each.name);
return imgz;
def getAllNetworks(self):
obj= self.nova.networks.list();
netwrk=[];
for each in obj:
netwrk.append(each.label);
return netwrk;
def getKeypairsList(self):
obj= self.nova.keypairs.list();
keyz=[];
for each in obj:
keyz.append(each.name);
return keyz;
def getSecurityList(self):
obj= self.nova.security_groups.list();
scrty=[];
for each in obj:
scrty.append(each.name);
return scrty;
示例2: __init__
class createKey:
def __init__(self):
self.aObj = Authentication("msssg");
self.nova = self.aObj.getComputeClient();
self.neutron = self.aObj.getNeutronClient();
self.keystone = self.aObj.getKeystoneClient();
self.glance = self.aObj.getGlanceClient();
self.cclient = self.aObj.getCeilometerClient();
def createKeyPlease(self):
keypair_name = "maKey";
self.nova.keypairs.list();
ts = time.time();
st = datetime.datetime.fromtimestamp(ts).strftime('%Y%m%d%H%M%S');
stri = keypair_name+st;
print stri;
self.nova.keypairs.create(name=stri)
def getKeypairsList(self):
obj = self.nova.keypairs.list();
keyz = [];
for each in obj:
keyz.append(each.name);
return keyz;
# obj = createKey();
# obj.createKeyPlease();
示例3: saveFile
def saveFile(ID, CADFile, filedesc):
try:
Authentication.authUpload(ID, CADFile, filedesc)
except Exception as e:
logging.error("Unable to save file: %s" % e)
return False
return True
示例4: __init__
class BillGeneratePreReq:
def __init__(self):
self.aObj = Authentication("yess");
self.nova = self.aObj.getComputeClient();
self.neutron = self.aObj.getNeutronClient();
self.keystone= self.aObj.getKeystoneClient();
self.glance = self.aObj.getGlanceClient();
self.cclient = self.aObj.getCeilometerClient();
self.dbObj = MongoDatabase();
def getAllBillsCategories(self):
checki = self.dbObj.getAllBillCat();
if(checki==False):
return False
else:
return checki;
def getAllRunningInstances(self):
servers = self.nova.servers.list();
return servers;
# obj = BillGeneratePreReq();
# obj.getAllBillsCategories();
示例5: changePassword
def changePassword(self, sid, safeOld, safeNew):
session = self.sessions[sid]
if not session:
raise SecurityException('No such session id.')
challenge = session.challenge
account = self.accounts[session.login]
oldPassword = Authentication.unwrapUserPassword(safeOld, challenge)
newPassword = Authentication.unwrapUserPassword(safeNew, challenge)
if not account.verifyPassword(oldPassword):
raise SecurityException('Wrong login and/or password.')
if len(newPassword) < ige.Const.ACCOUNT_PASSWD_MIN_LEN:
raise SecurityException('Password is too short.')
account.setPassword(newPassword)
log.debug('Password of account {0} successfully changed.'.format(session.login))
return None, None
示例6: createAccount
def createAccount(self, sid, login, safePasswd, nick, email):
log.message('Creating account', login, nick, email)
session = self.getSession(sid)
plainPassword = Authentication.unwrapUserPassword(safePasswd, session.challenge)
login = login.strip()
plainPassword = plainPassword.strip()
nick = nick.strip()
# check requirement
if len(login) < ige.Const.ACCOUNT_LOGIN_MIN_LEN:
raise SecurityException('Login is too short.')
if len(plainPassword) < ige.Const.ACCOUNT_PASSWD_MIN_LEN:
raise SecurityException('Password is too short.')
if len(nick) < ige.Const.ACCOUNT_NICK_MIN_LEN:
raise SecurityException('Nick is too short.')
# check login, nick and uid
for key in self.accounts.keys():
account = self.accounts[key]
if account.login == login:
raise SecurityException('Login already used.')
elif account.nick == nick:
raise SecurityException('Nick already used.')
elif account.email == email:
raise SecurityException('E-mail already used.')
# create account
account = Account(login, nick, email, plainPassword)
# update
self.accounts.create(account, id = str(account.login))
log.message('Account created, confirmation token:', account.confToken)
# TODO send confirmation token to the email address
return 1, None
示例7: __init__
def __init__(self, database, authMethod, configDir):
self.configDir = configDir
self.authMethod = authMethod
if not self.authMethod:
self.authMethod = Authentication.defaultMethod
if ige.igeRuntimeMode == 1:
Authentication.init(self.authMethod, 2048)
elif ige.igeRuntimeMode == 0:
# it is minimum to cater for AI generated passwords
Authentication.init(self.authMethod, 512)
self._filename = os.path.join(self.configDir, 'accounts')
self.sessions = {}
#
self.accounts = database
self._initAdminAccount()
self.generateAIList()
示例8: __init__
def __init__(self):
self.aObj = Authentication("yess");
self.nova = self.aObj.getComputeClient();
self.neutron = self.aObj.getNeutronClient();
self.keystone = self.aObj.getKeystoneClient();
self.glance = self.aObj.getGlanceClient();
self.cclient = self.aObj.getCeilometerClient();
示例9: __init__
def __init__(self,arguments):
self.aObj = Authentication("yess");
self.nova = self.aObj.getComputeClient();
self.neutron = self.aObj.getNeutronClient();
self.keystone= self.aObj.getKeystoneClient();
self.glance = self.aObj.getGlanceClient();
# self.cclient = self.aObj.getCeilometerClient();
self.args=arguments;
for each in arguments:
print "--->",each
示例10: __init__
def __init__(self,billName,flvr,price):
self.aObj = Authentication("yess");
self.nova = self.aObj.getComputeClient();
self.neutron = self.aObj.getNeutronClient();
self.keystone= self.aObj.getKeystoneClient();
self.glance = self.aObj.getGlanceClient();
self.cclient = self.aObj.getCeilometerClient();
self.price=price;
self.billName=billName;
self.flvrNames=flvr;
self.dbObj = MongoDatabase();
示例11: __init__
class RouterPreReq:
def __init__(self):
self.aObj = Authentication("yess");
self.nova = self.aObj.getComputeClient();
self.neutron = self.aObj.getNeutronClient();
self.keystone= self.aObj.getKeystoneClient();
self.glance = self.aObj.getGlanceClient();
self.cclient = self.aObj.getCeilometerClient();
def getAllSubnets(self):
subnets = self.neutron.list_subnets();
subList=[];
for each in subnets['subnets']:
subList.append(each['name']);
return subList;
def getAllTenants(self):
tenants = self.keystone.tenants.list();
tenNames=[];
for each in tenants:
tenNames.append(each.name);
return tenNames;
def getAllNetworks(self):
obj= self.nova.networks.list();
netwrk=[];
for each in obj:
netwrk.append(each.label);
return netwrk;
示例12: hello
def hello(self, sid, clientId):
log.debug(clientId, 'connected. User', repr(clientId))
# create sort of cookie
while 1:
sid = hashlib.sha256(str(random.random())).hexdigest()
if not self.sessions.has_key(sid):
break
challenge = Authentication.getWelcomeString(self.authMethod)
session = Session(sid)
session.challenge = challenge
session.clientIdent = clientId
self.sessions[sid] = session
return (sid, challenge), None
示例13: __init__
class InstanceBill:
def __init__(self,instnc,catg):
self.aObj = Authentication("yess");
self.nova = self.aObj.getComputeClient();
self.neutron = self.aObj.getNeutronClient();
self.keystone= self.aObj.getKeystoneClient();
self.glance = self.aObj.getGlanceClient();
self.cclient = self.aObj.getCeilometerClient();
self.inst = instnc;
slef.catg = catg;
def getInstanceID(self):
instanceList = nova.servers.list(search_opts={'all_tenants': 1});
for i in range(0,len(instanceList),1):
if(instanceList[i].name==self.inst):
return instncID = instanceList[i].id;
def getTopSamples(self):
示例14: login
def login(self, sid, login, cpasswd, hostID):
login = login.strip()
if not login:
raise SecurityException("Specify login, please.")
if login in ():
raise SecurityException("Account blocked")
log.debug(sid, 'login', repr(login), 'hostid', hostID)
login = str(login)
challenge = self.sessions[sid].challenge
account = None
# use metaserver login if metaserver is defined
if self.metaserver:
result = self.metaserver.verifyPassword(login, Authentication.processUserPassword(cpasswd, challenge))
if result:
account = Account()
account.login = login
account.nick = result["nick"]
account.email = result["email"]
log.debug("User", login, "has valid metaserver account")
#else:
# raise SecurityException("Wrong login and/or password.")
# local login
# TBD: option to disable local login completely
if not account:
log.debug("Trying local login for user", login)
if not self.accounts.has_key(login):
raise SecurityException('Wrong login and/or password.')
account = self.accounts[login]
if not Authentication.verify(cpasswd, account.passwd, challenge):
raise SecurityException('Wrong login and/or password.')
# setup session
self.sessions[sid].setAttrs(account.login, account.nick, account.email)
account.lastLogin = time.time()
account.addHostID(hostID)
self.tokens[sid] = hashlib.md5(str(random.random())).hexdigest()
return 1, None
示例15: __init__
def __init__(self,cat,instName):
inst = str(instName);
cat = str(cat);
print 'INST ->', inst;
print 'CATG ->', cat;
self.aObj = Authentication("yess");
self.nova = self.aObj.getComputeClient();
self.neutron = self.aObj.getNeutronClient();
self.keystone= self.aObj.getKeystoneClient();
self.glance = self.aObj.getGlanceClient();
self.cclient = self.aObj.getCeilometerClient();
self.dbObj = MongoDatabase();
self.cat = cat;
self.instName = inst;