Some impruvments and updates
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Digital Enegry Cloud Orchestration Technology (DECORT) modules for Ansible
|
||||
# Copyright: (c) 2018-2021 Digital Energy Cloud Solutions LLC
|
||||
# Copyright: (c) 2018-2023 Digital Energy Cloud Solutions LLC
|
||||
#
|
||||
# Apache License 2.0 (see http://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
#
|
||||
|
||||
#
|
||||
# Author: Sergey Shubin (sergey.shubin@digitalenergy.online)
|
||||
#
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
@@ -24,15 +20,14 @@ description: >
|
||||
network port forwarding rules, restart guest OS and delete a virtual machine thus releasing
|
||||
corresponding cloud resources.
|
||||
version_added: "2.2"
|
||||
author:
|
||||
- Sergey Shubin <sergey.shubin@digitalenergy.online>
|
||||
|
||||
requirements:
|
||||
- python >= 2.6
|
||||
- python >= 3.8
|
||||
- PyJWT Python module
|
||||
- requests Python module
|
||||
- netaddr Python module
|
||||
- decort_utils utility library (module)
|
||||
- DECORT cloud platform version 3.6.1 or higher
|
||||
- DECORT cloud platform version 3.8.6 or higher
|
||||
notes:
|
||||
- Environment variables can be used to pass selected parameters to the module, see details below.
|
||||
- Specified Oauth2 provider must be trusted by the DECORT cloud controller on which JWT will be used.
|
||||
@@ -231,7 +226,7 @@ options:
|
||||
choices: [ present, absent, poweredon, poweredoff, halted, paused, check ]
|
||||
tags:
|
||||
description:
|
||||
- String of custom tags to be assigned to the VM (This feature is not implemented yet!).
|
||||
- Dict of custom tags to be assigned to the VM.
|
||||
- These tags are arbitrary text that can be used for grouping or indexing the VMs by other applications.
|
||||
required: no
|
||||
user:
|
||||
@@ -287,24 +282,14 @@ EXAMPLES = '''
|
||||
name: SimpleVM
|
||||
cpu: 2
|
||||
ram: 4096
|
||||
boot_disk:
|
||||
size: 10
|
||||
model: ovs
|
||||
pool: boot
|
||||
boot_disk: 10
|
||||
image_name: "Ubuntu 16.04 v1.1"
|
||||
data_disks:
|
||||
- size: 50
|
||||
model: ovs
|
||||
pool: data
|
||||
port_forwards:
|
||||
- ext_port: 21022
|
||||
int_port: 22
|
||||
proto: tcp
|
||||
- ext_port: 80
|
||||
int_port: 80
|
||||
proto: tcp
|
||||
- {{DISK_ID}}
|
||||
state: present
|
||||
tags: "PROJECT:Ansible STATUS:Test"
|
||||
tags:
|
||||
PROJECT:Ansible
|
||||
STATUS:Test
|
||||
account_name: "Development"
|
||||
rg_name: "ANewVDC"
|
||||
delegate_to: localhost
|
||||
@@ -337,18 +322,6 @@ EXAMPLES = '''
|
||||
state: poweredoff
|
||||
delegate_to: localhost
|
||||
register: simple_vm
|
||||
- name: check if VM exists and read in its specs.
|
||||
decort_kvmvm:
|
||||
authenticator: oauth2
|
||||
app_id: "{{ MY_APP_ID }}"
|
||||
app_secret: "{{ MY_APP_SECRET }}"
|
||||
controller_url: "https://ds1.digitalenergy.online"
|
||||
name: "{{ TARGET_VM_NAME }}"
|
||||
rg_name: "{{ TARGET_VDC_NAME }}"
|
||||
account_name: "{{ TRAGET_TENANT }}"
|
||||
state: check
|
||||
delegate_to: localhost
|
||||
register: existing_vm
|
||||
'''
|
||||
|
||||
RETURN = '''
|
||||
@@ -573,6 +546,8 @@ class decort_kvmvm(DecortController):
|
||||
image_id=image_facts['id'],
|
||||
annotation=self.amodule.params['annotation'],
|
||||
userdata=cloud_init_params,
|
||||
sep_id=self.amodule.params['sep_id' ] if "sep_id" in self.amodule.params else None,
|
||||
pool_name=self.amodule.params['pool'] if "pool" in self.amodule.params else None,
|
||||
start_on_create=start_compute)
|
||||
self.comp_should_exist = True
|
||||
|
||||
@@ -652,11 +627,13 @@ class decort_kvmvm(DecortController):
|
||||
self.compute_resize(self.comp_info,
|
||||
self.amodule.params['cpu'], self.amodule.params['ram'],
|
||||
wait_for_state_change=arg_wait_cycles)
|
||||
|
||||
self.compute_affinity(self.comp_info,
|
||||
self.amodule.params['tag'],
|
||||
self.amodule.params['aff_rule'],
|
||||
self.amodule.params['aaff_rule'],
|
||||
label=self.amodule.params['affinity_label'],)
|
||||
|
||||
return
|
||||
|
||||
def package_facts(self, check_mode=False):
|
||||
@@ -686,6 +663,7 @@ class decort_kvmvm(DecortController):
|
||||
public_ips=[], # direct IPs; this list can be empty
|
||||
private_ips=[], # IPs on ViNSes; usually, at least one IP is listed
|
||||
nat_ip="", # IP of the external ViNS interface; can be empty.
|
||||
tags={},
|
||||
)
|
||||
|
||||
if check_mode or self.comp_info is None:
|
||||
@@ -703,6 +681,8 @@ class decort_kvmvm(DecortController):
|
||||
ret_dict['tech_status'] = self.comp_info['techStatus']
|
||||
ret_dict['account_id'] = self.comp_info['accountId']
|
||||
ret_dict['rg_id'] = self.comp_info['rgId']
|
||||
if self.comp_info['tags']:
|
||||
ret_dict['tags'] = self.comp_info['tags']
|
||||
# if the VM is an imported VM, then the 'accounts' list may be empty,
|
||||
# so check for this case before trying to access login and passowrd values
|
||||
if len(self.comp_info['osUsers']):
|
||||
@@ -764,6 +744,8 @@ class decort_kvmvm(DecortController):
|
||||
required=True,
|
||||
choices=['legacy', 'oauth2', 'jwt']),
|
||||
boot_disk=dict(type='int', required=False),
|
||||
sep_id=dict(type='int', required=False),
|
||||
pool=dict(type='str', required=False),
|
||||
controller_url=dict(type='str', required=True),
|
||||
# count=dict(type='int', required=False, default=1),
|
||||
cpu=dict(type='int', required=False),
|
||||
@@ -790,7 +772,7 @@ class decort_kvmvm(DecortController):
|
||||
rg_name=dict(type='str', default=""),
|
||||
ssh_key=dict(type='str', required=False),
|
||||
ssh_key_user=dict(type='str', required=False),
|
||||
tag=dict(type='list', required=False),
|
||||
tag=dict(type='dict', required=False),
|
||||
affinity_label=dict(type='str', required=False),
|
||||
aff_rule=dict(type='list', required=False),
|
||||
aaff_rule=dict(type='list', required=False),
|
||||
|
||||
Reference in New Issue
Block a user