Migrating IPAM and DNS managed objects between policies

Problem 

How to associate generated managed objects for IPAM and DNS to a different policy rather than the original one that was created by. Customers are not able to remove any policy that has existing managed objects in existence. Re-associating these managed objects with a new policy will allow for the later removal under that policy as well as the ability to delete (if so desired) the prior policy.

Cause

Customers who want to switch vendors/endpoints for IPAM and DNS. This is not currently supported by the OneFuse Platform.

Affected Versions

  • 1.1

Workaround or Solution

It is advised that prior to do the following operation that you take a backup of your OneFuse database.

Overview

The following process details how a user can re-associate managed objects with IPAM or DNS policies.

Migrating IPAM managed objects to a new IPAM policy

  1. python manage.py shell_plus

  2. IpamReservation.objects.filter(policy=1).update(policy=2)

    1. Where 1 is the id of the current IPAM policy

    2. and 2 is the new IPAM policy

Migrating DNS managed objects to a new DNS policy

  1. Download the attached dns_migrate_script2.tgz

  2. Using a FTP/SFT Client (e.g. WinSCP, FileZilla), copy the dns_migrate_script2.tgz to the OneFuse Appliance in a temporary directory (e.g. /var/tmp)

  3. SSH to the OneFuse Appliance as root and go into the directory the dns_migrate_script2.tgz was placed into (e.g. /var/tmp)

    ssh root@myonefuseappliance.company.domain
    cd /var/tmp
  4. Unpack the tarball and extract the script folder

    tar -zxvf dns_migrate_script.tgz 
  5. Go into the scripts directory

    cd scripts
  6. Determine the two DNS Policies you want to migrate from and to and get their IDs

  7. Edit the migrate_dns_reservation.py script to update the variable values

    vim migrate_dns_reservation.py
  8. Update the following variable values accordingly:

    1. from_policy_id (line 5) has to be the ID number of the DNS Policy

    2. to_policy_id (line 6) has to be the ID number of the DNS Policy

    3. split_host_record Keep this as default value. If migrating from an Infoblox provider to another provider, set the value to True. The value can either be False or True

      1. Note: this does NOT change the provider of the policy, but rather migrates the existing managed object from the previous policy to the new policy

    4. combine_a_and_ptr_to_host_record Keep this as default value unless a Host record is not desired when migrating from a non-Infoblox provider to an Infoblox provider. The value can either be False or True

      1. Note: this does NOT change the provider of the policy, but rather migrates the existing managed object from the previous policy to the new policy

    5. Example migrating from DNS Policy ID 2 migrating to DNS Policy ID 5 :

      # This is a script must  be placed in the scripts directory
      #    python manage.py runscript migrate_dns_reservations
      
      # Enter the policy ID for the policy you want to migrate DnsReservation managed objects from
      from_policy_id = 2
      # Enter the policy ID for the policy you want to migrate to, if set to None only change record types, don't move policy.
      to_policy_id = 5
      
      # Split Host Records into A and PTR records
      # This is only at the managed object level, not the provider, this is to accommodate migration from a
      # provider that supports Host Records to a provider that does not.
      # Actual migration of the provider data is not handled by this utility.
      split_host_record = False
      
      # If there are both an A and a PTR record, create a host record
      # This is only at the managed object level, not the provider, this is to accommodate migration from a
      # provider that supports only a and ptr records to a provider that supports Host Records.
      # Actual migration of the provider data is not handled by this utility.
      combine_a_and_ptr_to_host_record = True
  9. Save the file, press ESC key and type :wq! then hit Enter key

  10. Run the script: /opt/cloudbolt/manage.py shell_plus < migrate_dns_reservation.py

Additional information

If there are no DNS Reservations to migrate, you will see the following error:

NameError                                 Traceback (most recent call last)
<ipython-input-27-53fe0f0bd9cf> in <module>
      2     new_records = []
      3     record_dict = {}
----> 4     for record in reservation.records:
      5         print(record)
      6         if record["name"] in record_dict:

NameError: name 'reservation' is not defined

In [28]: Do you really want to exit ([y]/n)? 

Attachment

dns_migrate_script2.tgz


Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.