
    Vh                    h    d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	  G d d	e	      Z
 G d
 de      Zy)z(OpenNebula plugin for integration tests.    )annotationsN   )display   )CloudEnvironmentCloudEnvironmentConfigCloudProviderc                  ,     e Zd ZdZd fdZddZ xZS )OpenNebulaCloudProviderz[Checks if a configuration file has been passed or fixtures are going to be used for testingc                p    t         |           | j                         s| j                          d| _        y)zKSetup the cloud resource before delegation and register a cleanup callback.TN)supersetup_use_static_config_setup_dynamicuses_config)self	__class__s    l/home/dcms/DCMS/lib/python3.12/site-packages/ansible_test/_internal/commands/integration/cloud/opennebula.pyr   zOpenNebulaCloudProvider.setup   s,    &&(!    c                    t        j                  d       | j                         }t        ddddd      }| j	                  ||      }| j                  |       y )Nz4No config file provided, will run test from fixtureszhttp://localhost/RPC2oneadminonepasstrue)URLUSERNAMEPASSWORDFIXTURESREPLAY)r   info_read_config_templatedict_populate_config_template_write_config)r   configvaluess      r   r   z&OpenNebulaCloudProvider._setup_dynamic   sX    KL++-'
 //?6"r   )returnNone)__name__
__module____qualname____doc__r   r   __classcell__)r   s   @r   r   r      s    e #r   r   c                      e Zd ZdZddZy)OpenNebulaCloudEnvironmentz_Updates integration test environment after delegation. Will setup the config file as parameter.c                R   t        j                         }|j                  | j                         t	        | j
                        }|j                  t	        |j                  d                   t        j                  j                  |j                  d             t        |      S )zRReturn environment configuration for use in the test environment after delegation.)resource_prefixdefaultopennebula_password)ansible_vars)configparserConfigParserreadconfig_pathr!   r0   updateitemsr   	sensitiveaddgetr   )r   parserr3   s      r   get_environment_configz1OpenNebulaCloudEnvironment.get_environment_config/   s    **,D$$% 00
 	Di!89:l../DEF%%
 	
r   N)r&   r   )r(   r)   r*   r+   r>    r   r   r.   r.   ,   s
    i
r   r.   )r+   
__future__r   r4   utilr    r   r   r	   r   r.   r?   r   r   <module>rC      s6    . "  #m #6
!1 
r   