|
@@ -9,6 +9,10 @@ from coriolis import schemas
|
|
|
class BaseProvider(object):
|
|
class BaseProvider(object):
|
|
|
__metaclass__ = abc.ABCMeta
|
|
__metaclass__ = abc.ABCMeta
|
|
|
|
|
|
|
|
|
|
+ @property
|
|
|
|
|
+ def platform(self):
|
|
|
|
|
+ raise NotImplementedError("Missing provider platform attribute.")
|
|
|
|
|
+
|
|
|
@property
|
|
@property
|
|
|
def connection_info_schema(self):
|
|
def connection_info_schema(self):
|
|
|
raise NotImplementedError("Missing connection info schema.")
|
|
raise NotImplementedError("Missing connection info schema.")
|
|
@@ -18,7 +22,13 @@ class BaseProvider(object):
|
|
|
""" Checks the provided connection info and raises an exception
|
|
""" Checks the provided connection info and raises an exception
|
|
|
if it is invalid.
|
|
if it is invalid.
|
|
|
"""
|
|
"""
|
|
|
- schemas.validate_value(connection_info, self.connection_info_schema)
|
|
|
|
|
|
|
+ try:
|
|
|
|
|
+ schemas.validate_value(
|
|
|
|
|
+ connection_info, self.connection_info_schema)
|
|
|
|
|
+ except Exception as ex:
|
|
|
|
|
+ raise Exception(
|
|
|
|
|
+ "Error validating provider '%s' connection "
|
|
|
|
|
+ "info: %s" % str(ex)) from ex
|
|
|
|
|
|
|
|
|
|
|
|
|
class BaseImportProvider(BaseProvider):
|
|
class BaseImportProvider(BaseProvider):
|
|
@@ -36,10 +46,10 @@ class BaseImportProvider(BaseProvider):
|
|
|
try:
|
|
try:
|
|
|
schemas.validate_value(
|
|
schemas.validate_value(
|
|
|
target_environment, self.target_environment_schema)
|
|
target_environment, self.target_environment_schema)
|
|
|
- except:
|
|
|
|
|
- return False
|
|
|
|
|
-
|
|
|
|
|
- return True
|
|
|
|
|
|
|
+ except Exception as ex:
|
|
|
|
|
+ raise Exception(
|
|
|
|
|
+ "Error validating provider '%s' target environment: %s" % (
|
|
|
|
|
+ self.platform, str(ex))) from ex
|
|
|
|
|
|
|
|
@abc.abstractmethod
|
|
@abc.abstractmethod
|
|
|
def import_instance(self, ctxt, connection_info, target_environment,
|
|
def import_instance(self, ctxt, connection_info, target_environment,
|