Ejemplo n.º 1
0
def main():
    logger = logging.getLogger()
    stream = logging.StreamHandler(sys.stdout)
    stream.setLevel(logging.INFO)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - '
                                  '%(message)s')
    stream.setFormatter(formatter)
    logger.addHandler(stream)

    args = parse_cli_args()

    #if os.path.exists('autodock.config'):
    #  config_dict = parse_config('autodock.config')

    m = Manager(logger)
    if args.mode == 'list':
        logger.info('Listing the formations')
        m.list_formations(args.username)
        return 0
    elif args.mode == 'edit':
        logger.info('Editing the formation')
        e = FormationEditor(m, logger)
        e.edit_formation('args')
        return 0
    elif args.mode == 'verify':
        logger.info('Verifying the formation')
        v = VerifyFormations(m, logger)
        v.start_verifying()
        return 0
    elif args.mode == 'backup':
        logger.info('Backing up a formation')
        b = AppBackup(m, logger)
        b.backup_formation(args.username, args.formation, args.directory)
        return 0
    elif args.mode == 'delete':
        logger.info('Deleting a formation')
        m.delete_formation(args.username, args.formation)
    else:
        logger.info('Creating a new formation')
        m.create_containers(args.username, args.number, args.formation,
                            args.cpu_shares, args.ram, args.port_list,
                            args.hostname_scheme, args.volume_list, args.image,
                            args.host_server)
        return 0