@ -164,6 +164,7 @@ class CloudBase(ABC):
_CONFIG_PATH = ' config_path '
_CONFIG_PATH = ' config_path '
_RESOURCE_PREFIX = ' resource_prefix '
_RESOURCE_PREFIX = ' resource_prefix '
_MANAGED = ' managed '
_MANAGED = ' managed '
_SETUP_EXECUTED = ' setup_executed '
def __init__ ( self , args ) :
def __init__ ( self , args ) :
"""
"""
@ -172,6 +173,20 @@ class CloudBase(ABC):
self . args = args
self . args = args
self . platform = self . __module__ . split ( ' . ' ) [ 2 ]
self . platform = self . __module__ . split ( ' . ' ) [ 2 ]
@property
def setup_executed ( self ) :
"""
: rtype : bool
"""
return self . _get_cloud_config ( self . _SETUP_EXECUTED , False )
@setup_executed.setter
def setup_executed ( self , value ) :
"""
: type value : bool
"""
self . _set_cloud_config ( self . _SETUP_EXECUTED , value )
@property
@property
def config_path ( self ) :
def config_path ( self ) :
"""
"""
@ -214,11 +229,15 @@ class CloudBase(ABC):
"""
"""
self . _set_cloud_config ( self . _MANAGED , value )
self . _set_cloud_config ( self . _MANAGED , value )
def _get_cloud_config ( self , key ):
def _get_cloud_config ( self , key , default = None ):
"""
"""
: type key : str
: type key : str
: type default : str | int | bool | None
: rtype : str | int | bool
: rtype : str | int | bool
"""
"""
if default is not None :
return self . args . metadata . cloud_config [ self . platform ] . get ( key , default )
return self . args . metadata . cloud_config [ self . platform ] [ key ]
return self . args . metadata . cloud_config [ self . platform ] [ key ]
def _set_cloud_config ( self , key , value ) :
def _set_cloud_config ( self , key , value ) :
@ -357,9 +376,21 @@ class CloudProvider(CloudBase):
class CloudEnvironment ( CloudBase ) :
class CloudEnvironment ( CloudBase ) :
""" Base class for cloud environment plugins. Updates integration test environment after delegation. """
""" Base class for cloud environment plugins. Updates integration test environment after delegation. """
def setup_once ( self ) :
""" Run setup if it has not already been run. """
if self . setup_executed :
return
self . setup ( )
self . setup_executed = True
def setup ( self ) :
""" Setup which should be done once per environment instead of once per test target. """
pass
@abc.abstractmethod
@abc.abstractmethod
def configure_environment ( self , env , cmd ) :
def configure_environment ( self , env , cmd ) :
"""
""" Configuration which should be done once for each test target.
: type env : dict [ str , str ]
: type env : dict [ str , str ]
: type cmd : list [ str ]
: type cmd : list [ str ]
"""
"""