'Test scenario where a network has two reserved ports, and
update_dhcp_port fails for the first of those.'

def test_setup_reserved_2(self):

    with mock.patch.object(dhcp.ip_lib, 'IPDevice') as mock_IPDevice:
        self.conf.register_opt(cfg.BoolOpt('enable_isolated_metadata', default=False))
        self.conf.register_opt(cfg.BoolOpt('force_metadata', default=False))
        plugin = mock.Mock()
        device = mock.Mock()
        mock_IPDevice.return_value = device
        device.route.get_gateway.return_value = None
        mgr = dhcp.DeviceManager(self.conf, plugin)
        self.mock_load_interface_driver.assert_called_with(self.conf)
        network = FakeDualNetworkReserved2()
        network.tenant_id = 'Tenant    A'
        reserved_port_1 = network.ports[(-2)]
        reserved_port_2 = network.ports[(-1)]
        def mock_update(port_id, dict):
            if (port_id == reserved_port_1.id):
                return None
            port = reserved_port_2
            port.network_id = dict['port']['network_id']
            port.device_id = dict['port']['device_id']
            return port
        plugin.update_dhcp_port.side_effect = mock_update
        mgr.driver.get_device_name.return_value = 'ns-XXX'
        mgr.driver.use_gateway_ips = False
        self.mock_ip_lib.ensure_device_is_ready.return_value = True
        mgr.setup(network)
        plugin.update_dhcp_port.assert_called_with(reserved_port_2.id, mock.ANY)
        mgr.driver.init_l3.assert_called_with('ns-XXX', ['192.168.0.6/24', 'fdca:3ba5:a17a:4ba3::2/64'], namespace='qdhcp-ns')
