예제 #1
0
 def provision_appliances(
         self, count=1, preconfigured=False, version=None, stream=None, provider=None,
         lease_time=120, ram=None, cpu=None):
     # If we specify version, stream is ignored because we will get that specific version
     if version:
         stream = get_stream(version)
     # If we specify stream but not version, sprout will give us latest version of that stream
     elif stream:
         pass
     # If we dont specify either, we will get the same version as current appliance
     else:
         stream = get_stream(current_appliance.version)
         version = current_appliance.version.vstring
     request_id = self.call_method(
         'request_appliances', preconfigured=preconfigured, version=version,
         group=stream, provider=provider, lease_time=lease_time, ram=ram, cpu=cpu, count=count
     )
     wait_for(
         lambda: self.call_method('request_check', str(request_id))['finished'], num_sec=300,
         message='provision {} appliance(s) from sprout'.format(count))
     data = self.call_method('request_check', str(request_id))
     logger.debug(data)
     appliances = []
     for appliance in data['appliances']:
         appliances.append(IPAppliance(appliance['ip_address']))
     return appliances, request_id
예제 #2
0
def fqdn_appliance(appliance):
    sp = SproutClient.from_config()
    available_providers = set(sp.call_method('available_providers'))
    required_providers = set(cfme_data['fqdn_providers'])
    usable_providers = available_providers & required_providers
    version = appliance.version.vstring
    stream = get_stream(appliance.version)
    for provider in usable_providers:
        try:
            apps, pool_id = sp.provision_appliances(count=1,
                                                    preconfigured=True,
                                                    version=version,
                                                    stream=stream,
                                                    provider=provider)
            break
        except Exception as e:
            logger.warning(
                "Couldn't provision appliance with following error:")
            logger.warning("{}".format(e))
            continue
    else:
        logger.error("Couldn't provision an appliance at all")
        raise SproutException('No provision available')
    yield apps[0]

    apps[0].ssh_client.close()
    sp.destroy_pool(pool_id)
예제 #3
0
def temp_appliance_preconfig_funcscope_upgrade(appliance):
    stream = (
        int(''.join([i
                     for i in get_stream(appliance.version) if i.isdigit()])) -
        1)
    with temp_appliances(preconfigured=True, stream=stream) as appliances:
        yield appliances[0]
예제 #4
0
 def provision_appliances(self,
                          count=1,
                          preconfigured=False,
                          version=None,
                          stream=None,
                          provider=None,
                          lease_time=120,
                          ram=None,
                          cpu=None):
     # If we specify version, stream is ignored because we will get that specific version
     if version:
         stream = get_stream(version)
     # If we specify stream but not version, sprout will give us latest version of that stream
     elif stream:
         pass
     # If we dont specify either, we will get the same version as current appliance
     else:
         stream = get_stream(current_appliance.version)
         version = current_appliance.version.vstring
     request_id = self.call_method('request_appliances',
                                   preconfigured=preconfigured,
                                   version=version,
                                   group=stream,
                                   provider=provider,
                                   lease_time=lease_time,
                                   ram=ram,
                                   cpu=cpu,
                                   count=count)
     wait_for(lambda: self.call_method('request_check', str(request_id))[
         'finished'],
              num_sec=300,
              message='provision {} appliance(s) from sprout'.format(count))
     data = self.call_method('request_check', str(request_id))
     logger.debug(data)
     appliances = []
     for appliance in data['appliances']:
         appliances.append(IPAppliance(appliance['ip_address']))
     return appliances, request_id
