コード例 #1
0
ファイル: booth.py プロジェクト: tomjelinek/pcs
def _ticket_operation(operation, env, ticket, site_ip):
    if not env.is_cib_live:
        raise LibraryError(reports.live_environment_required(["CIB"]))
    if not site_ip:
        site_ip_list = resource.find_bound_ip(
            get_resources(env.get_cib()),
            get_config_file_name(env.booth.name)
        )
        if len(site_ip_list) != 1:
            raise LibraryError(
                booth_reports.booth_cannot_determine_local_site_ip()
            )
        site_ip = site_ip_list[0]

    stdout, stderr, return_code = env.cmd_runner().run([
        settings.booth_binary, operation,
        "-s", site_ip,
        ticket
    ])

    if return_code != 0:
        raise LibraryError(
            booth_reports.booth_ticket_operation_failed(
                operation,
                join_multilines([stderr, stdout]),
                site_ip,
                ticket
            )
        )
コード例 #2
0
def _ticket_operation(
    operation, env: LibraryEnvironment, ticket_name, site_ip, instance_name
):
    booth_env = env.get_booth_env(instance_name)
    _ensure_live_env(env, booth_env)

    if not site_ip:
        site_ip_list = resource.find_bound_ip(
            get_resources(env.get_cib()), booth_env.config_path
        )
        if len(site_ip_list) != 1:
            raise LibraryError(
                ReportItem.error(
                    reports.messages.BoothCannotDetermineLocalSiteIp()
                )
            )
        site_ip = site_ip_list[0]

    stdout, stderr, return_code = env.cmd_runner().run(
        [settings.booth_binary, operation, "-s", site_ip, ticket_name]
    )

    if return_code != 0:
        raise LibraryError(
            ReportItem.error(
                reports.messages.BoothTicketOperationFailed(
                    operation,
                    join_multilines([stderr, stdout]),
                    site_ip,
                    ticket_name,
                )
            )
        )
コード例 #3
0
def _ticket_operation(operation, env, ticket, site_ip):
    if not env.is_cib_live:
        raise LibraryError(reports.live_environment_required(["CIB"]))
    if not site_ip:
        site_ip_list = resource.find_bound_ip(
            get_resources(env.get_cib()),
            get_config_file_name(env.booth.name)
        )
        if len(site_ip_list) != 1:
            raise LibraryError(
                booth_reports.booth_cannot_determine_local_site_ip()
            )
        site_ip = site_ip_list[0]

    stdout, stderr, return_code = env.cmd_runner().run([
        settings.booth_binary, operation,
        "-s", site_ip,
        ticket
    ])

    if return_code != 0:
        raise LibraryError(
            booth_reports.booth_ticket_operation_failed(
                operation,
                join_multilines([stderr, stdout]),
                site_ip,
                ticket
            )
        )
コード例 #4
0
ファイル: booth.py プロジェクト: wyatt88/pcs
def ticket_operation(operation, env, name, ticket, site_ip):
    if not site_ip:
        site_ip_list = resource.find_bound_ip(
            get_resources(env.get_cib()),
            get_config_file_name(name)
        )
        if len(site_ip_list) != 1:
            raise LibraryError(
                booth_reports.booth_cannot_determine_local_site_ip()
            )
        site_ip = site_ip_list[0]

    command_output, return_code = env.cmd_runner().run([
        settings.booth_binary, operation,
        "-s", site_ip,
        ticket
    ])

    if return_code != 0:
        raise LibraryError(
            booth_reports.booth_ticket_operation_failed(
                operation,
                command_output,
                site_ip,
                ticket
            )
        )
コード例 #5
0
 def test_returns_None_when_no_ip(self):
     self.assertEqual(
         [],
         booth_resource.find_bound_ip(
             self.fixture_resource_section([]),
             "/PATH/TO/CONF",
         )
     )
コード例 #6
0
ファイル: test_resource.py プロジェクト: rriifftt/pcs
 def test_returns_ip_when_correctly_found(self):
     self.assertEqual(["192.168.122.31"],
                      booth_resource.find_bound_ip(
                          self.fixture_resource_section([
                              fixture_ip_element("ip1", "192.168.122.31"),
                          ]),
                          "/PATH/TO/CONF",
                      ))
コード例 #7
0
ファイル: test_resource.py プロジェクト: idevat/pcs
 def test_returns_ip_when_correctly_found(self):
     self.assertEqual(
         ["192.168.122.31"],
         booth_resource.find_bound_ip(
             self.fixture_resource_section([
                 fixture_ip_element("ip1", "192.168.122.31"),
             ]),
             "/PATH/TO/CONF",
         )
     )
コード例 #8
0
 def test_returns_none_when_more_ip(self):
     self.assertEqual(
         ["192.168.122.31", "192.168.122.32"],
         booth_resource.find_bound_ip(
             self.fixture_resource_section([
                 fixture_ip_element("ip1", "192.168.122.31"),
                 fixture_ip_element("ip2", "192.168.122.32"),
             ]),
             "/PATH/TO/CONF",
         ),
     )
コード例 #9
0
def _ticket_operation(operation, env, ticket_name, site_ip, instance_name):
    booth_env = env.get_booth_env(instance_name)
    _ensure_live_env(env, booth_env)

    if not site_ip:
        site_ip_list = resource.find_bound_ip(get_resources(env.get_cib()),
                                              booth_env.config_path)
        if len(site_ip_list) != 1:
            raise LibraryError(
                booth_reports.booth_cannot_determine_local_site_ip())
        site_ip = site_ip_list[0]

    stdout, stderr, return_code = env.cmd_runner().run(
        [settings.booth_binary, operation, "-s", site_ip, ticket_name])

    if return_code != 0:
        raise LibraryError(
            booth_reports.booth_ticket_operation_failed(
                operation, join_multilines([stderr, stdout]), site_ip,
                ticket_name))