File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/libcloud/common/__pycache__/openstack.cpython-310.pyc
Back
o ;jP � @ s� d Z ddlmZmZ ddlmZmZ ddlmZ ddl m Z mZmZ ddl mZ ddlmZmZmZmZ zddlZW n eyG ddlZY nw d Zg d �Zg d�ZG dd � d e�ZG dd� de�ZG dd� de�ZG dd� d�ZdS )z Common utilities for OpenStack � )�ET�httplib)�Response�ConnectionUserAndKey)� ProviderError)� LibcloudError�MalformedResponseError�KeyPairDoesNotExistError)� BaseHTTPError)�AUTH_TOKEN_HEADER�OpenStackServiceCatalog�OpenStackIdentityTokenScope�get_class_for_auth_versionN�1.1)r z2.0� 2.0_apikey�2.0_passwordz3.xz3.x_password)�OpenStackBaseConnection�OpenStackResponse�OpenStackException�OpenStackDriverMixinc s� e Zd ZdZdZdZdZdZdZdZ dZ dZdZdZ dddddddddejddddddddddf� fdd� Zdd � Zd� fd d� Zdd� Zdd� Zdd� Zdd� Zdd� Z� fdd�Zdd� Zdd� Z� ZS ) r a� Base class for OpenStack connections. :param user_id: User name to use when authenticating :type user_id: ``str`` :param key: Secret to use when authenticating. :type key: ``str`` :param secure: Use HTTPS? (True by default.) :type secure: ``bool`` :param ex_force_base_url: Base URL for connection requests. If not specified, this will be determined by authenticating. :type ex_force_base_url: ``str`` :param ex_force_auth_url: Base URL for authentication requests. :type ex_force_auth_url: ``str`` :param ex_force_auth_version: Authentication version to use. If not specified, defaults to AUTH_API_VERSION. :type ex_force_auth_version: ``str`` :param ex_force_auth_token: Authentication token to use for connection requests. If specified, the connection will not attempt to authenticate, and the value of ex_force_base_url will be used to determine the base request URL. If ex_force_auth_token is passed in, ex_force_base_url must also be provided. :type ex_force_auth_token: ``str`` :param token_scope: Whether to scope a token to a "project", a "domain" or "unscoped". :type token_scope: ``str`` :param ex_domain_name: When authenticating, provide this domain name to the identity service. A scoped token will be returned. Some cloud providers require the domain name to be provided at authentication time. Others will use a default domain if none is provided. :type ex_domain_name: ``str`` :param ex_tenant_name: When authenticating, provide this tenant name to the identity service. A scoped token will be returned. Some cloud providers require the tenant name to be provided at authentication time. Others will use a default tenant if none is provided. :type ex_tenant_name: ``str`` :param ex_tenant_domain_id: When authenticating, provide this tenant domain id to the identity service. A scoped token will be returned. Some cloud providers require the tenant domain id to be provided at authentication time. Others will use a default tenant domain id if none is provided. :type ex_tenant_domain_id: ``str`` :param ex_force_service_type: Service type to use when selecting an service. If not specified, a provider specific default will be used. :type ex_force_service_type: ``str`` :param ex_force_service_name: Service name to use when selecting an service. If not specified, a provider specific default will be used. :type ex_force_service_name: ``str`` :param ex_force_service_region: Region to use when selecting an service. If not specified, a provider specific default will be used. :type ex_force_service_region: ``str`` :param ex_auth_cache: External cache where authentication tokens are stored for reuse by other processes. Tokens are always cached in memory on the driver instance. To share tokens among multiple drivers, processes, or systems, pass a cache here. :type ex_auth_cache: :class:`OpenStackAuthenticationCache` NT�Default�defaultc s� t � j|||||||d� | r| | _|| _|| _| | _|| _|| _| | _|| _ || _ || _|| _|| _ || _|| _d | _|rD|sDtd��|rI|| _| jsOt| _| �� }|sYtd��d S )N)�secure�timeout�retry_delay�backoff� proxy_urlzHMust also provide ex_force_base_url when specifying ex_force_auth_token.z)OpenStack instance must have auth_url set)�super�__init__� _auth_versionZbase_url�_ex_force_base_url�_ex_force_auth_url�_ex_force_auth_token�_ex_token_scope�_ex_domain_name�_ex_tenant_name�_ex_tenant_domain_id�_ex_force_service_type�_ex_force_service_name�_ex_force_service_region�_ex_force_microversion�_ex_auth_cache�_osar � auth_token�AUTH_API_VERSION� _get_auth_url)�self�user_id�keyr �host�portr r �ex_force_base_url�ex_force_auth_url�ex_force_auth_version�ex_force_auth_token�ex_token_scope�ex_domain_name�ex_tenant_name�ex_tenant_domain_id�ex_force_service_type�ex_force_service_name�ex_force_service_region�ex_force_microversion� ex_auth_cacher r �auth_url�� __class__� �M/opt/saltstack/salt/lib/python3.10/site-packages/libcloud/common/openstack.pyr � sJ � ��z OpenStackBaseConnection.__init__c C sR | j s&| �� }t| jd�}||| j| j| j| j| j| j | j | j| | jd�| _ | j S )zz Retrieve identity / authentication class instance. :rtype: :class:`OpenStackIdentityConnection` )�auth_version)rB r1 r2 Ztenant_nameZtenant_domain_idZdomain_nameZtoken_scoper r Zparent_connZ auth_cache) r, r/ r r r1 r2 r% r&