コード例 #1
0
ファイル: test_utils.py プロジェクト: bacaldwell/ironic
 def test_check_dir_ok(self, mock_free_space, mock_dir_writable, mock_exists):
     mock_exists.return_value = True
     self.config(tempdir="/fake/path")
     utils.check_dir()
     mock_exists.assert_called_once_with(CONF.tempdir)
     mock_dir_writable.assert_called_once_with(CONF.tempdir)
     mock_free_space.assert_called_once_with(CONF.tempdir, 1)
コード例 #2
0
ファイル: test_utils.py プロジェクト: bacaldwell/ironic
 def test_check_dir_with_pass_in(self, mock_free_space, mock_dir_writable, mock_exists):
     mock_exists.return_value = True
     # test passing in a directory and size
     utils.check_dir(directory_to_check="/fake/path", required_space=5)
     mock_exists.assert_called_once_with("/fake/path")
     mock_dir_writable.assert_called_once_with("/fake/path")
     mock_free_space.assert_called_once_with("/fake/path", 5)
コード例 #3
0
ファイル: test_utils.py プロジェクト: ajya/ironic-fork
 def test_check_dir_with_pass_in(self, mock_free_space, mock_dir_writable,
                                 mock_exists):
     mock_exists.return_value = True
     # test passing in a directory and size
     utils.check_dir(directory_to_check='/fake/path', required_space=5)
     mock_exists.assert_called_once_with('/fake/path')
     mock_dir_writable.assert_called_once_with('/fake/path')
     mock_free_space.assert_called_once_with('/fake/path', 5)
コード例 #4
0
 def test_check_dir_ok(self, mock_free_space, mock_dir_writable,
                       mock_exists):
     mock_exists.return_value = True
     self.config(tempdir='/fake/path')
     utils.check_dir()
     mock_exists.assert_called_once_with(CONF.tempdir)
     mock_dir_writable.assert_called_once_with(CONF.tempdir)
     mock_free_space.assert_called_once_with(CONF.tempdir, 1)
コード例 #5
0
ファイル: test_utils.py プロジェクト: yzping/ironic
 def test_check_dir_with_pass_in(self, mock_gettempdir, mock_free_space,
                                 mock_dir_writable, mock_exists):
     mock_exists.return_value = True
     # test passing in a directory and size
     utils.check_dir(directory_to_check='/fake/path', required_space=5)
     self.assertFalse(mock_gettempdir.called)
     mock_free_space.assert_called_once_with('/fake/path', 5)
     mock_exists.assert_called_once_with('/fake/path')
コード例 #6
0
ファイル: test_utils.py プロジェクト: yzping/ironic
    def test_check_dir_ok(self, mock_gettempdir, mock_dir_writable,
                          mock_free_space, mock_exists):
        mock_gettempdir.return_value = "/fake/path"
        mock_exists.return_value = True

        utils.check_dir()
        mock_gettempdir.assert_called_once_with()
        mock_free_space.assert_called_once_with(mock_gettempdir.return_value)
        mock_exists.assert_called_once_with(mock_gettempdir.return_value)
コード例 #7
0
ファイル: test_utils.py プロジェクト: yzping/ironic
    def test_check_dir_with_conf(self, mock_gettempdir, mock_free_space,
                                 mock_dir_writable, mock_exists):
        self.config(tempdir='/fake/path')
        mock_exists.return_value = True

        utils.check_dir()
        self.assertFalse(mock_gettempdir.called)
        mock_free_space.assert_called_once_with(CONF.tempdir, 1)
        mock_exists.assert_called_once_with(CONF.tempdir)
コード例 #8
0
ファイル: test_utils.py プロジェクト: ajya/ironic-fork
 def test_check_dir_ok(self, mock_free_space, mock_dir_writable):
     self.config(tempdir='/fake/path')
     # NOTE(dtantsur): self.config uses os.path.exists, so we cannot mock
     # on the method level.
     with mock.patch.object(os.path, 'exists',
                            autospec=True) as mock_exists:
         mock_exists.return_value = True
         utils.check_dir()
         mock_exists.assert_called_once_with(CONF.tempdir)
     mock_dir_writable.assert_called_once_with(CONF.tempdir)
     mock_free_space.assert_called_once_with(CONF.tempdir, 1)
コード例 #9
0
ファイル: test_utils.py プロジェクト: michaeltchapman/ironic
 def test_check_dir_ok(self, mock_free_space, mock_dir_writable):
     self.config(tempdir='/fake/path')
     # NOTE(dtantsur): self.config uses os.path.exists, so we cannot mock
     # on the method level.
     with mock.patch.object(os.path, 'exists',
                            autospec=True) as mock_exists:
         mock_exists.return_value = True
         utils.check_dir()
         mock_exists.assert_called_once_with(CONF.tempdir)
     mock_dir_writable.assert_called_once_with(CONF.tempdir)
     mock_free_space.assert_called_once_with(CONF.tempdir, 1)
コード例 #10
0
def _check_temp_dir():
    """Check for Valid temp directory."""
    global TMP_DIR_CHECKED
    # because a temporary file is used to pass the password to ipmitool,
    # we should check the directory
    if TMP_DIR_CHECKED is None:
        try:
            utils.check_dir()
        except (exception.PathNotFound, exception.DirectoryNotWritable,
                exception.InsufficientDiskSpace) as e:
            with excutils.save_and_reraise_exception():
                TMP_DIR_CHECKED = False
                err_msg = (_("Ipmitool drivers need to be able to create "
                             "temporary files to pass password to ipmitool. "
                             "Encountered error: %s") % e)
                e.message = err_msg
                LOG.error(err_msg)
        else:
            TMP_DIR_CHECKED = True
コード例 #11
0
ファイル: ipmitool.py プロジェクト: ISCAS-VDI/ironic-base
def _check_temp_dir():
    """Check for Valid temp directory."""
    global TMP_DIR_CHECKED
    # because a temporary file is used to pass the password to ipmitool,
    # we should check the directory
    if TMP_DIR_CHECKED is None:
        try:
            utils.check_dir()
        except (exception.PathNotFound,
                exception.DirectoryNotWritable,
                exception.InsufficientDiskSpace) as e:
            with excutils.save_and_reraise_exception():
                TMP_DIR_CHECKED = False
                err_msg = (_("Ipmitool drivers need to be able to create "
                             "temporary files to pass password to ipmitool. "
                             "Encountered error: %s") % e)
                e.message = err_msg
                LOG.error(err_msg)
        else:
            TMP_DIR_CHECKED = True