Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36773c7bb3 | ||
|
|
3d9917b8a7 | ||
|
|
a166ce1c8d | ||
|
|
e81bf1ca16 |
@@ -1,12 +1,12 @@
|
||||
# decort-ansible
|
||||
Ansible modules for Digital Energy Orchestration Technology (DECORT) platform v3.5.0 and above
|
||||
Ansible modules for Digital Energy Orchestration Technology (DECORT) platform v3.6.1 and above.
|
||||
|
||||
Note that this module may produce unreliable results when used with older DECORT API versions.
|
||||
|
||||
Requirements:
|
||||
* Ansible 2.7 or higher
|
||||
* Python 2.6 or higher
|
||||
* PyJWT Python module
|
||||
* PyJWT 1.7.1 Python module
|
||||
* requests Python module
|
||||
* netaddr Python module
|
||||
* DECORT cloud platform version 3.5.0 or higher
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Digital Enegry Cloud Orchestration Technology (DECORT) modules for Ansible
|
||||
# Copyright: (c) 2018-2020 Digital Energy Cloud Solutions LLC
|
||||
# Copyright: (c) 2018-2021 Digital Energy Cloud Solutions LLC
|
||||
#
|
||||
# Apache License 2.0 (see http://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
#
|
||||
@@ -30,7 +30,7 @@ requirements:
|
||||
- requests Python module
|
||||
- netaddr Python module
|
||||
- decort_utils utility library (module)
|
||||
- DECORT cloud platform version 3.4.2 or higher
|
||||
- DECORT cloud platform version 3.6.1 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.
|
||||
@@ -274,7 +274,7 @@ def decort_disk_package_facts(disk_facts, check_mode=False):
|
||||
ret_dict['size'] = disk_facts['sizeMax']
|
||||
ret_dict['state'] = disk_facts['status']
|
||||
ret_dict['account_id'] = disk_facts['accountId']
|
||||
ret_dict['sep_id'] = disk_facts['sepid']
|
||||
ret_dict['sep_id'] = disk_facts['sepId']
|
||||
ret_dict['pool'] = disk_facts['pool']
|
||||
ret_dict['attached_to'] = disk_facts['vmid']
|
||||
ret_dict['gid'] = disk_facts['gid']
|
||||
@@ -454,10 +454,10 @@ def main():
|
||||
# request to place this disk on the same SEP as the specified OS image
|
||||
# validate specified OS image and assign SEP ID accordingly
|
||||
image_id, image_facts = decon.image_find(amodule.params['place_with'], "", 0)
|
||||
target_sep_id = image_facts['sepid']
|
||||
target_sep_id = image_facts['sepId']
|
||||
else:
|
||||
# no new SEP ID is explicitly specified, and no place_with option - use sep_id from the disk_facts
|
||||
target_sep_id = disk_facts['sepid']
|
||||
# no new SEP ID is explicitly specified, and no place_with option - use sepId from the disk_facts
|
||||
target_sep_id = disk_facts['sepId']
|
||||
disk_id = decon.disk_provision(disk_name=disk_facts['name'], # as this disk was found, its name is in the facts
|
||||
size=amodule.params['size'],
|
||||
account_id=validated_acc_id,
|
||||
@@ -495,7 +495,7 @@ def main():
|
||||
# request to place this disk on the same SEP as the specified OS image
|
||||
# validate specified OS image and assign SEP ID accordingly
|
||||
image_id, image_facts = decon.image_find(amodule.params['place_with'], "", 0)
|
||||
target_sep_id = image_facts['sepid']
|
||||
target_sep_id = image_facts['sepId']
|
||||
else:
|
||||
# no SEP ID is explicitly specified, and no place_with option - we do not know where
|
||||
# to place the new disk - fail the module
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Digital Enegry Cloud Orchestration Technology (DECORT) modules for Ansible
|
||||
# Copyright: (c) 2018-2020 Digital Energy Cloud Solutions LLC
|
||||
# Copyright: (c) 2018-2021 Digital Energy Cloud Solutions LLC
|
||||
#
|
||||
# Apache License 2.0 (see http://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
#
|
||||
@@ -32,7 +32,7 @@ requirements:
|
||||
- PyJWT module
|
||||
- requests module
|
||||
- decort_utils utility library (module)
|
||||
- DECORT cloud platform version 3.4.2 or higher
|
||||
- DECORT cloud platform version 3.6.1 or higher
|
||||
options:
|
||||
app_id:
|
||||
description:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Digital Enegry Cloud Orchestration Technology (DECORT) modules for Ansible
|
||||
# Copyright: (c) 2018-2020 Digital Energy Cloud Solutions LLC
|
||||
# Copyright: (c) 2018-2021 Digital Energy Cloud Solutions LLC
|
||||
#
|
||||
# Apache License 2.0 (see http://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
#
|
||||
@@ -32,7 +32,7 @@ requirements:
|
||||
- requests Python module
|
||||
- netaddr Python module
|
||||
- decort_utils utility library (module)
|
||||
- DECORT cloud platform version 3.4.2 or higher
|
||||
- DECORT cloud platform version 3.6.1 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.
|
||||
@@ -77,8 +77,8 @@ options:
|
||||
- Architecture of the KVM VM. DECORT supports KVM hosts based on Intel x86 and IBM PowerPC hardware.
|
||||
- This parameter is used when new KVM VM is created and ignored for all other operations.
|
||||
- Module may fail if your DECORT installation does not have physical nodes of specified architecture.
|
||||
default: KVM_X86
|
||||
choices: [ KVM_X86, KVM_PPC ]
|
||||
default: X86_64
|
||||
choices: [ X86_64, PPC64_LE ]
|
||||
required: yes
|
||||
authenticator:
|
||||
description:
|
||||
@@ -439,8 +439,8 @@ class decort_kvmvm(DecortController):
|
||||
check_state=False)
|
||||
|
||||
if self.comp_id:
|
||||
if self.comp_info['status'] != 'DESTROYED' and self.comp_info['arch'] not in ["KVM_X86", "KVM_PPC"]:
|
||||
# If we found a Compute in a non-DESTROYED state and it is not of type KVM_*, abort the module
|
||||
if self.comp_info['status'] != 'DESTROYED' and self.comp_info['arch'] not in ["X86_64", "PPC64_LE"]:
|
||||
# If we found a Compute in a non-DESTROYED state and it is not of type valid arch, abort the module
|
||||
self.result['failed'] = True
|
||||
self.result['msg'] = ("Compute ID {} architecture '{}' is not supported by "
|
||||
"decort_kvmvm module.").format(self.comp_id,
|
||||
@@ -500,7 +500,7 @@ class decort_kvmvm(DecortController):
|
||||
self.check_amodule_argument('cpu')
|
||||
self.check_amodule_argument('ram')
|
||||
|
||||
if self.amodule.params['arch'] not in ["KVM_X86", "KVM_PPC"]:
|
||||
if self.amodule.params['arch'] not in ["X86_64", "PPC64_LE"]:
|
||||
self.result['failed'] = True
|
||||
self.result['msg'] = ("Unsupported architecture '{}' is specified for "
|
||||
"KVM VM create.").format(self.amodule.params['arch'])
|
||||
@@ -743,7 +743,7 @@ class decort_kvmvm(DecortController):
|
||||
required=False,
|
||||
fallback=(env_fallback, ['DECORT_APP_SECRET']),
|
||||
no_log=True),
|
||||
arch=dict(type='str', choices=['KVM_X86', 'KVM_PPC'], default='KVM_X86'),
|
||||
arch=dict(type='str', choices=['X86_64', 'PPC64_LE'], default='X86_64'),
|
||||
authenticator=dict(type='str',
|
||||
required=True,
|
||||
choices=['legacy', 'oauth2', 'jwt']),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Digital Enegry Cloud Orchestration Technology (DECORT) modules for Ansible
|
||||
# Copyright: (c) 2018-2020 Digital Energy Cloud Solutions LLC
|
||||
# Copyright: (c) 2018-2021 Digital Energy Cloud Solutions LLC
|
||||
#
|
||||
# Apache License 2.0 (see http://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
#
|
||||
@@ -33,7 +33,7 @@ requirements:
|
||||
- requests Python module
|
||||
- netaddr Python module
|
||||
- decort_utils utility library (module)
|
||||
- DECORT cloud platform version 3.4.2 or higher.
|
||||
- DECORT cloud platform version 3.6.1 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.
|
||||
@@ -203,7 +203,7 @@ def decort_osimage_package_facts(arg_osimage_facts, arg_check_mode=False):
|
||||
ret_dict['size'] = arg_osimage_facts['size']
|
||||
ret_dict['type'] = arg_osimage_facts['type']
|
||||
# ret_dict['arch'] = arg_osimage_facts['architecture']
|
||||
ret_dict['sep_id'] = arg_osimage_facts['sepid']
|
||||
ret_dict['sep_id'] = arg_osimage_facts['sepId']
|
||||
ret_dict['pool'] = arg_osimage_facts['pool']
|
||||
ret_dict['state'] = arg_osimage_facts['status']
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Digital Enegry Cloud Orchestration Technology (DECORT) modules for Ansible
|
||||
# Copyright: (c) 2018-2020 Digital Energy Cloud Solutions LLC
|
||||
# Copyright: (c) 2018-2021 Digital Energy Cloud Solutions LLC
|
||||
#
|
||||
# Apache License 2.0 (see http://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
#
|
||||
@@ -30,7 +30,7 @@ requirements:
|
||||
- requests Python module
|
||||
- netaddr Python module
|
||||
- decort_utils utility library (module)
|
||||
- DECORT cloud platform version 3.4.2 or higher
|
||||
- DECORT cloud platform version 3.6.1 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Digital Enegry Cloud Orchestration Technology (DECORT) modules for Ansible
|
||||
# Copyright: (c) 2018-2020 Digital Energy Cloud Solutions LLC
|
||||
# Copyright: (c) 2018-2021 Digital Energy Cloud Solutions LLC
|
||||
#
|
||||
# Apache License 2.0 (see http://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
#
|
||||
@@ -30,7 +30,7 @@ requirements:
|
||||
- requests Python module
|
||||
- netaddr Python module
|
||||
- decort_utils utility library (module)
|
||||
- DECORT cloud platform version 3.4.2 or higher
|
||||
- DECORT cloud platform version 3.6.1 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
#
|
||||
# Digital Enegry Cloud Orchestration Technology (DECORT) modules for Ansible
|
||||
# Copyright: (c) 2018-2020 Digital Energy Cloud Solutions LLC
|
||||
# Copyright: (c) 2018-2021 Digital Energy Cloud Solutions LLC
|
||||
#
|
||||
# Apache License 2.0 (see http://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
#
|
||||
@@ -30,7 +30,7 @@ requirements:
|
||||
- requests Python module
|
||||
- netaddr Python module
|
||||
- decort_utils utility library (module)
|
||||
- DECORT cloud platform version 3.4.2 or higher
|
||||
- DECORT cloud platform version 3.6.1 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.
|
||||
@@ -273,7 +273,7 @@ def decort_vins_package_facts(arg_vins_facts, arg_check_mode=False):
|
||||
ret_dict['name'] = arg_vins_facts['name']
|
||||
ret_dict['state'] = arg_vins_facts['status']
|
||||
ret_dict['account_id'] = arg_vins_facts['accountId']
|
||||
ret_dict['rg_id'] = arg_vins_facts['rgid']
|
||||
ret_dict['rg_id'] = arg_vins_facts['rgId']
|
||||
ret_dict['int_net_addr'] = arg_vins_facts['network']
|
||||
ret_dict['gid'] = arg_vins_facts['gid']
|
||||
|
||||
@@ -385,7 +385,7 @@ def main():
|
||||
decon.fail_json(**decon.result)
|
||||
vins_level="ID"
|
||||
validated_acc_id = vins_facts['accountId']
|
||||
validated_rg_id = vins_facts['rgid']
|
||||
validated_rg_id = vins_facts['rgId']
|
||||
elif amodule.params['rg_id']:
|
||||
# expect ViNS @ RG level in the RG with specified ID
|
||||
vins_level="RG"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#
|
||||
# Digital Enegry Cloud Orchestration Technology (DECORT) modules for Ansible
|
||||
# Copyright: (c) 2018-2020 Digital Energy Cloud Solutions LLC
|
||||
# Copyright: (c) 2018-2021 Digital Energy Cloud Solutions LLC
|
||||
#
|
||||
# Apache License 2.0 (see http://www.apache.org/licenses/LICENSE-2.0.txt)
|
||||
#
|
||||
@@ -28,7 +28,7 @@ Requirements:
|
||||
- PyJWT Python module
|
||||
- requests Python module
|
||||
- netaddr Python module
|
||||
- DECORT cloud platform version 3.4.2 or higher
|
||||
- DECORT cloud platform version 3.6.1 or higher
|
||||
"""
|
||||
|
||||
import copy
|
||||
@@ -272,7 +272,7 @@ class DecortController(object):
|
||||
# never be executed
|
||||
return False
|
||||
|
||||
req_url = self.controller_url + "/restmachine/cloudapi/accounts/list"
|
||||
req_url = self.controller_url + "/restmachine/cloudapi/account/list"
|
||||
req_header = dict(Authorization="bearer {}".format(arg_jwt),)
|
||||
|
||||
try:
|
||||
@@ -316,7 +316,7 @@ class DecortController(object):
|
||||
self.amodule.fail_json(**self.result)
|
||||
return False
|
||||
|
||||
req_url = self.controller_url + "/restmachine/cloudapi/users/authenticate"
|
||||
req_url = self.controller_url + "/restmachine/cloudapi/user/authenticate"
|
||||
req_data = dict(username=self.user,
|
||||
password=self.password,)
|
||||
|
||||
@@ -769,8 +769,8 @@ class DecortController(object):
|
||||
|
||||
@param (int) rg_id: ID of the RG where the VM will be provisioned.
|
||||
@param (string) comp_name: that specifies the name of the VM.
|
||||
@param (string) arch: hardware architecture of KVM VM. Supported values are: "KVM_X86" for Intel x86
|
||||
and "KVM_PPC" for IBM PowerPC.
|
||||
@param (string) arch: hardware architecture of KVM VM. Supported values are: "X86_64" for Intel x86
|
||||
and "PPC64_LE" for IBM PowerPC.
|
||||
@param (int) cpu: how many virtual CPUs to allocate.
|
||||
@param (int) ram: volume of RAM in MB to allocate (i.e. pass 4096 to allocate 4GB RAM).
|
||||
@param (int) boot_disk: boot disk size in GB.
|
||||
@@ -792,9 +792,9 @@ class DecortController(object):
|
||||
return 0
|
||||
|
||||
api_url=""
|
||||
if arch == "KVM_X86":
|
||||
if arch == "X86_64":
|
||||
api_url = "/restmachine/cloudapi/kvmx86/create"
|
||||
elif arch == "KVM_PPC":
|
||||
elif arch == "PPC64_LE":
|
||||
api_url = "/restmachine/cloudapi/kvmppc/create"
|
||||
else:
|
||||
self.result['failed'] = True
|
||||
@@ -1190,11 +1190,11 @@ class DecortController(object):
|
||||
# OS image manipulation methods
|
||||
###################################
|
||||
def _image_get_by_id(self, image_id):
|
||||
# TODO: update once cloudapi/images/get is implemented, see ticket #2963
|
||||
# TODO: update once cloudapi/image/get is implemented, see ticket #2963
|
||||
|
||||
api_params = dict(imageId=image_id,
|
||||
showAll=False)
|
||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/images/get", api_params)
|
||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/image/get", api_params)
|
||||
# On success the above call will return here. On error it will abort execution by calling fail_json.
|
||||
ret_image_dict = json.loads(api_resp.content.decode('utf8'))
|
||||
|
||||
@@ -1229,7 +1229,7 @@ class DecortController(object):
|
||||
if image_id > 0:
|
||||
ret_image_id, ret_image_dict = self._image_get_by_id(image_id)
|
||||
if ( ret_image_id and
|
||||
(sepid == 0 or sepid == ret_image_dict['sepid']) and
|
||||
(sepid == 0 or sepid == ret_image_dict['sepId']) and
|
||||
(pool == "" or pool == ret_image_dict['pool']) ):
|
||||
return ret_image_id, ret_image_dict
|
||||
else:
|
||||
@@ -1243,7 +1243,7 @@ class DecortController(object):
|
||||
validated_acc_id = rg_facts['accountId']
|
||||
|
||||
api_params = dict(accountId=validated_acc_id)
|
||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/images/list", api_params)
|
||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/image/list", api_params)
|
||||
# On success the above call will return here. On error it will abort execution by calling fail_json.
|
||||
images_list = json.loads(api_resp.content.decode('utf8'))
|
||||
for image_record in images_list:
|
||||
@@ -1253,7 +1253,7 @@ class DecortController(object):
|
||||
return image_record['id'], image_record
|
||||
# if positive SEP ID and/or non-emtpy pool name are passed, match by them
|
||||
full_match = True
|
||||
if sepid > 0 and sepid != image_record['sepid']:
|
||||
if sepid > 0 and sepid != image_record['sepId']:
|
||||
full_match = False
|
||||
if pool != "" and pool != image_record['pool']:
|
||||
full_match = False
|
||||
@@ -1380,12 +1380,12 @@ class DecortController(object):
|
||||
self.amodule.fail_json(**self.result)
|
||||
# try to locate RG by name - start with getting all RGs IDs within the specified account
|
||||
api_params['accountId'] = arg_account_id
|
||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/accounts/get", api_params)
|
||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/account/listRG", api_params)
|
||||
if api_resp.status_code == 200:
|
||||
account_specs = json.loads(api_resp.content.decode('utf8'))
|
||||
api_params.pop('accountId')
|
||||
for rg_id in account_specs['rgs']:
|
||||
got_id, got_specs = self._rg_get_by_id(rg_id)
|
||||
for rg_item in account_specs:
|
||||
got_id, got_specs = self._rg_get_by_id(rg_item['id'])
|
||||
if got_id and got_specs['name'] == arg_rg_name:
|
||||
# name matches
|
||||
if not arg_check_state or got_specs['status'] not in RG_INVALID_STATES:
|
||||
@@ -1633,12 +1633,12 @@ class DecortController(object):
|
||||
|
||||
if account_name == "":
|
||||
api_params['accountId'] = account_id
|
||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/accounts/get", api_params)
|
||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/account/get", api_params)
|
||||
if api_resp.status_code == 200:
|
||||
account_details = json.loads(api_resp.content.decode('utf8'))
|
||||
return account_details['id'], account_details
|
||||
else:
|
||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/accounts/list", api_params)
|
||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/account/list", api_params)
|
||||
if api_resp.status_code == 200:
|
||||
# Parse response to see if a account matching arg_account_name is found in the output
|
||||
# If it is found, assign its ID to the return variable and copy dictionary with the facts
|
||||
@@ -1648,7 +1648,7 @@ class DecortController(object):
|
||||
# get detailed information about the account from "accounts/get" call as
|
||||
# "accounts/list" does not return all necessary fields
|
||||
api_params['accountId'] = runner['id']
|
||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/accounts/get", api_params)
|
||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/account/get", api_params)
|
||||
if api_resp.status_code == 200:
|
||||
account_details = json.loads(api_resp.content.decode('utf8'))
|
||||
return account_details['id'], account_details
|
||||
@@ -2147,7 +2147,7 @@ class DecortController(object):
|
||||
"was requested.").format(vins_dict['id'],vins_dict['name'])
|
||||
return
|
||||
|
||||
if not vins_dict['rgid']:
|
||||
if not vins_dict['rgId']:
|
||||
# this ViNS exists at account level - no updates are possible
|
||||
self.result['warning'] = ("vins_update(): no update is possible for ViNS ID {} "
|
||||
"as it exists at account level.").format(vins_dict['id'])
|
||||
@@ -2361,10 +2361,10 @@ class DecortController(object):
|
||||
api_params = dict(accountId=account_id,
|
||||
gid=target_gid,
|
||||
name=disk_name,
|
||||
description=desc,
|
||||
desc=desc,
|
||||
size=size,
|
||||
type='D',
|
||||
sep_id=sep_id,)
|
||||
sepId=sep_id,)
|
||||
if pool_name != "":
|
||||
api_params['pool'] = pool_name
|
||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/disks/create", api_params)
|
||||
|
||||
Reference in New Issue
Block a user