X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Fresources%2Fns3%2Fns3ccndceapplication.py;h=bbf5832c261bdd71d6d8acb5af595dbf345c92a8;hb=2886e68a48b44b82c1c554f52dfa5b580288893a;hp=232ac7141535a5b9f8d39b265a8da5a6977f3576;hpb=a7e76f2c5b9646f44e5cbf6c558ed08b5b73ce28;p=nepi.git diff --git a/src/nepi/resources/ns3/ns3ccndceapplication.py b/src/nepi/resources/ns3/ns3ccndceapplication.py index 232ac714..bbf5832c 100644 --- a/src/nepi/resources/ns3/ns3ccndceapplication.py +++ b/src/nepi/resources/ns3/ns3ccndceapplication.py @@ -22,26 +22,21 @@ from nepi.execution.resource import clsinit_copy, ResourceState, reschedule_dela from nepi.resources.ns3.ns3dceapplication import NS3BaseDceApplication import os +import threading @clsinit_copy class NS3BaseCCNDceApplication(NS3BaseDceApplication): _rtype = "abstract::ns3::CCNDceApplication" - @classmethod - def _register_attributes(cls): - files = Attribute("files", - "Semi-colon separated list of 'key=value' pairs to set as " - "DCE files (AddFile). The key should be a path to a local file " - "and the key is the path to be set in DCE for that file" , - flags = Flags.Design) + # Lock used to synchronize usage of CcnClientHelper + ccn_client_lock = threading.Lock() + _ccn_client_helper_uuid = None - stdinfile = Attribute("stdinFile", - "File to set as StdinFile. The value shoudl be either an empty " - "or a path to a local file ", - flags = Flags.Design) - - cls._register_attribute(files) - cls._register_attribute(stdinfile) + @property + def ccn_client_helper_uuid(self): + if not self._ccn_client_helper_uuid: + self._ccn_client_helper_uuid = self.simulation.create("CcnClientHelper") + return self._ccn_client_helper_uuid def _instantiate_object(self): pass @@ -53,62 +48,74 @@ class NS3BaseCCNDceApplication(NS3BaseDceApplication): # Preventing concurrent access to the DceApplicationHelper # from different DceApplication RMs - with self.simulation.dce_application_lock: + with self.ccn_client_lock: self.simulation.invoke( - self.simulation.ccn_client_helper_uuid, + self.ccn_client_helper_uuid, "ResetArguments") self.simulation.invoke( - self.simulation.ccn_client_helper_uuid, + self.ccn_client_helper_uuid, "ResetEnvironment") self.simulation.invoke( - self.simulation.ccn_client_helper_uuid, + self.ccn_client_helper_uuid, "SetBinary", self.get("binary")) self.simulation.invoke( - self.simulation.ccn_client_helper_uuid, + self.ccn_client_helper_uuid, "SetStackSize", self.get("stackSize")) arguments = self.get("arguments") if arguments: for arg in map(str.strip, arguments.split(";")): self.simulation.invoke( - self.simulation.ccn_client_helper_uuid, - "AddArgument", arg) + self.ccn_client_helper_uuid, + "AddArgument", arg) environment = self.get("environment") if environment: for env in map(str.strip, environment.split(";")): key, val = env.split("=") self.simulation.invoke( - self.simulation.ccn_client_helper_uuid, - "AddEnvironment", key, val) + self.ccn_client_helper_uuid, + "AddEnvironment", key, val) if self.has_attribute("files"): files = self.get("files") if files: - for files in map(str.strip, files.split(";")): - remotepath, dcepath = files.split("=") - localpath = "${SHARE}/" + os.path.basename(remotepath) + for file in map(str.strip, files.split(";")): + remotepath, dcepath = file.split("=") + localpath = os.path.join(self.simulation.app_home, + os.path.basename(remotepath)) self.simulation.invoke( - self.simulation.ccn_client_helper_uuid, - "AddFile", localpath, dcepath) + self.ccn_client_helper_uuid, + "AddFile", localpath, dcepath) if self.has_attribute("stdinFile"): stdinfile = self.get("stdinFile") if stdinfile: + # stdinfile might be an empty text that should be set as + # stdin if stdinfile != "": - stdinfile = "${SHARE}/" + os.path.basename(stdinfile) - + stdinfile = os.path.join(self.simulation.app_home, + os.path.basename(stdinfile)) + self.simulation.invoke( - self.simulation.ccn_client_helper_uuid, + self.ccn_client_helper_uuid, "SetStdinFile", stdinfile) apps_uuid = self.simulation.invoke( - self.simulation.ccn_client_helper_uuid, + self.ccn_client_helper_uuid, "InstallInNode", self.node.uuid) + """ + container_uuid = self.simulation.create("NodeContainer") + self.simulation.invoke(container_uuid, "Add", self.node.uuid) + apps_uuid = self.simulation.invoke( + self.ccn_client_helper_uuid, + "Install", container_uuid) + """ + self._uuid = self.simulation.invoke(apps_uuid, "Get", 0) if self.has_changed("StartTime"):