Exemplo n.º 1
0
 def from_config(cls):
     url = cfme_data.get("bugzilla", {}).get("url")
     product = cfme_data.get("bugzilla", {}).get("product")
     if url is None:
         raise Exception("No Bugzilla URL specified!")
     cr_root = cfme_data.get("bugzilla", {}).get("credentials")
     username = credentials.get(cr_root, {}).get("username")
     password = credentials.get(cr_root, {}).get("password")
     return cls(
         url=url, user=username, password=password, cookiefile=None,
         tokenfile=None, product=product)
Exemplo n.º 2
0
 def from_config(cls):
     url = cfme_data.get("bugzilla", {}).get("url", None)
     product = cfme_data.get("bugzilla", {}).get("product", None)
     if url is None:
         raise Exception("No Bugzilla URL specified!")
     cr_root = cfme_data.get("bugzilla", {}).get("credentials", None)
     username = credentials.get(cr_root, {}).get("username", None)
     password = credentials.get(cr_root, {}).get("password", None)
     return cls(
         url=url, user=username, password=password, cookiefile=None,
         tokenfile=None, product=product)
Exemplo n.º 3
0
 def from_config(cls, **kwargs):
     host = env.get("sprout", {}).get("hostname", "localhost")
     port = env.get("sprout", {}).get("port", 8000)
     user = os.environ.get("SPROUT_USER", credentials.get("sprout", {}).get("username", None))
     password = os.environ.get(
         "SPROUT_PASSWORD", credentials.get("sprout", {}).get("password", None))
     if user and password:
         auth = user, password
     else:
         auth = None
     return cls(host=host, port=port, auth=auth, **kwargs)
Exemplo n.º 4
0
 def from_config(cls, **kwargs):
     host = env.get("sprout", {}).get("hostname", "localhost")
     port = env.get("sprout", {}).get("port", 8000)
     user = os.environ.get("SPROUT_USER",
                           credentials.get("sprout", {}).get("username"))
     password = os.environ.get(
         "SPROUT_PASSWORD",
         credentials.get("sprout", {}).get("password"))
     if user and password:
         auth = user, password
     else:
         auth = None
     return cls(host=host, port=port, auth=auth, **kwargs)
Exemplo n.º 5
0
def setup_external_auth_ipa(**data):
    """Sets up the appliance for an external authentication with IPA.

    Keywords:
        get_groups: Get User Groups from External Authentication (httpd).
        ipaserver: IPA server address.
        iparealm: Realm.
        credentials: Key of the credential in credentials.yaml
    """
    ssh = SSHClient()
    ensure_browser_open()
    login_admin()
    if data["ipaserver"] not in get_ntp_servers():
        set_ntp_servers(data["ipaserver"])
        sleep(120)
    auth = ExternalAuthSetting(get_groups=data.pop("get_groups", False))
    auth.setup()
    logout()
    creds = credentials.get(data.pop("credentials"), {})
    data.update(**creds)
    rc, out = ssh.run_command(
        "appliance_console_cli --ipaserver {ipaserver} --iparealm {iparealm} "
        "--ipaprincipal {principal} --ipapassword {password}".format(**data)
    )
    assert rc == 0, out
    assert "failed" not in out.lower(), "External auth setup failed:\n{}".format(out)
    login_admin()
Exemplo n.º 6
0
def setup_external_auth_ipa(**data):
    """Sets up the appliance for an external authentication with IPA.

    Keywords:
        get_groups: Get User Groups from External Authentication (httpd).
        ipaserver: IPA server address.
        iparealm: Realm.
        credentials: Key of the credential in credentials.yaml
    """
    ssh = SSHClient()
    ensure_browser_open()
    login_admin()
    if data["ipaserver"] not in get_ntp_servers():
        set_ntp_servers(data["ipaserver"])
        sleep(120)
    auth = ExternalAuthSetting(get_groups=data.pop("get_groups", False))
    auth.setup()
    logout()
    creds = credentials.get(data.pop("credentials"), {})
    data.update(**creds)
    rc, out = ssh.run_command(
        "appliance_console_cli --ipaserver {ipaserver} --iparealm {iparealm} "
        "--ipaprincipal {principal} --ipapassword {password}".format(**data))
    assert rc == 0, out
    assert "failed" not in out.lower(
    ), "External auth setup failed:\n{}".format(out)
    login_admin()
