Beispiel #1
0
def modify_rrset(dns_client, module, modify_operation, modify_kwargs):
    result = {}
    try:
        # get current rrset
        rrset_old = oci_utils.call_with_backoff(
            dns_client.get_rr_set,
            zone_name_or_id=get_zone_name_or_id(module),
            domain=module.params['domain'],
            rtype=module.params['rtype']).data.items

        # update rrset
        updated_rec_coll = oci_utils.call_with_backoff(modify_operation,
                                                       **modify_kwargs).data
        result[RESOURCE_NAME] = oci_utils.to_dict(updated_rec_coll.items)

        # get rrset after update
        rrset_new = oci_utils.call_with_backoff(
            dns_client.get_rr_set,
            zone_name_or_id=get_zone_name_or_id(module),
            domain=module.params['domain'],
            rtype=module.params['rtype']).data.items

        # check if there is any change between the old and the new rrsets, and set changed accordingly
        result['changed'] = not oci_utils.are_lists_equal(rrset_old, rrset_new)
    except ServiceError as ex:
        module.fail_json(msg=str(ex))
    return result
Beispiel #2
0
def modify_domain_records(dns_client, module, modify_operation, modify_kwargs):
    result = {}
    try:
        # get current domain records
        domain_records_old = oci_utils.call_with_backoff(
            dns_client.get_domain_records,
            zone_name_or_id=get_zone_name_or_id(module),
            domain=module.params["domain"],
        ).data.items

        # update domain records
        updated_rec_coll = oci_utils.call_with_backoff(modify_operation,
                                                       **modify_kwargs).data
        result[RESOURCE_NAME] = oci_utils.to_dict(updated_rec_coll.items)

        # get domain records after update
        domain_records_new = oci_utils.call_with_backoff(
            dns_client.get_domain_records,
            zone_name_or_id=get_zone_name_or_id(module),
            domain=module.params["domain"],
        ).data.items

        # check if there is any change between the old and the new domain records, and set changed accordingly
        result["changed"] = not oci_utils.are_lists_equal(
            domain_records_old, domain_records_new)
    except ServiceError as ex:
        module.fail_json(msg=str(ex))
    return result