Skip to content

시나리오 구상 정리 (WIP) #10

@dongho-jung

Description

@dongho-jung

시나리오 원형

from abc import ABC, abstractmethod


class ScenarioMeta(type):
    def has_method(self, obj, name):
        return callable(getattr(obj, name, None))
    
    def __call__(self, *args, **kwargs):
        cls = type.__call__(self, *args)
        
        has_monitor = self.has_method(cls, 'monitor')
        has_trigger = self.has_method(cls, 'trigger')
        
        if not (has_monitor ^ has_trigger):
            raise Exception
        
        has_troubleshoot = self.has_method(cls, 'troubleshoot')
        
        if not has_troubleshoot:
            raise Exception
        
        return cls

class Scenario(metaclass=ScenarioMeta):
    def __init__(self, name=None, description=None):
        self.name = name
        self.description = description
        
    # def monitor(self):
    # def trigger(self):
        
    # def troubleshoot(self):

시나리오 구분

  1. passive
  2. active

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions