def sub_account_create(loginName, name, password, email): cursor = get_cursor() uuid = '' try: uuid = keystone.user_create(name, password, email) if (uuid == 'ERROR'): return False else: sql = '''insert into t_account values (null,'%s','%s',MD5(MD5('%s')),'%s',0,'%s',null,'%s',null) ''' % ( uuid, name, password, email, loginName, time.strftime('%Y-%m-%d %X', time.localtime())) cursor.execute(sql) except: logging.getLogger('operate').log( 30, 'create sub-account failed %s %s %s %s .' % (loginName, name, password, email)) keystone.user_delete(uuid) transaction.rollback() flag = False else: logging.getLogger('operate').log( 20, 'create sub-account successed %s %s %s %s.' % (loginName, name, password, email)) transaction.commit() flag = True finally: pass # print "Arrive finally" return flag
def sub_account_create(loginName, name, password, email): cursor = get_cursor() uuid = '' try: uuid = keystone.user_create(name, password, email) if(uuid == 'ERROR'): return False else: sql = '''insert into t_account values (null,'%s','%s',MD5(MD5('%s')),'%s',0,'%s',null,'%s',null) ''' % ( uuid, name, password, email, loginName, time.strftime('%Y-%m-%d %X', time.localtime())) cursor.execute(sql) except: logging.getLogger('operate').log(30, 'create sub-account failed %s %s %s %s .' % (loginName, name, password, email)) keystone.user_delete(uuid) transaction.rollback() flag = False else: logging.getLogger('operate').log(20, 'create sub-account successed %s %s %s %s.' % (loginName, name, password, email)) transaction.commit() flag = True finally: pass # print "Arrive finally" return flag
def sub_account_delete(name): try: keystone.user_delete(getUserIDInOS(name)) except: logging.getLogger('operate').log(30, 'DAOZO sub_account delete %s failed.' % (name)) flag = False else: try: cursor = get_cursor() sql = '''update t_account set delete_at = '%s' where t_account.loginName='%s' ''' % ( time.strftime('%Y-%m-%d %X', time.localtime()), name) cursor.execute(sql) except: logging.getLogger('operate').log(30, 'DAOZO sub_account delete %s failed.' % (name)) flag = False else: logging.getLogger('operate').log(20, 'DAOZO sub_account delete %s successful.' % (name)) flag = True finally: return flag
def sub_account_delete(name): try: keystone.user_delete(getUserIDInOS(name)) except: logging.getLogger('operate').log( 30, 'DAOZO sub_account delete %s failed.' % (name)) flag = False else: try: cursor = get_cursor() sql = '''update t_account set delete_at = '%s' where t_account.loginName='%s' ''' % ( time.strftime('%Y-%m-%d %X', time.localtime()), name) cursor.execute(sql) except: logging.getLogger('operate').log( 30, 'DAOZO sub_account delete %s failed.' % (name)) flag = False else: logging.getLogger('operate').log( 20, 'DAOZO sub_account delete %s successful.' % (name)) flag = True finally: return flag