Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Besser version 1.3.0 - state machine extension #105

Merged
merged 33 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a2a0373
Merge pull request #95 from BESSER-PEARL/master
ivan-alfonso Jun 25, 2024
f8cd20d
Merge pull request #100 from BESSER-PEARL/master
ivan-alfonso Jul 12, 2024
9e505df
PlantUML grammar update to add support for class operations and enume…
ivan-alfonso Jul 12, 2024
3bbaf64
Update enumLiteral gammar rule
ivan-alfonso Jul 12, 2024
c74c4cb
Update PlantUML grammar
ivan-alfonso Jul 12, 2024
d10370a
Add support for methods in the structural metamodel
ivan-alfonso Jul 15, 2024
a09e326
Merge pull request #101 from BESSER-PEARL/feature/plantuml_grammar_im…
ivan-alfonso Jul 15, 2024
38836a4
Add list of enumerations in the domain model
ivan-alfonso Jul 17, 2024
d0a494d
Add State Machine and Bot metamodels
mgv99 Jul 19, 2024
db414fc
update contributors
mgv99 Jul 19, 2024
414adbe
Update platnUML grammar, method rule
ivan-alfonso Jul 23, 2024
f66e115
Update PlantUML grammar (method support)
ivan-alfonso Jul 23, 2024
ea1cd53
Update plantuml grammar for structural models
ivan-alfonso Jul 24, 2024
d3154f9
Add support for methods in the plantUML listener
ivan-alfonso Jul 24, 2024
e4b14b5
Update plantUML grammar tests
ivan-alfonso Jul 24, 2024
d0758eb
Update docs
ivan-alfonso Jul 24, 2024
68fbd04
improve class documetentation
ivan-alfonso Jul 25, 2024
0116682
PlantUML grammar updated
ivan-alfonso Jul 25, 2024
02ebba3
Update PlantUML listener: improving support for methods definition
ivan-alfonso Jul 25, 2024
5a87a48
Update documentation and testing for method support in structural models
ivan-alfonso Jul 25, 2024
fffd4f3
update bot diagrams
mgv99 Jul 30, 2024
a1bd4fc
Update structural metamodel figure in the documentation
ivan-alfonso Jul 30, 2024
2f8b280
Merge pull request #103 from BESSER-PEARL/feature/plantuml_grammar_im…
ivan-alfonso Jul 30, 2024
ab8bd62
Merge pull request #102 from BESSER-PEARL/feature/state_machine
ivan-alfonso Aug 19, 2024
01ab685
Update deployment_mm.png
ivan-alfonso Aug 19, 2024
723b668
remove bot extension
mgv99 Aug 19, 2024
8d76a62
Merge pull request #104 from BESSER-PEARL/feature/state_machine
mgv99 Aug 19, 2024
f2b40ea
Update documentation of classes in State Machine
ivan-alfonso Aug 19, 2024
b3145b7
Improve code according to PEP-8
ivan-alfonso Aug 20, 2024
9f86957
Update documentation
ivan-alfonso Aug 20, 2024
bc0c3cb
Update tests
ivan-alfonso Aug 20, 2024
323d4c4
Update besser package version
ivan-alfonso Aug 20, 2024
fc615d0
Update v1.3.0.rst
ivan-alfonso Aug 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 64 additions & 35 deletions besser/BUML/metamodel/deployment/deployment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from besser.BUML.metamodel.structural import NamedElement, DomainModel, Model
from enum import Enum
from besser.BUML.metamodel.structural import NamedElement, DomainModel, Model