Exemplo n.º 7
0
 def direct_connection(self):
     """Returns an API from mgmt_system.py targeted at this provider"""
     # Find the credentials entry
     name = str(self.host_name)
     from utils.conf import cfme_data, credentials
     for prov_id, provider in cfme_data.get("management_systems", {}).iteritems():
         if provider.get("hostname", None) == name or provider.get("region", None) == name:
             credentials = credentials.get(provider["credentials"], {})
             provider_id = prov_id
             break
     else:
         raise NameError("Could not find provider %s in the credentials!" % name)
     ptype = str(self.type).lower()
     if ptype == "emsredhat":
         from utils.mgmt_system import RHEVMSystem
         return RHEVMSystem(self.host_name, credentials["username"], credentials["password"])
     elif ptype == "emsvmware":
         from utils.mgmt_system import VMWareSystem
         return VMWareSystem(self.host_name, credentials["username"], credentials["password"])
     elif ptype == "emsamazon":
         from utils.mgmt_system import EC2System
         return EC2System(**credentials)
     elif ptype == "emsopenstack":
         from utils.mgmt_system import OpenstackSystem
         credentials.update(
             {"auth_url": cfme_data["management_systems"][provider_id]["auth_url"]}
         )
         return OpenstackSystem(**credentials)
     else:
         TypeError("Unknown Provider type!")
Exemplo n.º 8
0
def objects_from_config(*keys):
    result = {}
    for key, data in cfme_data.get("storage", {}).get("managers", {}).iteritems():
        if keys and key not in keys:
            continue
        data = copy(data)
        if "credentials" in data:
            data["credentials"] = StorageManager.Credential(
                **credentials.get(data["credentials"], {}))
        result[key] = StorageManager(**data)
    return result
Exemplo n.º 9
0
def objects_from_config(*keys):
    result = {}
    for key, data in cfme_data.get("storage", {}).get("managers",
                                                      {}).iteritems():
        if keys and key not in keys:
            continue
        data = copy(data)
        if "credentials" in data:
            data["credentials"] = StorageManager.Credential(
                **credentials.get(data["credentials"], {}))
        result[key] = StorageManager(**data)
    return result
Exemplo n.º 10
0
def pytest_addoption(parser):
    group = parser.getgroup('Bugzilla integration')
    group.addoption('--bugzilla',
                    action='store_true',
                    default=cfme_data.get("bugzilla", {}).get("enabled", False),
                    dest='bugzilla',
                    help='Enable Bugzilla support.')
    group.addoption('--bugzilla-url',
                    action='store',
                    default=cfme_data.get("bugzilla", {}).get("url", None),
                    dest='bugzilla_url',
                    help='Bugzilla XMLRPC url.')
    cr_root = cfme_data.get("bugzilla", {}).get("credentials", None)
    group.addoption('--bugzilla-user',
                    action='store',
                    default=credentials.get(cr_root, {}).get("username", None),
                    dest='bugzilla_user',
                    help='Bugzilla user id.')
    group.addoption('--bugzilla-password',
                    action='store',
                    default=credentials.get(cr_root, {}).get("password", None),
                    dest='bugzilla_password',
                    help='Bugzilla password.')
Exemplo n.º 11
0
def pytest_addoption(parser):
    group = parser.getgroup('GitHub Issues integration')
    group.addoption('--github',
                    action='store_true',
                    default=cfme_data.get("github", {}).get("enabled", False),
                    dest='github',
                    help='Enable GitHub Issue blockers integration.')
    group.addoption('--github-default-repo',
                    action='store',
                    default=cfme_data.get("github", {}).get("default_repo", None),
                    dest='github_default_repo',
                    help='Default repo for GitHub queries')
    cr_root = cfme_data.get("github", {}).get("credentials", None)
    group.addoption('--github-user',
                    action='store',
                    default=credentials.get(cr_root, {}).get("username", None),
                    dest='github_user',
                    help='GH Username.')
    group.addoption('--github-password',
                    action='store',
                    default=credentials.get(cr_root, {}).get("password", None),
                    dest='github_password',
                    help='GH Password.')
