customCommands stored as binary data (BinData)
Zaid Abdulla
zaid at genieacs.com
Wed Aug 26 18:11:10 EDT 2015
On Wed, Aug 26, 2015, at 01:59 AM, gbyers at indue.com.au wrote:
> > I've written a custom command that connects to an OpenVPN server & determines
> > info about a device based on its ProvisioningCode & SerialNumber. The result
> > of that command is always a string, yet it's stored in mongo as BinData,
> > represented as some sort of hash. Therefore, if I create an alias for this
> > custom command to display in the UI, the output isn't as expected. Here's an
> > example ;
> >
> > > db.devices.find({}, {_customCommands: true})
> > { "_id" : "XXXXXXXXXXXXXXX", "_customCommands" : { "openvpn" : { "_value" : BinData(0,"XXXXXXXX"),
> > "_timestamp" : ISODate("2015-08-25T01:50:31.721Z") } } }
> >
> > Is there a way to coerce this into mongo as type: 'string', or do I need to decode this using a parameter
> > renderer within the UI?
>
>
> Alrighty then. Turns out to be a PEBKAC issue. I was using a ssh2 module
> for Node.js that was encoding the result in a Buffer object. This must
> have been a recent change & it caught me out. Dumping deviceUpdates ;
>
> { customCommands: [ [ 'openvpn', <Buffer 4d 57 30 30 30 36> ] ] }
>
> The simple fix was to add a toString() to the result of my custom command
> ;
>
> return callback(err, result.toString());
>
>
> Grant
Thank you for clarifying the fix.
Out of curiosity, how are you populating the ProvisioningCode parameter?
Zaid
More information about the Users
mailing list