Exemple #1
0
    def test_auto_tags(self):
        #
        # automatically-set tags for DiskDevice
        #
        with patch('blivet.devices.disk.util') as patched_util:
            patched_util.get_sysfs_attr.return_value = None
            d = DiskDevice('test1')
            self.assertIn(Tags.local, d.tags)
            self.assertNotIn(Tags.ssd, d.tags)
            self.assertNotIn(Tags.usb, d.tags)

            patched_util.get_sysfs_attr.return_value = '1'
            d = DiskDevice('test2')
            self.assertIn(Tags.local, d.tags)
            self.assertNotIn(Tags.ssd, d.tags)

            patched_util.get_sysfs_attr.return_value = '0'
            d = DiskDevice('test2')
            self.assertIn(Tags.local, d.tags)
            self.assertIn(Tags.ssd, d.tags)

        self.assertNotIn(Tags.usb, DiskDevice('test3').tags)
        self.assertIn(Tags.usb, DiskDevice('test4', bus='usb').tags)

        #
        # automatically-set tags for networked storage devices
        #
        iscsi_kwarg_names = [
            "initiator", "nic", "node", "ibft", "fw_name", "fw_address",
            "fw_port"
        ]
        iscsi_device = iScsiDiskDevice(
            'test5', **dict((k, None) for k in iscsi_kwarg_names))
        self.assertIn(Tags.remote, iscsi_device.tags)
        self.assertNotIn(Tags.local, iscsi_device.tags)
        fcoe_device = FcoeDiskDevice('test6', nic=None, identifier=None)
        self.assertIn(Tags.remote, fcoe_device.tags)
        self.assertNotIn(Tags.local, fcoe_device.tags)
        zfcp_device = ZFCPDiskDevice('test7',
                                     hba_id=None,
                                     wwpn=None,
                                     fcp_lun=None)
        self.assertIn(Tags.remote, zfcp_device.tags)
        self.assertNotIn(Tags.local, zfcp_device.tags)

        multipath_device = MultipathDevice('test8', parents=[iscsi_device])
        self.assertIn(Tags.remote, multipath_device.tags)
        self.assertNotIn(Tags.local, multipath_device.tags)

        #
        # built-in tags should also be accessible as str
        #
        self.assertIn("remote", multipath_device.tags)
Exemple #2
0
    def get_zfcp_device_data_test(self):
        """Test GetDeviceData for zFCP."""
        self._add_device(ZFCPDiskDevice(
            "dev1",
            fmt=get_format("ext4"),
            fcp_lun="0x5719000000000000",
            wwpn="0x5005076300c18154",
            hba_id="0.0.010a"
        ))

        data = self.interface.GetDeviceData("dev1")
        self.assertEqual(data['type'], get_variant(Str, 'zfcp'))
        self.assertEqual(data['attrs'], get_variant(Dict[Str, Str], {
            "fcp_lun": "0x5719000000000000",
            "wwpn": "0x5005076300c18154",
            "hba_id": "0.0.010a"
        }))
    def test_get_zfcp_device_data(self):
        """Test GetDeviceData for zFCP."""
        self._add_device(
            ZFCPDiskDevice("dev1",
                           fmt=get_format("ext4"),
                           size=Size("10 GiB"),
                           fcp_lun="0x5719000000000000",
                           wwpn="0x5005076300c18154",
                           hba_id="0.0.010a"))

        data = self.interface.GetDeviceData("dev1")
        assert data['type'] == get_variant(Str, 'zfcp')
        assert data['attrs'] == get_variant(
            Dict[Str, Str], {
                "fcp-lun": "0x5719000000000000",
                "wwpn": "0x5005076300c18154",
                "hba-id": "0.0.010a"
            })
Exemple #4
0
    def get_zfcp_device_data_test(self):
        """Test GetDeviceData for zFCP."""
        self._add_device(ZFCPDiskDevice(
            "dev1",
            fmt=get_format("ext4"),
            fcp_lun="0x5719000000000000",
            wwpn="0x5005076300c18154",
            hba_id="0.0.010a"
        ))

        self.assertEqual(self.interface.GetDeviceData("dev1"), {
            'type': get_variant(Str, 'zfcp'),
            'name': get_variant(Str, 'dev1'),
            'path': get_variant(Str, '/dev/dev1'),
            'size': get_variant(UInt64, 0),
            'is-disk': get_variant(Bool, True),
            'attrs': get_variant(Dict[Str, Str], {
                "fcp_lun": "0x5719000000000000",
                "wwpn": "0x5005076300c18154",
                "hba_id": "0.0.010a"
            }),
        })