Exemplo n.º 12
0
def setup_external_auth_ipa(**data):
    """Sets up the appliance for an external authentication with IPA.

    Keywords:
        get_groups: Get User Groups from External Authentication (httpd).
        ipaserver: IPA server address.
        iparealm: Realm.
        credentials: Key of the credential in credentials.yaml
    """
    connect_kwargs = {
        'username': credentials['host_default']['username'],
        'password': credentials['host_default']['password'],
        'hostname': data['ipaserver'],
    }
    current_appliance = get_or_create_current_appliance()
    appliance_name = 'cfmeappliance{}'.format(fauxfactory.gen_alpha(7).lower())
    appliance_address = current_appliance.address
    appliance_fqdn = '{}.{}'.format(appliance_name, data['iparealm'].lower())
    with SSHClient(**connect_kwargs) as ipaserver_ssh:
        ipaserver_ssh.run_command('cp /etc/hosts /etc/hosts_bak')
        ipaserver_ssh.run_command(
            "sed -i -r '/^{}/d' /etc/hosts".format(appliance_address))
        command = 'echo "{}\t{}" >> /etc/hosts'.format(appliance_address,
                                                       appliance_fqdn)
        ipaserver_ssh.run_command(command)
    with current_appliance.ssh_client as ssh:
        result = ssh.run_command(
            'appliance_console_cli --host {}'.format(appliance_fqdn)).success
        if not current_appliance.is_pod:
            assert result
        else:
            # appliance_console_cli fails when calls hostnamectl --host. it seems docker issue
            # raise BZ ?
            assert str(ssh.run_command('hostname')).rstrip() == appliance_fqdn

        ensure_browser_open()
        appliance.current_appliance.server.login_admin()
        if data["ipaserver"] not in get_ntp_servers():
            set_ntp_servers(data["ipaserver"])
            sleep(120)
        auth = ExternalAuthSetting(get_groups=data.pop("get_groups", False))
        auth.setup()
        creds = credentials.get(data.pop("credentials"), {})
        data.update(**creds)
        assert ssh.run_command(
            "appliance_console_cli --ipaserver {ipaserver} --iparealm {iparealm} "
            "--ipaprincipal {principal} --ipapassword {password}".format(
                **data))
    appliance.current_appliance.server.login_admin()
Exemplo n.º 13
0
def setup_external_auth_ipa(**data):
    """Sets up the appliance for an external authentication with IPA.

    Keywords:
        get_groups: Get User Groups from External Authentication (httpd).
        ipaserver: IPA server address.
        iparealm: Realm.
        credentials: Key of the credential in credentials.yaml
    """
    connect_kwargs = {
        'username': credentials['host_default']['username'],
        'password': credentials['host_default']['password'],
        'hostname': data['ipaserver'],
    }
    current_appliance = get_or_create_current_appliance()
    appliance_name = 'cfmeappliance{}'.format(fauxfactory.gen_alpha(7).lower())
    appliance_address = current_appliance.address
    appliance_fqdn = '{}.{}'.format(appliance_name, data['iparealm'].lower())
    with SSHClient(**connect_kwargs) as ipaserver_ssh:
        ipaserver_ssh.run_command('cp /etc/hosts /etc/hosts_bak')
        ipaserver_ssh.run_command("sed -i -r '/^{}/d' /etc/hosts".format(appliance_address))
        command = 'echo "{}\t{}" >> /etc/hosts'.format(appliance_address, appliance_fqdn)
        ipaserver_ssh.run_command(command)
    with current_appliance.ssh_client as ssh:
        result = ssh.run_command('appliance_console_cli --host {}'.format(appliance_fqdn)).success
        if not current_appliance.is_pod:
            assert result
        else:
            # appliance_console_cli fails when calls hostnamectl --host. it seems docker issue
            # raise BZ ?
            assert str(ssh.run_command('hostname')).rstrip() == appliance_fqdn

        ensure_browser_open()
        appliance.current_appliance.server.login_admin()
        if data["ipaserver"] not in get_ntp_servers():
            set_ntp_servers(data["ipaserver"])
            sleep(120)
        auth = ExternalAuthSetting(get_groups=data.pop("get_groups", False))
        auth.setup()
        creds = credentials.get(data.pop("credentials"), {})
        data.update(**creds)
        assert ssh.run_command(
            "appliance_console_cli --ipaserver {ipaserver} --iparealm {iparealm} "
            "--ipaprincipal {principal} --ipapassword {password}".format(**data)
        )
    appliance.current_appliance.server.login_admin()
