Instructions for migrating Idem based AVI resources to Aria Automation 8.18.1 Patch 3 and later
search cancel

Instructions for migrating Idem based AVI resources to Aria Automation 8.18.1 Patch 3 and later

book

Article ID: 403314

calendar_today

Updated On:

Products

VCF Operations/Automation (formerly VMware Aria Suite)

Issue/Introduction

  • In Aria Automation 8.18.1 patch 3, we introduce native Avi resource integration.
  • Any existing Idem based resources will need to be migrated to continue working.

Environment

Aria Automation 8.18.1 Patch 3

Cause

Changes to handling of Avi resources in Aria Automation 8.18.1 Patch 3

Resolution

Back up your environment first:

  1. You must back up all VMware Aria Automation or Orchestrator appliances, at the same time - simultaneously for all nodes.
  2. If you are making the snapshots manually, you must start the snapshots of the second and the third node not more than 40 seconds after you start the snapshots for the first node.
  3. If the quiesced state was not achieved for all 3 nodes within the ~40 seconds time frame, the following strings will be found in the logs: "Freeze synchronization failed" and "Sync failed, making inconsistent snapshot".
  4. Run the following command from one of the nodes to filter for all vmtoolsd messages: journal ctl --identifier=vmtoolsd
  5. When you back up the VMware Aria Automation or Orchestrator appliance, disable in-memory snapshots and enable quiescing.

