TheThingsNetwork / lorawan-stack-migrate

Migrate devices from other LoRaWAN Network Servers to The Things Stack
Apache License 2.0
8 stars 3 forks source link

TTS export all relevant fields #52

Closed jpmeijers closed 1 year ago

jpmeijers commented 1 year ago

Summary

The exported json does not contain the name and description when exporting from TTS.

Steps to Reproduce

  1. Export an application from TTS CE
  2. Look at the json

What do you see now?

name and description are missing

What do you want to see instead?

name and description should be included

Environment

TTS 3.22.1, ttn-lw-migrate 0.9.0-rc0

How do you propose to implement this?

Add the missing fields so that the exported json aligns with the json when exporting a device using ttn-lw-cli:

ttn-lw-cli end-devices get --application-id <app-id> --device-id <device-id> \
    --name  
    --description   
    --lorawan-version \
    --lorawan-phy-version \
    --frequency-plan-id \
    --supports-join \
    --root-keys \
    --mac-settings \
    --session.dev-addr \
    --session.keys > device-description.json

How do you propose to test this?

The exported json form ttn-lw-cli and ttn-lw-migrate should be exactly the same.

Can you do this yourself and submit a Pull Request?

Yes, but would be quicker if a TTI employ does it.

jpmeijers commented 1 year ago

Renamed this issue as I suspect the name and description was missing because they are empty. However, the version_ids is set, and not included in the export. So what we really want is to export ALL fields that are relevant for a migration.

happyRip commented 1 year ago

I've tried to reproduce the issue, but all the fields mentioned were exported.

Renamed this issue as I suspect the name and description was missing because they are empty.

That is correct. Fields are omitempty which means they are not going to be exported when they are empty.

Add the missing fields so that the exported json aligns with the json when exporting a device using ttn-lw-cli: ...

I've confirmed the fields mentioned are all exported. This was confirmed using jq utility to filter wanted fields:

jq '.name,.description,.lorawan_version,.lorawan_phy_version,.frequency_plan_id,.supports_join,.root_keys,.mac_settings,.session.dev_addr,.session.keys'

Which in combination with go run cmd/ttn-lw-migrate/main.go --source ttnv3 --dry-run dev brettm-bag-tracker produces expected output image

However, the version_ids is set, and not included in the export.

The same tool was used to check for existence of version_ids in the output: image

If name and description of the device is set it is going to be included in the output json: image

If this behaviour is different than experienced please provide more details to reproduce the issue.

jpmeijers commented 1 year ago

Testing again now and it indeed seems correct. It looks like I had two devices in the application mixed up. So all looks good. Thanks for checking!