* add the right key in telemetry

* added error handling in report.py
This commit is contained in:
maor.rayzin 2018-11-28 15:30:46 +02:00
parent 0fe7a9c6e1
commit 9d36cf3990
2 changed files with 7 additions and 2 deletions

View File

@ -192,7 +192,8 @@ class Telemetry(flask_restful.Resource):
wmi_handler = WMIHandler(monkey_id, telemetry_json['data']['wmi'], users_secrets)
wmi_handler.process_and_handle_wmi_info()
if 'aws' in telemetry_json['data']:
mongo.db.monkey.update_one({'_id': monkey_id}, {'aws_instance_id': telemetry_json['data']['instance-id']})
mongo.db.monkey.update_one({'_id': monkey_id},
{'aws_instance_id': telemetry_json['data']['aws']['instance-id']})
@staticmethod
def add_ip_to_ssh_keys(ip, ssh_info):

View File

@ -553,7 +553,11 @@ class ReportService:
@staticmethod
def get_machine_aws_instance_id(hostname):
return str(list(mongo.db.monkey.find({'hostname': hostname}, {'aws_instance_id': 1}))[0].get('aws_instance_id', None))
aws_instance_id_list = list(mongo.db.monkey.find({'hostname': hostname}, {'aws_instance_id': 1}))
if aws_instance_id_list:
return str(aws_instance_id_list[0].get('aws_instance_id', None))
else:
return None
@staticmethod
def get_issues():