Ejemplo n.º 1
0
def test_docs():
    cp_aws = CloudProvider(
        IRPMS(context_wrap(RPMS_AWS)),
        DMIDecode(context_wrap(DMIDECODE_AWS)),
        YumRepoList(context_wrap(YUM_REPOLIST_NOT_AZURE)),
        None
    )
    cp_azure = CloudProvider(
        IRPMS(context_wrap(RPMS_AZURE)),
        DMIDecode(context_wrap(DMIDECODE_AZURE_ASSET_TAG)),
        YumRepoList(context_wrap(YUM_REPOLIST_AZURE)),
        None
    )
    cp_alibaba = CloudProvider(
        IRPMS(context_wrap(RPMS)),
        DMIDecode(context_wrap(DMIDECODE_ALIBABA)),
        YumRepoList(context_wrap(YUM_REPOLIST_NOT_AZURE)),
        None
    )
    cp_ibm = CloudProvider(
        None, None, None, RHSMConf(context_wrap(IBM_RHSM_CONF))
    )
    env = {
        'cp_aws': cp_aws,
        'cp_azure': cp_azure,
        'cp_alibaba': cp_alibaba,
        'cp_ibm': cp_ibm
    }
    failed, total = doctest.testmod(cloud_provider, globs=env)
    assert failed == 0
def test_rpm_google():
    irpms = IRPMS(context_wrap(RPMS_GOOGLE))
    dmi = DMIDecode(context_wrap(DMIDECODE))
    yrl = YumRepoList(context_wrap(YUM_REPOLIST_NOT_AZURE))
    ret = CloudProvider(irpms, dmi, yrl)
    assert ret.cloud_provider == 'google'
    assert ret.cp_rpms.get('google')[0] == 'google-rhui-client-5.1.100-1.el7'
Ejemplo n.º 3
0
def test_rhsm_conf_ibm():
    rhsm_conf = RHSMConf(context_wrap(IBM_RHSM_CONF))
    ret = CloudProvider(None, None, None, rhsm_conf)
    assert ret.cloud_provider == CloudProvider.IBM
    assert ret.cp_rhsm_server_hostname[
        CloudProvider.IBM] == 'host.networklayer.com'
    assert ret.long_name == 'IBM Cloud'
Ejemplo n.º 4
0
def test_rpm_azure():
    irpms = IRPMS(context_wrap(RPMS_AZURE))
    dmi = DMIDecode(context_wrap(DMIDECODE_BARE_METAL))
    yrl = YumRepoList(context_wrap(YUM_REPOLIST_NOT_AZURE))
    ret = CloudProvider(irpms, dmi, yrl)
    assert ret.cloud_provider == 'azure'
    assert ret.cp_rpms.get('azure')[0] == 'WALinuxAgent-2.2.18-1.el7'
Ejemplo n.º 5
0
def test_dmidecode_alibaba():
    irpms = IRPMS(context_wrap(RPMS))
    dmi = DMIDecode(context_wrap(DMIDECODE_ALIBABA))
    yrl = YumRepoList(context_wrap(YUM_REPOLIST_NOT_AZURE))
    ret = CloudProvider(irpms, dmi, yrl)
    assert ret.cloud_provider == CloudProvider.ALIBABA
    assert ret.cp_manufacturer[CloudProvider.ALIBABA] == 'Alibaba Cloud'
Ejemplo n.º 6
0
def test__uuid():
    irpms = IRPMS(context_wrap(RPMS))
    dmi = DMIDecode(context_wrap(DMIDECODE_AWS_UUID))
    yrl = YumRepoList(context_wrap(YUM_REPOLIST_NOT_AZURE))
    ret = CloudProvider(irpms, dmi, yrl)
    assert ret.cloud_provider == 'aws'
    assert ret.cp_uuid['aws'] == 'EC2F58AF-2DAD-C57E-88C0-A81CB6084290'
Ejemplo n.º 7
0
def test__bios_vendor_google():
    irpms = IRPMS(context_wrap(RPMS))
    dmi = DMIDecode(context_wrap(DMIDECODE_GOOGLE))
    yrl = YumRepoList(context_wrap(YUM_REPOLIST_AZURE))
    ret = CloudProvider(irpms, dmi, yrl)
    assert ret.cloud_provider == 'google'
    assert ret.cp_bios_vendor['google'] == 'Google'
Ejemplo n.º 8
0
def test__asset_tag_azure():
    irpms = IRPMS(context_wrap(RPMS))
    dmi = DMIDecode(context_wrap(DMIDECODE_AZURE_ASSET_TAG))
    yrl = YumRepoList(context_wrap(YUM_REPOLIST_NOT_AZURE))
    ret = CloudProvider(irpms, dmi, yrl)
    assert ret.cloud_provider == 'azure'
    assert ret.cp_asset_tag['azure'] == '7783-7084-3265-9085-8269-3286-77'
