Ejemplo n.º 1
0
    def test_detect_openstack_oraclecloud_chassis_asset_tag(
            self, m_dmi, m_is_x86):
        """Return True on OpenStack reporting Oracle cloud asset-tag."""
        m_is_x86.return_value = True

        def fake_dmi_read(dmi_key):
            if dmi_key == 'system-product-name':
                return 'Standard PC (i440FX + PIIX, 1996)'  # No match
            if dmi_key == 'chassis-asset-tag':
                return 'OracleCloud.com'
            assert False, 'Unexpected dmi read of %s' % dmi_key

        m_dmi.side_effect = fake_dmi_read
        self.assertTrue(
            ds.detect_openstack(accept_oracle=True),
            'Expected detect_openstack == True on OracleCloud.com')
        self.assertFalse(ds.detect_openstack(accept_oracle=False),
                         'Expected detect_openstack == False.')
Ejemplo n.º 2
0
    def test_detect_openstack_intel_product_name_compute(self, m_dmi,
                                                         m_is_x86):
        """Return True on OpenStack compute and nova instances."""
        m_is_x86.return_value = True
        openstack_product_names = ['OpenStack Nova', 'OpenStack Compute']

        for product_name in openstack_product_names:
            m_dmi.return_value = product_name
            self.assertTrue(
                ds.detect_openstack(), 'Failed to detect_openstack')
Ejemplo n.º 3
0
    def test_detect_openstack_oraclecloud_chassis_asset_tag(self, m_dmi,
                                                            m_is_x86):
        """Return True on OpenStack reporting Oracle cloud asset-tag."""
        m_is_x86.return_value = True

        def fake_dmi_read(dmi_key):
            if dmi_key == 'system-product-name':
                return 'Standard PC (i440FX + PIIX, 1996)'  # No match
            if dmi_key == 'chassis-asset-tag':
                return 'OracleCloud.com'
            assert False, 'Unexpected dmi read of %s' % dmi_key

        m_dmi.side_effect = fake_dmi_read
        self.assertTrue(
            ds.detect_openstack(accept_oracle=True),
            'Expected detect_openstack == True on OracleCloud.com')
        self.assertFalse(
            ds.detect_openstack(accept_oracle=False),
            'Expected detect_openstack == False.')
Ejemplo n.º 4
0
    def test_detect_openstack_intel_product_name_compute(self, m_dmi,
                                                         m_is_x86):
        """Return True on OpenStack compute and nova instances."""
        m_is_x86.return_value = True
        openstack_product_names = ['OpenStack Nova', 'OpenStack Compute']

        for product_name in openstack_product_names:
            m_dmi.return_value = product_name
            self.assertTrue(
                ds.detect_openstack(), 'Failed to detect_openstack')
Ejemplo n.º 5
0
    def test_detect_openstack_sapccloud_chassis_asset_tag(
            self, m_dmi, m_is_x86):
        """Return True on OpenStack reporting SAP CCloud VM asset-tag."""
        m_is_x86.return_value = True

        def fake_dmi_read(dmi_key):
            if dmi_key == 'system-product-name':
                return 'VMware Virtual Platform'  # SAP CCloud uses VMware
            if dmi_key == 'chassis-asset-tag':
                return 'SAP CCloud VM'
            assert False, 'Unexpected dmi read of %s' % dmi_key

        m_dmi.side_effect = fake_dmi_read
        self.assertTrue(ds.detect_openstack(),
                        'Expected detect_openstack == True on SAP CCloud VM')
Ejemplo n.º 6
0
    def test_detect_openstack_opentelekomcloud_chassis_asset_tag(self, m_dmi,
                                                                 m_is_x86):
        """Return True on OpenStack reporting OpenTelekomCloud asset-tag."""
        m_is_x86.return_value = True

        def fake_dmi_read(dmi_key):
            if dmi_key == 'system-product-name':
                return 'HVM domU'  # Nothing 'openstackish' on OpenTelekomCloud
            if dmi_key == 'chassis-asset-tag':
                return 'OpenTelekomCloud'
            assert False, 'Unexpected dmi read of %s' % dmi_key

        m_dmi.side_effect = fake_dmi_read
        self.assertTrue(
            ds.detect_openstack(),
            'Expected detect_openstack == True on OpenTelekomCloud')
