Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/libcloud/compute/__pycache__/base.cpython-39.pyc
Ðазад
a q�h� � @ s� d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z dd lm Z dd lmZ ddlmZ ddl Z ddlZddlZddlZddlZddlZddlZddlZddlZdd lmZ ddlZddlmZ ddlmZmZmZ e�r ddl m!Z! ddlm"Z" ddlm#Z# ddlm$Z$ ddlm%Z% ddl&m'Z' ddl&m(Z( ddl&m)Z) ddl*m+Z+ ddlm,Z, ddlm-Z- ddl.m/Z/ ddl.m0Z0 e,�r�ddl1m2Z2 ddl1m3Z3 e3e2e4ej5ej6fZ7ne4ej5ej6fZ7e d Z8e ee9 e9f Z:d Z;d!Z<g d"�Z=g d#�Z>G d$d%� d%e?�Z@G d&d'� d'e@�ZAG d(d)� d)e@�ZBG d*d+� d+e@�ZCG d,d-� d-e@�ZDG d.d/� d/e?�ZEG d0d1� d1e?�ZFG d2d3� d3e?�ZGG d4d5� d5e@�ZHG d6d7� d7e?�ZIG d8d9� d9e?�ZJG d:d;� d;e)�ZKeLd<k�r�ddlMZMeM�N� dS )=z0 Provides base classes for working with drivers � )�with_statement)�Dict)�List)�Tuple)�Type)�Optional)�Any)�Union)�Callable)� TYPE_CHECKINGN)�b)�get_size_price)� NodeState�StorageVolumeState�DeploymentError)� Deployment)�Provider)�NodeImageMemberState)� SSHClient)� BaseSSHClient)� Connection)� ConnectionKey)� BaseDriver)� LibcloudError)� have_paramiko)�SSHCommandTimeoutError)�is_private_subnet)�is_valid_ip_address)�SSHException)�AuthenticationException)�NodeAuthSSHKey�NodeAuthPassword�X �, )zno such file or directoryzinvalid keyznot a valid zinvalid or unsupported key typezprivate file is encryptedzprivate key file is encryptedz'private key file checkints do not matchzinvalid password provided)�Noder �NodeSize� NodeImage�NodeImageMember�NodeLocationr r! � NodeDriver� StorageVolumer �VolumeSnapshotr r c @ s, e Zd ZdZdd� Zdd� Zedd� �ZdS ) � UuidMixinz, Mixin class for get_uuid function. c C s d | _ d S �N)�_uuid��self� r1 ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/libcloud/compute/base.py�__init__� s zUuidMixin.__init__c C s. | j s(t�td| j| jjf ���� | _ | j S )aW Unique hash for a node, node image, or node size The hash is a function of an SHA1 hash of the node, node image, or node size's ID and its driver which means that it should be unique between all objects of its type. In some subclasses (e.g. GoGridNode) there is no ID available so the public IP address is used. This means that, unlike a properly done system UUID, the same UUID may mean a different system install at a different time >>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> node = driver.create_node() >>> node.get_uuid() 'd3748461511d8b9b0e0bfa0d4d3383a619a2bb9f' Note, for example, that this example will always produce the same UUID! :rtype: ``str`` z%s:%s)r. �hashlib�sha1r �id�driver�type� hexdigestr/ r1 r1 r2 �get_uuid� s �zUuidMixin.get_uuidc C s | � � S r- )r: r/ r1 r1 r2 �uuid� s zUuidMixin.uuidN)�__name__� __module__�__qualname__�__doc__r3 r: �propertyr; r1 r1 r1 r2 r, { s r, c @ sB e Zd ZdZddd�Zdd� Zdd� Zd d � Zdd� Zd d� Z dS )r$ a1 Provide a common interface for handling nodes of all types. The Node object provides the interface in libcloud through which we can manipulate nodes in different cloud providers in the same way. Node objects don't actually do much directly themselves, instead the node driver handles the connection to the node. You don't normally create a node object yourself; instead you use a driver and then have that create the node for you. >>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> node = driver.create_node() >>> node.public_ips[0] '127.0.0.3' >>> node.name 'dummy-3' You can also get nodes from the driver's list_node function. >>> node = driver.list_nodes()[0] >>> node.name 'dummy-1' The node keeps a reference to its own driver which means that we can work on nodes from different providers without having to know which is which. >>> driver = DummyNodeDriver(72) >>> node2 = driver.create_node() >>> node.driver.creds 0 >>> node2.driver.creds 72 Although Node objects can be subclassed, this isn't normally done. Instead, any driver specific information is stored in the "extra" attribute of the node. >>> node.extra {'foo': 'bar'} Nc C sj |rt |�nd| _|| _|| _|r&|ng | _|r4|ng | _|| _|| _| | _|| _ | pXi | _ t�| � dS )a� :param id: Node ID. :type id: ``str`` :param name: Node name. :type name: ``str`` :param state: Node state. :type state: :class:`libcloud.compute.types.NodeState` :param public_ips: Public IP addresses associated with this node. :type public_ips: ``list`` :param private_ips: Private IP addresses associated with this node. :type private_ips: ``list`` :param driver: Driver this node belongs to. :type driver: :class:`.NodeDriver` :param size: Size of this node. (optional) :type size: :class:`.NodeSize` :param image: Image of this node. (optional) :type image: :class:`.NodeImage` :param created_at: The datetime this node was created (optional) :type created_at: :class: `datetime.datetime` :param extra: Optional provider specific attributes associated with this node. :type extra: ``dict`` N) �strr6 �name�state� public_ips�private_ipsr7 �size� created_at�image�extrar, r3 )r0 r6 rB rC rD rE r7 rF rH rI rG r1 r1 r2 r3 � s . z Node.__init__c C s | j �| �S )a� Reboot this node :return: ``bool`` This calls the node's driver and reboots the node >>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> node = driver.create_node() >>> node.state == NodeState.RUNNING True >>> node.state == NodeState.REBOOTING False >>> node.reboot() True >>> node.state == NodeState.REBOOTING True )r7 �reboot_noder/ r1 r1 r2 �reboot s zNode.rebootc C s | j �| �S )z= Start this node. :return: ``bool`` )r7 � start_noder/ r1 r1 r2 �start$ s z Node.startc C s | j �| �S )zG Stop (shutdown) this node. :return: ``bool`` )r7 � stop_noder/ r1 r1 r2 rN - s zNode.stop_nodec C s | j �| �S )a� Destroy this node :return: ``bool`` This calls the node's driver and destroys the node >>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> from libcloud.compute.types import NodeState >>> node = driver.create_node() >>> node.state == NodeState.RUNNING True >>> node.destroy() True >>> node.state == NodeState.RUNNING False )r7 �destroy_noder/ r1 r1 r2 �destroy6 s zNode.destroyc C s, t �| j�}d| j| j|| j| j| jjf S )NzR<Node: uuid=%s, name=%s, state=%s, public_ips=%s, private_ips=%s, provider=%s ...>)r ZtostringrC r; rB rD rE r7 )r0 rC r1 r1 r2 �__repr__M s ��z Node.__repr__)NNNN) r<