def is_update_necessary(self, existing_resources): update_model = self.get_update_model() protection_rules = self.get_update_model_dict_for_idempotence_check( update_model) # Oracle has a pre-defined set of resources already defined. Update can only edit only some of them. So compare # only with the resources that are being modified. if existing_resources: protection_rules_keys = [ protection_rule.get("key") for protection_rule in protection_rules ] existing_resources = [ existing_resource for existing_resource in existing_resources if existing_resource.get("key") in protection_rules_keys ] update_is_necessary = not oci_common_utils.compare_lists( protection_rules, existing_resources) _debug( "is update necessary for {resource_type}: {update_is_necessary}". format( resource_type=self.resource_type, update_is_necessary=update_is_necessary, )) return update_is_necessary
def patch(self): existing_zone_records = self.get_resource().data patched_resource = self.patch_resource() patched_zone_records = self.get_resource().data changed = not oci_common_utils.compare_lists( to_dict(patched_zone_records), to_dict(existing_zone_records)) return self.prepare_result( changed=changed, resource_type=self.resource_type, resource=to_dict(patched_resource.items), )
def is_update_necessary(self, existing_resources): update_model = self.get_update_model() whitelists = self.get_update_model_dict_for_idempotence_check( update_model) update_is_necessary = not oci_common_utils.compare_lists( whitelists, existing_resources) _debug( "is update necessary for {resource_type}: {update_is_necessary}". format( resource_type=self.resource_type, update_is_necessary=update_is_necessary, )) return update_is_necessary