コード例 #1
0
ファイル: test_qdevice_net.py プロジェクト: thulyacloud/pcs
    def test_success(self, mock_initialized):
        mock_initialized.return_value = False
        self.mock_runner.run.return_value = ("initialized", "", 0)

        lib.qdevice_setup(self.mock_runner)

        mock_initialized.assert_called_once_with()
        self.mock_runner.run.assert_called_once_with([_qnetd_cert_tool, "-i"])
コード例 #2
0
ファイル: test_qdevice_net.py プロジェクト: tomjelinek/pcs
    def test_success(self, mock_initialized):
        mock_initialized.return_value = False
        self.mock_runner.run.return_value = ("initialized", "", 0)

        lib.qdevice_setup(self.mock_runner)

        mock_initialized.assert_called_once_with()
        self.mock_runner.run.assert_called_once_with([_qnetd_cert_tool, "-i"])
コード例 #3
0
    def test_success(self, mock_is_dir_nonempty):
        mock_is_dir_nonempty.return_value = False
        self.mock_runner.run.return_value = ("initialized", 0)

        lib.qdevice_setup(self.mock_runner)

        mock_is_dir_nonempty.assert_called_once_with(_qnetd_cert_dir)
        self.mock_runner.run.assert_called_once_with([_qnetd_tool, "-i"])
コード例 #4
0
def qdevice_setup(lib_env: LibraryEnvironment, model, enable, start):
    """
    Initialize qdevice on local host with specified model
    string model qdevice model to initialize
    bool enable make qdevice service start on boot
    bool start start qdevice now
    """
    _check_model(model)
    qdevice_net.qdevice_setup(lib_env.cmd_runner())
    lib_env.report_processor.report(
        ReportItem.info(reports.messages.QdeviceInitializationSuccess(model)))
    if enable:
        _service_enable(lib_env, qdevice_net.qdevice_enable)
    if start:
        _service_start(lib_env, qdevice_net.qdevice_start)
コード例 #5
0
ファイル: qdevice.py プロジェクト: wuyeliang/pcs
def qdevice_setup(lib_env, model, enable, start):
    """
    Initialize qdevice on local host with specified model
    string model qdevice model to initialize
    bool enable make qdevice service start on boot
    bool start start qdevice now
    """
    _check_model(model)
    qdevice_net.qdevice_setup(lib_env.cmd_runner())
    lib_env.report_processor.process(
        reports.qdevice_initialization_success(model))
    if enable:
        _service_enable(lib_env, qdevice_net.qdevice_enable)
    if start:
        _service_start(lib_env, qdevice_net.qdevice_start)
コード例 #6
0
ファイル: qdevice.py プロジェクト: tomjelinek/pcs
def qdevice_setup(lib_env, model, enable, start):
    """
    Initialize qdevice on local host with specified model
    string model qdevice model to initialize
    bool enable make qdevice service start on boot
    bool start start qdevice now
    """
    _check_model(model)
    qdevice_net.qdevice_setup(lib_env.cmd_runner())
    lib_env.report_processor.process(
        reports.qdevice_initialization_success(model)
    )
    if enable:
        _service_enable(lib_env, qdevice_net.qdevice_enable)
    if start:
        _service_start(lib_env, qdevice_net.qdevice_start)
コード例 #7
0
ファイル: test_qdevice_net.py プロジェクト: thulyacloud/pcs
    def test_cert_db_exists(self, mock_initialized):
        mock_initialized.return_value = True

        assert_raise_library_error(
            lambda: lib.qdevice_setup(self.mock_runner),
            (severity.ERROR, report_codes.QDEVICE_ALREADY_INITIALIZED, {
                "model": "net"
            }))

        mock_initialized.assert_called_once_with()
        self.mock_runner.run.assert_not_called()
コード例 #8
0
ファイル: test_qdevice_net.py プロジェクト: thulyacloud/pcs
    def test_init_tool_fail(self, mock_initialized):
        mock_initialized.return_value = False
        self.mock_runner.run.return_value = ("stdout", "test error", 1)

        assert_raise_library_error(
            lambda: lib.qdevice_setup(self.mock_runner),
            (severity.ERROR, report_codes.QDEVICE_INITIALIZATION_ERROR, {
                "model": "net",
                "reason": "test error\nstdout",
            }))

        mock_initialized.assert_called_once_with()
        self.mock_runner.run.assert_called_once_with([_qnetd_cert_tool, "-i"])
コード例 #9
0
ファイル: test_qdevice_net.py プロジェクト: tomjelinek/pcs
    def test_cert_db_exists(self, mock_initialized):
        mock_initialized.return_value = True

        assert_raise_library_error(
            lambda: lib.qdevice_setup(self.mock_runner),
            (
                severity.ERROR,
                report_codes.QDEVICE_ALREADY_INITIALIZED,
                {"model": "net"}
            )
        )

        mock_initialized.assert_called_once_with()
        self.mock_runner.run.assert_not_called()
コード例 #10
0
ファイル: test_qdevice_net.py プロジェクト: tomjelinek/pcs
    def test_init_tool_fail(self, mock_initialized):
        mock_initialized.return_value = False
        self.mock_runner.run.return_value = ("stdout", "test error", 1)

        assert_raise_library_error(
            lambda: lib.qdevice_setup(self.mock_runner),
            (
                severity.ERROR,
                report_codes.QDEVICE_INITIALIZATION_ERROR,
                {
                    "model": "net",
                    "reason": "test error\nstdout",
                }
            )
        )

        mock_initialized.assert_called_once_with()
        self.mock_runner.run.assert_called_once_with([_qnetd_cert_tool, "-i"])