How to use the broker.utils.MockHub function in broker

To help you get started, we’ve selected a few broker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github quattor / aquilon / tests / broker / test_update_building.py View on Github external
def test_133_cannot_change_dns_domain_if_some_hosts_still_aligned_to_it(
            self):
        # If there are hosts in a building that align with the building's
        # default DNS domain, and then that building's default DNS domain is
        # subsequently changed, command 'aq update_building ...
        # --default_dns_domain ...' should emit a warning and abort unless
        # '--force_dns_domain' is used.
        mh = MockHub(self)
        building = mh.add_building()
        mh.add_hosts(2, building=building)
        old_dns_domain = mh.add_dns_domain('old.ms.cc')
        self.noouttest(['update_building', '--building', building,
                        '--default_dns_domain', old_dns_domain])
        # Add a host aligned with the default DNS domain old_dns_domain.
        mh.add_host(building=building)
        new_dns_domain = mh.add_dns_domain('new.ms.cc')
        command = ['update_building', '--building', building,
                   '--default_dns_domain', new_dns_domain]
        # An attempt to assign domain to building should fail with a warning.
        out = self.badrequesttest(command)

        self.searchoutput(
            out,
            (r'There is at least one host in building .*' + building
github quattor / aquilon / tests / broker / test_del_city.py View on Github external
def test_400_disallows_orphaned_cities_without_force(self):
        mh = MockHub(engine=self)
        country = mh.add_country()
        city = mh.add_city(country=country)
        mh.delete_countries()
        command = ['del_city', '--city', city]
        err = self.badrequesttest(command)
        self.searchoutput(
            err,
            (r'City "' + city + r'" is not associated with any country.*'
             + r'use --force_if_orphaned if you want to delete it.*'
             + r'cannot be automatically rolled back.*'
             ),
            command)
        mh.delete()
github quattor / aquilon / tests / broker / test_update_building.py View on Github external
def test_133_dns_domain_change_can_be_forced_even_if_hosts_use_previous(
            self):
        # Option --force_dns_domain should allow the default DNS domain to
        # be changed even if there are still some host aligned to the
        # previous default DNS domain in the building.
        mh = MockHub(self)
        building = mh.add_building()
        mh.add_hosts(2, building=building)
        old_dns_domain = mh.add_dns_domain('old.ms.cc')
        self.noouttest(['update_building', '--building', building,
                        '--default_dns_domain', old_dns_domain])
        # Add a host aligned with the default DNS domain old_dns_domain.
        mh.add_host(building=building)
        new_dns_domain = mh.add_dns_domain('new.ms.cc')
        self.successtest(['update_building', '--building', building,
                          '--default_dns_domain', new_dns_domain,
                          '--force_dns_domain'])
        command = ['show_building', '--building', building]
        out = self.commandtest(command)
        self.matchoutput(out, 'Default DNS Domain: {}'.format(new_dns_domain),
                         command)
        mh.delete()
github quattor / aquilon / tests / broker / test_update_building.py View on Github external
def test_133_current_default_dns_domain_should_be_assumed_valid(self):
        # In order to improve performance,
        # Given I run aq update_building ... --default_dns_domain ...,
        # When the currently set default DNS domain is the same as the new one,
        # I want CommandUpdateBuilding to skip all its DNS domain validation
        # checks.
        mh = MockHub(self)
        building = mh.add_building()
        mh.add_hosts(2, building=building)
        old_dns_domain = mh.add_dns_domain('old.ms.cc')
        self.noouttest(['update_building', '--building', building,
                        '--default_dns_domain', old_dns_domain])
        # Add a host aligned with the default DNS domain old_dns_domain.
        mh.add_host(building=building)
        # Since 'building' now contains a host that is aligned with the default
        # DNS domain of 'building', the following command will only succeed if
        # the DNS domain verification checks are skipped because the system
        # detects that the given DNS domain is the same as the currently set
        # one.
        self.successtest(['update_building', '--building', building,
                          '--default_dns_domain', old_dns_domain])
        command = ['show_building', '--building', building]
        out = self.commandtest(command)
github quattor / aquilon / tests / broker / test_del_city.py View on Github external
def test_400_force_if_orphaned_has_no_impact_on_non_orphaned(self):
        mh = MockHub(engine=self)
        country = mh.add_country()
        city = mh.add_city(country=country)
        command = ['del_city', '--city', city, '--force_if_orphaned']
        self.dsdb_expect('delete_city_aq -city {}'.format(city))
        self.successtest(command)
        self.dsdb_verify()
        mh.cities.remove(city)
        mh.delete()
github quattor / aquilon / tests / broker / test_del_city.py View on Github external
def test_400_can_be_forced_for_orphaned_cities(self):
        mh = MockHub(engine=self)
        country = mh.add_country()
        city = mh.add_city(country=country)
        mh.delete_countries()
        command = ['del_city', '--city', city, '--force_if_orphaned']
        self.dsdb_expect('delete_city_aq -city {}'.format(city))
        self.successtest(command)
        self.dsdb_verify()
        mh.cities.remove(city)
        mh.delete()