Fixed circular import
This commit is contained in:
parent
676d46307b
commit
875cf3318d
|
@ -0,0 +1,11 @@
|
|||
from typing import List
|
||||
|
||||
from common.cloud.aws.aws_instance import AwsInstance
|
||||
from common.cloud.azure.azure_instance import AzureInstance
|
||||
from common.cloud.instance import CloudInstance
|
||||
|
||||
all_cloud_instances = [AwsInstance(), AzureInstance()]
|
||||
|
||||
|
||||
def get_all_cloud_instances() -> List[CloudInstance]:
|
||||
return all_cloud_instances
|
|
@ -1,18 +1,11 @@
|
|||
from typing import List
|
||||
|
||||
from common.cloud.aws.aws_instance import AwsInstance
|
||||
from common.cloud.azure.azure_instance import AzureInstance
|
||||
|
||||
|
||||
class CloudInstance(object):
|
||||
"""
|
||||
This is an abstract class which represents a cloud instance.
|
||||
|
||||
The current machine can be a cloud instance (for example EC2 instance or Azure VM).
|
||||
"""
|
||||
def is_instance(self) -> bool:
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_cloud_provider_name(self) -> str:
|
||||
raise NotImplementedError()
|
||||
|
||||
all_cloud_instances = [AwsInstance(), AzureInstance()]
|
||||
|
||||
@staticmethod
|
||||
def get_all_cloud_instances() -> List['CloudInstance']:
|
||||
return CloudInstance.all_cloud_instances
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from common.cloud.all_instances import get_all_cloud_instances
|
||||
from common.cloud.aws.aws_instance import AwsInstance
|
||||
from common.cloud.azure.azure_instance import AzureInstance
|
||||
from common.cloud.environment_names import ON_PREMISE, AZURE, AWS
|
||||
|
@ -7,7 +8,7 @@ from infection_monkey.system_info.system_info_collector import SystemInfoCollect
|
|||
|
||||
def get_monkey_environment() -> str:
|
||||
env = ON_PREMISE
|
||||
for instance in CloudInstance.get_all_cloud_instances():
|
||||
for instance in get_all_cloud_instances():
|
||||
if instance.is_instance():
|
||||
env = instance.get_cloud_provider_name()
|
||||
return env
|
||||
|
|
Loading…
Reference in New Issue