Migration Steps:

  1. SSH into the Aria Automation Appliance (primary node).
  2. Log into the PostgreSQL database with the following command: 
    • vracli dev psql catalog-db
  3. Set the psql to output to a file named avi.txt under /tmp with the following commands:
    • \pset tuples_only
    • \pset footer off
    • \pset format unaligned
    • SELECT '/tmp/avi.txt' as spoolfile \gset
    • \out :spoolfile
  4. Run the following SQL SELECT statement to generate INSERT statements to run in the following steps:
    • SELECT 'INSERT INTO avi_resource_state(document_self_link, document_auth_principal_link,'

           || 'document_expiration_time_micros, document_update_action, document_update_time_micros,'

           || 'document_version, id, name, c_desc, tenant_links, org_auth_link, project_auth_link,'

           || 'owner_auth_link, endpoint_links, type, custom_properties) '

           || ' VALUES (''' || '/resources/avi-resources/' || (drd.properties ->> 'id') || ''','

           || '''/core/authz/system-user'',0,''PATCH'',(EXTRACT(EPOCH FROM NOW())::double precision*1000*1000)::bigint,'

           || '1,''' || (drd.properties ->> 'resource_id') || ''',''' || (drd.properties ->> 'name') || ''','

           || '''' || COALESCE(dr.description,'') || ''',(''["/tenants/organization/' || dr.org_id 

           || '","/provisioning/resources/projects/' || dr.project_id || '","/owner/provisioning/auth/csp/users/'

           || dr.owned_by || '"]'')::jsonb,''/tenants/organization/' || dr.org_id || ''','

           || '''/provisioning/resources/projects/' || dr.project_id || ''',''/owner/provisioning/auth/csp/users/'

           || dr.owned_by || ''',' || '(SELECT (''["'' || document_self_link || ''"]'')::jsonb FROM endpoint_state WHERE name = '''

           || dr.account || ''' and endpoint_type = ''' || dr.endpoint_type || ''' and document_update_action <> ''DELETE'''

           || ' and document_expiration_time_micros = 0 limit 1), ''' || dr.normalized_type || ''','

           || '(''{"resource_id": "' || (drd.properties ->> 'resource_id') || '", "__deploymentLink": "/resources/deployments/'

           || dr.deployment_id || '", "isSimulate": "false", "__operationTimeout": "7200", "__allocation_request": "true",'

           || ' "__projectPlacementPolicy": "DEFAULT",'

           || (CASE WHEN req.id IS NOT NULL THEN '"__blueprint_request_id": "' || req.id::TEXT || '",' ELSE '' END) 

           || (CASE WHEN (drd.properties ->> 'cloud_ref' IS NOT NULL) AND position('#' in drd.properties ->> 'cloud_ref') > 1 THEN ' "cloud_ref": "' || substring((drd.properties ->> 'cloud_ref') from (position('#' in drd.properties ->> 'cloud_ref') + 1)) || '",' ELSE '' END) 

           || (CASE WHEN (drd.properties ->> 'tenant_ref' IS NOT NULL) AND position('#' in drd.properties ->> 'tenant_ref') > 1 THEN ' "tenant_ref": "' || substring((drd.properties ->> 'tenant_ref') from (position('#' in drd.properties ->> 'tenant_ref') + 1)) || '",' ELSE '' END) 

           || (CASE WHEN evt.id IS NOT NULL THEN ' "__blueprint_request_event_id": "' || evt.id::TEXT || '",' ELSE '' END) 

           || ' "__blueprint_resource_name": "' || dr.name || '", "__ext:RequestBrokerState:STARTED:RESOURCE_COUNTED": "true"'

           || '}'')::jsonb);'

        FROM dep_resource dr

        JOIN dep_resource_data drd ON (dr.id = drd.resource_id)

        LEFT OUTER JOIN dep_request req ON (dr.deployment_id = req.deployment_id AND req.name = 'Create')

        LEFT OUTER JOIN dep_request_event evt ON (req.id = evt.request_id AND evt.name = 'ALLOCATE_IN_PROGRESS' AND dr.name = evt.resource_name)

      WHERE dr.type LIKE 'Idem.AVILB.%'

        AND drd.properties ->> 'id' NOT LIKE '/resources/avi-resources/%';
  5. End the session with the following commands:
    • \o
    • \q
  6. You should now have all of the data to be migrated located under /tmp/avi.txt.
  7. The output of the above SELECT statement will be in "/tmp/avi.txt" file on postgreSQL pod. In case multiple vRA nodes, the file should be on the master postgreSQL node. Run the following command to copy the avi.txt file to local directory
       and check the result. Take "postgres-0" as an example postgres pod:
    • kubectl -n prelude cp postgres-0:/tmp/avi.txt avi.txt
  8. Once reviewed, sign into the provisioning-db with the following command:
    • vracli dev psql provisioning-db
  9. Insert the statements into the file with the following command and change to the correct database:
    • \i /tmp/avi.txt
    • \c catalog-db
  10. After switching to catalog-db, run the following 4 UPDATE statements to migrate Idem based Avi resources.
    • UPDATE dep_resource_data drd

            SET properties = REGEXP_REPLACE(drd.properties::TEXT, 'https://[^\s]+/api', '/api', 'g')::jsonb

           FROM dep_resource dr

          WHERE drd.resource_id = dr.id

            AND dr.type LIKE 'Idem.AVILB.%'

            AND drd.properties ->> 'id' NOT LIKE '/resources/avi-resources/%';
    • UPDATE dep_resource_data drd

            SET properties = REPLACE(drd.properties::TEXT, '"resourceLink": "', '"resourceLink": "/resources/avi-resources/')::jsonb

           FROM dep_resource dr

          WHERE drd.resource_id = dr.id

            AND dr.type LIKE 'Idem.AVILB.%'

            AND drd.properties ->> 'id' NOT LIKE '/resources/avi-resources/%';
    • UPDATE dep_resource_data drd

            SET properties = REGEXP_REPLACE(drd.properties::TEXT, '/api([^\s]+)#[^"\s]+', '/api\1', 'g')::jsonb

           FROM dep_resource dr

          WHERE drd.resource_id = dr.id

            AND dr.type LIKE 'Idem.AVILB.%'

            AND drd.properties ->> 'id' NOT LIKE '/resources/avi-resources/%';
    • UPDATE dep_resource_data drd

            SET properties = REPLACE(drd.properties::TEXT, '"id": "', '"id": "/resources/avi-resources/')::jsonb

           FROM dep_resource dr

          WHERE drd.resource_id = dr.id

            AND dr.type LIKE 'Idem.AVILB.%'

            AND drd.properties ->> 'id' NOT LIKE '/resources/avi-resources/%';
  11. Wait for catalog resources to sync with provisioning data.