예제 #1
0
    def test__set_pxe_boot_sets_pxe(self):
        amt_power_driver = AMTPowerDriver()
        ip_address = factory.make_ipv4_address()
        power_pass = factory.make_name("power_pass")
        wsman_pxe_options = {
            "ChangeBootOrder": (
                join(dirname(dirname(__file__)), "amt.wsman-pxe.xml"),
                (
                    "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
                    'CIM_BootConfigSetting?InstanceID="Intel(r) '
                    'AMT: Boot Configuration 0"'
                ),
            ),
            "SetBootConfigRole": (
                join(dirname(dirname(__file__)), "amt.wsman-boot-config.xml"),
                (
                    "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
                    "CIM_BootService?SystemCreationClassName="
                    '"CIM_ComputerSystem"&SystemName="Intel(r) AMT"'
                    '&CreationClassName="CIM_BootService"&Name="Intel(r)'
                    ' AMT Boot Service"'
                ),
            ),
        }
        wsman_opts = (
            "--port",
            "16992",
            "--hostname",
            ip_address,
            "--username",
            "admin",
            "--password",
            power_pass,
            "--noverifypeer",
            "--noverifyhost",
        )
        _run_mock = self.patch(amt_power_driver, "_run")
        amt_power_driver._set_pxe_boot(ip_address, power_pass)

        commands = []
        stdins = []
        for method, (schema_file, schema_uri) in wsman_pxe_options.items():
            with open(schema_file, "rb") as fd:
                wsman_opts += ("--input", "-")
                action = ("invoke", "--method", method, schema_uri)
                command = ("wsman",) + wsman_opts + action
                commands.append(command)
                stdins.append(fd.read())

        self.assertThat(
            _run_mock,
            MockCallsMatch(
                call(commands[0], power_pass, stdin=stdins[0]),
                call(commands[1], power_pass, stdin=stdins[1]),
            ),
        )
예제 #2
0
    def test__set_pxe_boot_sets_pxe(self):
        amt_power_driver = AMTPowerDriver()
        ip_address = factory.make_ipv4_address()
        power_pass = factory.make_name('power_pass')
        wsman_pxe_options = {
            'ChangeBootOrder':
            (join(dirname(dirname(__file__)), "amt.wsman-pxe.xml"),
             ('http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/'
              'CIM_BootConfigSetting?InstanceID="Intel(r) '
              'AMT: Boot Configuration 0"')),
            'SetBootConfigRole':
            (join(dirname(dirname(__file__)), "amt.wsman-boot-config.xml"),
             ('http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/'
              'CIM_BootService?SystemCreationClassName='
              '"CIM_ComputerSystem",SystemName="Intel(r) AMT"'
              ',CreationClassName="CIM_BootService",Name="Intel(r)'
              ' AMT Boot Service"')),
        }
        wsman_opts = ('--port', '16992', '--hostname', ip_address,
                      '--username', 'admin', '--password', power_pass,
                      '--noverifypeer', '--noverifyhost')
        _run_mock = self.patch(amt_power_driver, '_run')
        amt_power_driver._set_pxe_boot(ip_address, power_pass)

        commands = []
        stdins = []
        for method, (schema_file, schema_uri) in wsman_pxe_options.items():
            with open(schema_file, "rb") as fd:
                command = 'wsman', 'invoke', '--method', method, schema_uri
                command += wsman_opts + ('--input', '-')
                commands.append(command)
                stdins.append(fd.read())

        self.assertThat(
            _run_mock,
            MockCallsMatch(call(commands[0], power_pass, stdin=stdins[0]),
                           call(commands[1], power_pass, stdin=stdins[1])))