Ë
    ÇVh³"  ã                   ój   — d dl mZmZmZ eZdZdZdZd dl	m
Z
  G d„ de
«      Zd„ Zed	k(  r e«        y
y
)é    )Úabsolute_importÚdivisionÚprint_functionaQ  
module: one_template

short_description: Manages OpenNebula templates

version_added: 2.4.0

requirements:
  - pyone

description:
  - Manages OpenNebula templates.
attributes:
  check_mode:
    support: partial
    details:
      - Note that check mode always returns C(changed=true) for existing templates, even if the template would not actually
        change.
  diff_mode:
    support: none

options:
  id:
    description:
      - A O(id) of the template you would like to manage. If not set then a new template will be created with the given O(name).
    type: int
  name:
    description:
      - A O(name) of the template you would like to manage. If a template with the given name does not exist it will be created,
        otherwise it will be managed by this module.
    type: str
  template:
    description:
      - A string containing the template contents.
    type: str
  state:
    description:
      - V(present) - state that is used to manage the template.
      - V(absent) - delete the template.
    choices: ["present", "absent"]
    default: present
    type: str
  filter:
    description:
      - V(user_primary_group) - Resources belonging to the user's primary group.
      - V(user) - Resources belonging to the user.
      - V(all) - All resources.
      - V(user_groups) - Resources belonging to the user and any of his groups.
    choices: [user_primary_group, user, all, user_groups]
    default: user
    type: str
    version_added: 10.3.0

extends_documentation_fragment:
  - community.general.opennebula
  - community.general.attributes

author:
  - "Jyrki Gadinger (@nilsding)"
aa  
- name: Fetch the TEMPLATE by id
  community.general.one_template:
    id: 6459
  register: result

- name: Print the TEMPLATE properties
  ansible.builtin.debug:
    var: result

- name: Fetch the TEMPLATE by name
  community.general.one_template:
    name: tf-prd-users-workerredis-p6379a
  register: result

- name: Create a new or update an existing TEMPLATE
  community.general.one_template:
    name: generic-opensuse
    template: |
      CONTEXT = [
        HOSTNAME = "generic-opensuse"
      ]
      CPU = "1"
      CUSTOM_ATTRIBUTE = ""
      DISK = [
        CACHE = "writeback",
        DEV_PREFIX = "sd",
        DISCARD = "unmap",
        IMAGE = "opensuse-leap-15.2",
        IMAGE_UNAME = "oneadmin",
        IO = "threads",
        SIZE = "" ]
      MEMORY = "2048"
      NIC = [
        MODEL = "virtio",
        NETWORK = "testnet",
        NETWORK_UNAME = "oneadmin" ]
      OS = [
        ARCH = "x86_64",
        BOOT = "disk0" ]
      SCHED_REQUIREMENTS = "CLUSTER_ID=\\"100\\""
      VCPU = "2"

- name: Delete the TEMPLATE by id
  community.general.one_template:
    id: 6459
    state: absent
aØ  
id:
  description: Template ID.
  type: int
  returned: when O(state=present)
  sample: 153
name:
  description: Template name.
  type: str
  returned: when O(state=present)
  sample: app1
template:
  description: The parsed template.
  type: dict
  returned: when O(state=present)
group_id:
  description: Template's group ID.
  type: int
  returned: when O(state=present)
  sample: 1
group_name:
  description: Template's group name.
  type: str
  returned: when O(state=present)
  sample: one-users
owner_id:
  description: Template's owner ID.
  type: int
  returned: when O(state=present)
  sample: 143
