@@ -439,6 +439,8 @@ def run(self, ib_obj_type, ib_spec):
439439
440440 # Checks if nios_next_ip param is passed in ipv4addrs/ipv4addr args
441441 proposed_object = self .check_if_nios_next_ip_exists (proposed_object )
442+ # Checks if a wapi function call is the payload of ipv4addrs/ipv4addr args
443+ proposed_object = self .check_if_ipv4addr_object_function_exists (proposed_object )
442444
443445 if state == 'present' :
444446 if ref is None :
@@ -558,6 +560,23 @@ def check_for_new_ipv4addr(self, proposed_object):
558560
559561 return proposed_object
560562
563+ def check_if_ipv4addr_object_function_exists (self , proposed_object ):
564+ ''' Check if _object_function argument is passed in ipaddr
565+ while creating host record, if yes then format proposed object ipv4addrs
566+ to create hostrecord with next available ip in one call to avoid any race condition
567+ This format support the exclude parameters unlike nextavailableip
568+ It also supports DHCP ranges, dynamic selection of ranges and networks '''
569+
570+ if 'ipv4addrs' in proposed_object :
571+ for ipv4addr_payload in proposed_object ['ipv4addrs' ]:
572+ if '_object_function' in ipv4addr_payload ['ipv4addr' ]:
573+ ipv4addr_payload ['ipv4addr' ] = check_type_dict (ipv4addr_payload ['ipv4addr' ])
574+ elif 'ipv4addr' in proposed_object :
575+ if '_object_function' in proposed_object ['ipv4addr' ]:
576+ proposed_object ['ipv4addr' ] = check_type_dict (proposed_object ['ipv4addr' ])
577+
578+ return proposed_object
579+
561580 def check_if_add_remove_ip_arg_exists (self , proposed_object ):
562581 '''
563582 This function shall check if add/remove param is set to true and
@@ -592,6 +611,8 @@ def check_next_ip_status(self, obj_filter):
592611 if 'ipv4addr' in obj_filter :
593612 if 'nios_next_ip' in obj_filter ['ipv4addr' ]:
594613 return True
614+ if '_object_function' in obj_filter ['ipv4addr' ] and check_type_dict (obj_filter ['ipv4addr' ])['_object_function' ] == 'next_available_ip' :
615+ return True
595616 return False
596617
597618 def issubset (self , item , objects ):
0 commit comments