예제 #5
0
def appliance_preupdate(temp_appliance_preconfig_funcscope_upgrade, appliance):
    '''Reconfigure appliance partitions and adds repo file for upgrade'''
    update_url = ('update_url_' + ''.join([i for i in get_stream(appliance.version)
        if i.isdigit()]))
    temp_appliance_preconfig_funcscope_upgrade.db.extend_partition()
    urls = process_url(cfme_data['basic_info'][update_url])
    output = build_file(urls)
    with tempfile.NamedTemporaryFile('w') as f:
        f.write(output)
        f.flush()
        os.fsync(f.fileno())
        temp_appliance_preconfig_funcscope_upgrade.ssh_client.put_file(
            f.name, '/etc/yum.repos.d/update.repo')
    return temp_appliance_preconfig_funcscope_upgrade
예제 #6
0
def appliance_preupdate(temp_appliance_preconfig_funcscope_upgrade, appliance):
    '''Reconfigure appliance partitions and adds repo file for upgrade'''
    update_url = (
        'update_url_' +
        ''.join([i for i in get_stream(appliance.version) if i.isdigit()]))
    temp_appliance_preconfig_funcscope_upgrade.db.extend_partition()
    urls = process_url(cfme_data['basic_info'][update_url])
    output = build_file(urls)
    with tempfile.NamedTemporaryFile('w') as f:
        f.write(output)
        f.flush()
        os.fsync(f.fileno())
        temp_appliance_preconfig_funcscope_upgrade.ssh_client.put_file(
            f.name, '/etc/yum.repos.d/update.repo')
    return temp_appliance_preconfig_funcscope_upgrade
예제 #7
0
파일: cli.py 프로젝트: rananda/cfme_tests
def fqdn_appliance():
    sp = SproutClient.from_config()
    available_providers = set(sp.call_method('available_providers'))
    required_providers = set(cfme_data['fqdn_providers'])
    usable_providers = available_providers & required_providers
    version = current_appliance.version.vstring
    stream = get_stream(current_appliance.version)
    for provider in usable_providers:
        try:
            apps, pool_id = sp.provision_appliances(
                count=1, preconfigured=True, version=version, stream=stream, provider=provider)
            break
        except Exception as e:
            logger.warning("Couldn't provision appliance with following error:")
            logger.warning("{}".format(e))
            continue
    else:
        logger.error("Couldn't provision an appliance at all")
        raise SproutException('No provision available')
    yield apps[0]

    sp.destroy_pool(pool_id)
예제 #8
0
    app.wait_for_web_ui()


@pytest.fixture(scope="function")
def stabilize_current_appliance(backup_orig_state):
    app = get_or_create_current_appliance()
    app.reboot(wait_for_web_ui=False)
    app.stop_evm_service()


@pytest.mark.ignore_stream('5.5', 'upstream')
@pytest.mark.tier(2)
@pytest.mark.uncollectif(
    lambda db_version:
        db_version >= version.current_version() or
        version.get_stream(db_version) == version.current_stream())
@pytest.mark.meta(
    blockers=[BZ(1354466, unblock=lambda db_url: 'ldap' not in db_url)])
def test_db_migrate(stabilize_current_appliance, db_url, db_version, db_desc):
    app = get_or_create_current_appliance()

    # Download the database
    logger.info("Downloading database: {}".format(db_desc))
    url_basename = os_path.basename(db_url)
    rc, out = app.ssh_client.run_command(
        'curl -o "/tmp/{}" "{}"'.format(url_basename, db_url), timeout=30)
    assert rc == 0, "Failed to download database: {}".format(out)

    # The v2_key is potentially here
    v2key_url = os_path.join(os_path.dirname(db_url), "v2_key")

@pytest.fixture(scope="module")
def temp_appliance_extended_db(temp_appliance_preconfig):
    app = temp_appliance_preconfig
    app.stop_evm_service()
    app.extend_db_partition()
    app.start_evm_service()
    return app


@pytest.mark.ignore_stream('5.5', 'upstream')
@pytest.mark.tier(2)
@pytest.mark.uncollectif(
    lambda db_version: db_version >= version.current_version(
    ) or version.get_stream(db_version) == version.current_stream())
@pytest.mark.meta(
    blockers=[BZ(1354466, unblock=lambda db_url: 'ldap' not in db_url)])
