def get_dasd_device_data_test(self):
        """Test GetDeviceData for DASD."""
        self._add_device(
            DASDDevice("dev1",
                       fmt=get_format("ext4"),
                       busid="0.0.0201",
                       opts={}))

        data = self.interface.GetDeviceData("dev1")
        self.assertEqual(data['type'], get_variant(Str, 'dasd'))
        self.assertEqual(data['attrs'],
                         get_variant(Dict[Str, Str], {"busid": "0.0.0201"}))
    def test_get_dasd_device_data(self):
        """Test GetDeviceData for DASD."""
        self._add_device(
            DASDDevice("dev1",
                       fmt=get_format("ext4"),
                       size=Size("10 GiB"),
                       busid="0.0.0201",
                       opts={}))

        data = self.interface.GetDeviceData("dev1")
        assert data['type'] == get_variant(Str, 'dasd')
        assert data['attrs'] == get_variant(Dict[Str, Str],
                                            {"bus-id": "0.0.0201"})
示例#3
0
    def find_formattable_test(self, blockdev):
        """Test FindFormattable."""
        with self.assertRaises(UnavailableStorageError):
            self.dasd_interface.FindFormattable(["dev1"])

        storage = create_storage()
        self.dasd_module.on_storage_changed(storage)

        with self.assertRaises(UnknownDeviceError):
            self.dasd_interface.FindFormattable(["dev1"])

        storage.devicetree._add_device(
            DASDDevice("dev1",
                       fmt=get_format("ext4"),
                       size=Size("10 GiB"),
                       busid="0.0.0201",
                       opts={}))

        # The policy doesn't allow tp format anything.
        self.assertEqual(self.dasd_interface.FindFormattable(["dev1"]), [])

        # The policy allows to format unformatted, but there are only FBA DASDs.
        self.dasd_module.on_format_unrecognized_enabled_changed(True)
        blockdev.s390.dasd_is_fba.return_value = True
        self.assertEqual(self.dasd_interface.FindFormattable(["dev1"]), [])

        # The policy allows to format unformatted, but there are none.
        self.dasd_module.on_format_unrecognized_enabled_changed(True)
        blockdev.s390.dasd_is_fba.return_value = False
        blockdev.s390.dasd_needs_format.return_value = False
        self.assertEqual(self.dasd_interface.FindFormattable(["dev1"]), [])

        # The policy allows to format LDL, but there are none.
        self.dasd_module.on_format_unrecognized_enabled_changed(False)
        self.dasd_module.on_format_ldl_enabled_changed(True)
        blockdev.s390.dasd_is_ldl.return_value = False
        self.assertEqual(self.dasd_interface.FindFormattable(["dev1"]), [])

        # The policy allows to format all and there are all.
        self.dasd_module.on_format_unrecognized_enabled_changed(True)
        blockdev.s390.dasd_needs_format.return_value = True
        blockdev.s390.dasd_is_ldl.return_value = True
        self.assertEqual(self.dasd_interface.FindFormattable(["dev1"]),
                         ["dev1"])
示例#4
0
    def get_dasd_device_data_test(self):
        """Test GetDeviceData for DASD."""
        self._add_device(DASDDevice(
            "dev1",
            fmt=get_format("ext4"),
            busid="0.0.0201",
            opts={}
        ))

        self.assertEqual(self.interface.GetDeviceData("dev1"), {
            'type': get_variant(Str, 'dasd'),
            '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], {
                "busid": "0.0.0201"
            }),
        })