'check if the networks exists and host
is set to each network.'

def validate_networks(self, context, networks):

    LOG.debug('Validate    networks')
    if ((networks is None) or (len(networks) == 0)):
        return
    for (network_uuid, address) in networks:
        if (address is not None):
            if (not netutils.is_valid_ip(address)):
                raise exception.FixedIpInvalid(address=address)
            fixed_ip_ref = objects.FixedIP.get_by_address(context, address, expected_attrs=['network'])
            network = fixed_ip_ref.network
            if (network.uuid != network_uuid):
                raise exception.FixedIpNotFoundForNetwork(address=address, network_uuid=network_uuid)
            if (fixed_ip_ref.instance_uuid is not None):
                raise exception.FixedIpAlreadyInUse(address=address, instance_uuid=fixed_ip_ref.instance_uuid)
