예제 #1
0
파일: iscsi.py 프로젝트: tjjh89017/curtin
def restart_iscsi_service():
    LOG.info('restarting iscsi service')
    if util.uses_systemd():
        cmd = ['systemctl', 'reload-or-restart', 'open-iscsi']
    else:
        cmd = ['service', 'open-iscsi', 'restart']
    util.subp(cmd, capture=True)
예제 #2
0
 def test_uses_systemd_on_systemd(self):
     """ Test that uses_systemd returns True if sdpath is a dir """
     # systemd_enabled
     self.mock_isdir.return_value = True
     result = util.uses_systemd()
     self.assertEqual(True, result)
     self.assertEqual(1, len(self.mock_isdir.call_args_list))
예제 #3
0
    def test_uses_systemd_cached(self):
        """Test that we cache the uses_systemd result"""

        # reset_cache should ensure it's unset
        self.assertEqual(None, util._USES_SYSTEMD)

        # systemd enabled
        self.mock_isdir.return_value = True

        # first time
        first_result = util.uses_systemd()

        # check the cache value
        self.assertEqual(first_result, util._USES_SYSTEMD)

        # second time
        second_result = util.uses_systemd()

        # results should match between tries
        self.assertEqual(True, first_result)
        self.assertEqual(True, second_result)

        # isdir should only be called once
        self.assertEqual(1, len(self.mock_isdir.call_args_list))
예제 #4
0
 def test_uses_systemd_on_non_systemd(self):
     """ Test that uses_systemd returns False if sdpath is not a dir """
     # systemd not available
     self.mock_isdir.return_value = False
     result = util.uses_systemd()
     self.assertEqual(False, result)