mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-21 22:47:48 +00:00
Allow passing a custom uuid to device register
This commit is contained in:
parent
f6d2043747
commit
d28ecf3230
@ -70,9 +70,19 @@
|
|||||||
description: 'register a device',
|
description: 'register a device',
|
||||||
help: 'Use this command to register a device to an application.\n\nExamples:\n\n $ resin device register MyApp',
|
help: 'Use this command to register a device to an application.\n\nExamples:\n\n $ resin device register MyApp',
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
signature: 'uuid',
|
||||||
|
description: 'custom uuid',
|
||||||
|
parameter: 'uuid',
|
||||||
|
alias: 'u'
|
||||||
|
}
|
||||||
|
],
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
return resin.models.application.get(params.application).then(function(application) {
|
return resin.models.application.get(params.application).then(function(application) {
|
||||||
return resin.models.device.generateUUID().then(function(uuid) {
|
return Promise["try"](function() {
|
||||||
|
return options.uuid || resin.models.device.generateUUID();
|
||||||
|
}).then(function(uuid) {
|
||||||
console.info("Registering to " + application.app_name + ": " + uuid);
|
console.info("Registering to " + application.app_name + ": " + uuid);
|
||||||
return resin.models.device.register(application.app_name, uuid);
|
return resin.models.device.register(application.app_name, uuid);
|
||||||
});
|
});
|
||||||
|
@ -250,6 +250,12 @@ Examples:
|
|||||||
|
|
||||||
$ resin device register MyApp
|
$ resin device register MyApp
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
#### --uuid, -u <uuid>
|
||||||
|
|
||||||
|
custom uuid
|
||||||
|
|
||||||
## device rm <uuid>
|
## device rm <uuid>
|
||||||
|
|
||||||
Use this command to remove a device from resin.io.
|
Use this command to remove a device from resin.io.
|
||||||
|
@ -98,10 +98,18 @@ exports.register =
|
|||||||
$ resin device register MyApp
|
$ resin device register MyApp
|
||||||
'''
|
'''
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
|
options: [
|
||||||
|
signature: 'uuid'
|
||||||
|
description: 'custom uuid'
|
||||||
|
parameter: 'uuid'
|
||||||
|
alias: 'u'
|
||||||
|
]
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
resin.models.application.get(params.application).then (application) ->
|
resin.models.application.get(params.application).then (application) ->
|
||||||
|
|
||||||
resin.models.device.generateUUID().then (uuid) ->
|
Promise.try ->
|
||||||
|
return options.uuid or resin.models.device.generateUUID()
|
||||||
|
.then (uuid) ->
|
||||||
console.info("Registering to #{application.app_name}: #{uuid}")
|
console.info("Registering to #{application.app_name}: #{uuid}")
|
||||||
return resin.models.device.register(application.app_name, uuid)
|
return resin.models.device.register(application.app_name, uuid)
|
||||||
.get('uuid')
|
.get('uuid')
|
||||||
|
Loading…
Reference in New Issue
Block a user