File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/libcloud/container/drivers/__pycache__/lxd.cpython-310.pyc
Back
o ;j[� � @ s| d dl Z d dlZd dlZd dlZd dlmZmZ d dlmZm Z m Z d dlmZ d dl mZ d dlmZmZmZ d dlmZ d dlmZ d d lmZ zd dlZW n ey] d dlZY nw d gZg d�Zg d�Zd Zdd� Z dd� Z!dd� Z"G dd� de�Z#G dd� d�Z$G dd� d�Z%G dd� d�Z&e�'dg d��Z(G dd� de�Z)G d d!� d!e �Z*G d"d#� d#e �Z+G d$d%� d%e�Z,dS )&� N)�b�httplib)�JsonResponse�ConnectionUserAndKey�KeyCertificateConnection)�InvalidCredsError)� StorageVolume)� Container�ContainerImage�ContainerDriver)�ContainerState)� BaseHTTPError)�ProviderZSuccess)�stop�start�restart�freeze�unfreeze)�imageZ migration�copy�none�errorc C s* ddg}|D ]}| � |�r| �|�} q| S )Nzhttp://�https://)� startswith�strip)�host�prefixes�prefix� r �R/opt/saltstack/salt/lib/python3.10/site-packages/libcloud/container/drivers/lxd.py�strip_http_prefix/ s �r c K s | du s|du rt d��| dks|dkrt d��d|�� v r;| �d�}|d |d vr;t dt|d � d |d ��d |�� v r^|�d�}|d |d vr^t d t|d � d |d ��tj�| �}tj�|�ootj�|�}|svt d��tj�|�}tj�|�o�tj�|�}|s�t d��dS ) zH Basic checks for the provided certificates in LXDtlsConnection NzJTLS Connection requires specification of a key file and a certificate file� Zkey_files_allowed�.���zValid key files are: zyou provided: Zcert_files_allowedzValid certification files are: zRYou need a key file to authenticate with LXD tls. This can be found in the server.zZYou need a certificate file to authenticate with LXD tls. This can be found in the server.) r �keys�split�str�os�path� expanduser�exists�isfile)�key_file� cert_file�kwargsZkey_file_suffixZcert_file_suffixZkeypathZis_file_pathZcertpathr r r �check_certificates8 sZ �� ���� �������r/ c C sD | d t krtd| d��| d |kr d�|| d �}t|| d��dS )zS Basic checks that the response is of the type the client is expecting �typezresponse type is error)�message� response_dict�status_codez*Status code should be {} but is {}N)�LXD_ERROR_STATUS_RESP�LXDAPIException�format)r2 r3 �msgr r r �assert_responset s ��r8 c s* e Zd ZdZd � fdd� Zdd� Z� ZS ) r5 zW Basic exception to be thrown when LXD API returns with some kind of error �Unknown Error OccurredNr! c s"