Skip to content

Commit

Permalink
CMR-8965: Create script to update legacy providers to new system (CMR) (
Browse files Browse the repository at this point in the history
#1880)

Adds a migration script to create metadata for each of the
  • Loading branch information
eudoroolivares2016 authored Apr 14, 2023
1 parent 62f9697 commit 6664ab9
Show file tree
Hide file tree
Showing 3 changed files with 515 additions and 3 deletions.
6 changes: 3 additions & 3 deletions legacy-migration/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Legacy Serivce Migration
# Legacy Service Migration

Legacy Service Migration holds the migration scripts for migrating ordering related data from CMR Legacy Service to CMR.

Expand All @@ -19,12 +19,12 @@ The data is read from Legacy Service tables in Oracle and ingested into CMR via
* export ACCESS_TOKEN=<user_token_for_CMR>

## Run Migration
Make sure you can access Oracle database (via tunnel to localhost:1521) in the corresponding CMR envirionment that you want to perform the migration.
Make sure you can access Oracle database (via tunnel to localhost:1521) in the corresponding CMR environment that you want to perform the migration.

`python3 migrate.py`

By default, OrderOptionDefinitions and ServiceOptionDefinitions will not be ingested into CMR again if a matching order-option concept already exist in CMR. User can use the `-f` option to force migration of OrderOptionDefinitions and ServiceOptionDefinitions regardless of if they already exist in CMR or not.

## License

Copyright © 2022 NASA
Copyright © 2023 NASA
63 changes: 63 additions & 0 deletions legacy-migration/providers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Legacy Service Migration for Providers

Provider Legacy Service Migration holds the migration scripts for migrating providers from CMR Legacy Service to CMR.

The data migrated are all of the providers from legacy services.

The data calls the legacy services REST api parses those values into metadata documents inside of a subdirectory called providerMetadata. These can then be ingested into the CMR utilizing the new providers interface. This will enable us to store metadata on these providers and change this metadata by versioning a schema against it.

# Development Environment

## Prerequisites
* [Python](https://www.python.org/)

## Installation
* brew install python3

## Environment Variables
Due to needing system tokens to be able to retrieve all provider data please align your env variables in the following format where env is either uat, sit, or prod. Alternatively you may use ops instead of prod if you prefer that
* export CMR_<ENV>_TOKEN=<SYSTEM_TOKEN_FOR_CMR>

* Install the needed python packages using pip
pip install validators

## Ingesting into local CMR:
To validate the generated metadata you must have a running CMR instance. Please see https://github.com/nasa/Common-Metadata-Repository for how to setup CMR and what dependencies are needed. Alternatively you can validate the metadata a different way if you prefer after it is generated. Note that you should of course reset your CMR between runs where you ingest all of the provider metadata otherwise you will receive errors from CMR that you are trying to ingest duplicate providers.

## Run Migration Without Ingesting

Copy this ./provider directory locally. Make sure that you are connected to the VPN for SIT and UAT migrations

`python3 migrate.py --env sit`

## Run Migration over a specific CMR environment

We should pass a flag to indicate which cmr env we want to pass. This will also align your system token for the given env as long as it was named in the proper way (see section on environment variables)

This example will generate the provider metadata for providers in uat
`python3 migrate.py --env uat`

Note: that if you don't specify an env such as the call below;the default is the SIT environment
`python3 migrate.py`


## Run Migration With Ingesting to validate metadata

We pass a flag for the migration script to try to ingest the provider metadata documents into a CMR env
Note: this is always done locally for validation purposes and so a CMR env/instance must be running on your machine.

The example below would attempt to ingest all of the sit providers from legacy services into your local CMR (sit is default with the env flag)
`python3 migrate.py --ingest`


## Run Migration With logging levels
Logging levels for user cmd line output can be specified by passing the --logging or -log flags. Please only use valid logging allowed by the python logging library:
debug, warning, info, or error. The default logging is info if one is not specified


# Migration Report
After a successful migration, a report file `provider_migration_log_file.txt` will be created
this contains data on how many legacy-services providers were migrated how many were in CMR but, not in legacy services and vice-versa
## License

Copyright © 2023 NASA
Loading

0 comments on commit 6664ab9

Please sign in to comment.