class Hypervisor(Enum):
'''Enumeration to list various types of hypervisors.
Expand Down Expand Up @@ -165,7 +166,8 @@ class Application(NamedElement):
domain_model (DomainModel): The domain model of the application.
"""

def __init__(self, name: str, image_repo: str, port: int, required_resources: Resources, domain_model: DomainModel):
def __init__(self, name: str, image_repo: str, port: int, required_resources: Resources,
domain_model: DomainModel):
super().__init__(name)
self.image_repo: str = image_repo
self.port: str = port
Expand Down Expand Up @@ -201,19 +203,22 @@ def required_resources(self) -> Resources:
def required_resources(self, required_resources: Resources):
"""Resource: Set the required resources."""
self.__required_resources = required_resources

@property
def domain_model(self) -> DomainModel:
"""str: Get the domain model."""
return self.__domain_model

@image_repo.setter
@domain_model.setter
def domain_model(self, domain_model: DomainModel):
"""str: Set the domain model."""
self.__domain_model = domain_model

def __repr__(self) -> str:
return f'Application({self.name}, {self.required_resources}, {self.image_repo}, {self.domain_model})'
return (
f'Application({self.name}, {self.required_resources}, {self.image_repo}, '
f'{self.domain_model})'
)


class Volume(NamedElement):
Expand Down Expand Up @@ -273,11 +278,12 @@ class Container(NamedElement):
volumes (set[Volume]): The set of volumes attached to the container.
"""

def __init__(self, name: str, application: Application, resources_limit: Resources = None, volumes: set[Volume] = set()):
def __init__(self, name: str, application: Application, resources_limit: Resources = None,
volumes: set[Volume] = None):
super().__init__(name)
self.application: Application = application
self.resources_limit: Resources = resources_limit
self.volumes: set[Volume] = volumes
self.volumes: set[Volume] = volumes if volumes is not None else set()

@property
def application(self) -> Application:
Expand Down Expand Up @@ -311,7 +317,7 @@ def volumes(self, volumes: set[Volume]):

def __repr__(self) -> str:
return f'Container({self.name}, {self.application}, {self.resources_limit}, {self.volumes})'


class Deployment(NamedElement):
""" A class to represent a deployment.
Expand Down Expand Up @@ -350,7 +356,7 @@ def containers(self) -> set[Container]:
def containers(self, containers: set[Container]):
"""set[Container]: Set the set of containers."""
self.__containers = containers

def __repr__(self) -> str:
return f'Deployment({self.name}, {self.replicas}, {self.containers})'

Expand All @@ -374,7 +380,8 @@ class Service(NamedElement):
application (Application): The application associated with the service.
"""

def __init__(self, name: str, port: int, target_port: int, type: ServiceType, protocol: Protocol, application: Application = None):
def __init__(self, name: str, port: int, target_port: int, type: ServiceType,
protocol: Protocol, application: Application = None):
super().__init__(name)
self.port: int = port
self.target_port: int = target_port
Expand Down Expand Up @@ -431,10 +438,13 @@ def application(self) -> Application:
def application(self, application: Application):
"""Application: Set the application associated with the service."""
self.__application = application

def __repr__(self) -> str:
return f'Service({self.name}, {self.port}, {self.target_port}, {self.type}, {self.protocol}, {self.application})'

return (
f'Service({self.name}, {self.port}, {self.target_port}, {self.type}, '
f'{self.protocol}, {self.application})'
)

class IPRange(NamedElement):
"""A class to represent an IP range.

Expand Down Expand Up @@ -487,7 +497,7 @@ def public(self, public: bool):
self.__public = public

def __repr__(self) -> str:
return f'IPRange({self.name}, {self.cidr_range}, {self.type}, {self.public})'
return f'IPRange({self.name}, {self.cidr_range}, {self.type}, {self.public})'


class SecurityGroup(NamedElement):
Expand All @@ -504,7 +514,7 @@ class SecurityGroup(NamedElement):
def __init__(self, name: str, rules: set[Service]):
super().__init__(name)
self.rules: set[Service] = rules

@property
def rules(self) -> set[Service]:
"""set[Service]: Get the set of security rules."""
Expand All @@ -524,15 +534,17 @@ class Network(NamedElement):

Args:
name (str): The name of the network.
security_groups (set[SecurityGroup], optional): The set of security groups associated with the network.
security_groups (set[SecurityGroup], optional): The set of security groups associated
with the network.

Attributes:
security_groups (set[SecurityGroup]): The set of security groups associated with the network.
security_groups (set[SecurityGroup]): The set of security groups associated with the
network.
"""

def __init__(self, name: str, security_groups: set[SecurityGroup] = set()):
def __init__(self, name: str, security_groups: set[SecurityGroup] = None):
super().__init__(name)
self.security_groups: set[SecurityGroup] = security_groups
self.security_groups: set[SecurityGroup] = security_groups if security_groups is not None else set()

@property
def security_groups(self) -> set[SecurityGroup]:
Expand All @@ -545,7 +557,7 @@ def security_groups(self, security_groups: set[SecurityGroup]):
self.__security_groups = security_groups

def __repr__(self) -> str:
return f'Network({self.name})'
return f'Network({self.name})'


class Subnetwork(NamedElement):
Expand Down Expand Up @@ -587,7 +599,7 @@ def network(self, network: Network):
self.__network = network

def __repr__(self) -> str:
return f'Subnetwork({self.name}, {self.ip_ranges}, {self.network})'
return f'Subnetwork({self.name}, {self.ip_ranges}, {self.network})'


class Zone(NamedElement):
Expand Down Expand Up @@ -656,7 +668,8 @@ class Node(NamedElement):
processor (Processor): The processor type of the node.
"""

def __init__(self, name: str, public_ip: str, private_ip, os: str, resources: Resources, storage: int, processor: Processor):
def __init__(self, name: str, public_ip: str, private_ip, os: str, resources: Resources,
storage: int, processor: Processor):
super().__init__(name)
self.public_ip: str = public_ip
self.private_ip: str = private_ip
Expand Down Expand Up @@ -730,15 +743,17 @@ class EdgeNode(Node):
"""A class to represent an edge node.
"""

def __init__(self, name: str, public_ip: str, private_ip, os: str, resources: Resources, storage: int, processor: Processor):
def __init__(self, name: str, public_ip: str, private_ip, os: str, resources: Resources,
storage: int, processor: Processor):
super().__init__(name, public_ip, private_ip, os, resources, storage, processor)


class CloudNode(Node):
"""A class to represent a cloud node.
"""

def __init__(self, name: str, public_ip: str, private_ip, os: str, resources: Resources, storage: int, processor: Processor):
def __init__(self, name: str, public_ip: str, private_ip, os: str, resources: Resources,
storage: int, processor: Processor):
super().__init__(name, public_ip, private_ip, os, resources, storage, processor)


Expand All @@ -765,8 +780,9 @@ class Cluster(NamedElement):
subnets (set[Subnetwork]): The set of subnetworks in the cluster.
"""

def __init__(self, name: str, services: set[Service], deployments: set[Deployment], regions: set[Region], net_config: bool = True, nodes: set[Node] = set(),
networks: set[Network] = set(), subnets: set[Subnetwork] = set()):
def __init__(self, name: str, services: set[Service], deployments: set[Deployment],
regions: set[Region], net_config: bool = True, nodes: set[Node] = None,
networks: set[Network] = None, subnets: set[Subnetwork] = None):
super().__init__(name)
self.services: set[Service] = services
self.deployments: set[Deployment] = deployments
Expand Down Expand Up @@ -847,7 +863,10 @@ def subnets(self, subnets: set[Subnetwork]):
self.__subnets = subnets

def __repr__(self) -> str:
return f'Cluster({self.name}, {self.services}, {self.deployments}, {self.regions}, {self.net_config}, {self.nodes}, {self.networks}, {self.subnets})'
return (
f'Cluster({self.name}, {self.services}, {self.deployments}, {self.regions}, '
f'{self.net_config}, {self.nodes}, {self.networks}, {self.subnets})'
)


class PublicCluster(Cluster):
Expand All @@ -871,8 +890,10 @@ class PublicCluster(Cluster):
provider (Provider): The provider of the public cluster.
"""

def __init__(self, name: str, services: set[Service], deployments: set[Deployment], regions: Region, num_nodes: int, provider: Provider,
config_file: str, networks: set[Network] = set(), subnets: set[Subnetwork] = set(), net_config: bool = True):
def __init__(self, name: str, services: set[Service], deployments: set[Deployment],
regions: Region, num_nodes: int, provider: Provider, config_file: str,
networks: set[Network] = None, subnets: set[Subnetwork] = None,
net_config: bool = True):
super().__init__(name, services, deployments, regions, net_config, networks, subnets)
self.config_file: str = config_file
self.num_nodes: int = num_nodes
Expand Down Expand Up @@ -909,7 +930,11 @@ def provider(self, provider: Provider):
self.__provider = provider

def __repr__(self) -> str:
return f'PublicCluster({self.name}, {self.services},{self.deployments}, {self.regions}, {self.config_file}, {self.provider}, {self.networks}, {self.subnets}, {self.net_config})'
return (
f'PublicCluster({self.name}, {self.services},{self.deployments}, '
f'{self.regions}, {self.config_file}, {self.provider}, '
f'{self.networks}, {self.subnets}, {self.net_config})'
)

class OnPremises(Cluster):
"""A class to represent an on-premises cluster.
Expand All @@ -928,8 +953,9 @@ class OnPremises(Cluster):
hypervisor (Hypervisor): The hypervisor used in the on-premises cluster.
"""

def __init__(self, name: str, services: set[Service], deployments: set[Deployment], regions: Region, nodes: set[Node],
hypervisor: Hypervisor, networks: set[Network], subnets: set[Subnetwork]):
def __init__(self, name: str, services: set[Service], deployments: set[Deployment],
regions: Region, nodes: set[Node], hypervisor: Hypervisor,
networks: set[Network], subnets: set[Subnetwork]):
super().__init__(name, services, deployments, regions, nodes, networks, subnets)
self.hypervisor: str = hypervisor

Expand All @@ -944,8 +970,11 @@ def hypervisor(self, hypervisor: Hypervisor):
self.__hypervisor = hypervisor

def __repr__(self) -> str:
return f'Cluster({self.name}, {self.services},{self.deployments}, {self.regions}, {self.nodes}, {self.hypervisor}, {self.networks}, {self.subnets})'

return (
f'Cluster({self.name}, {self.services},{self.deployments}, {self.regions}, '
f'{self.nodes}, {self.hypervisor}, {self.networks}, {self.subnets})'
)


class DeploymentModel(Model):
"""A class to represent a deployment model.
Expand Down Expand Up @@ -973,4 +1002,4 @@ def clusters(self, clusters: set[Cluster]):
self.__clusters = clusters

def __repr__(self) -> str:
return f'Cluster({self.name}, {self.clusters})'
return f'Cluster({self.name}, {self.clusters})'
2 changes: 1 addition & 1 deletion besser/BUML/metamodel/ocl/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ class IterateExp(LoopExp):
def __init__(self,name: str, type: Type):
super().__init__(name, type)

self.result=Variable()
self.result=Variable(name, type)

class IteratorExp(LoopExp):
"""A class to define Iterator expression
Expand Down
Empty file.
Loading