About

Tool to migrate the software repository entries prior to Cumulocity v10.7 to the new Software Repository package model including Software Versions. The tool supports the migration of single tenants and a bulk migration of multiple tenants at once.

Usage

  1. Clone the git repositoy to your localhost: git clone https://github.com/ButKor/c8y-swmigration.git

  2. Jump into cloned project: cd swmigration

  3. Build the docker image: docker build -t swmigration .

  4. In case you want to use the bulk migration, updgrade the CSV File found in /runtime/input/input.csv. Each line represents one tenant, for each tenant the baseUrl, User and Password needs to be provided:

url,user,pass
"https://example.cumulocity.com","[email protected]","mysecretpassword"
"https://example2.cumulocity.com","[email protected]","myothersecretpassword"
  1. Either run the container with the ./runtime directory mounted:
docker run -v ${PWD}/runtime:/app/runtime swmigration ./swmigration migrate bulk ./runtime/input/input.csv

Or run the container to migrate a single tenant using positional parameters:

docker run -v ${PWD}/runtime:/app/runtime swmigration ./swmigration migrate single 'https://example.cumulocity.com' '[email protected]' 'mysecretpassword'
  1. Check execution logs in /runtime/logs folder (it was mounted while running the script). If everything went well:
  • /runtime/logs/runtime.log: has log entries

  • /runtime/logs/runtime.err: is empty

In case of issues, feel free to reach out.

App Logic

Essentially the script does:

  1. Fetch all old software objects (once a software object has no childAdditions, it is considered as being the old domain model)
  2. Group these softare objects by name
  3. For each of these groups:
    3.1 Create a (new) single software entry with the given software name
    3.2 Create a new software version for each ‘old’ software object with the same name
    3.3 Assign the software version to the software package created in 3.1
    3.4 “Burry” the old software object by changing its type to c8y_SoftwareDeprecated and adding a migration note to the Inventory Object
    3.5 Log action in platforms audit log

Below activity diagram shall illustrate the process:

drawing

Rollback

The existing Software Objects are not deleted but only burried by changing it’s types. Thus, a rollback is possible at any time. To do so, two things need to be done:

  • The newly created Software Repository entries shall be deleted (either manually or via script)

  • Do the following call to each object of type c8y_SoftwareDeprecated (either manually or via script):

Fetch all deprecated inventory objects

GET https://kobu.latest.stage.c8y.io/inventory/managedObjects?type=c8y_SoftwareDeprecated

For each of them:

PUT /inventory/<<mangedObjectId>>
{
    "type": "c8y_Software",
    "status": null,
    "note": null,
}

GitHub

View Github