Failed to export attachments with error that no host-name key found
suchandanreddy opened this issue · 3 comments
Traceback
Traceback (most recent call last):
File "/usr/local/bin/vmanage", line 11, in
load_entry_point('viptela==0.2.3', 'console_scripts', 'vmanage')()
File "/Library/Python/3.7/site-packages/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/Library/Python/3.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Library/Python/3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Library/Python/3.7/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Library/Python/3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Library/Python/3.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Library/Python/3.7/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context().obj, *args, **kwargs)
File "/Library/Python/3.7/site-packages/vmanage/cli/export/attachments.py", line 31, in attachments
num = vmanage_files.export_attachments_to_file(output_file, name_list=name, device_type=device_type)
File "/Library/Python/3.7/site-packages/vmanage/apps/files.py", line 272, in export_attachments_to_file
if name_list == [] or device_config['host-name'] in name_list:
KeyError: 'host-name'
there could be certain times when the device (vedge or cedge) in the response of API /system/device/vedges don't have the host-name key so we would have to handle that by skipping the check for host-name but we would still need to export the attachment and use the device uuid when importing it to uniquely identify a device if needed. for those specific devices which doesn't have hostname we can ignore to support with the -n name option to export attachments.
{
"deviceType": "vedge",
"serialNumber": "<removed>",
"ncsDeviceName": "<removed>",
"configStatusMessage": "In Sync",
"templateApplyLog": [
<removed>
],
"uuid": "<removed>",
"managementSystemIP": "<removed>",
"templateStatus": "Success",
"chasisNumber": "<removed>",
"configStatusMessageDetails": "",
"configOperationMode": "vmanage",
"deviceModel": "vedge-100-M",
"deviceState": "READY",
"validity": "valid",
"platformFamily": "vedge-mips",
"vedgeCertificateState": "certinstalled",
"rootCertHash": "<removed>",
"deviceIP": "<removed>",
"personality": "vedge",
"uploadSource": "Smart Account",
"template": "<removed>",
"templateId": "<removed>",
"lifeCycleRequired": false,
"expirationDate": "NA",
"hardwareCertSerialNumber": "NA"
},
similarly sometimes "site-id" could be not available for certain devices
bug fix is pushed to master branch