Ejemplo n.º 7
0
    def _test_detect_openstack_nova_compute_chassis_asset_tag(
            self, m_dmi, m_is_x86, chassis_tag):
        """Return True on OpenStack reporting generic asset-tag."""
        m_is_x86.return_value = True

        def fake_dmi_read(dmi_key):
            if dmi_key == 'system-product-name':
                return 'Generic OpenStack Platform'
            if dmi_key == 'chassis-asset-tag':
                return chassis_tag
            assert False, 'Unexpected dmi read of %s' % dmi_key

        m_dmi.side_effect = fake_dmi_read
        self.assertTrue(
            ds.detect_openstack(),
            'Expected detect_openstack == True on Generic OpenStack Platform')
Ejemplo n.º 8
0
    def test_detect_openstack_opentelekomcloud_chassis_asset_tag(self, m_dmi,
                                                                 m_is_x86):
        """Return True on OpenStack reporting OpenTelekomCloud asset-tag."""
        m_is_x86.return_value = True

        def fake_dmi_read(dmi_key):
            if dmi_key == 'system-product-name':
                return 'HVM domU'  # Nothing 'openstackish' on OpenTelekomCloud
            if dmi_key == 'chassis-asset-tag':
                return 'OpenTelekomCloud'
            assert False, 'Unexpected dmi read of %s' % dmi_key

        m_dmi.side_effect = fake_dmi_read
        self.assertTrue(
            ds.detect_openstack(),
            'Expected detect_openstack == True on OpenTelekomCloud')
Ejemplo n.º 9
0
    def test_not_detect_openstack_intel_x86_ec2(self, m_dmi, m_proc_env,
                                                m_is_x86):
        """Return False on EC2 platforms."""
        m_is_x86.return_value = True
        # No product_name in proc/1/environ
        m_proc_env.return_value = {'HOME': '/'}

        def fake_dmi_read(dmi_key):
            if dmi_key == 'system-product-name':
                return 'HVM domU'  # Nothing 'openstackish' on EC2
            if dmi_key == 'chassis-asset-tag':
                return ''  # Empty string on EC2
            assert False, 'Unexpected dmi read of %s' % dmi_key

        m_dmi.side_effect = fake_dmi_read
        self.assertFalse(
            ds.detect_openstack(), 'Expected detect_openstack == False on EC2')
        m_proc_env.assert_called_with(1)
Ejemplo n.º 10
0
    def test_not_detect_openstack_intel_x86_ec2(self, m_dmi, m_proc_env,
                                                m_is_x86):
        """Return False on EC2 platforms."""
        m_is_x86.return_value = True
        # No product_name in proc/1/environ
        m_proc_env.return_value = {"HOME": "/"}

        def fake_dmi_read(dmi_key):
            if dmi_key == "system-product-name":
                return "HVM domU"  # Nothing 'openstackish' on EC2
            if dmi_key == "chassis-asset-tag":
                return ""  # Empty string on EC2
            assert False, "Unexpected dmi read of %s" % dmi_key

        m_dmi.side_effect = fake_dmi_read
        self.assertFalse(ds.detect_openstack(),
                         "Expected detect_openstack == False on EC2")
        m_proc_env.assert_called_with(1)
