Пример #1
0
 def test_is_vfat_drive_mtools_not_given(self):
     with self.assertRaises(exception.CloudbaseInitException) as cm:
         vfat.is_vfat_drive(mock.sentinel.osutils,
                            mock.sentinel.target_path)
     expected_message = ('"mtools_path" needs to be provided in order '
                         'to access VFAT drives')
     self.assertEqual(expected_message, str(cm.exception.args[0]))
Пример #2
0
 def test_is_vfat_drive_mtools_not_given(self):
     with self.assertRaises(exception.CloudbaseInitException) as cm:
         vfat.is_vfat_drive(mock.sentinel.osutils,
                            mock.sentinel.target_path)
     expected_message = ('"mtools_path" needs to be provided in order '
                         'to access VFAT drives')
     self.assertEqual(expected_message, str(cm.exception.args[0]))
Пример #3
0
 def _get_config_drive_from_vfat(self):
     for drive_path in self._osutils.get_physical_disks():
         if vfat.is_vfat_drive(self._osutils, drive_path):
             LOG.info('Config Drive found on disk %r', drive_path)
             vfat.copy_from_vfat_drive(self._osutils, drive_path,
                                       self.target_path)
             return True
     return False
Пример #4
0
 def _get_config_drive_from_vfat(self):
     for drive_path in self._osutils.get_physical_disks():
         if vfat.is_vfat_drive(self._osutils, drive_path):
             LOG.info('Config Drive found on disk %r', drive_path)
             vfat.copy_from_vfat_drive(self._osutils, drive_path,
                                       self.target_path)
             return True
     return False
Пример #5
0
 def _get_conf_drive_from_vfat(self, target_path):
     osutils = osutils_factory.get_os_utils()
     for drive_path in osutils.get_physical_disks():
         if vfat.is_vfat_drive(osutils, drive_path):
             LOG.info('Config Drive found on disk %r', drive_path)
             os.makedirs(target_path)
             vfat.copy_from_vfat_drive(osutils, drive_path, target_path)
             return True
Пример #6
0
 def _get_conf_drive_from_vfat(self, target_path):
     osutils = osutils_factory.get_os_utils()
     for drive_path in osutils.get_physical_disks():
         if vfat.is_vfat_drive(osutils, drive_path):
             LOG.info('Config Drive found on disk %r', drive_path)
             os.makedirs(target_path)
             vfat.copy_from_vfat_drive(osutils, drive_path, target_path)
             return True
Пример #7
0
    def _test_is_vfat_drive(self, execute_process_value, expected_logging, expected_response):

        mock_osutils = mock.Mock()
        mock_osutils.execute_process.return_value = execute_process_value

        with testutils.LogSnatcher("cloudbaseinit.utils.windows." "vfat") as snatcher:
            with testutils.ConfPatcher("mtools_path", "mtools_path"):

                response = vfat.is_vfat_drive(mock_osutils, mock.sentinel.drive)

                mdir = os.path.join(CONF.mtools_path, "mlabel.exe")
                mock_osutils.execute_process.assert_called_once_with(
                    [mdir, "-i", mock.sentinel.drive, "-s"], shell=False
                )

        self.assertEqual(expected_logging, snatcher.output)
        self.assertEqual(expected_response, response)
Пример #8
0
    def _test_is_vfat_drive(self, execute_process_value, expected_logging,
                            expected_response):

        mock_osutils = mock.Mock()
        mock_osutils.execute_process.return_value = execute_process_value

        with testutils.LogSnatcher('cloudbaseinit.utils.windows.'
                                   'vfat') as snatcher:
            with testutils.ConfPatcher('mtools_path', 'mtools_path'):

                response = vfat.is_vfat_drive(mock_osutils,
                                              mock.sentinel.drive)

                mdir = os.path.join(CONF.mtools_path, "mlabel.exe")
                mock_osutils.execute_process.assert_called_once_with(
                    [mdir, "-i", mock.sentinel.drive, "-s"], shell=False)

        self.assertEqual(expected_logging, snatcher.output)
        self.assertEqual(expected_response, response)