libcloud.loadbalancer.drivers.gce module

class libcloud.loadbalancer.drivers.gce.GCELBDriver(*args, **kwargs)[source]

Bases: Driver

Parameters:
  • key (str) – API key or username to be used (required)

  • secret (str) – Secret password to be used (required)

  • secure (bool) – Whether to use HTTPS or HTTP. Note: Some providers only support HTTPS, and it is on by default.

  • host (str) – Override hostname used for connections.

  • port (int) – Override port used for connections.

  • api_version (str) – Optional API version. Only used by drivers which support multiple API versions.

  • region (str) – Optional driver region. Only used by drivers which support multiple regions.

Return type:

None

apiname = 'googleapis'
balancer_attach_compute_node(balancer, node)[source]

Attach a compute node as a member to the load balancer.

Parameters:
  • balancer (LoadBalancer) – LoadBalancer which should be used

  • node (Node) – Node to join to the balancer

Returns:

Member after joining the balancer.

Return type:

Member

balancer_attach_member(balancer, member)[source]

Attach a member to balancer

Parameters:
  • balancer (LoadBalancer) – LoadBalancer which should be used

  • member (Member) – Member to join to the balancer

Returns:

Member after joining the balancer.

Return type:

Member

balancer_detach_member(balancer, member)[source]

Detach member from balancer

Parameters:
  • balancer (LoadBalancer) – LoadBalancer which should be used

  • member (Member) – Member which should be used

Returns:

True if member detach was successful, otherwise False

Return type:

bool

balancer_list_members(balancer)[source]

Return list of members attached to balancer

Parameters:

balancer (LoadBalancer) – LoadBalancer which should be used

Return type:

list of Member

connectionCls

alias of GCEConnection

create_balancer(name, port, protocol, algorithm, members, ex_region=None, ex_healthchecks=None, ex_address=None, ex_session_affinity=None)[source]

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.

Parameters:
  • name (str) – Name of the new load balancer (required)

  • port (str) – Port or range of ports the load balancer should listen on, defaults to all ports. Examples: ‘80’, ‘5000-5999’

  • protocol (str) – Load balancer protocol. Should be ‘tcp’ or ‘udp’, defaults to ‘tcp’.

  • members (list of Member or Node) – 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.

  • algorithm (Algorithm or None) – Load balancing algorithm. Ignored for GCE which uses a hashing-based algorithm.

  • ex_region (C{GCERegion} or str) – Optional region to create the load balancer in. Defaults to the default region of the GCE Node Driver.

  • ex_healthchecks (list of GCEHealthCheck or list of str) – Optional list of healthcheck objects or names to add to the load balancer.

  • ex_address (C{GCEAddress}) – Optional static address object to be assigned to the load balancer.

  • ex_session_affinity (str) – 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.

Returns:

LoadBalancer object

Return type:

LoadBalancer

destroy_balancer(balancer)[source]

Destroy a load balancer.

For GCE, this means destroying the associated forwarding rule, then destroying the target pool that was attached to the forwarding rule.

Parameters:

balancer (LoadBalancer) – LoadBalancer which should be used

Returns:

True if successful

Return type:

bool

ex_balancer_attach_healthcheck(balancer, healthcheck)[source]

Attach a healthcheck to balancer

Parameters:
  • balancer (LoadBalancer) – LoadBalancer which should be used

  • healthcheck (GCEHealthCheck) – Healthcheck to add

Returns:

True if successful

Return type:

bool

ex_balancer_detach_healthcheck(balancer, healthcheck)[source]

Detach healtcheck from balancer

Parameters:
  • balancer (LoadBalancer) – LoadBalancer which should be used

  • healthcheck (GCEHealthCheck) – Healthcheck to remove

Returns:

True if successful

Return type:

bool

ex_balancer_list_healthchecks(balancer)[source]

Return list of healthchecks attached to balancer

Parameters:

balancer (LoadBalancer) – LoadBalancer which should be used

Return type:

list of HealthChecks

ex_create_healthcheck(*args, **kwargs)[source]
ex_list_healthchecks()[source]
get_balancer(balancer_id)[source]

Return a LoadBalancer object.

Parameters:
  • balancer_id – Name of load balancer you wish to fetch. For GCE, this is the name of the associated forwarding rule.

  • balancer_idstr

Return type:

LoadBalancer

list_balancers(ex_region=None)[source]

List all loadbalancers

Parameters:

ex_region (str or GCERegion or None) – The region to return balancers from. If None, will default to self.region. If ‘all’, will return all balancers.

Return type:

list of LoadBalancer

list_protocols()[source]

Return a list of supported protocols.

For GCE, this is simply a hardcoded list.

Return type:

list of str

name = 'Google Compute Engine Load Balancer'
website = 'https://cloud.google.com/'