aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/cloud/complex_create.py
blob: 60565f4d27697235a98f9981f2cb77839a4474d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from onapsdk.aai.cloud_infrastructure import Complex
from onapsdk.configuration import settings
from onapsdk.exceptions import APIError

from ..base import BaseStep


class ComplexCreateStep(BaseStep):
    """Complex creation step."""

    @property
    def description(self) -> str:
        """Step description."""
        return "Create complex."

    @property
    def component(self) -> str:
        """Component name."""
        return "AAI"

    @BaseStep.store_state
    def execute(self):
        """Create complex.

        Use settings values:
         - COMPLEX_PHYSICAL_LOCATION_ID,
         - COMPLEX_DATA_CENTER_CODE.

        """
        super().execute()
        try:
            Complex.create(
                physical_location_id=settings.COMPLEX_PHYSICAL_LOCATION_ID,
                data_center_code=settings.COMPLEX_DATA_CENTER_CODE,
                name=settings.COMPLEX_PHYSICAL_LOCATION_ID)
        except APIError:
            self._logger.warn("Try to update the complex failed.")