Initial adaptation for DECORT API ver.3.6.1
This commit is contained in:
@@ -274,7 +274,7 @@ def decort_disk_package_facts(disk_facts, check_mode=False):
|
|||||||
ret_dict['size'] = disk_facts['sizeMax']
|
ret_dict['size'] = disk_facts['sizeMax']
|
||||||
ret_dict['state'] = disk_facts['status']
|
ret_dict['state'] = disk_facts['status']
|
||||||
ret_dict['account_id'] = disk_facts['accountId']
|
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['pool'] = disk_facts['pool']
|
||||||
ret_dict['attached_to'] = disk_facts['vmid']
|
ret_dict['attached_to'] = disk_facts['vmid']
|
||||||
ret_dict['gid'] = disk_facts['gid']
|
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
|
# request to place this disk on the same SEP as the specified OS image
|
||||||
# validate specified OS image and assign SEP ID accordingly
|
# validate specified OS image and assign SEP ID accordingly
|
||||||
image_id, image_facts = decon.image_find(amodule.params['place_with'], "", 0)
|
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:
|
else:
|
||||||
# no new SEP ID is explicitly specified, and no place_with option - use sep_id from the disk_facts
|
# no new SEP ID is explicitly specified, and no place_with option - use sepId from the disk_facts
|
||||||
target_sep_id = disk_facts['sepid']
|
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
|
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'],
|
size=amodule.params['size'],
|
||||||
account_id=validated_acc_id,
|
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
|
# request to place this disk on the same SEP as the specified OS image
|
||||||
# validate specified OS image and assign SEP ID accordingly
|
# validate specified OS image and assign SEP ID accordingly
|
||||||
image_id, image_facts = decon.image_find(amodule.params['place_with'], "", 0)
|
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:
|
else:
|
||||||
# no SEP ID is explicitly specified, and no place_with option - we do not know where
|
# no SEP ID is explicitly specified, and no place_with option - we do not know where
|
||||||
# to place the new disk - fail the module
|
# to place the new disk - fail the module
|
||||||
|
|||||||
@@ -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['size'] = arg_osimage_facts['size']
|
||||||
ret_dict['type'] = arg_osimage_facts['type']
|
ret_dict['type'] = arg_osimage_facts['type']
|
||||||
# ret_dict['arch'] = arg_osimage_facts['architecture']
|
# 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['pool'] = arg_osimage_facts['pool']
|
||||||
ret_dict['state'] = arg_osimage_facts['status']
|
ret_dict['state'] = arg_osimage_facts['status']
|
||||||
|
|
||||||
|
|||||||
@@ -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['name'] = arg_vins_facts['name']
|
||||||
ret_dict['state'] = arg_vins_facts['status']
|
ret_dict['state'] = arg_vins_facts['status']
|
||||||
ret_dict['account_id'] = arg_vins_facts['accountId']
|
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['int_net_addr'] = arg_vins_facts['network']
|
||||||
ret_dict['gid'] = arg_vins_facts['gid']
|
ret_dict['gid'] = arg_vins_facts['gid']
|
||||||
|
|
||||||
@@ -385,7 +385,7 @@ def main():
|
|||||||
decon.fail_json(**decon.result)
|
decon.fail_json(**decon.result)
|
||||||
vins_level="ID"
|
vins_level="ID"
|
||||||
validated_acc_id = vins_facts['accountId']
|
validated_acc_id = vins_facts['accountId']
|
||||||
validated_rg_id = vins_facts['rgid']
|
validated_rg_id = vins_facts['rgId']
|
||||||
elif amodule.params['rg_id']:
|
elif amodule.params['rg_id']:
|
||||||
# expect ViNS @ RG level in the RG with specified ID
|
# expect ViNS @ RG level in the RG with specified ID
|
||||||
vins_level="RG"
|
vins_level="RG"
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ class DecortController(object):
|
|||||||
# never be executed
|
# never be executed
|
||||||
return False
|
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),)
|
req_header = dict(Authorization="bearer {}".format(arg_jwt),)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -316,7 +316,7 @@ class DecortController(object):
|
|||||||
self.amodule.fail_json(**self.result)
|
self.amodule.fail_json(**self.result)
|
||||||
return False
|
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,
|
req_data = dict(username=self.user,
|
||||||
password=self.password,)
|
password=self.password,)
|
||||||
|
|
||||||
@@ -1190,11 +1190,11 @@ class DecortController(object):
|
|||||||
# OS image manipulation methods
|
# OS image manipulation methods
|
||||||
###################################
|
###################################
|
||||||
def _image_get_by_id(self, image_id):
|
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,
|
api_params = dict(imageId=image_id,
|
||||||
showAll=False)
|
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.
|
# 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'))
|
ret_image_dict = json.loads(api_resp.content.decode('utf8'))
|
||||||
|
|
||||||
@@ -1229,7 +1229,7 @@ class DecortController(object):
|
|||||||
if image_id > 0:
|
if image_id > 0:
|
||||||
ret_image_id, ret_image_dict = self._image_get_by_id(image_id)
|
ret_image_id, ret_image_dict = self._image_get_by_id(image_id)
|
||||||
if ( ret_image_id and
|
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']) ):
|
(pool == "" or pool == ret_image_dict['pool']) ):
|
||||||
return ret_image_id, ret_image_dict
|
return ret_image_id, ret_image_dict
|
||||||
else:
|
else:
|
||||||
@@ -1243,7 +1243,7 @@ class DecortController(object):
|
|||||||
validated_acc_id = rg_facts['accountId']
|
validated_acc_id = rg_facts['accountId']
|
||||||
|
|
||||||
api_params = dict(accountId=validated_acc_id)
|
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.
|
# 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'))
|
images_list = json.loads(api_resp.content.decode('utf8'))
|
||||||
for image_record in images_list:
|
for image_record in images_list:
|
||||||
@@ -1253,7 +1253,7 @@ class DecortController(object):
|
|||||||
return image_record['id'], image_record
|
return image_record['id'], image_record
|
||||||
# if positive SEP ID and/or non-emtpy pool name are passed, match by them
|
# if positive SEP ID and/or non-emtpy pool name are passed, match by them
|
||||||
full_match = True
|
full_match = True
|
||||||
if sepid > 0 and sepid != image_record['sepid']:
|
if sepid > 0 and sepid != image_record['sepId']:
|
||||||
full_match = False
|
full_match = False
|
||||||
if pool != "" and pool != image_record['pool']:
|
if pool != "" and pool != image_record['pool']:
|
||||||
full_match = False
|
full_match = False
|
||||||
@@ -1380,7 +1380,7 @@ class DecortController(object):
|
|||||||
self.amodule.fail_json(**self.result)
|
self.amodule.fail_json(**self.result)
|
||||||
# try to locate RG by name - start with getting all RGs IDs within the specified account
|
# try to locate RG by name - start with getting all RGs IDs within the specified account
|
||||||
api_params['accountId'] = arg_account_id
|
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/get", api_params)
|
||||||
if api_resp.status_code == 200:
|
if api_resp.status_code == 200:
|
||||||
account_specs = json.loads(api_resp.content.decode('utf8'))
|
account_specs = json.loads(api_resp.content.decode('utf8'))
|
||||||
api_params.pop('accountId')
|
api_params.pop('accountId')
|
||||||
@@ -1633,12 +1633,12 @@ class DecortController(object):
|
|||||||
|
|
||||||
if account_name == "":
|
if account_name == "":
|
||||||
api_params['accountId'] = account_id
|
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:
|
if api_resp.status_code == 200:
|
||||||
account_details = json.loads(api_resp.content.decode('utf8'))
|
account_details = json.loads(api_resp.content.decode('utf8'))
|
||||||
return account_details['id'], account_details
|
return account_details['id'], account_details
|
||||||
else:
|
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:
|
if api_resp.status_code == 200:
|
||||||
# Parse response to see if a account matching arg_account_name is found in the output
|
# 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
|
# 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
|
# get detailed information about the account from "accounts/get" call as
|
||||||
# "accounts/list" does not return all necessary fields
|
# "accounts/list" does not return all necessary fields
|
||||||
api_params['accountId'] = runner['id']
|
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:
|
if api_resp.status_code == 200:
|
||||||
account_details = json.loads(api_resp.content.decode('utf8'))
|
account_details = json.loads(api_resp.content.decode('utf8'))
|
||||||
return account_details['id'], account_details
|
return account_details['id'], account_details
|
||||||
@@ -2147,7 +2147,7 @@ class DecortController(object):
|
|||||||
"was requested.").format(vins_dict['id'],vins_dict['name'])
|
"was requested.").format(vins_dict['id'],vins_dict['name'])
|
||||||
return
|
return
|
||||||
|
|
||||||
if not vins_dict['rgid']:
|
if not vins_dict['rgId']:
|
||||||
# this ViNS exists at account level - no updates are possible
|
# this ViNS exists at account level - no updates are possible
|
||||||
self.result['warning'] = ("vins_update(): no update is possible for ViNS ID {} "
|
self.result['warning'] = ("vins_update(): no update is possible for ViNS ID {} "
|
||||||
"as it exists at account level.").format(vins_dict['id'])
|
"as it exists at account level.").format(vins_dict['id'])
|
||||||
@@ -2361,10 +2361,10 @@ class DecortController(object):
|
|||||||
api_params = dict(accountId=account_id,
|
api_params = dict(accountId=account_id,
|
||||||
gid=target_gid,
|
gid=target_gid,
|
||||||
name=disk_name,
|
name=disk_name,
|
||||||
description=desc,
|
desc=desc,
|
||||||
size=size,
|
size=size,
|
||||||
type='D',
|
type='D',
|
||||||
sep_id=sep_id,)
|
sepId=sep_id,)
|
||||||
if pool_name != "":
|
if pool_name != "":
|
||||||
api_params['pool'] = pool_name
|
api_params['pool'] = pool_name
|
||||||
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/disks/create", api_params)
|
api_resp = self.decort_api_call(requests.post, "/restmachine/cloudapi/disks/create", api_params)
|
||||||
|
|||||||
Reference in New Issue
Block a user