Exemplo n.º 1
0
def main():
    utils.check_login_user()

    # parse input option
    argv = [encode.convert_to_unicode(a) for a in sys.argv[1:]]
    args = get_parser().parse_args(argv)

    # read and check args
    kwargs = {}
    if args.name is not None:
        kwargs['name'] = args.name
    if args.metadata is not None:
        kwargs['metadata'] = args.metadata
    if args.description is not None:
        kwargs['description'] = args.description
    if args.file_name is not None:
        kwargs['file_name'] = args.file_name
    if args.fpga_image_id is not None:
        kwargs['fpga_image_id'] = args.fpga_image_id
    if args.image_id is not None:
        kwargs['image_id'] = args.image_id
    if args.page is not None:
        kwargs['page'] = args.page
    if args.size is not None:
        kwargs['size'] = args.size
    try:
        utils.check_param(**kwargs)
    except Exception as e:
        utils.exit('Error: %s' % encode.exception_to_unicode(e))

    # read and check config file
    config.read_config_and_verify()
    access_key = os.getenv('OS_ACCESS_KEY')
    secret_key = os.getenv('OS_SECRET_KEY')
    bucket_name = os.getenv('OS_BUCKET_NAME')
    region_id = os.getenv('OS_REGION_ID')
    domain_id = os.getenv('OS_DOMAIN_ID')
    project_id = os.getenv('OS_PROJECT_ID')
    obs_endpoint = os.getenv('OS_OBS_ENDPOINT')
    vpc_endpoint = os.getenv('OS_VPC_ENDPOINT')
    fis_endpoint = os.getenv('OS_FIS_ENDPOINT')

    try:
        # configure intranet dns of ecs
        config.configure_intranet_dns_ecs(region_id)

        # check bucket
        utils._check_bucket_acl_location(bucket_name, access_key, secret_key,
                                         obs_endpoint, region_id, domain_id)
        # check fis
        rest.fpga_image_relation_list(access_key, secret_key, project_id,
                                      region_id, fis_endpoint)
    except Exception as e:
        utils.exit('Error: %s' % encode.exception_to_unicode(e))

    if kwargs:
        print('fis argument(s) and config file are OK')
    else:
        print('fis config file is OK')
Exemplo n.º 2
0
def main():
    parser = get_parser()
    if len(sys.argv) <= 1:
        parser.print_help()
        return

    argv = [encode.convert_to_unicode(a) for a in sys.argv[1:]]
    args = parser.parse_args(argv)
    if args.subcmd.startswith('fpga-image'):
        config.read_config_and_verify()
    elif args.subcmd == 'help':
        args.subcommands = subcommands
        args.parser = parser
    try:
        args.func(args)
    except Exception as e:
        utils.exit('Error: %s' % encode.exception_to_unicode(e))