Esempio n. 1
0
class TestMSCMProbeAndEnlist(MAASTestCase):

    run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)

    scenarios = [
        (key, dict(product_name=key, arch=value))
        for key, value in cartridge_mapping.items()
    ]
    scenarios += [("default", dict(product_name="fake", arch="amd64/generic"))]

    @inlineCallbacks
    def test_probe_and_enlist(self):
        node_id = make_node_id()
        node_list = NODE_LIST % node_id
        node_info = NODE_INFO % (node_id, self.product_name)
        node_macaddr = NODE_MACADDR % (
            node_id,
            factory.make_mac_address(),
            factory.make_mac_address(),
        )
        macs = re.findall(r":".join(["[0-9a-f]{2}"] * 6), node_macaddr)

        user = factory.make_name("user")
        host = factory.make_hostname("mscm")
        username = factory.make_name("user")
        password = factory.make_name("password")
        domain = factory.make_name("domain")
        system_id = factory.make_name("system_id")
        mscm_driver = self.patch(mscm_module, "MSCMPowerDriver").return_value
        mscm_driver.run_mscm_command.side_effect = (
            node_list,
            None,
            node_info,
            node_macaddr,
        )
        create_node = self.patch(mscm_module, "create_node")
        create_node.side_effect = asynchronous(lambda *args: system_id)
        commission_node = self.patch(mscm_module, "commission_node")
        params = {
            "power_address": host,
            "power_user": username,
            "power_pass": password,
            "node_id": node_id,
        }

        yield deferToThread(
            probe_and_enlist_mscm, user, host, username, password, True, domain
        )

        self.expectThat(
            create_node,
            MockCalledOnceWith(macs, self.arch, "mscm", params, domain),
        )
        self.expectThat(commission_node, MockCalledOnceWith(system_id, user))
Esempio n. 2
0
class TestMSCMProbeAndEnlist(MAASTestCase):

    run_tests_with = MAASTwistedRunTest.make_factory(timeout=5)

    scenarios = [(key, dict(product_name=key, arch=value))
                 for key, value in cartridge_mapping.items()]
    scenarios += [
        ('default', dict(product_name="fake", arch='amd64/generic')),
    ]

    @inlineCallbacks
    def test_probe_and_enlist(self):
        node_id = make_node_id()
        node_list = NODE_LIST % node_id
        node_info = NODE_INFO % (node_id, self.product_name)
        node_macaddr = NODE_MACADDR % (node_id, factory.make_mac_address(),
                                       factory.make_mac_address())
        macs = re.findall(r':'.join(['[0-9a-f]{2}'] * 6), node_macaddr)

        user = factory.make_name('user')
        host = factory.make_hostname('mscm')
        username = factory.make_name('user')
        password = factory.make_name('password')
        domain = factory.make_name('domain')
        system_id = factory.make_name('system_id')
        mscm_driver = self.patch(mscm_module, "MSCMPowerDriver").return_value
        mscm_driver.run_mscm_command.side_effect = (node_list, None, node_info,
                                                    node_macaddr)
        create_node = self.patch(mscm_module, 'create_node')
        create_node.side_effect = asynchronous(lambda *args: system_id)
        commission_node = self.patch(mscm_module, 'commission_node')
        params = {
            'power_address': host,
            'power_user': username,
            'power_pass': password,
            'node_id': node_id,
        }

        yield deferToThread(probe_and_enlist_mscm, user, host, username,
                            password, True, domain)

        self.expectThat(
            create_node,
            MockCalledOnceWith(macs, self.arch, 'mscm', params, domain))
        self.expectThat(commission_node, MockCalledOnceWith(system_id, user))