@@ -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 :
@@ -548,6 +550,23 @@ def check_if_nios_next_ip_exists(self, proposed_object):
548550
549551 return proposed_object
550552
553+ def check_if_ipv4addr_object_function_exists (self , proposed_object ):
554+ ''' Check if _object_function argument is passed in ipaddr
555+ while creating host record, if yes then format proposed object ipv4addrs
556+ to create hostrecord with next available ip in one call to avoid any race condition
557+ This format support the exclude parameters unlike nextavailableip
558+ It also supports DHCP ranges, dynamic selection of ranges and networks '''
559+
560+ if 'ipv4addrs' in proposed_object :
561+ for ipv4addr_payload in proposed_object ['ipv4addrs' ]:
562+ if '_object_function' in ipv4addr_payload ['ipv4addr' ]:
563+ ipv4addr_payload ['ipv4addr' ] = check_type_dict (ipv4addr_payload ['ipv4addr' ])
564+ elif 'ipv4addr' in proposed_object :
565+ if '_object_function' in proposed_object ['ipv4addr' ]:
566+ proposed_object ['ipv4addr' ] = check_type_dict (proposed_object ['ipv4addr' ])
567+
568+ return proposed_object
569+
551570 def check_for_new_ipv4addr (self , proposed_object ):
552571 ''' Checks if new_ipv4addr parameter is passed in the argument
553572 while updating the record with new ipv4addr with static allocation'''
@@ -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