tumblr / collins

groovy kind of love
tumblr.github.com/collins
Apache License 2.0
572 stars 99 forks source link

handle empty xml files gracefully when updating asset #116

Open discordianfish opened 10 years ago

discordianfish commented 10 years ago

Hi,

I have no lldp in my infrastructure but still want to use collins. Unfortunately for updating an asset, both lldp and lshw is required. Moreover, an empty lldp xml file (lldpctl -f xml w/o any neighbours) will result in such (kinda misleading) error:

Error updating asset: Couldn't find interface nodes in XML

Talked to @Primer42 and we agreed that there is no reason why collins requires lldp (and even lshw) data to be available when updating a asset.

william-richard commented 10 years ago

Hi @discordianfish - we had a similar scenario. If you just create the asset directly with the api, without going through the intake process, you shouldn't need to upload lldp information. Let me know if that works for you too.

discordianfish commented 10 years ago

@Primer42 What do you mean by 'create the asset directly with the api, without going through the intake process'? Here is the workaround I've implemented, any way to improve that by not posting fake lldp data? https://github.com/discordianfish/collins-pxe/commit/efd79306038564ba99aa8f07bf0eb90ab2afe02d

william-richard commented 10 years ago

@discordianfish - sorry, I left out a critical step that isn't super well documented. If you put the node into Maintenance mode, it will accept only one of lshw or lldp at a time. So the process really is:

I just ran through these steps and it seemed to work.

curl --basic -u blake:admin:first -X PUT http://localhost:9000/api/asset/tumblrtag30
curl --basic -u blake:admin:first -d status=Maintenance -d reason='moving to Maintenance mode to upload lshw' http://localhost:9000/api/asset/tumblrtag30/status
curl --basic -u blake:admin:first --data-urlencode "lshw@./test/resources/lshw-basic.xml" http://localhost:9000/api/asset/tumblrtag30
curl --basic -u blake:admin:first -d status=Allocated -d reason='done with intake' http://localhost:9000/api/asset/tumblrtag30/status

I think we primarily use this when we upgrade hardware on a node, but I think it should also work in your situation. Let me know if that causes your problems.

axlroden commented 9 years ago

AHA! A shame this is not documented, I was about to give up on using LSHW via collins.

byxorna commented 9 years ago

@axlroden @discordianfish any objection to closing this?

discordianfish commented 9 years ago

@byxorna Maybe the documentation should be fixed? But I'm fine with closing it.