From 72af1e279da0b98f57477046b1452ab89f7330c0 Mon Sep 17 00:00:00 2001 From: giancarlo Date: Mon, 19 Oct 2020 12:32:25 +0200 Subject: [PATCH] Updated to support service constraint node.role==worker --- FUNDING.md | 26 ++++++++++++++++++++++++++ README.md | 19 +++++++++++++++++++ dockerimageexecutor.py | 6 +++--- engine/dockerengine.py | 10 +++++----- engine/swarmengine.py | 19 ++++++++++++------- 5 files changed, 65 insertions(+), 15 deletions(-) create mode 100644 FUNDING.md diff --git a/FUNDING.md b/FUNDING.md new file mode 100644 index 0000000..6fa9eac --- /dev/null +++ b/FUNDING.md @@ -0,0 +1,26 @@ +# Acknowledgments + +The projects leading to this software have received funding from a series of European Union programmes including: + +- the Sixth Framework Programme for Research and Technological Development + - [DILIGENT](https://cordis.europa.eu/project/id/004260) (grant no. 004260). +- the Seventh Framework Programme for research, technological development and demonstration + - [D4Science](https://cordis.europa.eu/project/id/212488) (grant no. 212488); + - [D4Science-II](https://cordis.europa.eu/project/id/239019) (grant no.239019); + - [ENVRI](https://cordis.europa.eu/project/id/283465) (grant no. 283465); + - [iMarine](https://cordis.europa.eu/project/id/283644) (grant no. 283644); + - [EUBrazilOpenBio](https://cordis.europa.eu/project/id/288754) (grant no. 288754). +- the H2020 research and innovation programme + - [SoBigData](https://cordis.europa.eu/project/id/654024) (grant no. 654024); + - [PARTHENOS](https://cordis.europa.eu/project/id/654119) (grant no. 654119); + - [EGI-Engage](https://cordis.europa.eu/project/id/654142) (grant no. 654142); + - [ENVRI PLUS](https://cordis.europa.eu/project/id/654182) (grant no. 654182); + - [BlueBRIDGE](https://cordis.europa.eu/project/id/675680) (grant no. 675680); + - [PerformFISH](https://cordis.europa.eu/project/id/727610) (grant no. 727610); + - [AGINFRA PLUS](https://cordis.europa.eu/project/id/731001) (grant no. 731001); + - [DESIRA](https://cordis.europa.eu/project/id/818194) (grant no. 818194); + - [ARIADNEplus](https://cordis.europa.eu/project/id/823914) (grant no. 823914); + - [RISIS 2](https://cordis.europa.eu/project/id/824091) (grant no. 824091); + - [EOSC-Pillar](https://cordis.europa.eu/project/id/857650) (grant no. 857650); + - [Blue Cloud](https://cordis.europa.eu/project/id/862409) (grant no. 862409); + - [SoBigData-PlusPlus](https://cordis.europa.eu/project/id/871042) (grant no. 871042); \ No newline at end of file diff --git a/README.md b/README.md index 8e55883..9e4a2a5 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,22 @@ python3 dockerimageexecutor.py "microservices-VirtualBox:443/sortapp" sortapp 54 ``` +## Authors + +* **Giancarlo Panichi** ([ORCID](http://orcid.org/0000-0001-8375-6644)) - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience) + + + +## License + +This project is licensed under the EUPL V.1.1 License - see the [LICENSE.md](LICENSE.md) file for details. + + +## About the gCube Framework +This software is part of the [gCubeFramework](https://www.gcube-system.org/ "gCubeFramework"): an +open-source software toolkit used for building and operating Hybrid Data +Infrastructures enabling the dynamic deployment of Virtual Research Environments +by favouring the realisation of reuse oriented policies. + +The projects leading to this software have received funding from a series of European Union programmes see [FUNDING.md](FUNDING.md) + diff --git a/dockerimageexecutor.py b/dockerimageexecutor.py index 28622d2..cfcf37e 100644 --- a/dockerimageexecutor.py +++ b/dockerimageexecutor.py @@ -25,7 +25,7 @@ class DockerImageExecutor: self.storageHubUrl = None self.softwareImage = sys.argv[1] # Software Image self.softwareExecuteCommandName = sys.argv[2] # Command to Run - self.fileItemId = sys.argv[3] # Input Data File + self.itemId = sys.argv[3] # Input Data Item self.tempFolderItemId = None # '32c0422f-a777-4452-adea-007347ec4484' def main(self): @@ -73,14 +73,14 @@ class DockerImageExecutor: def executeOnDocker(self): print("Execute On Docker") dEngine = DockerEngine(self.gcubeToken, self.storageHubUrl, - self.softwareImage, self.softwareExecuteCommandName, self.fileItemId, self.tempFolderItemId) + self.softwareImage, self.softwareExecuteCommandName, self.itemId, self.tempFolderItemId) dEngine.execute() self.downloadResults() def executeOnSwarm(self): print("Execute On Swarm") sEngine = SwarmEngine(self.gcubeToken, self.storageHubUrl, - self.softwareImage, self.softwareExecuteCommandName, self.fileItemId, self.tempFolderItemId) + self.softwareImage, self.softwareExecuteCommandName, self.itemId, self.tempFolderItemId) sEngine.execute() self.downloadResults() diff --git a/engine/dockerengine.py b/engine/dockerengine.py index 418a6cf..704d78a 100644 --- a/engine/dockerengine.py +++ b/engine/dockerengine.py @@ -12,7 +12,7 @@ import gzip class DockerEngine: - def __init__(self, gcubeToken, storageHubUrl, softwareImage, softwareExecuteCommandName, fileItemId, tempFolderItemId): + def __init__(self, gcubeToken, storageHubUrl, softwareImage, softwareExecuteCommandName, itemId, tempFolderItemId): self.gcubeToken = gcubeToken self.storageHubUrl = storageHubUrl @@ -21,8 +21,8 @@ class DockerEngine: # Software Execute Command Name for example: "sortapp" self.softwareExecuteCommandName = softwareExecuteCommandName - # Input Data File - self.fileItemId = fileItemId + # Input Data Item + self.itemId = itemId self.tempFolderItemId = tempFolderItemId self.dockerImageArchive = "sortapp-img.tar.gz" @@ -52,7 +52,7 @@ class DockerEngine: print(*imagesList, sep="\n") print("Create Container") - cmdValue = "{} {} {} {}".format(self.softwareExecuteCommandName, self.gcubeToken, self.fileItemId, self.tempFolderItemId) + cmdValue = "{} {} {} {}".format(self.softwareExecuteCommandName, self.gcubeToken, self.itemId, self.tempFolderItemId) print("CommandValue: " + cmdValue) hostConf = client.api.create_host_config(auto_remove=True); container = client.api.create_container( @@ -69,5 +69,5 @@ class DockerEngine: return ('DEngine[storageHubUrl=' + str(self.storageHubUrl) + ', softwareImage=' + str(self.softwareImage) + ', softwareExecuteCommandName=' + str(self.softwareExecuteCommandName) + - ', fileItemId=' + str(self.fileItemId) + + ', itemId=' + str(self.itemId) + ', tempFolderItemId=' + str(self.tempFolderItemId) + ']') diff --git a/engine/swarmengine.py b/engine/swarmengine.py index 812788d..1e56e41 100644 --- a/engine/swarmengine.py +++ b/engine/swarmengine.py @@ -13,7 +13,7 @@ from docker.types.services import RestartPolicy class SwarmEngine: - def __init__(self, gcubeToken, storageHubUrl, softwareImage, softwareExecuteCommandName, fileItemId, tempFolderItemId): + def __init__(self, gcubeToken, storageHubUrl, softwareImage, softwareExecuteCommandName, itemId, tempFolderItemId): self.gcubeToken = gcubeToken self.storageHubUrl = storageHubUrl @@ -22,8 +22,8 @@ class SwarmEngine: # Software Execute Command Name for example: "sortapp" self.softwareExecuteCommandName = softwareExecuteCommandName - # Input Data File - self.fileItemId = fileItemId + # Input Data Item + self.itemId = itemId self.tempFolderItemId = tempFolderItemId # Client Base URL @@ -90,12 +90,17 @@ class SwarmEngine: print("Services: " + str(client.services.list())) - cmdValue = "{} {} {} {}".format(self.softwareExecuteCommandName, self.gcubeToken, self.fileItemId, self.tempFolderItemId) + cmdValue = "{} {} {} {}".format(self.softwareExecuteCommandName, self.gcubeToken, self.itemId, self.tempFolderItemId) print("CommandValue: " + cmdValue) - + + constraintsList=["node.role==worker"] + print("Contraints: ") + print(*constraintsList, sep = "\n") + + print("Create Service") - srv = client.services.create(self.softwareImage, command=cmdValue, + srv = client.services.create(self.softwareImage, command=cmdValue, constraints=constraintsList, restart_policy=RestartPolicy(condition='none', delay=0, max_attempts=0, window=0)) print("Service: " + str(srv)) @@ -112,6 +117,6 @@ class SwarmEngine: return ('SwarmRegistryEngine[storageHubUrl=' + str(self.storageHubUrl) + ', softwareImage=' + str(self.softwareImage) + ', softwareExecuteCommandName=' + str(self.softwareExecuteCommandName) + - ', fileItemId=' + str(self.fileItemId) + + ', itemId=' + str(self.itemId) + ', tempFolderItemId=' + str(self.tempFolderItemId) + ']')