示例#1
0
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)
示例#2
0
文件: user.py 项目: cloudcache/cc1
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)
示例#3
0
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')
示例#4
0
文件: user.py 项目: cloudcache/cc1
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')
示例#5
0
文件: user.py 项目: cc1-cloud/cc1
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')
示例#6
0
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')
示例#7
0
文件: user.py 项目: cloudcache/cc1
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')
示例#8
0
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')
示例#9
0
文件: admin.py 项目: cc1-cloud/cc1
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')