Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/libcloud/compute/drivers/__pycache__/dummy.cpython-39.pyc
Ðазад
a q�hB+ � @ s� d Z ddlZddlZddlZddlmZ ddlmZmZm Z ddlm Z mZ ddlmZ ddl mZmZ G dd � d e�ZG d d� de �Zdd � Zdd� Zedkr�ddlZe�� dS )z1 Dummy Driver @note: This driver is out of date � N)� ConnectionKey)� NodeImage�NodeSize�Node)� NodeDriver�NodeLocation��KeyPair)�Provider� NodeStatec @ s e Zd ZdZddd�ZdS )�DummyConnectionz Dummy connection class Nc C s d S )N� )�self�host�portr r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/libcloud/compute/drivers/dummy.py�connect$ s zDummyConnection.connect)NN)�__name__� __module__�__qualname__�__doc__r r r r r r s r c @ st e Zd ZdZdZdZejZdd� Z ddd�Z d d � Zdd� Zd d� Z ddd�Zddd�Zdd� Zdd� Zdd� ZdS )�DummyNodeDriveram Dummy node driver This is a fake driver which appears to always create or destroy nodes successfully. >>> 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' If the credentials you give convert to an integer then the next node to be created will be one higher. Each time you create a node you will get a different IP address. >>> driver = DummyNodeDriver(22) >>> node=driver.create_node() >>> node.name 'dummy-23' zDummy Node Providerzhttp://example.comc C s� || _ zt|�}W n ty( d}Y n0 |r�g | _td�}t|�D ]:}t|| �}| j�t|d| t j |gg | ddid�� qDn>tddt j dgg | ddid�td d t j dgg | ddid�g| _t| j �| _dS )ze :param creds: Credentials :type creds: ``str`` :rtype: ``None`` Nz 127.0.0.1�dummy-%d�foo�bar)�id�name�state� public_ips�private_ips�driver�extra� zdummy-1� zdummy-2) �creds�int� ValueError�nl� _ip_to_int�range� _int_to_ip�appendr r �RUNNINGr � connection)r r$ �numZstartip�i�ipr r r �__init__G sL �����zDummyNodeDriver.__init__Nc C s t t�� �S )zz :param unique_field: Unique field :type unique_field: ``bool`` :rtype: :class:`UUID` )�str�uuid�uuid4)r Zunique_fieldr r r �get_uuidt s zDummyNodeDriver.get_uuidc C s | j S )a\ List the nodes known to a particular driver; There are two default nodes created at the beginning >>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> driver = DummyNodeDriver(0) >>> node_list=driver.list_nodes() >>> sorted([node.name for node in node_list ]) ['dummy-1', 'dummy-2'] each item in the list returned is a node object from which you can carry out any node actions you wish >>> node_list[0].reboot() True As more nodes are added, list_nodes will return them >>> node=driver.create_node() >>> node.size.id 's1' >>> node.image.id 'i2' >>> sorted([n.name for n in driver.list_nodes()]) ['dummy-1', 'dummy-2', 'dummy-3'] @inherits: :class:`NodeDriver.list_nodes` )r'