'Create a new load balancer instance.
For GCE, this means creating a forwarding rule and a matching target
pool, then adding the members to the target pool.
:param  name: Name of the new load balancer (required)
:type   name: ``str``
:param  port: Port or range of ports the load balancer should listen
on, defaults to all ports.  Examples: \'80\', \'5000-5999\'
:type   port: ``str``
:param  protocol: Load balancer protocol.  Should be \'tcp\' or \'udp\',
defaults to \'tcp\'.
:type   protocol: ``str``
:param  members: List of Members to attach to balancer.  Can be Member
objects or Node objects.  Node objects are preferred
for GCE, but Member objects are accepted to comply
with the established libcloud API.  Note that the
\'port\' attribute of the members is ignored.
:type   members: ``list`` of :class:`Member` or :class:`Node`
:param  algorithm: Load balancing algorithm.  Ignored for GCE which
uses a hashing-based algorithm.
:type   algorithm: :class:`Algorithm` or ``None``
:keyword  ex_region:  Optional region to create the load balancer in.
Defaults to the default region of the GCE Node
Driver.
:type     ex_region:  C{GCERegion} or ``str``
:keyword  ex_healthchecks: Optional list of healthcheck objects or
names to add to the load balancer.
:type     ex_healthchecks: ``list`` of :class:`GCEHealthCheck` or
``list`` of ``str``
:keyword  ex_address: Optional static address object to be assigned to
the load balancer.
:type     ex_address: C{GCEAddress}
:keyword  ex_session_affinity: Optional algorithm to use for session
affinity.  This will modify the hashing
algorithm such that a client will tend
to stick to a particular Member.
:type     ex_session_affinity: ``str``
:return:  LoadBalancer object
:rtype:   :class:`LoadBalancer`'

def create_balancer(self, name, port, protocol, algorithm, members, ex_region=None, ex_healthchecks=None, ex_address=None, ex_session_affinity=None):

    node_list = []
    for member in members:
        if hasattr(member, 'ip'):
            if member.extra.get('node'):
                node_list.append(member.extra['node'])
            else:
                node_list.append(self._get_node_from_ip(member.ip))
        elif hasattr(member, 'name'):
            node_list.append(member)
        else:
            node_list.append(self.gce.ex_get_node(member, 'all'))
    tp_name = ('%s-tp' % name)
    targetpool = self.gce.ex_create_targetpool(tp_name, region=ex_region, healthchecks=ex_healthchecks, nodes=node_list, session_affinity=ex_session_affinity)
    try:
        forwarding_rule = self.gce.ex_create_forwarding_rule(name, targetpool, region=ex_region, protocol=protocol, port_range=port, address=ex_address)
    except:
        targetpool.destroy()
        raise
    return self._forwarding_rule_to_loadbalancer(forwarding_rule)