Exemplo n.º 14
0
def setup_external_auth_ipa(**data):
    """Sets up the appliance for an external authentication with IPA.

    Keywords:
        get_groups: Get User Groups from External Authentication (httpd).
        ipaserver: IPA server address.
        iparealm: Realm.
        credentials: Key of the credential in credentials.yaml
    """
    connect_kwargs = {
        'username': credentials['host_default']['username'],
        'password': credentials['host_default']['password'],
        'hostname': data['ipaserver'],
    }
    import fauxfactory
    appliance_name = 'cfmeappliance'.format(fauxfactory.gen_alpha(7).lower())
    appliance_address = appliance.IPAppliance().address
    appliance_fqdn = '{}.{}'.format(appliance_name, data['iparealm'].lower())
    ipaserver_ssh = SSHClient(**connect_kwargs)
    # updating the /etc/hosts is a workaround due to the
    # https://bugzilla.redhat.com/show_bug.cgi?id=1360928
    command = 'echo "{}\t{}" >> /etc/hosts'.format(appliance_address, appliance_fqdn)
    ipaserver_ssh.run_command(command)
    ipaserver_ssh.close()
    ssh = SSHClient()
    rc, out = ssh.run_command('appliance_console_cli --host {}'.format(appliance_fqdn))
    assert rc == 0, out
    ssh.run_command('echo "127.0.0.1\t{}" > /etc/hosts'.format(appliance_fqdn))
    ensure_browser_open()
    login_admin()
    if data["ipaserver"] not in get_ntp_servers():
        set_ntp_servers(data["ipaserver"])
        sleep(120)
    auth = ExternalAuthSetting(get_groups=data.pop("get_groups", False))
    auth.setup()
    logout()
    creds = credentials.get(data.pop("credentials"), {})
    data.update(**creds)
    rc, out = ssh.run_command(
        "appliance_console_cli --ipaserver {ipaserver} --iparealm {iparealm} "
        "--ipaprincipal {principal} --ipapassword {password}".format(**data)
    )
    assert rc == 0, out
    assert "failed" not in out.lower(), "External auth setup failed:\n{}".format(out)
    login_admin()
Exemplo n.º 15
0
 def direct_connection(self):
     """Returns an API from mgmt_system.py targeted at this provider"""
     # Find the credentials entry
     name = str(self.host_name)
     from utils.conf import cfme_data, credentials
     for prov_id, provider in cfme_data.get("management_systems",
                                            {}).iteritems():
         if provider.get("hostname", None) == name or provider.get(
                 "region", None) == name:
             credentials = credentials.get(provider["credentials"], {})
             provider_id = prov_id
             break
     else:
         raise NameError("Could not find provider %s in the credentials!" %
                         name)
     ptype = str(self.type).lower()
     if ptype == "emsredhat":
         from utils.mgmt_system import RHEVMSystem
         return RHEVMSystem(self.host_name, credentials["username"],
                            credentials["password"])
     elif ptype == "emsvmware":
         from utils.mgmt_system import VMWareSystem
         return VMWareSystem(self.host_name, credentials["username"],
                             credentials["password"])
     elif ptype == "emsmicrosoft":
         from utils.mgmt_system import SCVMMSystem
         return SCVMMSystem(hostname=self.host_name,
                            username=credentials["username"],
                            password=credentials["password"],
                            domain=credentials["domain"])
     elif ptype == "emsamazon":
         from utils.mgmt_system import EC2System
         return EC2System(**credentials)
     elif ptype == "emsopenstack":
         from utils.mgmt_system import OpenstackSystem
         credentials.update({
             "auth_url":
             cfme_data.get("management_systems",
                           {})[provider_id]["auth_url"]
         })
         return OpenstackSystem(**credentials)
     else:
         TypeError("Unknown Provider type!")
