def newInstance(self, instance="main", role='', args={}, path='', parent=None, consume="", originator=None, yaml=None): """ """ if parent is not None and instance == "main": instance = parent.instance instance = instance.lower() service = j.atyourservice.getService(role=self.role, instance=instance, die=False) if service != None: print("NEWINSTANCE: Service instance %s!%s exists." % (self.name, instance)) service.args.update(args or {}) # needed to get the new args in service._recipe = self service.init() else: shortkey = "%s!%s" % (self.role, instance) if path: fullpath = path elif parent is not None: fullpath = j.sal.fs.joinPaths(parent.path, shortkey) else: ppath = j.sal.fs.joinPaths(j.atyourservice.basepath, "services") fullpath = j.sal.fs.joinPaths(ppath, shortkey) if j.sal.fs.isDir(fullpath): j.events.opserror_critical( msg= 'Service with same role ("%s") and of same instance ("%s") is already installed.\nPlease remove dir:%s it could be this is broken install.' % (self.role, instance, fullpath), category="ays.servicetemplate") service = Service(self, instance=instance, args=args, path=fullpath, parent=parent, originator=originator) j.atyourservice._services[service.shortkey] = service if not j.sal.fs.exists(self.template.path_hrd_schema): service.init(yaml=yaml) else: service.init() service.consume(consume) return service