aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/onboard/vendor.py
blob: ae9373828e97bc635455c90e56e9a785e612d780 (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.configuration import settings
from onapsdk.sdc.vendor import Vendor

from ..base import BaseStep


class VendorOnboardStep(BaseStep):
    """Vendor onboard step."""

    def __init__(self):
        """Initialize step."""
        super().__init__(cleanup=settings.CLEANUP_FLAG)

    @property
    def description(self) -> str:
        """Step description."""
        return "Onboard vendor in SDC."

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

    def check_preconditions(self, cleanup=False) -> bool:
        if not super().check_preconditions(cleanup):
            return False
        if cleanup:
            return settings.SDC_CLEANUP
        return True

    @BaseStep.store_state
    def execute(self):
        """Onboard vendor.

        Use settings values:
         - VENDOR_NAME.

        """
        super().execute()
        vendor: Vendor = Vendor(name=settings.VENDOR_NAME)
        vendor.onboard()

    @BaseStep.store_state(cleanup=True)
    def cleanup(self) -> None:
        vendor: Vendor = Vendor(name=settings.VENDOR_NAME)
        if vendor.exists():
            vendor.archive()
            vendor.delete()
        super().cleanup()