Changed get_monkey_env logic to return as soon as a results is found and added docs

This commit is contained in:
Shay Nehmad 2020-01-21 15:29:46 +02:00
parent ab330219d5
commit db5c0f4786
1 changed files with 7 additions and 3 deletions

View File

@ -5,11 +5,15 @@ from infection_monkey.system_info.system_info_collector import SystemInfoCollect
def get_monkey_environment() -> str: def get_monkey_environment() -> str:
env = ON_PREMISE """
Get the Monkey's running environment.
:return: One of the cloud providers if on cloud; otherwise, assumes "on premise".
"""
for instance in get_all_cloud_instances(): for instance in get_all_cloud_instances():
if instance.is_instance(): if instance.is_instance():
env = instance.get_cloud_provider_name() return instance.get_cloud_provider_name()
return env
return ON_PREMISE
class EnvironmentCollector(SystemInfoCollector): class EnvironmentCollector(SystemInfoCollector):