def get_config(self): pool = self.dispatcher.call_sync('zfs.pool.get_boot_pool') @lazy def collect_disks(): disks = [] for vdev, _ in iterate_vdevs(pool['groups']): try: disks.append({ 'disk_id': self.dispatcher.call_sync('disk.partition_to_disk', vdev['path']), 'guid': vdev['guid'], 'status': vdev['status'] }) except RpcException: continue return disks return { 'name': pool['id'], 'guid': pool['guid'], 'status': pool['status'], 'scan': pool['scan'], 'properties': include( pool['properties'], 'size', 'capacity', 'health', 'version', 'delegation', 'failmode', 'autoreplace', 'dedupratio', 'free', 'allocated', 'readonly', 'comment', 'expandsize', 'fragmentation', 'leaked' ), 'disks': collect_disks }
def run(self, id, updated_params): boot_pool_name = self.configstore.get('system.boot_pool_name') new_id = updated_params.get('id', id) be = FindClone(id) if not be: raise TaskException(errno.ENOENT, 'Boot environment {0} not found'.format(id)) if not include(updated_params, 'id', 'keep', 'active'): return def doit(): if 'id' in updated_params: if not RenameClone(id, updated_params['id']): raise TaskException( errno.EIO, 'Cannot rename the {0} boot evironment'.format(id)) if 'keep' in updated_params: self.run_subtask_sync( 'zfs.update', f'{boot_pool_name}/ROOT/{be["realname"]}', {'beadm:keep': { 'value': str(updated_params['keep']) }}) if updated_params.get('active'): if not ActivateClone(id): raise TaskException( errno.EIO, 'Cannot activate the {0} boot environment'.format(id)) self.dispatcher.exec_and_wait_for_event( 'boot.environment.changed', lambda args: args['operation'] == 'update' and (id in args['ids'] or new_id in args['ids']), doit, 600)
def run(self, id, updated_params): new_id = updated_params.get('id', id) be = FindClone(id) if not be: raise TaskException(errno.ENOENT, 'Boot environment {0} not found'.format(id)) if not include(updated_params, 'id', 'keep', 'active'): return def doit(): if 'id' in updated_params: if not RenameClone(id, updated_params['id']): raise TaskException( errno.EIO, 'Cannot rename the {0} boot evironment'.format(id)) if 'keep' in updated_params: if not CloneSetAttr(be, keep=updated_params['keep']): raise TaskException( errno.EIO, 'Cannot set keep flag on boot environment {0}'.format( id)) if updated_params.get('active'): if not ActivateClone(id): raise TaskException( errno.EIO, 'Cannot activate the {0} boot environment'.format(id)) self.dispatcher.exec_and_wait_for_event( 'boot.environment.changed', lambda args: args['operation'] == 'update' and (id in args['ids'] or new_id in args['ids']), doit, 600)
def run(self, id, updated_params): new_id = updated_params.get('id', id) be = FindClone(id) if not be: raise TaskException(errno.ENOENT, 'Boot environment {0} not found'.format(id)) if not include(updated_params, 'id', 'keep', 'active'): return def doit(): if 'id' in updated_params: if not RenameClone(id, updated_params['id']): raise TaskException(errno.EIO, 'Cannot rename the {0} boot evironment'.format(id)) if 'keep' in updated_params: if not CloneSetAttr(be, keep=updated_params['keep']): raise TaskException(errno.EIO, 'Cannot set keep flag on boot environment {0}'.format(id)) if updated_params.get('active'): if not ActivateClone(id): raise TaskException(errno.EIO, 'Cannot activate the {0} boot environment'.format(id)) self.dispatcher.exec_and_wait_for_event( 'boot.environment.changed', lambda args: args['operation'] == 'update' and (id in args['ids'] or new_id in args['ids']), doit, 600 )
def extend_dataset(ds): ds = wrap(ds) return { 'name': ds['name'], 'type': ds['type'], 'mountpoint': ds['mountpoint'], 'volsize': ds.get('properties.volsize.rawvalue'), 'properties': include( ds['properties'], 'used', 'available', 'compression', 'atime', 'dedup', 'quota', 'refquota', 'reservation', 'refreservation', 'casesensitivity', 'volsize', 'volblocksize', ), 'permissions_type': ds.get('properties.org\\.freenas:permissions_type.value'), }
def get_config(self): pool = self.dispatcher.call_sync('zfs.pool.get_boot_pool') @lazy def collect_disks(): disks = [] for vdev, _ in iterate_vdevs(pool['groups']): disk_id = None disk = None try: disk_id = self.dispatcher.call_sync( 'disk.partition_to_disk', vdev['path']) disk = self.dispatcher.call_sync('disk.query', [('id', '=', disk_id), ('online', '=', True)], {'single': True}) except RpcException: pass disks.append({ 'disk_id': disk_id, 'path': q.get(disk, 'path', vdev['path']), 'guid': vdev['guid'], 'status': vdev['status'] }) return disks return { 'name': pool['id'], 'guid': pool['guid'], 'status': pool['status'], 'scan': pool['scan'], 'properties': include(pool['properties'], 'size', 'capacity', 'health', 'version', 'delegation', 'failmode', 'autoreplace', 'dedupratio', 'free', 'allocated', 'readonly', 'comment', 'expandsize', 'fragmentation', 'leaked'), 'disks': collect_disks }
def extend(snapshot): dataset, _, name = snapshot['name'].partition('@') pool = dataset.partition('/')[0] if pool == boot_pool: return None return { 'id': snapshot['name'], 'pool': pool, 'dataset': dataset, 'name': name, 'properties': include( snapshot['properties'], 'used', 'referenced', 'compressratio', 'clones' ), 'holds': snapshot['holds'] }
def __getstate__(self): return extend( include(self._dict, *getattr(self, '__annotations__', {}).keys()), {'%type': self.__class__.__name__})
def __getstate__(self): return extend( include(self._dict, *getattr(self, '__annotations__', {}).keys()), {'%type': self.__class__.__name__} )
def __getstate__(self): return extend(include(self._dict, *self.__annotations__.keys()), {'%type': self.json_schema_name()})