def __init__(self, path="/", name="home", description="Add Description here", status="active", *args, **kwargs): DBObject.__init__(self, **kwargs) self.path = path self.name = name self.description = description self.status = status self._devices = NodeManager(self) self._tasks = TaskManager(self)
def __init__(self,path="/",name="home",description="Add Description here",status="active",*args,**kwargs): DBObject.__init__(self,**kwargs) self.path=path self.name=name self.description=description self.status=status self._devices=NodeManager(self) self._tasks=TaskManager(self)
class Environment(DBObject): HASMANY = ['nodes'] HASMANY = ['tasks'] EXPOSE=["name","description","id","status","_tasks","_nodes"] def __init__(self,path="/",name="home",description="Add Description here",status="active",*args,**kwargs): DBObject.__init__(self,**kwargs) self.path=path self.name=name self.description=description self.status=status self._devices=NodeManager(self) self._tasks=TaskManager(self) """ #################################################################################### Configuration and shutdown methods """ @defer.inlineCallbacks def setup(self): """ Method configuring additional elements of the current environment """ yield self._nodes.setup() yield self._tasks.setup() #create db if not existent else just connect to it # dbPath=self.path+os.sep+self.name+"_db" # if not os.path.exists(dbPath): # self.db=db_manager_SQLLITE(dbPath) # self.db.add_environment(self.name,self.description) # else: # self.db=db_manager_SQLLITE(dbPath) log.msg("Environment ",self.name ,"with id", self.id," setup correctly", logLevel=logging.CRITICAL, system="environment") defer.returnValue(None) def tearDown(self): """ Tidilly shutdown and cleanup after environment """ #self._nodes.tearDown() def get_environmentInfo(self): return self.name def _toDict(self): result={"environment":{"id":self.id,"name":self.name,"description":self.description,"status":self.status,"link":{"rel":"environment"}}} return result def __getattr__(self, attr_name): if hasattr(self._nodes, attr_name): return getattr(self._nodes, attr_name) elif hasattr(self._tasks, attr_name): return getattr(self._tasks, attr_name) else: raise AttributeError(attr_name) def update(self,name,description,status): self.status=status self.description=description log.msg("Environment ",name," updated succesfully",system="Environement manager",logLevel=logging.INFO) return self
class Environment(DBObject): HASMANY = ['nodes'] HASMANY = ['tasks'] EXPOSE = ["name", "description", "id", "status", "_tasks", "_nodes"] def __init__(self, path="/", name="home", description="Add Description here", status="active", *args, **kwargs): DBObject.__init__(self, **kwargs) self.path = path self.name = name self.description = description self.status = status self._devices = NodeManager(self) self._tasks = TaskManager(self) """ #################################################################################### Configuration and shutdown methods """ @defer.inlineCallbacks def setup(self): """ Method configuring additional elements of the current environment """ yield self._nodes.setup() yield self._tasks.setup() #create db if not existent else just connect to it # dbPath=self.path+os.sep+self.name+"_db" # if not os.path.exists(dbPath): # self.db=db_manager_SQLLITE(dbPath) # self.db.add_environment(self.name,self.description) # else: # self.db=db_manager_SQLLITE(dbPath) log.msg("Environment ", self.name, "with id", self.id, " setup correctly", logLevel=logging.CRITICAL, system="environment") defer.returnValue(None) def tearDown(self): """ Tidilly shutdown and cleanup after environment """ #self._nodes.tearDown() def get_environmentInfo(self): return self.name def _toDict(self): result = { "environment": { "id": self.id, "name": self.name, "description": self.description, "status": self.status, "link": { "rel": "environment" } } } return result def __getattr__(self, attr_name): if hasattr(self._nodes, attr_name): return getattr(self._nodes, attr_name) elif hasattr(self._tasks, attr_name): return getattr(self._tasks, attr_name) else: raise AttributeError(attr_name) def update(self, name, description, status): self.status = status self.description = description log.msg("Environment ", name, " updated succesfully", system="Environement manager", logLevel=logging.INFO) return self