def set_scsi_dev_smart(request): scsi_id = request.matchdict['scsi_id'] scsi_mgr = scsimgr.scsi_mgr() scsi_dev_info = scsi_mgr.get_scsi_dev_by_id(scsi_id) params = get_params_from_request(request, scsi_dev_smart_schema) smart_set = params.get("smart", None), offline_set = params.get("offline_auto", None), scsi_dev_info.set_smart_config(smart_set,offline_set) return Response(status=200) #@get_view(route_name='adapter_list') #def adapters_get(request): #pass #@get_view(route_name='adapter') #def adapters_get(request): #pass #@get_view(route_name='adapter_disk_list') #def adapters_get(request): #pass #@get_view(route_name='adapter_vdisk_list') #def adapters_get(request): #pass
def set_block_opt(request): scsi_id = request.matchdict['scsi_id'] scsi_mgr = scsimgr.scsi_mgr() scsi_dev_info = scsi_mgr.get_scsi_dev_by_id(scsi_id) params = get_params_from_request(request, scsi_dev_smart_schema) smart_set = params.get("smart", None), offline_set = params.get("offline_auto", None), scsi_dev_info.set_smart_config(smart_set,offline_set) return Response(status=200)
def scan_bus(request): scsi_mgr = scsimgr.scsi_mgr() params = get_params_from_request(request, scan_bus_schema) remove = params.get("remove", False), force_rescan = params.get("force_rescan", False), force_remove = params.get("force_remove", False), if params['opt'] == "re_scan": scsi_mgr.rescan_bus(params['host'], params['channels'], params['targets'],\ params['luns'],remove,force_rescan, force_remove) return Response(status=200)
def scan_bus(request): scsi_mgr = scsimgr.scsi_mgr() params = get_params_from_request(request, scan_bus_schema) remove = params.get("remove", None), force_rescan = params.get("force_rescan", None), force_remove = params.get("force_remove", None), if params['opt'] == "re_scan": scsi_mgr.rescan_bus(params['host'], params['channels'], params['targets'],\ params['luns'],remove,force_rescan, force_remove) return Response(status=200)
def get_scsi_dev(request): scsi_id = request.matchdict['scsi_id'] scsi_mgr = scsimgr.scsi_mgr() scsi_dev_info = scsi_mgr.get_scsi_dev_by_id(scsi_id) model = scsi_dev_info.model scsi_dev = { 'scsi_id':scsi_dev_info.scsi_id, 'scsi_type':scsi_dev_info.scsi_type, 'dev_file':scsi_dev_info.dev_file, 'sg_file':scsi_dev_info.sg_file, 'vendor':scsi_dev_info.vendor, 'model':model, 'rev':scsi_dev_info.rev, 'state':scsi_dev_info.state } return scsi_dev
def scsi_list_get(request): scsi_mgr = scsimgr.scsi_mgr() scsi_list = scsi_mgr.get_scsi_dev_list() scsi_list_dict = [] for scsi_dev_info in scsi_list: model = scsi_dev_info.model scsi_dev = { 'scsi_id':scsi_dev_info.scsi_id, 'scsi_type':scsi_dev_info.scsi_type, 'dev_file':scsi_dev_info.dev_file, 'sg_file':scsi_dev_info.sg_file, 'vendor':scsi_dev_info.vendor, 'model':model, 'rev':scsi_dev_info.rev, 'state':scsi_dev_info.state } scsi_list_dict.append(scsi_dev) return scsi_list_dict
def test_scsi_op(self): mgr = scsi_mgr() test_dev_file = get_block_dev() if test_dev_file == "": return dev_list = mgr.get_scsi_dev_list() test_scsi_dev = None for scsi_dev in dev_list: if scsi_dev.dev_file == test_dev_file: test_scsi_dev = scsi_dev break self.assertTrue(test_scsi_dev is not None) self.assertEquals(test_scsi_dev.state, "running") test_scsi_id = test_scsi_dev.scsi_id test_scsi_dev = mgr.get_scsi_dev_by_id(test_scsi_id) smart_info = test_scsi_dev.get_smart_info() test_scsi_dev.rescan_dev() test_scsi_dev.safe_delete() dev_list = mgr.get_scsi_dev_list() found = False for scsi_dev in dev_list: if scsi_dev.dev_file == test_dev_file: found = True self.assertFalse(found) mgr.rescan_bus() dev_list = mgr.get_scsi_dev_list() found = False for scsi_dev in dev_list: if scsi_dev.dev_file == test_dev_file: found = True self.assertTrue(found)
def test_scsi_op(self): mgr = scsi_mgr() test_dev_file = get_block_dev() if test_dev_file == "": return dev_list = mgr.get_scsi_dev_list() test_scsi_dev = None for scsi_dev in dev_list: if scsi_dev.dev_file == test_dev_file: test_scsi_dev = scsi_dev break; self.assertTrue(test_scsi_dev is not None) self.assertEquals(test_scsi_dev.state, "running") test_scsi_id = test_scsi_dev.scsi_id test_scsi_dev = mgr.get_scsi_dev_by_id(test_scsi_id) smart_info = test_scsi_dev.get_smart_info() test_scsi_dev.rescan_dev() test_scsi_dev.safe_delete() dev_list = mgr.get_scsi_dev_list() found = False for scsi_dev in dev_list: if scsi_dev.dev_file == test_dev_file: found = True self.assertFalse(found) mgr.rescan_bus() dev_list = mgr.get_scsi_dev_list() found = False for scsi_dev in dev_list: if scsi_dev.dev_file == test_dev_file: found = True self.assertTrue(found)
def test_scsi_list(self): mgr = scsi_mgr() dev_list = mgr.get_scsi_dev_list() self.assertTrue(len(dev_list) != 0) host_list = mgr.get_scsi_host_list() self.assertTrue(len(host_list) != 0)
def get_scsi_dev_smartinfo(request): scsi_id = request.matchdict['scsi_id'] scsi_mgr = scsimgr.scsi_mgr() scsi_dev_info = scsi_mgr.get_scsi_dev_by_id(scsi_id) samrt_info = scsi_dev_info.get_smart_info() return samrt_info
def host_list_get(request): scsi_mgr = scsimgr.scsi_mgr() scsi_list = scsi_mgr.get_scsi_host_list() return scsi_list