Ejemplo n.º 1
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
Ejemplo n.º 2
0
 def test_copy_from_vfat_drive_mtools_not_given(self):
     with self.assertRaises(exception.CloudbaseInitException) as cm:
         vfat.copy_from_vfat_drive(mock.sentinel.osutils,
                                   mock.sentinel.drive_path,
                                   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]))
Ejemplo n.º 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
Ejemplo n.º 4
0
 def test_copy_from_vfat_drive_mtools_not_given(self):
     with self.assertRaises(exception.CloudbaseInitException) as cm:
         vfat.copy_from_vfat_drive(mock.sentinel.osutils,
                                   mock.sentinel.drive_path,
                                   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]))
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 7
0
    def test_copy(self, mock_os_chdir):
        cwd = os.getcwd()
        mock_osutils = mock.Mock()

        vfat.copy_from_vfat_drive(mock_osutils, mock.sentinel.drive, mock.sentinel.target_path)

        mock_os_chdir_calls = [mock.call(mock.sentinel.target_path), mock.call(cwd)]
        self.assertEqual(mock_os_chdir_calls, mock_os_chdir.mock_calls)
        self.assertEqual(os.getcwd(), cwd)

        mcopy = os.path.join(CONF.mtools_path, "mcopy.exe")
        mock_osutils.execute_process.assert_called_once_with(
            [mcopy, "-s", "-n", "-i", mock.sentinel.drive, "::/", "."], shell=False
        )
Ejemplo n.º 8
0
    def test_copy(self, mock_os_chdir):
        cwd = os.getcwd()
        mock_osutils = mock.Mock()

        vfat.copy_from_vfat_drive(mock_osutils, mock.sentinel.drive,
                                  mock.sentinel.target_path)

        mock_os_chdir_calls = [
            mock.call(mock.sentinel.target_path),
            mock.call(cwd),
        ]
        self.assertEqual(mock_os_chdir_calls, mock_os_chdir.mock_calls)
        self.assertEqual(os.getcwd(), cwd)

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