aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/cloud/link_cloud_to_complex.py
blob: fcfa7110090665171786d68b3d9940335552354b (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
38
39
40
41
42
43
44
45
46
47
48
49
from onapsdk.aai.cloud_infrastructure import CloudRegion, Complex
from onapsdk.configuration import settings

from ..base import BaseStep
from .complex_create import ComplexCreateStep


class LinkCloudRegionToComplexStep(BaseStep):
    """Link cloud region to complex step"""

    def __init__(self, cleanup=False):
        """Initialize step.

        Substeps:
            - ComplexCreateStep,
            - CloudRegionCreateStep.
        """
        super().__init__(cleanup=cleanup)
        self.add_step(ComplexCreateStep(cleanup=cleanup))

    @property
    def description(self) -> str:
        """Step description."""
        return "Connect cloud region with complex."

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

    @BaseStep.store_state
    def execute(self):
        """Link cloud region to complex.

        Use settings values:
         - COMPLEX_PHYSICAL_LOCATION_ID,
         - CLOUD_REGION_CLOUD_OWNER,
         - CLOUD_REGION_ID.
        """
        super().execute()
        cmplx = Complex(
            physical_location_id=settings.COMPLEX_PHYSICAL_LOCATION_ID,
            name=settings.COMPLEX_PHYSICAL_LOCATION_ID
        )
        cloud_region = CloudRegion.get_by_id(
            cloud_owner=settings.CLOUD_REGION_CLOUD_OWNER,
            cloud_region_id=settings.CLOUD_REGION_ID,
        )
        cloud_region.link_to_complex(cmplx)