Updated to support service constraint node.role==worker

master
giancarlo 4 years ago
parent 613b624dbd
commit 72af1e279d

@ -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);

@ -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)

@ -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()

@ -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) + ']')

@ -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) + ']')

Loading…
Cancel
Save