Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/libcloud/compute/drivers/__pycache__/abiquo.cpython-39.pyc
Ðазад
a q�h){ � @ s� d Z ddlmZ ddlmZmZ ddlmZmZ ddl m Z mZmZ ddlm Z mZmZ ddlmZ G dd � d e�ZG d d� de�ZdS ) z� Abiquo Compute Driver The driver implements the compute Abiquo functionality for the Abiquo API. This version is compatible with the following versions of Abiquo: * Abiquo 3.4 (http://wiki.abiquo.com/display/ABI34/The+Abiquo+API) � )�ET)� NodeDriver�NodeSize)�Provider� LibcloudError)�AbiquoConnection�get_href�AbiquoResponse)�NodeLocation� NodeImage�Node)�tostringc s< e Zd ZdZejZdZdZe Z dZdZdZ dZdZd Zd ZdZdZd ZdZdZdZdZdZdZdZdZ� fdd�ZdEdd�Zdd� Zdd� Z dd � Z!dFd!d"�Z"d#d$� Z#dGd%d&�Z$dHd'd(�Z%d)d*� Z&dId+d,�Z'dJd-d.�Z(d/d0� Z)d1d2� Z*d3d4� Z+d5d6� Z,d7d8� Z-d9d:� Z.dKd;d<�Z/d=d>� Z0d?d@� Z1dLdAdB�Z2dMdCdD�Z3� Z4S )N�AbiquoNodeDriverzN Implements the :class:`NodeDriver`'s for the Abiquo Compute Provider ZAbiquozhttp://www.abiquo.com/i� z*application/vnd.abiquo.virtualmachines+xmlz)application/vnd.abiquo.virtualmachine+xmlz,application/vnd.abiquo.virtualappliances+xmlz+application/vnd.abiquo.virtualappliance+xmlz-application/vnd.abiquo.virtualmachinetask+xmlzapplication/vnd.abiquo.user+xmlz%application/vnd.abiquo.enterprise+xmlz-application/vnd.abiquo.virtualdatacenters+xmlz,application/vnd.abiquo.virtualdatacenter+xmlz&application/vnd.abiquo.datacenters+xmlz2application/vnd.abiquo.virtualmachinetemplates+xmlz1application/vnd.abiquo.virtualmachinetemplate+xmlzapplication/vnd.abiquo.nics+xmlz1application/vnd.abiquo.datacenterrepositories+xmlz/application/vnd.abiquo.datacenterrepository+xmlz*application/vnd.abiquo.acceptedrequest+xmli @c s4 || _ tt| �jf ||dddd�|�� | �� dS )a� Initializes Abiquo Driver Initializes the :class:`NodeDriver` object and populate the cache. :param user_id: identifier of Abiquo user (required) :type user_id: ``str`` :param secret: password of the Abiquo user (required) :type secret: ``str`` :param endpoint: Abiquo API endpoint (required) :type endpoint: ``str`` that can be parsed as URL FN)�key�secret�secure�host�port)�endpoint�superr �__init__�ex_populate_cache)�selfZuser_idr r �kwargs�� __class__� ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/libcloud/compute/drivers/abiquo.pyr A s ��zAbiquoNodeDriver.__init__Nc C sn | j ||d�\}}| �|||�}| j||||d�} | �| � t| d�} d| ji}| jj| |d�j} | � | | �S )a? Create a new node instance in Abiquo All the :class:`Node`s need to be defined inside a VirtualAppliance (called :class:`NodeGroup` here). If there is no group name defined, 'libcloud' name will be used instead. This method wraps these Abiquo actions: 1. Create a group if it does not exist. 2. Register a new node in the group. 3. Deploy the node and boot it. 4. Retrieves it again to get schedule-time attributes (such as ips and vnc ports). The rest of the driver methods has been created in a way that, if any of these actions fail, the user can not reach an inconsistent state :keyword name: The name for this new node (required) :type name: ``str`` :keyword size: The size of resources allocated to this node. :type size: :class:`NodeSize` :keyword image: OS Image to boot on node. (required) :type image: :class:`NodeImage` :keyword location: Which data center to create a node in. If empty, undefined behavior will be selected. (optional) :type location: :class:`NodeLocation` :keyword ex_group_name: Which group this node belongs to. If empty, it will be created into 'libcloud' group. If it does not found any group in the target location (random location if you have not set the parameter), then it will create a new group with this name. :type ex_group_name: c{str} :return: The newly created node. :rtype: :class:`Node` )�image�location)�name�sizer �edit�Accept��headers) �_define_create_node_location�_define_create_node_group�_define_create_node_node�_deploy_remoter �NODE_MIME_TYPE� connection�request�object�_to_node)r r r r! r Z ex_group_name�xml_loc�loc�group�vm�edit_vmr% r r r �create_nodeT s 0� � zAbiquoNodeDriver.create_nodec C s� d| j i}| jj|jd |d�j}|�d�}|dv r>td| ��|dkr�t�d�}t� |d �}d |_ |jd d }| j| jd�}| jj |d t|�|d�}|dks�|�� r�| jj|jd dd� dS dS dS )aC Destroy a node Depending on the provider, this may destroy all data associated with the node, including backups. :param node: The node to be destroyed :type node: :class:`Node` :return: True if the destroy was successful, otherwise False :rtype: ``bool`` r# �uri_idr$ �state)Z ALLOCATEDZ CONFIGURED�LOCKED�UNKNOWN�Invalid Node state� NOT_ALLOCATED�virtualmachinetask� forceUndeploy�True�/action/undeploy�r# zContent-type�POST��action�method�datar% �DELETE�rB rC TFN)r* r+ r, �extrar- �findtextr r �Element� SubElement�text�AR_MIME_TYPE�VM_TASK_MIME_TYPE� async_requestr � async_success) r �noder% �e_vmr6 �vm_task�force_undeployZdestroy_uri�resr r r �destroy_node� s4 � ���zAbiquoNodeDriver.destroy_nodec C sl | j �|jd �j}|�d�}|dkr0td| ��| �|� t|d�}d| ji}| j j||d�j}| � || �S )a� Runs a node Here there is a bit difference between Abiquo states and libcloud states, so this method is created to have better compatibility. In libcloud, if the node is not running, then it does not exist (avoiding UNKNOWN and temporal states). In Abiquo, you can define a node, and then deploy it. If the node is in :class:`NodeState.TERMINATED` libcloud's state and in 'NOT_DEPLOYED' Abiquo state, there is a way to run and recover it for libcloud using this method. There is no way to reach this state if you are using only libcloud, but you may have used another Abiquo client and now you want to recover your node to be used by libcloud. :param node: The node to run :type node: :class:`Node` :return: The node itself, but with the new state :rtype: :class:`Node` r5 r6 r: r9 r"