Skip to content
Snippets Groups Projects
Commit 79cb2306 authored by Michele Chiari's avatar Michele Chiari
Browse files

Add DOML models

parent 03d7bfb6
No related branches found
No related tags found
No related merge requests found
# PIACERE Model Checker REST API server
Thys project is packaged with [Poetry](https://python-poetry.org/).
This project is packaged with [Poetry](https://python-poetry.org/).
## Build and Run
......
......@@ -7,6 +7,20 @@ def make_error(user_msg, debug_msg=None):
return result
def post(body):
if body["model"] is None:
if "model" not in body:
return make_error("Model to be checked is missing."), 400
return { "result": "dontknow" }
doml = body["model"]
if doml["typeId"] != "commons_DOMLModel":
return make_error("Not a DOML model."), 400
apps = doml["application"][0]["children"]
for app in apps:
if "exposedInterfaces" in app:
for intf in app["exposedInterfaces"]:
if "endPoint" in intf and intf["endPoint"] == "80":
return { "result": "unsat",
"description": "Endpoint on default HTTP port 80." }
return { "result": "sat" }
{
"typeId": "commons_DOMLModel",
"modelname": "POSIDONIA",
"version": "0.1",
"id": "posidonia",
"application": [{
"typeId": "application_ApplicationLayer",
"name": "POSIDONIA APP LAYER",
"children": [{
"typeId": "application_SoftwarePackage",
"name": "EstacionEDI",
"consumedInterfaces->application_SoftwareInterface": ["SOFTWAREINTERFACE_1", "SOFTWAREINTERFACE_2", "SOFTWAREINTERFACE_3", "SOFTWAREINTERFACE_4"],
"exposedInterfaces": []
}, {
"typeId": "application_SoftwarePackage",
"name": "ProcesosEDI-WS",
"consumedInterfaces->application_SoftwareInterface": ["SOFTWAREINTERFACE_1"],
"exposedInterfaces": [{
"typeId": "application_SoftwareInterface",
"name": "HTTP",
"endPoint": "9002"
}]
}, {
"typeId": "application_SoftwarePackage",
"name": "EDIMERTEL",
"consumedInterfaces->application_SoftwareInterface": ["SOFTWAREINTERFACE_2"],
"exposedInterfaces": [{
"typeId": "application_SoftwareInterface",
"name": "EDIMERTEL HTTP",
"endPoint": "8080"
}]
}, {
"typeId": "application_SoftwarePackage",
"name": "VALEDIENGINE"
}, {
"typeId": "application_SoftwarePackage",
"name": "EDIMER-SERVICESTEDI"
}, {
"typeId": "application_SoftwarePackage",
"name": "POSIDONIA-PCS"
}, {
"typeId": "application_SoftwarePackage",
"name": "POSIDONIA-ESTEDI"
}, {
"typeId": "application_SoftwarePackage",
"name": "POSIDONIA-GESTAUT"
}, {
"typeId": "application_SoftwarePackage",
"name": "VALEDI"
}, {
"typeId": "application_SoftwarePackage",
"name": "PCS-SERVICES"
}, {
"typeId": "application_SoftwarePackage",
"name": "ESTEDI-SERVICES"
}, {
"typeId": "application_SoftwarePackage",
"name": "GESTAUT-SERVICES"
}, {
"typeId": "application_SaaSDBMS",
"name": "ORACLE"
}]
}],
"infrastructure": [{
"typeId": "infrastructure_InfrastructureLayer",
"nodes": [{
"typeId": "infrastructure_VirtualMachine",
"name": "Plataforma EDI"
}, {
"typeId": "infrastructure_VirtualMachine",
"name": "EDIMER"
}, {
"typeId": "infrastructure_VirtualMachine",
"name": "DATABASE"
}, {
"typeId": "infrastructure_VirtualMachine",
"name": "PIDEWEB"
}, {
"typeId": "infrastructure_VirtualMachine",
"name": "ELASTIC SEARCH"
}, {
"typeId": "infrastructure_VirtualMachine",
"name": "PMS"
}, {
"typeId": "infrastructure_Container",
"name": "prodevelop/edi/procesos:latest"
}, {
"typeId": "infrastructure_Container",
"name": "prodevelop/edimer/procesos:latest"
}],
"networks": [{
"typeId": "infrastructure_Network",
"name": "Subnet1",
"protocol": "TCP/IP",
"addressRange": "10.100.1.0/24"
}, {
"typeId": "infrastructure_Network",
"protocol": "TCP/IP",
"name": "Subnet2",
"addressRange": "10.100.2.0/24"
}, {
"typeId": "infrastructure_Network",
"protocol": "TCP/IP",
"name": "Subnet3",
"addressRange": "10.100.3.0/24"
}],
"groups": [{
"typeId": "infrastructure_AutoScalingGroup",
"name": "GestautASG"
}, {
"typeId": "infrastructure_AutoScalingGroup",
"name": "ElasticSearchASG"
}, {
"typeId": "infrastructure_AutoScalingGroup",
"name": "EdiASG"
}, {
"typeId": "infrastructure_SecurityGroup",
"name": "BalearesDBSG"
}, {
"typeId": "infrastructure_SecurityGroup",
"name": "BalearesSG"
}, {
"typeId": "infrastructure_SecurityGroup",
"name": "BalearesELBSG"
}, {
"typeId": "infrastructure_SecurityGroup",
"name": "CheckmkSG"
}]
}],
"optimization": [{
"typeId": "optimization_OptimizationLayer"
}],
"concretizations": [{
"typeId": "concrete_ConcreteInfrastructure",
"groups": [{
"typeId": "concrete_ComputingGroup",
"name": "VPC"
}],
"vms": [{
"typeId": "concrete_VirtualMachine",
"maps->infrastructure_VirtualMachine": "VIRTUALMACHINE_1",
"name": "ORACLE DB",
"description": "AWS::RDS::DBInstance"
}, {
"typeId": "concrete_VirtualMachine",
"name": "PlataformaEDI",
"description": "t3a.large"
}, {
"typeId": "concrete_VirtualMachine",
"name": "EDIMER",
"description": "m5a.large"
}],
"providers": [{
"typeId": "concrete_RuntimeProvider",
"name": "AWS",
"supportedGroups->concrete_ComputingGroup": ["COMPUTINGGROUP_1"],
"providedVMs->concrete_VirtualMachine": ["VIRTUALMACHINE_1"],
"contributesTo->commons_Requirement": ["REQUIREMENT_1", "REQUIREMENT_2"],
"storages->concrete_Storage": ["STORAGE_1", "STORAGE_2"],
"providedNetworks->concrete_Network": ["NETWORK_1", "NETWORK_2", "NETWORK_3"],
"description": "The Selected Runtime Provider"
}],
"storages": [{
"typeId": "concrete_Storage",
"contributesTo->commons_Requirement": [],
"maps->infrastructure_Storage": "STORAGE_1",
"name": "STORAGE 1"
}, {
"typeId": "concrete_Storage",
"maps->infrastructure_Storage": "STORAGE_2",
"name": "STORAGE 2"
}],
"networks": [{
"typeId": "concrete_Network",
"name": "AWS EC2 Subnet",
"maps->infrastructure_Network": "NETWORK_1"
}]
}],
"name": "POSIDONIA"
}
{
"typeId": "commons_DOMLModel",
"modelname": "POSIDONIA",
"version": "0.1",
"id": "posidonia",
"application": [{
"typeId": "application_ApplicationLayer",
"name": "POSIDONIA APP LAYER",
"children": [{
"typeId": "application_SoftwarePackage",
"name": "EstacionEDI",
"consumedInterfaces->application_SoftwareInterface": ["SOFTWAREINTERFACE_1", "SOFTWAREINTERFACE_2", "SOFTWAREINTERFACE_3", "SOFTWAREINTERFACE_4"],
"exposedInterfaces": []
}, {
"typeId": "application_SoftwarePackage",
"name": "ProcesosEDI-WS",
"consumedInterfaces->application_SoftwareInterface": ["SOFTWAREINTERFACE_1"],
"exposedInterfaces": [{
"typeId": "application_SoftwareInterface",
"name": "HTTP",
"endPoint": "80"
}]
}, {
"typeId": "application_SoftwarePackage",
"name": "EDIMERTEL",
"consumedInterfaces->application_SoftwareInterface": ["SOFTWAREINTERFACE_2"],
"exposedInterfaces": [{
"typeId": "application_SoftwareInterface",
"name": "EDIMERTEL HTTP",
"endPoint": "8080"
}]
}, {
"typeId": "application_SoftwarePackage",
"name": "VALEDIENGINE"
}, {
"typeId": "application_SoftwarePackage",
"name": "EDIMER-SERVICESTEDI"
}, {
"typeId": "application_SoftwarePackage",
"name": "POSIDONIA-PCS"
}, {
"typeId": "application_SoftwarePackage",
"name": "POSIDONIA-ESTEDI"
}, {
"typeId": "application_SoftwarePackage",
"name": "POSIDONIA-GESTAUT"
}, {
"typeId": "application_SoftwarePackage",
"name": "VALEDI"
}, {
"typeId": "application_SoftwarePackage",
"name": "PCS-SERVICES"
}, {
"typeId": "application_SoftwarePackage",
"name": "ESTEDI-SERVICES"
}, {
"typeId": "application_SoftwarePackage",
"name": "GESTAUT-SERVICES"
}, {
"typeId": "application_SaaSDBMS",
"name": "ORACLE"
}]
}],
"infrastructure": [{
"typeId": "infrastructure_InfrastructureLayer",
"nodes": [{
"typeId": "infrastructure_VirtualMachine",
"name": "Plataforma EDI"
}, {
"typeId": "infrastructure_VirtualMachine",
"name": "EDIMER"
}, {
"typeId": "infrastructure_VirtualMachine",
"name": "DATABASE"
}, {
"typeId": "infrastructure_VirtualMachine",
"name": "PIDEWEB"
}, {
"typeId": "infrastructure_VirtualMachine",
"name": "ELASTIC SEARCH"
}, {
"typeId": "infrastructure_VirtualMachine",
"name": "PMS"
}, {
"typeId": "infrastructure_Container",
"name": "prodevelop/edi/procesos:latest"
}, {
"typeId": "infrastructure_Container",
"name": "prodevelop/edimer/procesos:latest"
}],
"networks": [{
"typeId": "infrastructure_Network",
"name": "Subnet1",
"protocol": "TCP/IP",
"addressRange": "10.100.1.0/24"
}, {
"typeId": "infrastructure_Network",
"protocol": "TCP/IP",
"name": "Subnet2",
"addressRange": "10.100.2.0/24"
}, {
"typeId": "infrastructure_Network",
"protocol": "TCP/IP",
"name": "Subnet3",
"addressRange": "10.100.3.0/24"
}],
"groups": [{
"typeId": "infrastructure_AutoScalingGroup",
"name": "GestautASG"
}, {
"typeId": "infrastructure_AutoScalingGroup",
"name": "ElasticSearchASG"
}, {
"typeId": "infrastructure_AutoScalingGroup",
"name": "EdiASG"
}, {
"typeId": "infrastructure_SecurityGroup",
"name": "BalearesDBSG"
}, {
"typeId": "infrastructure_SecurityGroup",
"name": "BalearesSG"
}, {
"typeId": "infrastructure_SecurityGroup",
"name": "BalearesELBSG"
}, {
"typeId": "infrastructure_SecurityGroup",
"name": "CheckmkSG"
}]
}],
"optimization": [{
"typeId": "optimization_OptimizationLayer"
}],
"concretizations": [{
"typeId": "concrete_ConcreteInfrastructure",
"groups": [{
"typeId": "concrete_ComputingGroup",
"name": "VPC"
}],
"vms": [{
"typeId": "concrete_VirtualMachine",
"maps->infrastructure_VirtualMachine": "VIRTUALMACHINE_1",
"name": "ORACLE DB",
"description": "AWS::RDS::DBInstance"
}, {
"typeId": "concrete_VirtualMachine",
"name": "PlataformaEDI",
"description": "t3a.large"
}, {
"typeId": "concrete_VirtualMachine",
"name": "EDIMER",
"description": "m5a.large"
}],
"providers": [{
"typeId": "concrete_RuntimeProvider",
"name": "AWS",
"supportedGroups->concrete_ComputingGroup": ["COMPUTINGGROUP_1"],
"providedVMs->concrete_VirtualMachine": ["VIRTUALMACHINE_1"],
"contributesTo->commons_Requirement": ["REQUIREMENT_1", "REQUIREMENT_2"],
"storages->concrete_Storage": ["STORAGE_1", "STORAGE_2"],
"providedNetworks->concrete_Network": ["NETWORK_1", "NETWORK_2", "NETWORK_3"],
"description": "The Selected Runtime Provider"
}],
"storages": [{
"typeId": "concrete_Storage",
"contributesTo->commons_Requirement": [],
"maps->infrastructure_Storage": "STORAGE_1",
"name": "STORAGE 1"
}, {
"typeId": "concrete_Storage",
"maps->infrastructure_Storage": "STORAGE_2",
"name": "STORAGE 2"
}],
"networks": [{
"typeId": "concrete_Network",
"name": "AWS EC2 Subnet",
"maps->infrastructure_Network": "NETWORK_1"
}]
}],
"name": "POSIDONIA"
}
\ No newline at end of file
from mc_openapi import __version__
import requests
import json
def test_version():
assert __version__ == '0.1.0'
def test_post():
r = requests.post("http://0.0.0.0:8080/modelcheck", json={'model': {'sbirio': 'frosco'}})
def test_post_sat():
with open("tests/doml/POSIDONIA.doml", "r") as f:
doml = json.load(f)
r = requests.post("http://0.0.0.0:8080/modelcheck", json={'model': doml})
payload = r.json()
assert r.status_code == requests.codes.ok
assert payload["result"] is not None
assert payload["result"] == "sat"
def test_post_unsat():
with open("tests/doml/POSIDONIA_wrong.doml", "r") as f:
doml = json.load(f)
r = requests.post("http://0.0.0.0:8080/modelcheck", json={'model': doml})
payload = r.json()
assert r.status_code == requests.codes.ok
assert payload["result"] is not None
assert payload["result"] == "unsat"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment