def __init__(self, wok_options): make_dirs = [ os.path.dirname(os.path.abspath(config.get_object_store())), os.path.abspath(config.get_distros_store()), os.path.abspath(config.get_screenshot_path()), os.path.abspath(config.get_virtviewerfiles_path()) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) # When running on test mode, specify the objectstore location to # remove the file on server shutting down. That way, the system will # not suffer any change while running on test mode if wok_options.test and (wok_options.test is True or wok_options.test.lower() == 'true'): self.objectstore_loc = tempfile.mktemp() self.model = mockmodel.MockModel(self.objectstore_loc) def remove_objectstore(): if os.path.exists(self.objectstore_loc): os.unlink(self.objectstore_loc) cherrypy.engine.subscribe('exit', remove_objectstore) else: self.model = kimchiModel.Model() dev_env = wok_options.environment != 'production' super(Kimchi, self).__init__(self.model, dev_env) for ident, node in sub_nodes.items(): setattr(self, ident, node(self.model)) self.api_schema = json.load( open( os.path.join(os.path.dirname(os.path.abspath(__file__)), 'API.json'))) self.paths = config.kimchiPaths self.domain = 'kimchi' self.messages = messages self.extends = { "/plugins/gingerbase": { "host-dashboard.html": "/plugins/kimchi/js/kimchi.peers.js" } } self.depends = ['gingerbase'] # Some paths or URI's present in the objectstore have changed after # Kimchi 2.0.0 release. Check here if an upgrade in the schema and data # are necessary. if upgrade_objectstore_schema(config.get_object_store(), 'version'): upgrade_objectstore_data('icon', 'images', 'plugins/kimchi/') upgrade_objectstore_data('storagepool', '/storagepools', '/plugins/kimchi') upgrade_objectstore_template_disks(self.model.conn) # Upgrade memory data, if necessary upgrade_objectstore_memory()
def __init__(self): objstore_loc = wok_config.get_object_store() + '_ginger' self._objstore = ObjectStore(objstore_loc) # Some paths or URI's present in the objectstore have changed after # Wok 2.0.0 release. Check here if a schema upgrade is necessary. upgrade_objectstore_schema(objstore_loc, 'version') kargs = {'objstore': self._objstore} models = get_all_model_instances(__name__, __file__, kargs) # Import task model from Wok instances = get_model_instances('wok.model.tasks') for instance in instances: models.append(instance(**kargs)) super(GingerModel, self).__init__(models)
def __init__(self, objstore_loc=None): def get_instances(module_name): instances = [] module = import_module(module_name) members = inspect.getmembers(module, inspect.isclass) for cls_name, instance in members: if inspect.getmodule(instance) == module and \ cls_name.endswith('Model'): instances.append(instance) return instances if objstore_loc is None: objstore_loc = config.get_object_store() # Some paths or URI's present in the objectstore have changed after # Wok 2.0.0 release. Check here if a schema upgrade is necessary. upgrade_objectstore_schema(objstore_loc, 'version') self.objstore = ObjectStore(objstore_loc) kargs = {'objstore': self.objstore} models = [] # Import task model from Wok instances = get_instances('wok.model.tasks') for instance in instances: models.append(instance(**kargs)) # Import all Kimchi plugin models this = os.path.basename(__file__) this_mod = os.path.splitext(this)[0] for mod_name in listPathModules(os.path.dirname(__file__)): if mod_name.startswith("_") or mod_name == this_mod: continue instances = get_instances('wok.plugins.gingerbase.model.' + mod_name) for instance in instances: models.append(instance(**kargs)) return super(Model, self).__init__(models)
def __init__(self, wok_options): make_dirs = [ os.path.dirname(os.path.abspath(config.get_object_store())), os.path.abspath(config.get_distros_store()), os.path.abspath(config.get_screenshot_path()), os.path.abspath(config.get_virtviewerfiles_path()), ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) # When running on test mode, specify the objectstore location to # remove the file on server shutting down. That way, the system will # not suffer any change while running on test mode if wok_options.test and ( wok_options.test is True or wok_options.test.lower() == 'true' ): self.objectstore_loc = tempfile.mktemp() self.model = mockmodel.MockModel(self.objectstore_loc) def remove_objectstore(): if os.path.exists(self.objectstore_loc): os.unlink(self.objectstore_loc) cherrypy.engine.subscribe('exit', remove_objectstore) else: self.model = kimchiModel.Model() dev_env = wok_options.environment != 'production' super(Kimchi, self).__init__(self.model, dev_env) for ident, node in sub_nodes.items(): setattr(self, ident, node(self.model)) with open( os.path.join(os.path.dirname( os.path.abspath(__file__)), 'API.json') ) as fd: self.api_schema = json.load(fd) self.paths = config.kimchiPaths self.domain = 'kimchi' self.messages = messages # Some paths or URI's present in the objectstore have changed after # Kimchi 2.0.0 release. Check here if an upgrade in the schema and data # are necessary. if upgrade_objectstore_schema(config.get_object_store(), 'version'): upgrade_objectstore_data('icon', 'images', 'plugins/kimchi/') upgrade_objectstore_data( 'storagepool', '/storagepools', '/plugins/kimchi') upgrade_objectstore_template_disks(self.model.conn) # Upgrade memory data, if necessary upgrade_objectstore_memory()
def __init__(self, wok_options): make_dirs = [ os.path.dirname(os.path.abspath(config.get_object_store())), os.path.abspath(config.get_distros_store()), os.path.abspath(config.get_screenshot_path()), os.path.abspath(config.get_virtviewerfiles_path()) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) if hasattr(wok_options, "model"): self.model = wok_options.model elif wok_options.test: self.model = mockmodel.MockModel() else: self.model = kimchiModel.Model() dev_env = wok_options.environment != 'production' super(Kimchi, self).__init__(self.model, dev_env) for ident, node in sub_nodes.items(): setattr(self, ident, node(self.model)) if isinstance(self.model, kimchiModel.Model): ws_proxy = websocket.new_ws_proxy() cherrypy.engine.subscribe('exit', ws_proxy.terminate) self.api_schema = json.load( open( os.path.join(os.path.dirname(os.path.abspath(__file__)), 'API.json'))) self.paths = config.kimchiPaths self.domain = 'kimchi' self.messages = messages self.extends = { "/plugins/gingerbase": { "host-dashboard.html": "/plugins/kimchi/js/kimchi.peers.js" } } # Some paths or URI's present in the objectstore have changed after # Kimchi 2.0.0 release. Check here if an upgrade in the schema and data # are necessary. if upgrade_objectstore_schema(config.get_object_store(), 'version'): upgrade_objectstore_data('icon', 'images', 'plugins/kimchi/') upgrade_objectstore_data('storagepool', '/storagepools', '/plugins/kimchi') upgrade_objectstore_template_disks(self.model.conn) # Upgrade memory data, if necessary upgrade_objectstore_memory()
def __init__(self, wok_options): make_dirs = [ os.path.dirname(os.path.abspath(config.get_object_store())), os.path.abspath(config.get_distros_store()), os.path.abspath(config.get_screenshot_path()), os.path.abspath(config.get_virtviewerfiles_path()) ] for directory in make_dirs: if not os.path.isdir(directory): os.makedirs(directory) if hasattr(wok_options, "model"): self.model = wok_options.model elif wok_options.test: self.model = mockmodel.MockModel() else: self.model = kimchiModel.Model() dev_env = wok_options.environment != 'production' super(Kimchi, self).__init__(self.model, dev_env) for ident, node in sub_nodes.items(): setattr(self, ident, node(self.model)) if isinstance(self.model, kimchiModel.Model): ws_proxy = websocket.new_ws_proxy() cherrypy.engine.subscribe('exit', ws_proxy.terminate) self.api_schema = json.load(open(os.path.join(os.path.dirname( os.path.abspath(__file__)), 'API.json'))) self.paths = config.kimchiPaths self.domain = 'kimchi' self.messages = messages self.extends = { "/plugins/gingerbase": { "host-dashboard.html": "/plugins/kimchi/js/kimchi.peers.js" } } # Some paths or URI's present in the objectstore have changed after # Kimchi 2.0.0 release. Check here if an upgrade in the schema and data # are necessary. if upgrade_objectstore_schema(config.get_object_store(), 'version'): upgrade_objectstore_data('icon', 'images', 'plugins/kimchi/') upgrade_objectstore_data('storagepool', '/storagepools', '/plugins/kimchi') upgrade_objectstore_template_disks(self.model.conn) # Upgrade memory data, if necessary upgrade_objectstore_memory()
def __init__(self): def get_instances(module_name): instances = [] module = import_module(module_name) members = inspect.getmembers(module, inspect.isclass) for cls_name, instance in members: if inspect.getmodule(instance) == module and \ cls_name.endswith('Model'): instances.append(instance) return instances objstore_loc = wok_config.get_object_store() + '_ginger' self._objstore = ObjectStore(objstore_loc) # Some paths or URI's present in the objectstore have changed after # Wok 2.0.0 release. Check here if a schema upgrade is necessary. upgrade_objectstore_schema(objstore_loc, 'version') sub_models = [] firmware = FirmwareModel(objstore=self._objstore) firmwareprogress = FirmwareProgressModel(objstore=self._objstore) powerprofiles = PowerProfilesModel() powerprofile = PowerProfileModel() users = UsersModel() user = UserModel() interfaces = InterfacesModel() interface = InterfaceModel() cfginterface = CfginterfaceModel() cfginterfaces = CfginterfacesModel() dasddevs = DASDdevsModel() dasddev = DASDdevModel(objstore=self._objstore) dasdpartitions = DASDPartitionsModel() dasdpartition = DASDPartitionModel() network = NetworkModel() filesystems = FileSystemsModel() filesystem = FileSystemModel() log_volumes = LogicalVolumesModel(objstore=self._objstore) log_volume = LogicalVolumeModel(objstore=self._objstore) partitions = PartitionsModel() partition = PartitionModel(objstore=self._objstore) archives = ArchivesModel(objstore=self._objstore) archive = ArchiveModel(objstore=self._objstore) backup = BackupModel(objstore=self._objstore, archives_model=archives, archive_model=archive) san_adapters = SanAdaptersModel() san_adapter = SanAdapterModel() swaps = SwapsModel(objstore=self._objstore) swap = SwapModel() sysmodules = SysModulesModel() sysmodule = SysModuleModel() sensors = SensorsModel() stgdevs = StorageDevsModel() ibm_sep = SepModel() subscription = SubscriptionModel() subscriber = SubscribersModel() physical_vols = PhysicalVolumesModel(objstore=self._objstore) physical_vol = PhysicalVolumeModel(objstore=self._objstore) vol_groups = VolumeGroupsModel(objstore=self._objstore) vol_group = VolumeGroupModel(objstore=self._objstore) features = [firmware, swaps, backup, network, powerprofiles, san_adapters, sensors, ibm_sep, users, filesystems, dasddevs, dasdpartitions, partitions, physical_vols, vol_groups, log_volumes, stgdevs, firmwareprogress, sysmodules, cfginterfaces] capabilities = CapabilitiesModel(features) config = ConfigModel() sub_models = [ backup, archives, archive, firmware, firmwareprogress, interfaces, interface, cfginterface, cfginterfaces, dasddevs, dasddev, dasdpartitions, dasdpartition, network, filesystems, filesystem, log_volumes, log_volume, partitions, partition, physical_vols, physical_vol, powerprofiles, powerprofile, users, user, san_adapters, san_adapter, sensors, stgdevs, swaps, swap, sysmodules, sysmodule, vol_groups, vol_group, ibm_sep, subscription, subscriber, capabilities, config] # Import task model from Wok kargs = {'objstore': self._objstore} task_model_instances = [] instances = get_instances('wok.model.tasks') for instance in instances: task_model_instances.append(instance(**kargs)) sub_models += task_model_instances super(GingerModel, self).__init__(sub_models)