X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=nepi%2Fexecution%2Fec.py;fp=nepi%2Fexecution%2Fec.py;h=a4b939b6c07f79052ae57967d4bd7b14ee60027f;hb=12725aa3f218df819120197098c02cf2140fb3d0;hp=5f34f8268c0da3fc35bf16d7fc21c782bd586bda;hpb=d41903e7e1e9b494f484294c70b5da5ab187e52d;p=nepi.git diff --git a/nepi/execution/ec.py b/nepi/execution/ec.py index 5f34f826..a4b939b6 100644 --- a/nepi/execution/ec.py +++ b/nepi/execution/ec.py @@ -603,6 +603,26 @@ class ExperimentController(object): :return: Guid of the RM :rtype: int + Specifying additional keywords results in the following actions + * autoDeploy: + boolean: if set, causes the created object to be `deploy`ed + before returning from register_resource + * connectedTo: + resourceObject: if set, causes the `register_connection` method + to be called before returning and after auto-deployment if relevant + * other keywords are used to call `set` to set attributes + + Example: + app = ec.register_resource("linux::Application", + command = "systemctl start httpd", + autoDeploy = True, + connectedTo = node) + ### instead of + app = ec.register_resource("linux::Application") + ec.set(app, "command", "systemctl start httpd") + ec.deploy(app) + ec.register_connection(app, node) + """ # Get next available guid # xxx_next_hiccup @@ -614,17 +634,30 @@ class ExperimentController(object): # Store RM self._resources[guid] = rm - ### so we can do something like - # node = ec.register_resource("linux::Node", - # username = user, - # hostname = host) - ### instead of - # node = ec.register_resource("linux::Node") - # ec.set(node, "username", user) - # ec.set(node, "hostname", host) + ### special keywords + specials = [] + + # is there a need to call deploy + special = 'autoDeploy' + specials.append(special) + auto_deploy = special in keywords and keywords[special] + + # is there a need to call register_connection, and if so to what + special = 'connectedTo' + specials.append(special) + connected_to = special in keywords and keywords[special] + ### now we can do all the calls to 'set' for name, value in keywords.items(): - self.set(guid, name, value) + # specials are handled locally and not propagated to 'set' + if name not in specials: + self.set(guid, name, value) + + ### deal with specials + if auto_deploy: + self.deploy(guid) + if connected_to: + self.register_connection(guid, connected_to) return guid