File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/runners/__pycache__/f5.cpython-310.pyc
Back
o ;j�% � @ s� d Z ddlmZ z ddlmZ dZW n ey dZY nw dd� ZG dd � d �Z d d� Z dd d�Zdd� Zdd� Z dd� Zdd� ZdS )a� Runner to provide F5 Load Balancer functionality :depends: - pycontrol Python module :configuration: In order to connect to a F5 Load Balancer, you must specify in the Salt master configuration the currently available load balancers .. code-block:: yaml load_balancers: bigip1.example.com: username: admin password: secret bigip2.example.com: username: admin password: secret � )�CommandExecutionErrorNTFc C s t sdS dS )NFT)� HAS_PYCONTROL� r r �C/opt/saltstack/salt/lib/python3.10/site-packages/salt/runners/f5.py�__virtual__ s r c @ sV e Zd Zdd� Zdd� Zdd� Zddd �Zd d� Zdd � Zdd� Z dd� Z dd� ZdS )�F5Mgmtc C s || _ || _|| _| �� d S )N)�lb�username�password�_connect)�selfr r r r r r �__init__% s zF5Mgmt.__init__c C sF zt j| j| j| jdddgd�| _W dS ty" td| j� ���w )z Connect to F5 TzLocalLB.VirtualServerzLocalLB.Pool)�hostnamer r ZfromurlZwsdlszUnable to connect to )�f5ZBIGIPr r r �bigIP� Exception)r r r r r + s � ��zF5Mgmt._connectc sT | j jj}|j�d�}||_||_||_|j�d�} � fdd�| D �} | r)| |_nt d��|j�d�}|g|_ |j�d�}|j�d�} |j| _|| _ |j�d �}| g|_ |j�d �}|j�d�}|j|_� |_|j�d�}||_|j�d�}d|_|j�d �}|||g|_ z|j|dg||gd� W dS ty� } z td|� d|� ���d}~ww )z) Create a virtual server zCommon.VirtualServerDefinitionzCommon.ProtocolTypec s. g | ]}|d � d�d � �� kr|d �qS )r �_� ��split�upper��.0�i��protocolr r � <listcomp>I s . z$F5Mgmt.create_vs.<locals>.<listcomp>zUnknown protocolzCommon.VirtualServerSequencez'LocalLB.VirtualServer.VirtualServerTypez+LocalLB.VirtualServer.VirtualServerResourcez3LocalLB.VirtualServer.VirtualServerResourceSequencezLocalLB.ProfileContextTypez*LocalLB.VirtualServer.VirtualServerProfileZ oneconnectz2LocalLB.VirtualServer.VirtualServerProfileSequencez255.255.255.255)ZdefinitionsZ wildmasksZ resourcesZprofiles�Unable to create `z` virtual server NT)r �LocalLB� VirtualServer�typefactory�create�name�address�portr r �itemZRESOURCE_TYPE_POOL�typeZdefault_pool_nameZPROFILE_CONTEXT_TYPE_ALLZprofile_contextZprofile_namer )r r"