aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests/steps/cloud/customer_service_subscription_create.py
blob: 707d79b827526a97d938d2afe58ac3485547f9c7 (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
from onapsdk.aai.business import Customer
from onapsdk.sdc.service import Service
from onapsdk.configuration import settings

from ..base import BaseStep
from .customer_create import CustomerCreateStep


class CustomerServiceSubscriptionCreateStep(BaseStep):
    """Cutomer service subsription creation step"""

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

        Substeps:
            - CustomerCreateStep.
        """
        super().__init__(cleanup=cleanup)
        self.add_step(CustomerCreateStep(cleanup=cleanup))

    @BaseStep.store_state
    def execute(self):
        """Create customer service subsription.

        Use settings values:
         - GLOBAL_CUSTOMER_ID,
         - SERVICE_NAME.
        """
        super().execute()
        service = Service(name=settings.SERVICE_NAME)
        customer = Customer.get_by_global_customer_id(settings.GLOBAL_CUSTOMER_ID)
        customer.subscribe_service(service)