owner_name:
  description: Template's owner name.
  type: str
  returned: when O(state=present)
  sample: ansible-test
)ÚOpenNebulaModulec                   óH   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zy)ÚTemplateModulec                 óô   — t        t        dd¬«      t        dd¬«      t        dddgd¬«      t        dd¬«      t        ddg d¢d	¬
«      ¬«      }ddgg}dg}dddggg}t        j                  | |d|||¬«       y )NÚintF)ÚtypeÚrequiredÚstrÚpresentÚabsent)r   ÚchoicesÚdefault©Úuser_primary_groupÚuserÚallÚuser_groupsr   )r   r   r   r   )ÚidÚnameÚstateÚtemplateÚfilterr   r   )r   r   r   r   T)Úsupports_check_modeÚmutually_exclusiveÚrequired_one_ofÚrequired_if)Údictr   Ú__init__)ÚselfÚargument_specr   r   r   s        úr/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/one_template.pyr!   zTemplateModule.__init__¤   s£   € ÜÜ˜¨Ô/Ü˜5¨5Ô1Ü˜E¨I°xÐ+@È)ÔTÜ˜u¨uÔ5Ü˜U¨UÒ<pð  {Aô  Bô
ˆð 6ˆNð
Ðð *Ð*ˆð i * Ð.ð
ˆô 	×!Ñ! $Ø"/Ø6:Ø5GØ2AØ.9ö	;ó    c                 ó  — |j                   }|j                  d«      }|j                  d«      }|j                  d«      }|j                  d«      }|j                  d«      }	i | _        | j                  |||	«      }
d}|
s(|dk7  r#|r|j	                  dt        |«      z   ¬	«       nd
}|dk(  r| j                  |
«      | _        n3|r| j                  |||	«      | _        n| j                  |
||	«      | _        | j                  «        y )Nr   r   r   r   r   Fr   zThere is no template with id=)ÚmsgT)
ÚparamsÚgetÚresultÚget_template_instanceÚ	fail_jsonr   Údelete_templateÚcreate_templateÚupdate_templateÚexit)r"   ÚoneÚmoduler*   r(   r   r   Údesired_stateÚtemplate_datar   r   Úneeds_creations               r$   ÚrunzTemplateModule.run¾   sð   € Ø—‘ˆØZ‰Z˜ÓˆØz‰z˜&Ó!ˆØŸ
™
 7Ó+ˆØŸ
™
 :Ó.ˆØ—‘˜HÓ%ˆàˆŒà×-Ñ-¨b°$¸Ó?ˆØˆÙ˜M¨XÒ5ÙØ× Ñ Ð%DÄsÈ2ÃwÑ%NÐ ÕOà!%à˜HÒ$Ø×.Ñ.¨xÓ8ˆDKáØ"×2Ñ2°4¸ÈÓO•à"×2Ñ2°8¸]ÈFÓS”à	‰	r%   c                 ó    — dddddœ}| j                   j                  j                  ||   dd«      }|j                  D ]  } ||«      sŒ|c S  y )Néüÿÿÿéýÿÿÿéþÿÿÿéÿÿÿÿr   )r1   ÚtemplatepoolÚinfoÚ
VMTEMPLATE)r"   Ú	predicater   Úfilter_valuesÚpoolr   s         r$   Úget_templatezTemplateModule.get_templateÚ   s[   € ð
 02¸2ÀbÐY[Ñ\ˆØx‰x×$Ñ$×)Ñ)¨-¸Ñ*?ÀÀRÓHˆàŸ™ò 	 ˆHÙ˜Õ"Ø’ð	 ð r%   c                 ó.   ‡— | j                  ˆfd„|«      S )Nc                 ó"   •— | j                   ‰k(  S ©N)ÚID)r   Útemplate_ids    €r$   ú<lambda>z3TemplateModule.get_template_by_id.<locals>.<lambda>é   s   ø€ °8·;±;À+Ñ3M€ r%   ©rB   )r"   rG   r   s    ` r$   Úget_template_by_idz!TemplateModule.get_template_by_idè   s   ø€ Ø× Ñ Ó!NÐPVÓWÐWr%   c                 ó.   ‡— | j                  ˆfd„|«      S )Nc                 ó"   •— | j                   ‰k(  S rE   )ÚNAME)r   r   s    €r$   rH   z5TemplateModule.get_template_by_name.<locals>.<lambda>ì   s   ø€ °8·=±=ÀDÑ3H€ r%   rI   )r"   r   r   s    ` r$   Úget_template_by_namez#TemplateModule.get_template_by_nameë   s   ø€ Ø× Ñ Ó!IÈ6ÓRÐRr%   c                 óN   — |r| j                  ||«      S | j                  ||«      S rE   )rJ   rN   )r"   Úrequested_idÚrequested_namer   s       r$   r+   z$TemplateModule.get_template_instanceî   s+   € ÙØ×*Ñ*¨<¸Ó@Ð@à×,Ñ,¨^¸VÓDÐDr%   c                 ó¦   — |j                   |j                  |j                  |j                  |j                  |j
                  |j                  dœ}|S )N)r   r   r   Ú	user_nameÚuser_idÚ
