@pytest.fixture
def add_host_with_net(host, add_host_with_interface, add_network):
    'Adds a host with a network. The first network this adds defaults to pxe=True.'

    def _inner(hostname, rack, rank, appliance, interface, ip, network, address, pxe):
        add_host_with_interface(hostname=hostname, rack=rack, rank=rank, appliance=appliance, interface=interface)
        add_network(name=network, address=address, pxe=pxe)
        result = host.run(f'stack set host interface network {hostname} network={network} interface={interface}')
        assert (result.rc == 0)
        result = host.run(f'stack set host interface ip {hostname} ip={ip} network={network}')
        assert (result.rc == 0)
        result = host.run('stack list host interface a:frontend output-format=json')
        assert (result.rc == 0)
        interface_on_network = False
        for frontend_interface in json.loads(result.stdout):
            if (frontend_interface['network'] == network):
                interface_on_network = True
                break
        if interface_on_network:
            return
        latest_interface = max((frontend_interface['interface'] for frontend_interface in json.loads(result.stdout)))
        new_interface = list(latest_interface)
        new_interface[(- 1)] = str((int(new_interface[(- 1)]) + 1))
        new_interface = ''.join(new_interface)
        result = host.run(f'stack add host interface a:frontend interface={new_interface} network={network} ip={(ipaddress.ip_address(ip) + 1)}')
        assert (result.rc == 0)
    result = host.run(f'stack remove network test')
    assert (result.rc == 0)
    add_network(name='test', address='192.168.0.0', pxe=True)
    result = host.run(f'stack set host interface network backend-0-0 network=test interface=eth0 ip=192.168.0.3')
    assert (result.rc == 0)
    result = host.run(f'stack add host interface a:frontend interface=eth2 network=test ip=192.168.0.2')
    assert (result.rc == 0)
    return _inner
Adds a host with a network. The first network this adds defaults to pxe=True.
@pytest.fixture
def add_host_with_net(host, add_host_with_interface, add_network):
    

    def _inner(hostname, rack, rank, appliance, interface, ip, network, address, pxe):
        add_host_with_interface(hostname=hostname, rack=rack, rank=rank, appliance=appliance, interface=interface)
        add_network(name=network, address=address, pxe=pxe)
        result = host.run(f'stack set host interface network {hostname} network={network} interface={interface}')
        assert (result.rc == 0)
        result = host.run(f'stack set host interface ip {hostname} ip={ip} network={network}')
        assert (result.rc == 0)
        result = host.run('stack list host interface a:frontend output-format=json')
        assert (result.rc == 0)
        interface_on_network = False
        for frontend_interface in json.loads(result.stdout):
            if (frontend_interface['network'] == network):
                interface_on_network = True
                break
        if interface_on_network:
            return
        latest_interface = max((frontend_interface['interface'] for frontend_interface in json.loads(result.stdout)))
        new_interface = list(latest_interface)
        new_interface[(- 1)] = str((int(new_interface[(- 1)]) + 1))
        new_interface = .join(new_interface)
        result = host.run(f'stack add host interface a:frontend interface={new_interface} network={network} ip={(ipaddress.ip_address(ip) + 1)}')
        assert (result.rc == 0)
    result = host.run(f'stack remove network test')
    assert (result.rc == 0)
    add_network(name='test', address='192.168.0.0', pxe=True)
    result = host.run(f'stack set host interface network backend-0-0 network=test interface=eth0 ip=192.168.0.3')
    assert (result.rc == 0)
    result = host.run(f'stack add host interface a:frontend interface=eth2 network=test ip=192.168.0.2')
    assert (result.rc == 0)
    return _inner