def add(caller_id, user_id): """ Adds specified CC1 User to current CM. @cmview_user @note This method is decorated by user_log decorator, not by admin_cm_log. This is caused by the fact that CLMAdmin doesn't need to be CMAdmin and despite not having rights to call CMAdmin functions he needs to call it on CMAdmin privileges. @param_post{user_id} """ User.create(user_id)
def add(caller_id, user_id): """ Function adds new user to DB and creates its home directory. @cmview_user @note This method is decorated by user_log decorator, not by admin_cm_log. This is caused by the fact that CLMAdmin doesn't need to be CMAdmin and despite not having rights to call CMAdmin functions he needs to call it on CMAdmin priviledges. @parameter{user_id} @response{None} """ User.create(user_id)
def add_missing(caller_id, remote): """ Adds Users whose ids are listed in @prm{remote} and who are locally missing. @cmview_user @param_post{remote,list(int)} ids of the remote Users """ # remote must be passed through POST as a list # it is a list of users id try: # put all the user ids in a list local = User.objects.all().values_list('id', flat=True) # create user for all the ids which are in remote but not in the local cm for user_id in [uid for uid in remote if uid not in local]: User.create(user_id) except: raise CMException('user_create')
def add_missing(caller_id, remote): """ Function adds missing users listed in remote that don't belong to local. @cmview_user @parameter{remote,list of int} @response{None} """ # remote must be passed through POST as a list # it is a list of users id try: # put all the user ids in a list local = User.objects.all().values_list('id', flat=True) # create user for all the ids which are in remote but not in the local cm for user_id in [uid for uid in remote if uid not in local]: User.create(user_id) except: raise CMException('user_create')
def add(new_user_id): """ Adds existing CLM User to CM Users. @cmview_guest @param_post{new_user_id,int} id of the existing CLM User @response{None} """ user = User.create(new_user_id) try: user.save() except Exception, e: log.debug(0, "Adding to DB: %s" % str(e)) raise CMException('user_create')
def add(new_user_id): """ Function adds new user to DB and creates its home directory. @cmview_guest @dictkey{new_user_id,int} @response{None} """ user = User.create(new_user_id) try: user.save() except Exception, e: log.debug(0, "Adding to DB: %s" % str(e)) raise CMException('user_create')
def first_admin_add(caller_id, new_password, clm_address): """ Creates first admin of the cluster. It should be called right after submiting the form for adding new CM. System will not operate properly with no CM admin existing. @note It can be run only if no CM admin exists in the CM database. @cmview_user @param_post{new_password,string} first *CM admin password* to set @param_post{clm_address,string} """ user = User.create(1) user.save() # creates a new admin, which is the caller admin = Admin() admin.user = user admin.password = new_password try: admin.save() except: raise CMException('admin_add') # Update config and setup CLM address try: lines = [] config = open('/usr/lib/cc1/cm/config.py', 'r') for line in config.readlines(): if line.startswith('CLM_ADDRESS') and 'NOT_CONFIGURED' in line: lines.append('CLM_ADDRESS = "https://%s:8000/"\n' % clm_address) else: lines.append(line) config.close() config = open('/usr/lib/cc1/cm/config.py', 'w') config.write(''.join(lines)) config.close() except: log.exception(caller_id, 'config_update') raise CMException('config_update')