Example #1
0
def download_assets():
    all_assets = asset.get_all_assets()
    if all_assets:
        logging.info("Available download assets:")
        logging.info("")
        for asset_info in all_assets:
            asset_keys = asset_info.keys()
            logging.info(
                "%d - %s" %
                (all_assets.index(asset_info) + 1, asset_info['title']))
            asset_keys.pop(asset_keys.index('title'))
            asset_keys.sort()
            for k in asset_keys:
                logging.info("    %s = %s" % (k, asset_info[k]))
            logging.info("")
    indexes = raw_input("%s INFO | Type the index for the assets you want to "
                        "download (comma separated, Ctrl+C to abort): " %
                        time.strftime("%H:%M:%S", time.localtime()))

    index_list = []

    for idx in indexes.split(","):
        try:
            index = int(idx) - 1
            index_list.append(index)
            all_assets[index]
        except (ValueError, IndexError):
            logging.error("Invalid index(es), aborting...")
            sys.exit(1)

    for idx in index_list:
        asset_info = all_assets[idx]
        asset.download_file(asset_info, interactive=True)
Example #2
0
def download_assets():
    all_assets = asset.get_all_assets()
    if all_assets:
        logging.info("Available download assets:")
        logging.info("")
        for asset_info in all_assets:
            asset_keys = asset_info.keys()
            logging.info("%d - %s" % (all_assets.index(asset_info) + 1,
                         asset_info['title']))
            asset_keys.pop(asset_keys.index('title'))
            asset_keys.sort()
            for k in asset_keys:
                logging.info("    %s = %s" % (k, asset_info[k]))
            logging.info("")
    indexes = raw_input("%s INFO | Type the index for the assets you want to "
                        "download (comma separated, Ctrl+C to abort): " %
                        time.strftime("%H:%M:%S", time.localtime()))

    index_list = []

    for idx in indexes.split(","):
        try:
            index = int(idx) - 1
            index_list.append(index)
            all_assets[index]
        except (ValueError, IndexError):
            logging.error("Invalid index(es), aborting...")
            sys.exit(1)

    for idx in index_list:
        asset_info = all_assets[idx]
        asset.download_file(asset_info, interactive=True)
Example #3
0
def download_assets():
    view = output.View()
    all_assets = asset.get_all_assets()
    if all_assets:
        view.notify(msg="Available download assets:")
        view.notify(msg="")
        for asset_info in all_assets:
            asset_keys = asset_info.keys()
            view.notify(
                event='minor',
                msg="%d - %s" %
                (all_assets.index(asset_info) + 1, asset_info['title']))
            asset_keys.pop(asset_keys.index('title'))
            asset_keys.sort()
            for k in asset_keys:
                view.notify(event='minor',
                            msg="    %s = %s" % (k, asset_info[k]))
            view.notify(msg="")
    indexes = raw_input("Type the index for the assets you want to "
                        "download (comma separated, leave empty to abort): ")

    index_list = []

    for idx in indexes.split(","):
        try:
            index = int(idx) - 1
            index_list.append(index)
            all_assets[index]
        except (ValueError, IndexError):
            logging.error("Invalid index(es), aborting...")
            sys.exit(1)

    for idx in index_list:
        asset_info = all_assets[idx]
        asset.download_file(asset_info, interactive=True)
Example #4
0
def download_assets():
    view = output.View()
    all_assets = asset.get_all_assets()
    if all_assets:
        view.notify(msg="Available download assets:")
        view.notify(msg="")
        for asset_info in all_assets:
            asset_keys = asset_info.keys()
            view.notify(event='minor', msg="%d - %s" % (all_assets.index(asset_info) + 1,
                                                        asset_info['title']))
            asset_keys.pop(asset_keys.index('title'))
            asset_keys.sort()
            for k in asset_keys:
                view.notify(event='minor', msg="    %s = %s" % (k, asset_info[k]))
            view.notify(msg="")
    indexes = raw_input("Type the index for the assets you want to "
                        "download (comma separated, leave empty to abort): ")

    index_list = []

    for idx in indexes.split(","):
        try:
            index = int(idx) - 1
            index_list.append(index)
            all_assets[index]
        except (ValueError, IndexError):
            logging.error("Invalid index(es), aborting...")
            sys.exit(1)

    for idx in index_list:
        asset_info = all_assets[idx]
        asset.download_file(asset_info, interactive=True)
Example #5
0
def download_assets():
    all_assets = asset.get_all_assets()
    all_assets_sorted = []
    if all_assets:
        view.notify(msg="Available download assets:")
        view.notify(msg="")
        title_list = [a['title'] for a in all_assets]
        for index, title in enumerate(sorted(title_list)):
            asset_info = [a for a in all_assets if a['title'] == title][0]
            all_assets_sorted.append(asset_info)
            asset_present_str = output.term_support.partial_str('Missing')
            if asset_info['asset_exists']:
                asset_present_str = output.term_support.healthy_str('Present')
            asset_msg = ("%s - [%s] %s (%s)" %
                         (index + 1,
                          asset_present_str,
                          output.term_support.header_str(asset_info['title']),
                          asset_info['destination']))
            view.notify(event='minor', msg=asset_msg)
    indexes = raw_input("Type the index for the assets you want to "
                        "download (comma separated, leave empty to abort): ")

    index_list = []

    for idx in indexes.split(","):
        try:
            assert int(idx) > 0
            index = int(idx) - 1
            index_list.append(index)
            all_assets_sorted[index]
        except (ValueError, IndexError, AssertionError):
            view.notify(event='error', msg="Invalid index(es), aborting...")
            sys.exit(1)

    for idx in index_list:
        asset_info = all_assets_sorted[idx]
        try:
            asset.download_file(asset_info, interactive=True)
        except urllib2.HTTPError, http_error:
            view.notify(event='error', msg='HTTP Error %s: URL %s' %
                                           (http_error.code,
                                            asset_info['url']))
            os.remove(asset_info['destination'])