Ejemplo n.º 9
0
def test__yum_azure():
    irpms = IRPMS(context_wrap(RPMS))
    dmi = DMIDecode(context_wrap(DMIDECODE))
    yrl = YumRepoList(context_wrap(YUM_REPOLIST_AZURE))
    ret = CloudProvider(irpms, dmi, yrl)
    assert ret.cloud_provider == 'azure'
    assert 'rhui-microsoft-azure-rhel7-2.2-74' in ret.cp_yum.get('azure')
Ejemplo n.º 10
0
def test__bios_version_aws():
    irpms = IRPMS(context_wrap(RPMS))
    dmi = DMIDecode(context_wrap(DMIDECODE_AWS))
    yrl = YumRepoList(context_wrap(YUM_REPOLIST_AZURE))
    ret = CloudProvider(irpms, dmi, yrl)
    assert ret.cloud_provider == 'aws'
    assert ret.cp_bios_version['aws'] == '4.2.amazon'
Ejemplo n.º 11
0
def test_rpm_aws():
    irpms = IRPMS(context_wrap(RPMS_AWS))
    dmi = DMIDecode(context_wrap(DMIDECODE))
    yrl = YumRepoList(context_wrap(YUM_REPOLIST_NOT_AZURE))
    ret = CloudProvider(irpms, dmi, yrl)
    assert ret.cloud_provider == 'aws'
    assert ret.cp_rpms.get('aws')[0] == 'rh-amazon-rhui-client-2.2.124-1.el7'
Ejemplo n.º 12
0
def test_no_data():
    irpms = IRPMS(context_wrap(RPMS))
    dmi = DMIDecode(context_wrap(DMIDECODE))
    yrl = YumRepoList(context_wrap(YUM_REPOLIST_NOT_AZURE))
    ret = CloudProvider(irpms, dmi, yrl, None)
    assert ret.cloud_provider is None
    assert ret.long_name is None
Ejemplo n.º 13
0
def test__uuid_not_aws():
    irpms = IRPMS(context_wrap(RPMS))
    dmi = DMIDecode(context_wrap(DMIDECODE_BARE_METAL))
    yrl = YumRepoList(context_wrap(YUM_REPOLIST_NOT_AZURE))
    ret = CloudProvider(irpms, dmi, yrl, None)
    assert ret.cloud_provider is None
    assert ret.cp_uuid[
        CloudProvider.AWS] == 'EC245678-1234-1234-1234-123456681234'
Ejemplo n.º 14
0
def test_rpm_aws():
    irpms = IRPMS(context_wrap(RPMS_AWS))
    dmi = DMIDecode(context_wrap(DMIDECODE))
    yrl = YumRepoList(context_wrap(YUM_REPOLIST_NOT_AZURE))
    ret = CloudProvider(irpms, dmi, yrl, None)
    assert ret.cloud_provider == CloudProvider.AWS
    assert ret.cp_rpms.get(CloudProvider.AWS)[0] == 'rh-amazon-rhui-client-2.2.124-1.el7'
    assert ret.long_name == 'Amazon Web Services'
Ejemplo n.º 15
0
def test_rpm_google():
    irpms = IRPMS(context_wrap(RPMS_GOOGLE))
    dmi = DMIDecode(context_wrap(DMIDECODE))
    yrl = YumRepoList(context_wrap(YUM_REPOLIST_NOT_AZURE))
    ret = CloudProvider(irpms, dmi, yrl, None)
    assert ret.cloud_provider == CloudProvider.GOOGLE
    assert 'google-rhui-client-5.1.100-1.el7' in ret.cp_rpms.get(CloudProvider.GOOGLE)
    assert 'google-rhui-client-5.1.100-1.el6' in ret.cp_rpms.get(CloudProvider.GOOGLE)
    assert ret.long_name == 'Google Cloud'
def test_is_aws():
    dmi = DMIDecode(context_wrap(DMIDECODE_AWS))
    cp = CloudProvider(None, dmi, None, None)
    result = IsAWS(cp)
    assert isinstance(result, IsAWS)
def test_is_gcp():
    dmi = DMIDecode(context_wrap(DMIDECODE_GOOGLE))
    cp = CloudProvider(None, dmi, None, None)
    result = IsGCP(cp)
    assert isinstance(result, IsGCP)
def test_is_azure():
    dmi = DMIDecode(context_wrap(DMIDECODE_AZURE_ASSET_TAG))
    cp = CloudProvider(None, dmi, None, None)
    result = IsAzure(cp)
    assert isinstance(result, IsAzure)