def reset(self): MockModel._mock_vms = {} MockModel._mock_snapshots = {} self._mock_swupdate = MockSoftwareUpdate() self._mock_repositories = MockRepositories() if hasattr(self, 'objstore'): self.objstore = ObjectStore(self.objstore_loc) params = { 'vms': [u'test'], 'templates': [], 'networks': [u'default'], 'storagepools': [u'default-pool'] } for res, items in params.iteritems(): resources = getattr(self, '%s_get_list' % res)() for i in resources: if i in items: continue try: getattr(self, '%s_deactivate' % res[:-1])(i) except: pass getattr(self, '%s_delete' % res[:-1])(i) volumes = self.storagevolumes_get_list('default-pool') for v in volumes: self.storagevolume_delete('default-pool', v)
def __init__(self, libvirt_uri=None, objstore_loc=None): self.objstore = ObjectStore(objstore_loc) self.conn = LibvirtConnection(libvirt_uri) kargs = {'objstore': self.objstore, 'conn': self.conn} if self.conn.isQemuURI(): for pool_name, pool_arg in DEFAULT_POOLS.iteritems(): self._default_pool_check(pool_name, pool_arg) this = os.path.basename(__file__) this_mod = os.path.splitext(this)[0] models = [] for mod_name in listPathModules(os.path.dirname(__file__)): if mod_name.startswith("_") or mod_name == this_mod: continue module = import_module('model.' + mod_name) members = inspect.getmembers(module, inspect.isclass) for cls_name, instance in members: if inspect.getmodule(instance) == module: if cls_name.endswith('Model'): models.append(instance(**kargs)) return super(Model, self).__init__(models)
def __init__(self): objstore_loc = config.get_object_store() + '_ginger' self._objstore = ObjectStore(objstore_loc) sub_models = [] firmware = FirmwareModel() powerprofiles = PowerProfilesModel() powerprofile = PowerProfileModel() users = UsersModel() user = UserModel() interfaces = InterfacesModel() interface = InterfaceModel() network = NetworkModel() 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() sensors = SensorsModel() ibm_sep = SepModel() features = [ firmware, backup, network, powerprofiles, san_adapters, sensors, ibm_sep, users ] capabilities = CapabilitiesModel(features) sub_models = [ backup, archives, archive, firmware, interfaces, interface, network, powerprofiles, powerprofile, users, user, san_adapters, san_adapter, sensors, ibm_sep, capabilities ] super(GingerModel, self).__init__(sub_models)
def __init__(self, objstore_loc=None): # Override osinfo.defaults to ajust the values according to # test:///default driver defaults = dict(osinfo.defaults) defaults.update(mockmodel_defaults) osinfo.defaults = dict(defaults) self._mock_devices = MockDevices() self._mock_partitions = MockPartitions() self._mock_storagevolumes = MockStorageVolumes() self._mock_swupdate = MockSoftwareUpdate() self._mock_repositories = MockRepositories() kimchi.model.cpuinfo.get_topo_capabilities = \ MockModel.get_topo_capabilities libvirt.virConnect.defineXML = MockModel.domainDefineXML libvirt.virDomain.XMLDesc = MockModel.domainXMLDesc libvirt.virDomain.undefine = MockModel.undefineDomain libvirt.virDomain.attachDeviceFlags = MockModel.attachDeviceFlags libvirt.virDomain.detachDeviceFlags = MockModel.detachDeviceFlags libvirt.virDomain.updateDeviceFlags = MockModel.updateDeviceFlags libvirt.virStorageVol.resize = MockModel.volResize libvirt.virStorageVol.wipePattern = MockModel.volWipePattern IscsiPoolDef.prepare = NetfsPoolDef.prepare = StoragePoolDef.prepare PAMUsersModel.auth_type = 'fake' PAMGroupsModel.auth_type = 'fake' super(MockModel, self).__init__('test:///default', objstore_loc) self.objstore_loc = objstore_loc self.objstore = ObjectStore(objstore_loc) # The MockModel methods are instantiated on runtime according to Model # and BaseModel # Because that a normal method override will not work here # Instead of that we also need to do the override on runtime for method in dir(self): if method.startswith('_mock_'): mock_method = getattr(self, method) if not callable(mock_method): continue m = method[6:] model_method = getattr(self, m) setattr(self, '_model_' + m, model_method) setattr(self, m, mock_method) DeviceModel.lookup = self._mock_device_lookup StoragePoolModel._update_lvm_disks = self._update_lvm_disks StorageVolumesModel.get_list = self._mock_storagevolumes_get_list StorageVolumeModel.doUpload = self._mock_storagevolume_doUpload DebugReportsModel._gen_debugreport_file = self._gen_debugreport_file LibvirtVMTemplate._get_volume_path = self._get_volume_path VMTemplate.get_iso_info = self._probe_image imageinfo.probe_image = self._probe_image
def __init__(self, objstore_loc=None): self.reset() self.objstore = ObjectStore(objstore_loc) self.vnc_port = 5999 # open vnc port # make it here to make sure it will be available on server startup cmd = config.find_qemu_binary() args = [cmd, "-vnc", ":99"] cmd = "ps aux | grep '%s' | grep -v grep" % " ".join(args) proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) if len(proc.stdout.readlines()) == 0: p = subprocess.Popen(args, close_fds=True)
def __init__(self): objstore_loc = config.get_object_store() self.objstore = ObjectStore(objstore_loc) sub_models = [] collectionsample = CollectionSampleModel() collectionresourcesample = \ CollectionResourceSampleModel(collectionsample) resourcesample = ResourceSampleModel() progresssample = ProgressSampleModel(objstore=self.objstore) sub_models = [ collectionresourcesample, collectionsample, progresssample, resourcesample ] return super(DummyModel, self).__init__(sub_models)
def __init__(self, libvirt_uri=None, objstore_loc=None): self.libvirt_uri = libvirt_uri or 'qemu:///system' self.conn = LibvirtConnection(self.libvirt_uri) self.objstore = ObjectStore(objstore_loc) self.graphics_ports = {} self.next_taskid = 1 self.stats = {} self.qemu_stream = False self.qemu_stream_dns = False self.libvirt_stream_protocols = [] # Subscribe function to set host capabilities to be run when cherrypy # server is up # It is needed because some features tests depends on the server cherrypy.engine.subscribe('start', self._set_capabilities) self.statsThread = BackgroundTask(STATS_INTERVAL, self._update_stats) self.statsThread.start() self.distros = self._get_distros() if 'qemu:///' in self.libvirt_uri: self._default_pool_check() self._default_network_check()
def __init__(self, objstore_loc=None): self.reset() self.objstore = ObjectStore(objstore_loc) self.distros = self._get_distros()