Example #6
0
def download_asset(asset_name, ini_dir=None, section=None, ddir=None):
    provider_dirs = asset.get_test_provider_subdirs(backend="spice")[0]
    if ini_dir:
        provider_dirs.insert(0, ini_dir)
    logger.debug("Provider_dirs: %s.", repr(provider_dirs))
    fname = "%s.ini" % asset_name
    for d in os.walk(provider_dirs):
        d = d[0]
        ini_file = os.path.join(d, fname)
        if os.path.isfile(ini_file):
            asset_dir = d
            break
    assert os.path.isfile(ini_file), "Cannot find %s.ini file." % asset_name
    logger.info("Section: %s", section)
    asset_info = asset.get_asset_info(asset_name, ini_dir=asset_dir,
                                      section=section)
    if ddir:
        dst_file = os.path.basename(asset_info['destination'])
        asset_info['destination'] = os.path.join(ddir, dst_file)
    asset.download_file(asset_info)
    stored_at = asset_info['destination']
    logger.info("Asset stored at: %s.", stored_at)
    return stored_at
Example #7
0
def download_asset(asset_name, ini_dir=None, section=None, ddir=None):
    provider_dirs = asset.get_test_provider_subdirs(backend="spice")[0]
    if ini_dir:
        provider_dirs.insert(0, ini_dir)
    logger.debug("Provider_dirs: %s.", repr(provider_dirs))
    fname = "%s.ini" % asset_name
    for d in os.walk(provider_dirs):
        d = d[0]
        ini_file = os.path.join(d, fname)
        if os.path.isfile(ini_file):
            asset_dir = d
            break
    assert os.path.isfile(ini_file), "Cannot find %s.ini file." % asset_name
    logger.info("Section: %s", section)
    asset_info = asset.get_asset_info(asset_name,
                                      ini_dir=asset_dir,
                                      section=section)
    if ddir:
        dst_file = os.path.basename(asset_info['destination'])
        asset_info['destination'] = os.path.join(ddir, dst_file)
    asset.download_file(asset_info)
    stored_at = asset_info['destination']
    logger.info("Asset stored at: %s.", stored_at)
    return stored_at
Example #8
0
        error.context("Check the existence of source image")
        src_path = '%s/%s.%s' % (mount_dest_dir, asset_name, params['image_format'])
        asset_info = asset.get_file_asset(asset_name, src_path, dst_path)
        if asset_info is None:
            raise error.TestError('Could not find %s' % image)
    else:
        asset_info = asset.get_asset_info(asset_name)

    # Do not force extraction if integrity information is available
    if asset_info['sha1_url']:
        force = params.get("force_copy", "no") == "yes"
    else:
        force = params.get("force_copy", "yes") == "yes"

    try:
        error.context("Copy image '%s'" % image, logging.info)
        if utils.is_url(asset_info['url']):
            asset.download_file(asset_info, interactive=False, force=force)
        else:
            utils.get_file(asset_info['url'], asset_info['destination'])

    finally:
        sub_type = params.get("sub_type")
        if sub_type:
            error.context("Run sub test '%s'" % sub_type, logging.info)
            params['image_name'] += "-error"
            params['boot_once'] = "c"
            vm.create(params=params)
            utils_test.run_virt_sub_test(test, params, env,
                                         params.get("sub_type"))
Example #9
0
                                  mount_dest_dir)

        error.context("Mount the NFS share directory")
        if not utils_misc.mount(src, mount_dest_dir, 'nfs', 'ro'):
            raise error.TestError('Could not mount NFS share %s to %s' %
                                  (src, mount_dest_dir))
        src_path = '%s/%s.%s' % (mount_dest_dir, asset_name,
                                 params['image_format'])
        asset_info = asset.get_file_asset(asset_name, src_path, dst_path)
        if asset_info is None:
            raise error.TestError('Could not find %s' % image)
    else:
        asset_info = asset.get_asset_info(asset_name)

    # Do not force extraction if integrity information is available
    if asset_info['sha1_url']:
        force = params.get("force_copy", "no") == "yes"
    else:
        force = params.get("force_copy", "yes") == "yes"

    try:
        asset.download_file(asset_info, interactive=False, force=force)

    finally:
        if params.get("sub_type"):
            params['image_name'] += "-error"
            params['boot_once'] = "c"
            vm.create(params=params)
            utils_test.run_virt_sub_test(test, params, env,
                                         params.get("sub_type"))