def list_instances(klass, adapter, parent): s = adapter.make_session() entities = s.query(klass).all() for e in entities: Resource.__init__(e, adapter = adapter, type = e.__class__.__name__.lower(), parent = parent, name = e.id ) #if klass.__name__.lower() == "mysql": #raise Exception(entities) return entities
def get_instance(klass, adapter, parent, name): s = adapter.make_session() try: e = s.query(klass).filter_by(id = name).one() except NoResultFound: logger.exception("Resource not found: %s %s" % (klass, name)) raise Exception("Resource %s not found (%s)" % (name, klass)) Resource.__init__(e, adapter = adapter, type = klass.__name__.lower(), parent = parent, name = name) return e
def __init__(self, db, *args, **kw): Resource.__init__(self, *args, **kw) self._check_string(self.name) self._check_string(db) rdbms = self.parent config = rdbms.get_configuration() self.__host = config["public_ip"] self.__port = config["port_number"] self.__user = config["admin_user"] self.__pw = config["admin_pass"] self.__db = db
def __init__(self, hostname, pw, adapter, identifier = None, parent_id = None, type = None, name = None): Resource.__init__(self, adapter, identifier, parent_id, type, name) if not isinstance(hostname, basestring): raise TypeError("Need a string for Hostname: " + str(hostname)) self.__hostname = hostname self.__pw = pw
def __init__(self, adapter, uuid = None, parent = None, type = None, name = None, *args, **kw): Resource.__init__(self, adapter, uuid, parent, type, name) self.id = self.name