

def switch_dns_backward(databaseinfra, source_object_list, ip_attribute_name, dns_attribute_name, equivalent_atribute_name):
    for source_object in source_object_list:
        target_object = source_object.__getattribute__(equivalent_atribute_name)
        old_ip = target_object.__getattribute__(ip_attribute_name)
        dns = target_object.__getattribute__(dns_attribute_name)
        target_object.__setattr__(dns_attribute_name, old_ip)
        new_ip = source_object.__getattribute__(ip_attribute_name)
        source_object.__setattr__(dns_attribute_name, dns)
        LOG.info('Changing {}: from {} to {}'.format(dns, old_ip, new_ip))
        DNSAPIProvider.update_database_dns_content(databaseinfra=databaseinfra, dns=dns, old_ip=old_ip, new_ip=new_ip)
        target_object.save()
        source_object.save()

dataset/ETHPy150Open globocom/database-as-a-service/dbaas/workflow/steps/util/__init__.py switch_dns_backward/original