Aria Automation 8.18.1 Patch 3
Changes to handling of Avi resources in Aria Automation 8.18.1 Patch 3
Back up your environment first:
Migration Steps:
vracli dev psql catalog-db
\pset tuples_only
\pset footer off
\pset format unaligned
SELECT '/tmp/avi.txt' as spoolfile \gset
\out :spoolfile
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/%';
\o
\q
kubectl -n prelude cp postgres-0:/tmp/avi.txt avi.txt
vracli dev psql provisioning-db
\i /tmp/avi.txt
\c catalog-db
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/%';