group_nameÚgroup_id)rF   rM   ÚTEMPLATEÚUNAMEÚUIDÚGNAMEÚGID)r"   r   r=   s      r$   Úget_template_infoz TemplateModule.get_template_infoô   sC   € à—+‘+Ø—M‘MØ ×)Ñ)Ø!Ÿ™Ø—|‘|Ø"Ÿ.™.Ø Ÿ™ñ
ˆð ˆr%   c                 óÚ   — | j                   j                  s.| j                  j                  j	                  d|z   dz   |z   «       | j                  | j                  ||«      «      }d|d<   |S )NzNAME = "z"
TÚchanged)r2   Ú
check_moder1   r   Úallocater\   rN   )r"   r   r4   r   r*   s        r$   r.   zTemplateModule.create_template  sb   € Ø{‰{×%Ò%ØH‰H×Ñ×&Ñ& {°TÑ'9¸FÑ'BÀ]Ñ'RÔSà×'Ñ'¨×(AÑ(AÀ$ÈÓ(OÓPˆØ ˆˆyÑàˆr%   c                 óN  — | j                   j                  s1| j                  j                  j	                  |j
                  |d«       | j                  | j                  |j
                  |«      «      }| j                   j                  rd|d<   |S |j                  |d   k7  |d<   |S )Nr   Tr^   r   )	r2   r_   r1   r   ÚupdaterF   r\   rJ   rW   )r"   r   r4   r   r*   s        r$   r/   zTemplateModule.update_template
  s   € Ø{‰{×%Ò%àH‰H×Ñ×$Ñ$ X§[¡[°-ÀÔCà×'Ñ'¨×(?Ñ(?ÀÇÁÈVÓ(TÓUˆØ;‰;×!Ò!à $ˆF9Ñð
 ˆð !)× 1Ñ 1°V¸JÑ5GÑ GˆF9Ñàˆr%   c                 ó    — |sddiS | j                   j                  s/| j                  j                  j	                  |j
                  «       ddiS )Nr^   FT)r2   r_   r1   r   ÚdeleterF   )r"   r   s     r$   r-   zTemplateModule.delete_template  sD   € ÙØ˜uÐ%Ð%à{‰{×%Ò%ØH‰H×Ñ×$Ñ$ X§[¡[Ô1à˜4Ð Ð r%   N)Ú__name__Ú
__module__Ú__qualname__r!   r6   rB   rJ   rN   r+   r\   r.   r/   r-   © r%   r$   r   r   £   s7   „ ò;ò4ò8òXòSòEòòòó!r%   r   c                  ó4   — t        «       j                  «        y rE   )r   Ú
run_modulerh   r%   r$   Úmainrk   #  s   € ÜÓ×ÑÕ!r%   Ú__main__N)Ú
__future__r   r   r   r   Ú__metaclass__ÚDOCUMENTATIONÚEXAMPLESÚRETURNÚEansible_collections.community.general.plugins.module_utils.opennebular   r   rk   re   rh   r%   r$   ú<module>rs      sZ   ð÷ CÑ BØ€ð;€ðz/€ðb#
€õL cô}!Ð%ô }!ò@"ð ˆzÒÙ…Fð r%   