def test_db_migrate(app_creds, temp_appliance_extended_db, db_url, db_version,
                    db_desc):
    app = temp_appliance_extended_db

    # Download the database
    logger.info("Downloading database: {}".format(db_desc))
    url_basename = os_path.basename(db_url)
    rc, out = app.ssh_client.run_command('curl -o "/tmp/{}" "{}"'.format(
        url_basename, db_url),
                                         timeout=30)
    assert rc == 0, "Failed to download database: {}".format(out)

    # The v2_key is potentially here
예제 #10
0
from collections import defaultdict, namedtuple
from datetime import date

import slumber

from utils.conf import env
from utils.providers import providers_data
from utils.version import get_stream


# regexen to match templates to streams and pull out the date
# stream names must be slugified (alphanumeric, dashes, underscores only)
# regex must include month and day, may include year
# If year is unset, will be the most recent month/day (not in the future)
stream_matchers = (
    (get_stream('latest'), '^miq-nightly-(?P<year>\d{4})(?P<month>\d{2})(?P<day>\d{2})'),
    (get_stream('5.2'), r'^cfme-52.*-(?P<month>\d{2})(?P<day>\d{2})'),
    (get_stream('5.3'), r'^cfme-53.*-(?P<month>\d{2})(?P<day>\d{2})'),
    (get_stream('5.4'), r'^cfme-54.*-(?P<month>\d{2})(?P<day>\d{2})'),
    (get_stream('5.5'), r'^cfme-55.*-(?P<month>\d{2})(?P<day>\d{2})'),
    # Nightly builds are currently in the 5.4.z stream
    (get_stream('5.5'), r'^cfme-nightly-(?P<year>\d{4})(?P<month>\d{2})(?P<day>\d{2})'),
)
generic_matchers = (
    ('sprout', r'^s_tpl'),
    ('sprout', r'^sprout_template'),
    ('rhevm-internal', r'^auto-tmp'),
)
conf = env.get('trackerbot', {})
_active_streams = None
예제 #11
0
from datetime import date
import urllib

import slumber
import requests

from utils.conf import env
from utils.providers import providers_data
from utils.version import get_stream

# regexen to match templates to streams and pull out the date
# stream names must be slugified (alphanumeric, dashes, underscores only)
# regex must include month and day, may include year
# If year is unset, will be the most recent month/day (not in the future)
stream_matchers = (
    (get_stream('latest'),
     '^miq-nightly-(?P<year>\d{4})(?P<month>\d{2})(?P<day>\d{2})'),
    (get_stream('5.2'), r'^cfme-52.*-(?P<month>\d{2})(?P<day>\d{2})'),
    (get_stream('5.3'), r'^cfme-53.*-(?P<month>\d{2})(?P<day>\d{2})'),
    (get_stream('5.4'), r'^cfme-54.*-(?P<month>\d{2})(?P<day>\d{2})'),
    (get_stream('5.5'), r'^cfme-55.*-(?P<month>\d{2})(?P<day>\d{2})'),
    (get_stream('5.6'), r'^cfme-56.*-(?P<month>\d{2})(?P<day>\d{2})'),
    # Nightly builds have potentially multiple version streams bound to them so we
    # cannot use get_stream()
    ('downstream-nightly',
     r'^cfme-nightly-(?P<year>\d{4})(?P<month>\d{2})(?P<day>\d{2})'),
    # new format
    ('downstream-nightly',
     r'^cfme-nightly-\d*-(?P<year>\d{4})(?P<month>\d{2})(?P<day>\d{2})'),
)
generic_matchers = (
예제 #12
0
def temp_appliance_preconfig_funcscope_upgrade(appliance):
    stream = (int(''.join([i for i in get_stream(appliance.version)
        if i.isdigit()])) - 1)
    with temp_appliances(preconfigured=True, stream=stream) as appliances:
        yield appliances[0]