1 """Instantiate basic vm using SO macro flow."""
6 from onapsdk.configuration import settings
7 from onapsdk.exceptions import SDKException
8 from xtesting.core import testcase
10 from onaptests.steps.base import YamlTemplateBaseStep
11 from onaptests.steps.onboard.cds import CbaPublishStep
12 from onaptests.utils.exceptions import OnapTestException
13 from onaptests.steps.instantiate.service_macro import YamlTemplateServiceMacroInstantiateStep
16 class BasicVmMacroStep(YamlTemplateBaseStep):
18 def __init__(self, cleanup=False):
23 - YamlTemplateServiceAlaCarteInstantiateStep.
25 super().__init__(cleanup=cleanup)
26 self._yaml_template: dict = None
27 self.add_step(CbaPublishStep(
28 cleanup=settings.CLEANUP_FLAG
30 self.add_step(YamlTemplateServiceMacroInstantiateStep(
31 cleanup=settings.CLEANUP_FLAG
35 def description(self) -> str:
44 return "Basic VM macro scenario step"
47 def component(self) -> str:
50 Name of component which step is related with.
51 Most is the name of ONAP component.
57 return "PythonSDK-tests"
60 def yaml_template(self) -> dict:
61 """YAML template abstract property.
63 Every YAML template step need to implement that property.
69 if not self._yaml_template:
70 with open(settings.SERVICE_YAML_TEMPLATE, "r") as yaml_template:
71 self._yaml_template: dict = load(yaml_template)
72 return self._yaml_template
75 def service_name(self) -> dict:
78 Get from YAML template.
84 return next(iter(self.yaml_template.keys()))
87 def service_instance_name(self) -> str:
88 """Service instance name.
91 str: Service instance name
94 return settings.SERVICE_INSTANCE_NAME
97 class BasicVmMacro(testcase.TestCase):
98 """Instantiate a basic vm macro."""
100 __logger = logging.getLogger(__name__)
102 def __init__(self, **kwargs):
103 """Init Basic Macro use case."""
104 if "case_name" not in kwargs:
105 kwargs["case_name"] = 'basic_vm_macro'
106 super().__init__(**kwargs)
107 self.__logger.debug("Basic VM macro init started")
108 self.test = BasicVmMacroStep(cleanup=settings.CLEANUP_FLAG)
111 """Run basic vm macro test."""
112 self.start_time = time.time()
117 except OnapTestException as exc:
119 self.__logger.error(exc.error_message)
122 self.__logger.error("SDK Exception")
124 self.stop_time = time.time()
127 """Generate report."""
128 self.test.reports_collection.generate_report()