Exemplo n.º 1
0
 def test_mount_data_invalid_device_ref_raises_valueerror(self):
     """test_mount_data raises ValueError if device is invalid ref."""
     mnt = self.mnt.copy()
     mnt['device'] = 'myinvalid'
     scfg = OrderedDict([(i['id'], i) for i in self.base_cfg + [mnt]])
     with self.assertRaisesRegexp(ValueError, r".*refers.*myinvalid"):
         block_meta.mount_data(mnt, scfg)
Exemplo n.º 2
0
 def test_mount_data_invalid_format_ref_raises_valueerror(self):
     """test_mount_data raises ValueError if format.volume is invalid."""
     mycfg = copy.deepcopy(self.base_cfg) + [self.mnt.copy()]
     scfg = OrderedDict([(i['id'], i) for i in mycfg])
     # change the 'volume' entry for the 'format' type.
     scfg['fs1']['volume'] = 'myinvalidvol'
     with self.assertRaisesRegexp(ValueError, r".*refers.*myinvalidvol"):
         block_meta.mount_data(scfg['m1'], scfg)
Exemplo n.º 3
0
    def test_spec_fstype_override_inline(self, m_gptsv, m_is_iscsi):
        """spec and fstype are preferred over lookups from 'device' ref.

        If a mount entry has 'fstype' and 'spec', those are prefered over
        values looked up via the 'device' reference present in the entry.
        The test here enforces that the device reference present in
        the mount entry is not looked up, that isn't strictly necessary.
        """
        m_gptsv.side_effect = Exception(
            "Unexpected Call to get_path_to_storage_volume")
        m_is_iscsi.return_value = Exception(
            "Unexpected Call to volpath_is_iscsi")

        myspec = '/dev/disk/by-label/LABEL=rfs'
        mnt = {
            'id': 'm1',
            'type': 'mount',
            'device': 'fs1',
            'path': '/',
            'options': 'noatime',
            'spec': myspec,
            'fstype': 'ext3'
        }
        scfg = OrderedDict([(i['id'], i) for i in self.base_cfg + [mnt]])
        self.assertEqual(
            block_meta.FstabData(spec=myspec,
                                 fstype="ext3",
                                 path="/",
                                 options="noatime",
                                 freq="0",
                                 passno="0",
                                 device=None),
            block_meta.mount_data(mnt, scfg))
Exemplo n.º 4
0
    def test_device_mount_iscsi(self, m_gptsv, m_is_iscsi):
        """mount_data for a iscsi device should have _netdev in opts."""
        m_gptsv.side_effect = self._my_gptsv
        m_is_iscsi.return_value = True

        scfg = OrderedDict([(i['id'], i) for i in self.base_cfg + [self.mnt]])
        self.assertEqual(
            block_meta.FstabData(spec=None,
                                 fstype="ext4",
                                 path="/",
                                 options="noatime,_netdev",
                                 freq="0",
                                 passno="0",
                                 device="/dev/xda1"),
            block_meta.mount_data(scfg['m1'], scfg))
Exemplo n.º 5
0
    def test_device_mount_basic(self, m_gptsv, m_is_iscsi):
        """Test mount_data for FstabData with a device."""
        m_gptsv.side_effect = self._my_gptsv
        m_is_iscsi.return_value = False

        scfg = OrderedDict([(i['id'], i) for i in self.base_cfg + [self.mnt]])
        self.assertEqual(
            block_meta.FstabData(spec=None,
                                 fstype="ext4",
                                 path="/",
                                 options="noatime",
                                 freq="0",
                                 passno="0",
                                 device="/dev/xda1"),
            block_meta.mount_data(scfg['m1'], scfg))
Exemplo n.º 6
0
 def test_non_device_mount_with_spec(self):
     """mount_info with a spec does not need device."""
     info = {
         'id': 'xm1',
         'spec': 'none',
         'type': 'mount',
         'fstype': 'tmpfs',
         'path': '/tmpfs'
     }
     self.assertEqual(
         block_meta.FstabData(spec="none",
                              fstype="tmpfs",
                              path="/tmpfs",
                              options="defaults",
                              freq="0",
                              passno="0",
                              device=None),
         block_meta.mount_data(info, {'xm1': info}))
Exemplo n.º 7
0
    def test_device_mount_boot_efi(self, m_gptsv, m_is_iscsi):
        """Test mount_data fat fs gets converted to vfat."""
        bcfg = copy.deepcopy(self.base_cfg)
        bcfg[2]['fstype'] = 'fat32'
        mnt = {
            'id': 'm1',
            'type': 'mount',
            'device': 'fs1',
            'path': '/boot/efi'
        }
        m_gptsv.side_effect = self._my_gptsv

        scfg = OrderedDict([(i['id'], i) for i in bcfg + [mnt]])
        self.assertEqual(
            block_meta.FstabData(spec=None,
                                 fstype="vfat",
                                 path="/boot/efi",
                                 options="defaults",
                                 freq="0",
                                 passno="0",
                                 device="/dev/xda1"),
            block_meta.mount_data(scfg['m1'], scfg))
Exemplo n.º 8
0
 def test_mount_data_no_device_or_spec_raises_valueerror(self):
     """test_mount_data raises ValueError if no device or spec."""
     mnt = self.mnt.copy()
     del mnt['device']
     with self.assertRaisesRegexp(ValueError, r".*mount.*missing.*"):
         block_meta.mount_data(mnt, {mnt['id']: mnt})
Exemplo n.º 9
0
 def test_mount_data_raises_valueerror_if_not_mount(self):
     """mount_data on non-mount type raises ValueError."""
     mnt = self.mnt.copy()
     mnt['type'] = "not-mount"
     with self.assertRaisesRegexp(ValueError, r".*not type 'mount'"):
         block_meta.mount_data(mnt, {mnt['id']: mnt})