def _create_task(self, cb, params): pvname = params['pv_name'] cb('entering task to create pv') try: cb('create pv') part = PartitionModel(objstore=self.objstore) part_name = pvname.split('/')[-1] dev_type = part.lookup(part_name) if dev_type['type'] == 'part': if 'dasd' in dev_type['name']: type = '4' change_dasdpart_type(part_name, type) else: type = '8e' # hex value for type Linux LVM part.change_type(part_name, type) utils._create_pv(pvname) except OperationFailed: raise OperationFailed("GINPV00002E", {'name': pvname}) cb('OK', True)
def _create_task(self, cb, params): type = params['type'] file_loc = params['file_loc'] cb('entering task to create swap file') with RollbackContext() as rollback: try: if type == 'file': cb('create a file') size = params['size'] utils._create_file(size, file_loc) except (InvalidParameter) as e: cb('OK', False) raise InvalidParameter("GINSP00020E") except (OperationFailed) as e: cb('OK', False) raise OperationFailed('GINSP00005E', { 'file_loc': file_loc, 'err': e.message }) try: if type == 'device': dev = file_loc.split("/")[-1] if dev.startswith('dm-'): dmname = utils.get_dm_name(file_loc.split("/")[-1]) else: dmname = dev part = PartitionModel(objstore=self.objstore) dev_type = part.lookup(dmname) if dev_type['type'] == 'part': type = '82' # hex value for type Linux Swap part.change_type(dmname, type) cb('create swap from file') utils._make_swap(file_loc) cb('activate swap device') utils._activate_swap(file_loc) cb('persist swap device') import fs_utils fs_utils.persist_swap_dev(file_loc) cb('OK', True) except (OperationFailed) as e: rollback.prependDefer(SwapsModel.delete_swap_file, file_loc) cb('OK', False) raise OperationFailed('GINSP00005E', { 'file_loc': file_loc, 'err': e.message })
def _create_task(self, cb, params): type = params['type'] file_loc = params['file_loc'] cb('entering task to create swap file') with RollbackContext() as rollback: try: if type == 'file': cb('create a file') size = params['size'] utils._create_file(size, file_loc) except (InvalidParameter) as e: cb('OK', False) raise InvalidParameter("GINSP00020E") except (OperationFailed) as e: cb('OK', False) raise OperationFailed('GINSP00005E', {'file_loc': file_loc, 'err': e.message}) try: if type == 'device': dev = file_loc.split("/")[-1] if dev.startswith('dm-'): dmname = utils.get_dm_name(file_loc.split("/")[-1]) else: dmname = dev part = PartitionModel(objstore=self.objstore) dev_type = part.lookup(dmname) if dev_type['type'] == 'part': type = '82' # hex value for type Linux Swap part.change_type(dmname, type) cb('create swap from file') utils._make_swap(file_loc) cb('activate swap device') utils._activate_swap(file_loc) cb('persist swap device') import fs_utils fs_utils.persist_swap_dev(file_loc) cb('OK', True) except (OperationFailed) as e: rollback.prependDefer(SwapsModel.delete_swap_file, file_loc) cb('OK', False) raise OperationFailed('GINSP00005E', {'file_loc': file_loc, 'err': e.message})