Ejemplo n.º 1
0
def create_plan_to_start_services_after_rebooting(services, rebooted_hosts, components):
    start_plan = metalogic(
        yadtshell.settings.START,
        services,
        plan_post_handler=identity)

    for start_action in start_plan.actions:
        if start_action.uri in services:
            for host_uri in get_all_adjacent_needed_hosts(start_action.uri, components):
                if host_uri in rebooted_hosts:
                    start_action.preconditions.add(yadtshell.actions.TargetState(
                        host_uri, 'state', 'rebooted'))

    return start_plan
    def test_should_include_hosts_from_host_and_service_dependencies(self):
        self.service.needs = ['host://thehost', 'service://otherhost/otherservice']

        adjacent_hosts = get_all_adjacent_needed_hosts(self.service.uri, self.components)

        self.assertEqual(adjacent_hosts, set(['host://otherhost', 'host://thehost']))
    def test_should_include_immediate_host_from_service(self):
        self.service.needs = ['host://thehost']

        adjacent_hosts = get_all_adjacent_needed_hosts(self.service.uri, self.components)

        self.assertEqual(adjacent_hosts, set(['host://thehost']))