示例#1
0
def mkdir_divison_dc(divison_dc, user, acl_path=None):
    """Creates the directory division dc in cvs

    @param divison_dc: division dc to be created
    @param user: user

    @raise CVSCommandError: Failed to execute
    """
    try:

        divison_dc = str(divison_dc).upper()

        os.chdir(PATH_ACL)

        if divison_dc == DIVISON_DC.BORDA:
            divison_dc = 'Borda'

        directory = divison_dc

        if acl_path:
            directory = acl_path

        Cvs.synchronization()

        # Set path - Ipv4 - Ipv6
        list_path = []
        list_path.append('%s%s/' % (PATH_ACL, 'v4'))
        list_path.append('%s%s/' % (PATH_ACL, 'v6'))

        for path in list_path:

            os.chdir(path)

            folders = directory.split('/')

            for folder in folders:
                if folder:
                    if not os.path.exists(folder):
                        os.mkdir(folder)
                        Cvs.add(folder)
                        Cvs.commit(
                            folder,
                            'Criação do diretório de divisão dc %s/%s pelo usuário: %s'
                            % (path, folder, user.user))
                        logger.info('%s criou no CVS o diretório: %s/%s' %
                                    (user.user, path, folder))
                        Cvs.synchronization()

                    path = '%s/%s' % (path, folder)
                    os.chdir(path)

    except Exception, e:
        logger.error(
            'Erro quando o usuário %s tentou criar o diretório: %s no Cvs' %
            (user.user, dir))
        logger.error(e)
        raise CVSCommandError(e)
示例#2
0
def mkdir_divison_dc(divison_dc, user, acl_path=None):
    """Creates the directory division dc in cvs

    @param divison_dc: division dc to be created
    @param user: user

    @raise CVSCommandError: Failed to execute
    """
    try:

        divison_dc = str(divison_dc).upper()

        os.chdir(PATH_ACL)

        if divison_dc == DIVISON_DC.BORDA:
            divison_dc = 'Borda'

        directory = divison_dc

        if acl_path:
            directory = acl_path

        Cvs.synchronization()

        # Set path - Ipv4 - Ipv6
        list_path = []
        list_path.append('%s%s/' % (PATH_ACL, 'v4'))
        list_path.append('%s%s/' % (PATH_ACL, 'v6'))

        for path in list_path:

            os.chdir(path)

            folders = directory.split('/')

            for folder in folders:
                if folder:
                    if not os.path.exists(folder):
                        os.mkdir(folder)
                        Cvs.add(folder)
                        Cvs.commit(
                            folder, 'Criação do diretório de divisão dc %s/%s pelo usuário: %s' % (path, folder, user.user))
                        logger.info(
                            '%s criou no CVS o diretório: %s/%s' % (user.user, path, folder))
                        Cvs.synchronization()

                    path = '%s/%s' % (path, folder)
                    os.chdir(path)

    except Exception, e:
        logger.error('Erro quando o usuário %s tentou criar o diretório: %s no Cvs' % (
            user.user, dir))
        logger.error(e)
        raise CVSCommandError(e)
示例#3
0
def createAclCvs(acl_name, environment, network, user):
    """Create the file acl.

    @param acl_name: acl name
    @param environment: Environment
    @param network: v4 or v6
    @param user: user

    @raise CVSCommandError:  Failed to execute command
    """
    try:

        acl = check_name_file(acl_name)

        path = path_acl(environment['nome_ambiente_logico'],
                        environment['nome_divisao'], environment['acl_path'])

        mkdir_divison_dc(environment['nome_divisao'], user,
                         environment['acl_path'])

        chdir(PATH_TYPES.ACL, network, path)

        Cvs.synchronization()

        File.create(acl)

        Cvs.add(acl)

        Cvs.commit(acl,
                   'Criação do Arquivo %s pelo usuário: %s' % (acl, user.user))

        logger.info('%s criou no CVS o arquivo: %s' % (user.user,
                                                       (path + acl)))

    except (CVSCommandError, FileError, Exception), e:
        logger.error(
            'Erro quando o usuário %s tentou criar o arquivo: %s no Cvs' %
            (user.user, (path + acl)))
        logger.error(e)
        raise CVSCommandError(e)
示例#4
0
def createAclCvs(acl_name, environment, network, user):
    """Create the file acl.

    @param acl_name: acl name
    @param environment: Environment
    @param network: v4 or v6
    @param user: user

    @raise CVSCommandError:  Failed to execute command
    """
    try:

        acl = check_name_file(acl_name)

        path = path_acl(environment['nome_ambiente_logico'], environment['nome_divisao'],
                        environment['acl_path'])

        mkdir_divison_dc(
            environment['nome_divisao'], user, environment['acl_path'])

        chdir(PATH_TYPES.ACL, network, path)

        Cvs.synchronization()

        File.create(acl)

        Cvs.add(acl)

        Cvs.commit(acl, 'Criação do Arquivo %s pelo usuário: %s' %
                   (acl, user.user))

        logger.info('%s criou no CVS o arquivo: %s' %
                    (user.user, (path + acl)))

    except (CVSCommandError, FileError, Exception), e:
        logger.error('Erro quando o usuário %s tentou criar o arquivo: %s no Cvs' % (
            user.user, (path + acl)))
        logger.error(e)
        raise CVSCommandError(e)