Exemplo n.º 16
0
def setup_external_auth_ipa(**data):
    """Sets up the appliance for an external authentication with IPA.

    Keywords:
        get_groups: Get User Groups from External Authentication (httpd).
        ipaserver: IPA server address.
        iparealm: Realm.
        credentials: Key of the credential in credentials.yaml
    """
    connect_kwargs = {
        'username': credentials['host_default']['username'],
        'password': credentials['host_default']['password'],
        'hostname': data['ipaserver'],
    }
    appliance_name = 'cfmeappliance{}'.format(fauxfactory.gen_alpha(7).lower())
    appliance_address = appliance.IPAppliance().address
    appliance_fqdn = '{}.{}'.format(appliance_name, data['iparealm'].lower())
    ipaserver_ssh = SSHClient(**connect_kwargs)
    ipaserver_ssh.run_command('cp /etc/hosts /etc/hosts_bak')
    ipaserver_ssh.run_command(
        "sed -i -r '/^{}/d' /etc/hosts".format(appliance_address))
    command = 'echo "{}\t{}" >> /etc/hosts'.format(appliance_address,
                                                   appliance_fqdn)
    ipaserver_ssh.run_command(command)
    ipaserver_ssh.close()
    ssh = SSHClient()
    assert ssh.run_command(
        'appliance_console_cli --host {}'.format(appliance_fqdn))
    ensure_browser_open()
    login_admin()
    if data["ipaserver"] not in get_ntp_servers():
        set_ntp_servers(data["ipaserver"])
        sleep(120)
    auth = ExternalAuthSetting(get_groups=data.pop("get_groups", False))
    auth.setup()
    creds = credentials.get(data.pop("credentials"), {})
    data.update(**creds)
    assert ssh.run_command(
        "appliance_console_cli --ipaserver {ipaserver} --iparealm {iparealm} "
        "--ipaprincipal {principal} --ipapassword {password}".format(**data))
    login_admin()
Exemplo n.º 17
0
def setup_external_auth_ipa(**data):
    """Sets up the appliance for an external authentication with IPA.

    Keywords:
        get_groups: Get User Groups from External Authentication (httpd).
        ipaserver: IPA server address.
        iparealm: Realm.
        credentials: Key of the credential in credentials.yaml
    """
    connect_kwargs = {
        'username': credentials['host_default']['username'],
        'password': credentials['host_default']['password'],
        'hostname': data['ipaserver'],
    }
    appliance_name = 'cfmeappliance{}'.format(fauxfactory.gen_alpha(7).lower())
    appliance_address = appliance.IPAppliance().address
    appliance_fqdn = '{}.{}'.format(appliance_name, data['iparealm'].lower())
    ipaserver_ssh = SSHClient(**connect_kwargs)
    ipaserver_ssh.run_command('cp /etc/hosts /etc/hosts_bak')
    ipaserver_ssh.run_command("sed -i -r '/^{}/d' /etc/hosts".format(appliance_address))
    command = 'echo "{}\t{}" >> /etc/hosts'.format(appliance_address, appliance_fqdn)
    ipaserver_ssh.run_command(command)
    ipaserver_ssh.close()
    ssh = SSHClient()
    assert ssh.run_command('appliance_console_cli --host {}'.format(appliance_fqdn))
    ensure_browser_open()
    login_admin()
    if data["ipaserver"] not in get_ntp_servers():
        set_ntp_servers(data["ipaserver"])
        sleep(120)
    auth = ExternalAuthSetting(get_groups=data.pop("get_groups", False))
    auth.setup()
    creds = credentials.get(data.pop("credentials"), {})
    data.update(**creds)
    assert ssh.run_command(
        "appliance_console_cli --ipaserver {ipaserver} --iparealm {iparealm} "
        "--ipaprincipal {principal} --ipapassword {password}".format(**data)
    )
    login_admin()