|
7 | 7 | from insights.core.exceptions import ContentException, SkipComponent
|
8 | 8 | from insights.parsers.aws_instance_id import AWSInstanceIdDoc
|
9 | 9 | from insights.parsers.azure_instance import AzureInstanceID, AzureInstanceType
|
| 10 | +from insights.parsers.dmidecode import DMIDecode |
10 | 11 | from insights.parsers.gcp_instance_type import GCPInstanceType
|
11 | 12 | from insights.parsers.installed_rpms import InstalledRpms
|
12 | 13 | from insights.parsers.subscription_manager import SubscriptionManagerFacts
|
|
23 | 24 | uname.sysname: Linux
|
24 | 25 | """.strip()
|
25 | 26 |
|
| 27 | +AWS_RHSM_FACTS = """ |
| 28 | +aws_instance_id: i-01234567890abcdef |
| 29 | +aws_instance_type: m5.large |
| 30 | +""".strip() |
| 31 | + |
| 32 | +AWS_RHSM_FACTS_NO_TYPE = """ |
| 33 | +aws_instance_id: i-01234567890abcdef |
| 34 | +""".strip() |
| 35 | + |
| 36 | +AWS_DMIDECODE = """ |
| 37 | +# dmidecode 3.3 |
| 38 | +Getting SMBIOS data from sysfs. |
| 39 | +SMBIOS 2.7 present. |
| 40 | +13 structures occupying 568 bytes. |
| 41 | +Table at 0xBFFF0000. |
| 42 | +
|
| 43 | +Handle 0x0000, DMI type 0, 24 bytes |
| 44 | +BIOS Information |
| 45 | + Vendor: Amazon EC2 |
| 46 | + Version: 1.0 |
| 47 | + Release Date: 10/16/2017 |
| 48 | + Address: 0xF0000 |
| 49 | + Runtime Size: 64 kB |
| 50 | + ROM Size: 64 kB |
| 51 | + Characteristics: |
| 52 | + PCI is supported |
| 53 | + EDD is supported |
| 54 | + ACPI is supported |
| 55 | + System is a virtual machine |
| 56 | + BIOS Revision: 1.0 |
| 57 | +
|
| 58 | +Handle 0x000C, DMI type 127, 4 bytes |
| 59 | +End Of Table |
| 60 | +""".strip() |
| 61 | + |
26 | 62 |
|
27 | 63 | def test_cloud_instance_google():
|
28 | 64 | rpms = InstalledRpms(context_wrap(RPMS_GOOGLE))
|
@@ -59,6 +95,30 @@ def test_cloud_instance_azure():
|
59 | 95 | assert ret.size == "Standard_NV48s_v3"
|
60 | 96 |
|
61 | 97 |
|
| 98 | +def test_cloud_instance_aws_from_submanfacts(): |
| 99 | + rpms = InstalledRpms(context_wrap(RPMS_AWS)) |
| 100 | + bios = DMIDecode(context_wrap(AWS_DMIDECODE)) |
| 101 | + facts = SubscriptionManagerFacts(context_wrap(AWS_RHSM_FACTS)) |
| 102 | + cp = CloudProvider(rpms, bios, None, None) |
| 103 | + ret = CloudInstance(cp, None, None, None, None, facts) |
| 104 | + assert ret.provider == CloudProvider.AWS |
| 105 | + assert ret.id == "i-01234567890abcdef" |
| 106 | + assert ret.type == "m5.large" |
| 107 | + assert ret.size == "m5.large" |
| 108 | + |
| 109 | + |
| 110 | +def test_cloud_instance_aws_from_submanfacts_no_type(): |
| 111 | + rpms = InstalledRpms(context_wrap(RPMS_AWS)) |
| 112 | + bios = DMIDecode(context_wrap(AWS_DMIDECODE)) |
| 113 | + facts = SubscriptionManagerFacts(context_wrap(AWS_RHSM_FACTS_NO_TYPE)) |
| 114 | + cp = CloudProvider(rpms, bios, None, None) |
| 115 | + ret = CloudInstance(cp, None, None, None, None, facts) |
| 116 | + assert ret.provider == CloudProvider.AWS |
| 117 | + assert ret.id == "i-01234567890abcdef" |
| 118 | + assert ret.type is None |
| 119 | + assert ret.size is None |
| 120 | + |
| 121 | + |
62 | 122 | def test_cloud_instance_ex():
|
63 | 123 | rpms = InstalledRpms(context_wrap(RPMS_GOOGLE))
|
64 | 124 | _type = GCPInstanceType(context_wrap(GOOGLE_TYPE_1))
|
|
0 commit comments