Ejemplo n.º 11
0
    def test_not_detect_openstack_intel_x86_ec2(self, m_dmi, m_proc_env,
                                                m_is_x86):
        """Return False on EC2 platforms."""
        m_is_x86.return_value = True
        # No product_name in proc/1/environ
        m_proc_env.return_value = {'HOME': '/'}

        def fake_dmi_read(dmi_key):
            if dmi_key == 'system-product-name':
                return 'HVM domU'  # Nothing 'openstackish' on EC2
            if dmi_key == 'chassis-asset-tag':
                return ''  # Empty string on EC2
            assert False, 'Unexpected dmi read of %s' % dmi_key

        m_dmi.side_effect = fake_dmi_read
        self.assertFalse(
            ds.detect_openstack(), 'Expected detect_openstack == False on EC2')
        m_proc_env.assert_called_with(1)
Ejemplo n.º 12
0
    def test_detect_openstack_by_proc_1_environ(self, m_dmi, m_proc_env,
                                                m_is_x86):
        """Return True when nova product_name specified in /proc/1/environ."""
        m_is_x86.return_value = True
        # Nova product_name in proc/1/environ
        m_proc_env.return_value = {
            'HOME': '/', 'product_name': 'OpenStack Nova'}

        def fake_dmi_read(dmi_key):
            if dmi_key == 'system-product-name':
                return 'HVM domU'  # Nothing 'openstackish'
            if dmi_key == 'chassis-asset-tag':
                return ''  # Nothin 'openstackish'
            assert False, 'Unexpected dmi read of %s' % dmi_key

        m_dmi.side_effect = fake_dmi_read
        self.assertTrue(
            ds.detect_openstack(),
            'Expected detect_openstack == True on OpenTelekomCloud')
        m_proc_env.assert_called_with(1)
Ejemplo n.º 13
0
    def test_detect_openstack_by_proc_1_environ(self, m_dmi, m_proc_env,
                                                m_is_x86):
        """Return True when nova product_name specified in /proc/1/environ."""
        m_is_x86.return_value = True
        # Nova product_name in proc/1/environ
        m_proc_env.return_value = {
            'HOME': '/', 'product_name': 'OpenStack Nova'}

        def fake_dmi_read(dmi_key):
            if dmi_key == 'system-product-name':
                return 'HVM domU'  # Nothing 'openstackish'
            if dmi_key == 'chassis-asset-tag':
                return ''  # Nothin 'openstackish'
            assert False, 'Unexpected dmi read of %s' % dmi_key

        m_dmi.side_effect = fake_dmi_read
        self.assertTrue(
            ds.detect_openstack(),
            'Expected detect_openstack == True on OpenTelekomCloud')
        m_proc_env.assert_called_with(1)
Ejemplo n.º 14
0
    def test_detect_openstack_by_proc_1_environ(self, m_dmi, m_proc_env,
                                                m_is_x86):
        """Return True when nova product_name specified in /proc/1/environ."""
        m_is_x86.return_value = True
        # Nova product_name in proc/1/environ
        m_proc_env.return_value = {
            "HOME": "/",
            "product_name": "OpenStack Nova",
        }

        def fake_dmi_read(dmi_key):
            if dmi_key == "system-product-name":
                return "HVM domU"  # Nothing 'openstackish'
            if dmi_key == "chassis-asset-tag":
                return ""  # Nothin 'openstackish'
            assert False, "Unexpected dmi read of %s" % dmi_key

        m_dmi.side_effect = fake_dmi_read
        self.assertTrue(
            ds.detect_openstack(),
            "Expected detect_openstack == True on OpenTelekomCloud",
        )
        m_proc_env.assert_called_with(1)
Ejemplo n.º 15
0
 def test_detect_openstack_non_intel_x86(self, m_is_x86):
     """Return True on non-intel platforms because dmi isn't conclusive."""
     m_is_x86.return_value = False
     self.assertTrue(
         ds.detect_openstack(), 'Expected detect_openstack == True')
Ejemplo n.º 16
0
 def test_detect_openstack_non_intel_x86(self, m_is_x86):
     """Return True on non-intel platforms because dmi isn't conclusive."""
     m_is_x86.return_value = False
     self.assertTrue(
         ds.detect_openstack(), 'Expected detect_openstack == True')