'Create port for network_requests that don\'t have a port_id
:param context: The request context.
:param instance: nova.objects.instance.Instance object.
:param ordered_networks: objects.NetworkRequestList in requested order
:param nets: a dict of network_id to networks returned from neutron
:param neutron: neutronclient using built from users request context
:param security_group_ids: a list of security_groups to go to neutron
:returns a list of pairs (NetworkRequest, created_port_uuid)'

def _create_ports_for_instance(self, context, instance, ordered_networks, nets, neutron, security_group_ids):

    created_port_ids = []
    requests_and_created_ports = []
    for request in ordered_networks:
        network = nets.get(request.network_id)
        if (not network):
            continue
        try:
            port_security_enabled = network.get('port_security_enabled', True)
            if port_security_enabled:
                if (not network.get('subnets')):
                    LOG.debug('Network    with    port    security    enabled    does    not    have    subnets    so    security    groups    cannot    be    applied:    %s', network, instance=instance)
                    raise exception.SecurityGroupCannotBeApplied()
            elif security_group_ids:
                LOG.debug('Network    has    port    security    disabled    so    security    groups    cannot    be    applied:    %s', network, instance=instance)
                raise exception.SecurityGroupCannotBeApplied()
            created_port_id = None
            if (not request.port_id):
                created_port = self._create_port_minimal(neutron, instance, request.network_id, request.address, security_group_ids)
                created_port_id = created_port['id']
                created_port_ids.append(created_port_id)
            requests_and_created_ports.append((request, created_port_id))
        except Exception:
            with excutils.save_and_reraise_exception():
                if created_port_ids:
                    self._delete_ports(neutron, instance, created_port_ids)
    return requests_and_created_ports
