Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/libcloud/loadbalancer/drivers/__pycache__/gce.cpython-39.pyc
Ðазад
a q�hh5 � @ sj zd dl ZW n ey& d dlZY n0 d dlmZmZmZmZ d dlm Z m Z ejZG dd� de�Z dS )� N)�LoadBalancer�Member�Driver� Algorithm)� GCEConnection� GCENodeDriverc @ s� e Zd ZeZdZdZdZdej iZ dd� Zdd� Zd d � Z d*dd �Zd+dd�Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zd d!� Zd"d#� Zd$d%� Zd&d'� Zd(d)� ZdS ),�GCELBDriverZ googleapisz#Google Compute Engine Load Balancerzhttps://cloud.google.com/�RANDOMc O s4 |� d�r|d | _nt|i |��| _| jj| _d S )NZ gce_driver)�get�gcer � connection��self�args�kwargs� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/libcloud/loadbalancer/drivers/gce.py�__init__( s zGCELBDriver.__init__c C s. | j jdd�}|D ]}||jv r| S qdS )a Return the node object that matches a given public IP address. :param ip: Public IP address to search for :type ip: ``str`` :return: Node object that has the given IP, or None if not found. :rtype: :class:`Node` or None �all)Zex_zoneN)r Z list_nodes� public_ips)r �ipZ all_nodes�noder r r �_get_node_from_ip1 s zGCELBDriver._get_node_from_ipc C s ddgS )z� Return a list of supported protocols. For GCE, this is simply a hardcoded list. :rtype: ``list`` of ``str`` ZTCPZUDPr �r r r r �list_protocolsA s zGCELBDriver.list_protocolsNc C s, g }| j j|d�D ]}|�| �|�� q|S )al List all loadbalancers :keyword ex_region: The region to return balancers from. If None, will default to self.region. If 'all', will return all balancers. :type ex_region: ``str`` or :class:`GCERegion` or ``None`` :rtype: ``list`` of :class:`LoadBalancer` )�region)r Zex_list_forwarding_rules�append� _forwarding_rule_to_loadbalancer)r � ex_regionZ balancers�fwrr r r �list_balancersK s zGCELBDriver.list_balancersc C s� g } |D ]j}t |d�rH|j�d�r4| �|jd � qr| �| �|j�� qt |d�r^| �|� q| �| j�|d�� qd| }| jj|||| | d�} z| jj || ||||d�}W n t y� | �� � Y n0 | �|�S )a^ 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` r r �namer z%s-tp)r �healthchecks�nodesZsession_affinity)r �protocolZ port_range�address) �hasattr�extrar r r r r Zex_get_nodeZex_create_targetpoolZex_create_forwarding_rule� Exception�destroyr )r r! �portr$ � algorithm�membersr Zex_healthchecksZ ex_addressZex_session_affinityZ node_list�memberZtp_name� targetpool�forwarding_ruler r r �create_balancer[ s. 6 �� zGCELBDriver.create_balancerc C s, |j d �� }|r$|j d �� }|S |S dS )ar 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. :param balancer: LoadBalancer which should be used :type balancer: :class:`LoadBalancer` :return: True if successful :rtype: ``bool`` r/ r. N)r'