'Allocates all network structures for an instance.
:param context: The request context.
:param instance: nova.objects.instance.Instance object.
:param vpn: A boolean, if True, indicate a vpn to access the instance.
:param requested_networks: A list of requested_network tuples
containing network_id and fixed_ip
:param macs: None or a set of MAC addresses that the instance
should use. macs is supplied by the hypervisor driver (contrast
with requested_networks which is user supplied).
:param security_groups: None or security groups to allocate for
instance.
:param dhcp_options: None or a set of key/value pairs that should
determine the DHCP BOOTP response, eg. for PXE booting an instance
configured with the baremetal hypervisor. It is expected that these
are already formatted for the neutron v2 api.
See nova/virt/driver.py:dhcp_options_for_instance for an example.
:param bind_host_id: ignored by this driver.
:returns: network info as from get_instance_nw_info() below'

@base_api.refresh_cache
def allocate_for_instance(self, context, instance, vpn, requested_networks, macs=None, security_groups=None, dhcp_options=None, bind_host_id=None):

    flavor = instance.get_flavor()
    args = {}
    args['vpn'] = vpn
    args['requested_networks'] = requested_networks
    args['instance_id'] = instance.uuid
    args['project_id'] = instance.project_id
    args['host'] = instance.host
    args['rxtx_factor'] = flavor['rxtx_factor']
    args['macs'] = macs
    args['dhcp_options'] = dhcp_options
    if requested_networks:
        requested_networks = self._requested_nets_as_obj_list(requested_networks)
        if requested_networks.auto_allocate:
            args['requested_networks'] = None
    nw_info = self.network_rpcapi.allocate_for_instance(context, **args)
    nw_info = network_model.NetworkInfo.hydrate(nw_info)
    if ((not nw_info) and requested_networks and requested_networks.auto_allocate):
        raise exception.UnableToAutoAllocateNetwork(project_id=instance.project_id)
    return nw_info
