Skip to content

Commit b127da2

Browse files
committed
tools: provision: detect conflict in cloud and CLI ID
Detect conflicts between the ID a board is already provisioned with on the cloud and the ID the user provides on the command line. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 30edfc8 commit b127da2

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/infuse_iot/tools/provision.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ def run(self):
148148
assert isinstance(response.parsed, Device)
149149
self._org = response.parsed.organisation_id
150150
self._board = response.parsed.board_id
151+
cloud_id = int(response.parsed.device_id, 16)
152+
if self._id and (self._id != cloud_id):
153+
# ID provided on the command line but device already provisioned as another ID
154+
err = f"HW ID 0x{hardware_id:016x} provisioned as 0x{cloud_id:016x} on the cloud"
155+
err += f" but CLI requested 0x{self._id:016x}"
156+
sys.exit(err)
151157
pass
152158
elif response.status_code == HTTPStatus.NOT_FOUND:
153159
# Create new device here

0 commit comments

Comments
 (0)