Ejemplo n.º 1
0
 def interpret_sdk_plugin(self):
     plugins = self.extra("sdk.plugins", [])
     # concatenate commands
     if len(self.protocol.setdefault(
             "deployments",
         [])) == 0:  # will move to plugin fields when it is ready
         # we could use a new deployments for every pre- / post- commands plugin
         deployment_name, task_role_names = "sdk_deployment", list(
             self.protocol["taskRoles"])
         deployment = {
             key: dict(preCommands=[], postCommands=[])
             for key in task_role_names
         }
         plugins_to_remove = []
         for i, plugin in enumerate(plugins):
             target = find("container.(\w+)", plugin["plugin"])
             if target not in ["preCommands", "postCommands"]:
                 continue
             for t in plugin.get("taskRoles", task_role_names):
                 deployment[t][target].extend(
                     plugin["parameters"]["commands"])
             plugins_to_remove.append(i)
         if plugins_to_remove:
             self.protocol["deployments"].append({
                 "name": deployment_name,
                 "taskRoles": deployment,
             })
             self.protocol.setdefault("defaults",
                                      {})["deployment"] = deployment_name
             for i in reversed(plugins_to_remove):
                 del plugins[i]
     return self
Ejemplo n.º 2
0
 def local_process(self):
     "pre-process the job protocol locally, including uploading files, deal with pre-/post- commands"
     self.validate()
     plugins = self.protocol.get("extras", {}).get("sdk.plugins", [])
     for plugin in plugins:
         s = find("local.(\w+)", plugin["plugin"])
         if not s:
             continue
         getattr(self, "plugin_" + s)(plugin)
     return self