Files
PrimAITE/src/primaite/common/service.py

29 lines
899 B
Python
Raw Normal View History

# © Crown-owned copyright 2023, Defence Science and Technology Laboratory UK
"""The Service class."""
from primaite.common.enums import SoftwareState
class Service(object):
2023-07-06 16:08:51 +01:00
"""Service class."""
2023-07-14 14:43:47 +01:00
def __init__(self, name: str, port: str, software_state: SoftwareState) -> None:
2023-07-06 16:08:51 +01:00
"""
Initialise a service.
:param name: The service name.
:param port: The service port.
:param software_state: The service SoftwareState.
"""
2023-07-13 12:25:54 +01:00
self.name: str = name
self.port: str = port
self.software_state: SoftwareState = software_state
self.patching_count: int = 0
2023-07-13 12:25:54 +01:00
def reduce_patching_count(self) -> None:
"""Reduces the patching count for the service."""
self.patching_count -= 1
if self.patching_count <= 0:
self.patching_count = 0
self.software_state = SoftwareState.GOOD