This PR is raised to implement update of existing Nios Zone and Network objects (#44118)

* to resolve issue 43658

* removing unused variable
pull/44148/merge
Sumit Jaiswal 6 years ago committed by GitHub
parent d6cc1c37cc
commit 167c389270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -213,10 +213,8 @@ class WapiModule(WapiBase):
obj_filter = dict([(k, self.module.params[k]) for k, v in iteritems(ib_spec) if v.get('ib_req')])
if('name' in obj_filter):
ib_obj_ref, update, new_name = self.get_object_ref(ib_obj_type, obj_filter, ib_spec)
else:
ib_obj_ref = self.get_object(ib_obj_type, obj_filter.copy(), return_fields=ib_spec.keys())
# get object reference
ib_obj_ref, update, new_name = self.get_object_ref(self.module, ib_obj_type, obj_filter, ib_spec)
if ib_obj_ref:
current_object = ib_obj_ref[0]
@ -324,10 +322,13 @@ class WapiModule(WapiBase):
return True
def get_object_ref(self, ib_obj_type, obj_filter, ib_spec):
''' this function gets and returns the current object based on name/old_name passed'''
def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec):
''' this function gets the reference object of pre-existing nios objects '''
update = False
old_name = new_name = None
if ('name' in obj_filter):
# gets and returns the current object based on name/old_name passed
try:
name_obj = self.module._check_type_dict(obj_filter['name'])
old_name = name_obj['old_name']
@ -358,6 +359,16 @@ class WapiModule(WapiBase):
else:
test_obj_filter = dict([('name', name)])
ib_obj = self.get_object(ib_obj_type, test_obj_filter.copy(), return_fields=ib_spec.keys())
elif (ib_obj_type == NIOS_ZONE):
# del key 'restart_if_needed' as nios_zone get_object fails with the key present
temp = ib_spec['restart_if_needed']
del ib_spec['restart_if_needed']
ib_obj = self.get_object(ib_obj_type, obj_filter.copy(), return_fields=ib_spec.keys())
# reinstate restart_if_needed key if it's set to true in play
if module.params['restart_if_needed']:
ib_spec['restart_if_needed'] = temp
else:
ib_obj = self.get_object(ib_obj_type, obj_filter.copy(), return_fields=ib_spec.keys())
return ib_obj, update, new_name
def on_update(self, proposed_object, ib_spec):

Loading…
Cancel
Save