9.0.0
This commit is contained in:
@@ -24,7 +24,6 @@ class decort_vins(DecortController):
|
||||
validated_rg_id = 0
|
||||
rg_facts = None # will hold RG facts
|
||||
validated_acc_id = 0
|
||||
acc_facts = None # will hold Account facts
|
||||
|
||||
if arg_amodule.params['vins_id']:
|
||||
# expect existing ViNS with the specified ID
|
||||
@@ -45,6 +44,7 @@ class decort_vins(DecortController):
|
||||
# This call to rg_find will abort the module if no RG with such ID is present
|
||||
validated_rg_id, rg_facts = self.rg_find(0, # account ID set to 0 as we search for RG by RG ID
|
||||
arg_amodule.params['rg_id'], arg_rg_name="")
|
||||
validated_acc_id = rg_facts['accountId']
|
||||
|
||||
# This call to vins_find may return vins_id=0 if no ViNS found
|
||||
self.vins_id, self.vins_facts = self.vins_find(vins_id=0, vins_name=arg_amodule.params['vins_name'],
|
||||
@@ -56,7 +56,7 @@ class decort_vins(DecortController):
|
||||
pass
|
||||
elif arg_amodule.params['account_id'] or arg_amodule.params['account_name'] != "":
|
||||
# Specified account must be present and accessible by the user, otherwise abort the module
|
||||
validated_acc_id, acc_facts = self.account_find(arg_amodule.params['account_name'], arg_amodule.params['account_id'])
|
||||
validated_acc_id, self._acc_info = self.account_find(arg_amodule.params['account_name'], arg_amodule.params['account_id'])
|
||||
if not validated_acc_id:
|
||||
self.result['failed'] = True
|
||||
self.result['msg'] = ("Current user does not have access to the requested account "
|
||||
@@ -102,15 +102,25 @@ class decort_vins(DecortController):
|
||||
self.amodule.fail_json(**self.result)
|
||||
|
||||
return
|
||||
|
||||
self.rg_id = validated_rg_id
|
||||
self.acc_id = validated_acc_id
|
||||
|
||||
if self.vins_id and self.vins_facts['status'] != 'DESTROYED':
|
||||
self.check_amodule_args_for_change()
|
||||
else:
|
||||
self.check_amodule_args_for_create()
|
||||
|
||||
return
|
||||
|
||||
def create(self):
|
||||
self.vins_id = self.vins_provision(self.amodule.params['vins_name'],
|
||||
self.acc_id, self.rg_id,
|
||||
self.amodule.params['ipcidr'],
|
||||
self.amodule.params['ext_net_id'], self.amodule.params['ext_ip_addr'],
|
||||
self.amodule.params['description'])
|
||||
self.amodule.params['description'],
|
||||
zone_id=self.amodule.params['zone_id'],
|
||||
)
|
||||
|
||||
if self.amodule.params['mgmtaddr'] or self.amodule.params['connect_to']:
|
||||
_, self.vins_facts = self.vins_find(self.vins_id)
|
||||
@@ -150,6 +160,14 @@ class decort_vins(DecortController):
|
||||
|
||||
if d_state != '':
|
||||
self.vins_state(self.vins_facts, d_state)
|
||||
|
||||
aparam_zone_id = self.aparams['zone_id']
|
||||
if aparam_zone_id is not None and aparam_zone_id != self.vins_facts['zoneId']:
|
||||
self.vins_migrate_to_zone(
|
||||
net_id=self.vins_id,
|
||||
zone_id=aparam_zone_id,
|
||||
)
|
||||
|
||||
return
|
||||
def delete(self):
|
||||
self.vins_delete(self.vins_id, permanently=True)
|
||||
@@ -235,6 +253,7 @@ class decort_vins(DecortController):
|
||||
else:
|
||||
ret_dict['ext_ip_addr'] = ""
|
||||
ret_dict['ext_net_id'] = -1
|
||||
ret_dict['zone_id'] = self.vins_facts['zoneId']
|
||||
|
||||
return ret_dict
|
||||
|
||||
@@ -309,12 +328,31 @@ class decort_vins(DecortController):
|
||||
type='str',
|
||||
default='',
|
||||
),
|
||||
zone_id=dict(
|
||||
type=int,
|
||||
),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
required_one_of=[
|
||||
('vins_id', 'vins_name'),
|
||||
],
|
||||
)
|
||||
|
||||
def check_amodule_args_for_change(self):
|
||||
check_errors = False
|
||||
if self.check_aparam_zone_id() is False:
|
||||
check_errors = True
|
||||
|
||||
if check_errors:
|
||||
self.exit(fail=True)
|
||||
|
||||
def check_amodule_args_for_create(self):
|
||||
check_errors = False
|
||||
if self.check_aparam_zone_id() is False:
|
||||
check_errors = True
|
||||
|
||||
if check_errors:
|
||||
self.exit(fail=True)
|
||||
|
||||
# Workflow digest:
|
||||
# 1) authenticate to DECORT controller & validate authentication by issuing API call - done when creating DECORTController
|
||||
|
||||
Reference in New Issue
Block a user