How to use the broker.utils.import_depends 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_personality.py View on Github external
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module for testing the update personality command."""

if __name__ == "__main__":
    from broker import utils
    utils.import_depends()

import unittest2 as unittest
from broker.brokertest import TestBrokerCommand
from broker.grntest import VerifyGrnsMixin


class TestUpdatePersonality(VerifyGrnsMixin, TestBrokerCommand):

    def test_200_invalid_function(self):
        """ Verify that the list of built-in functions is restricted """
        command = ["update_personality", "--personality", "vulcan-1g-desktop-prod",
                   "--archetype", "esx_cluster",
                   "--vmhost_capacity_function", "locals()"]
        out = self.badrequesttest(command)
        self.matchoutput(out, "name 'locals' is not defined", command)
github quattor / aquilon / tests / broker / test_add_host.py View on Github external
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module for testing the add host command."""

import unittest

if __name__ == "__main__":
    from broker import utils
    utils.import_depends()

from broker.brokertest import TestBrokerCommand
from networktest import DummyIP
from machinetest import MachineTestMixin


class TestAddHost(MachineTestMixin, TestBrokerCommand):
    def test_100_add_unittest16_fail_ipfromtype(self):
        # Test fail to use --ipfromtype for hosts not in bunker
        command = ["add", "host",
                   "--hostname", "unittest16.aqd-unittest.ms.com",
                   "--ipfromtype", "localvip", "--ipalgorithm", "lowest",
                   "--machine", "ut8s02p2", "--domain", "unittest",
                   "--archetype", "aquilon",
                   "--personality", "compileserver"]
        err = self.badrequesttest(command)
github quattor / aquilon / tests / broker / test_del_parameter.py View on Github external
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module for testing the del parameter command."""

import unittest

if __name__ == "__main__":
    from broker import utils
    utils.import_depends()

from broker.brokertest import TestBrokerCommand


class TestDelParameter(TestBrokerCommand):

    def test_100_del_testrequired(self):
        self.check_plenary_exists("aquilon", "personality", "utpers-dev+next",
                                  "foo")
        self.noouttest(["del_parameter", "--personality", "utpers-dev",
                        "--archetype", "aquilon", "--path", "foo/testrequired"])
        self.check_plenary_gone("aquilon", "personality", "utpers-dev+next",
                                "foo")

    def test_110_del_single_action(self):
        self.noouttest(["del_parameter", "--personality", "utpers-dev",
github quattor / aquilon / tests / broker / test_update_alias.py View on Github external
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module for testing the update archetype command."""

import unittest

if __name__ == "__main__":
    from broker import utils
    utils.import_depends()

from broker.brokertest import TestBrokerCommand
from eventstest import EventsTestMixin


class TestUpdateAlias(EventsTestMixin, TestBrokerCommand):

    def test_100_update(self):
        command = ["update", "alias",
                   "--fqdn", "alias2host.aqd-unittest.ms.com",
                   "--target", "arecord14.aqd-unittest.ms.com"]
        self.noouttest(command)

    def test_105_update_self(self):
        command = ["update_alias",
                   "--fqdn", "alias2alias.aqd-unittest.ms.com",
github quattor / aquilon / tests / broker / test_update_parameter.py View on Github external
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module for testing the update parameter command."""

import unittest

if __name__ == "__main__":
    from broker import utils
    utils.import_depends()

from broker.brokertest import TestBrokerCommand


class TestUpdateParameter(TestBrokerCommand):

    def check_match(self, out, expected, command):
        out = ' '.join(out.split())
        self.matchoutput(out, expected, command)

    def test_100_update_existing_leaf_path(self):
        self.noouttest(["update_parameter", "--personality", "utpers-dev",
                        "--archetype", "aquilon",
                        "--path", "actions/testaction/user",
                        "--value", "user2"])
github quattor / aquilon / tests / broker / test_constraints_archetype.py View on Github external
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module for testing constraints in commands involving archetype."""

if __name__ == "__main__":
    from broker import utils
    utils.import_depends()

import unittest2 as unittest
from broker.brokertest import TestBrokerCommand


class TestArchetypeConstraints(TestBrokerCommand):

    def testdelarchetypewithpersonality(self):
        command = "del archetype --archetype aquilon"
        out = self.badrequesttest(command.split(" "))
        self.matchoutput(out, "Archetype aquilon is still in use by "
                         "personality aquilon/badpersonality and "
                         "cannot be deleted.",
                         command)

    def testverifydelarchetypewithmodel(self):
github quattor / aquilon / tests / broker / test_add_address.py View on Github external
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module for testing the add address command."""

import unittest

if __name__ == "__main__":
    from broker import utils
    utils.import_depends()

from ipaddress import IPv6Address, ip_address

from broker.brokertest import TestBrokerCommand
from eventstest import EventsTestMixin
from dnstest import inaddr_ptr, in6addr_ptr


class TestAddAddress(EventsTestMixin, TestBrokerCommand):

    def event_add_arecord(self, fqdn, ip, reverse=None, ttl=None,
                          dns_environment='internal',
                          network_environment='internal',
                          reverse_dns_environment=None):
        # Determine the IP type
        ip = ip_address(unicode(ip))
github quattor / aquilon / tests / broker / test_refresh_windows_hosts.py View on Github external
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module for testing refresh_windows_hosts."""


import os
import unittest
from subprocess import Popen, PIPE

if __name__ == "__main__":
    from broker import utils
    utils.import_depends()

from broker.brokertest import TestBrokerCommand


class TestRefreshWindowsHosts(TestBrokerCommand):

    def reset_machines_db(self, sqlfile):
        dbfile = self.config.get("broker", "windows_host_info")
        if dbfile.startswith("/ms/dist"):
            self.fail("Please use a writeable location for "
                      "broker/windows_host_info in the regression "
                      "test configuration file.")
        sqlite = self.config.get("unittest", "sqlite")
        with open(sqlfile) as f:
            sql = f.read()
        if os.path.exists(dbfile):
github quattor / aquilon / tests / broker / test_reconfigure.py View on Github external
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module for testing the reconfigure command."""


import os
import re
from datetime import datetime

import unittest

if __name__ == "__main__":
    from broker import utils
    utils.import_depends()

from broker.brokertest import TestBrokerCommand
from broker.grntest import VerifyGrnsMixin
from broker.notificationtest import VerifyNotificationsMixin


class TestReconfigure(VerifyGrnsMixin, VerifyNotificationsMixin,
                      TestBrokerCommand):
    linux_version_prev = None
    linux_version_curr = None

    # Note that some tests for reconfigure --list appear in
    # test_make_aquilon.py.

    @classmethod
    def setUpClass(cls):
github quattor / aquilon / tests / broker / test_add_personality.py View on Github external
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module for testing the add personality command."""

from collections import defaultdict

import unittest

if __name__ == "__main__":
    from broker import utils
    utils.import_depends()

from broker.brokertest import TestBrokerCommand
from broker.grntest import VerifyGrnsMixin
from broker.personalitytest import PersonalityTestMixin

GRN = "grn:/ms/ei/aquilon/aqd"


class TestAddPersonality(VerifyGrnsMixin, PersonalityTestMixin,
                         TestBrokerCommand):
    def test_100_add_utunused(self):
        # Unused personality with basic settings
        command = ["add_personality", "--personality=utunused/dev",
                   "--archetype=aquilon", "--grn=%s" % GRN, "--config_override",
                   "--host_environment=dev",
                   "--comments", "Some personality comments"]