def fs(self, search_key=None, search_value=None, flags=0): fs_list = self._request("get_all_names", "folder", [""]) fss = [] pools = {} for fs in fs_list: try: pool_name = NexentaStor._get_pool_id(fs) if pool_name == 'syspool': continue if pool_name not in pools: pool_info = self._request("get_child_props", "volume", [str(fs), ""]) pools[pool_name] = pool_info else: pool_info = pools[pool_name] fss.append( FileSystem(fs, fs, NexentaStor._to_bytes(pool_info['size']), self._to_bytes(pool_info['available']), pool_name, self.system.id)) except LsmError as e: error('nstor:fs: %s' % str(e)) pass return search_property(fss, search_key, search_value)
def fs(self, search_key=None, search_value=None, flags=0): rc = [] for fs in self._jsonrequest("fs_list"): # self, id, name, total_space, free_space, pool_id, system_id rc.append(FileSystem(fs['uuid'], fs['name'], fs['total_space'], fs['free_space'], fs['pool'], self.system.id)) return search_property(rc, search_key, search_value)
def fs_create(self, pool, name, size_bytes, flags=0): """ Consider you have 'data' pool and folder 'a' in it (data/a) If you want create 'data/a/b', command line should look like: --create-fs=a/b --pool=data --size=1G """ if name.startswith(pool.name + '/'): chunks = name.split('/')[1:] name = '/'.join(chunks) fs_name = self._request("create", "folder", [pool.name, name])[0] filesystem = FileSystem(fs_name, fs_name, pool.total_space, pool.free_space, pool.id, self.system.id) return None, filesystem
def fs(self, search_key=None, search_value=None, flags=0): """List filesystems, required for other operations""" fss = [] parts = list_mounts() for prt in parts: try: (total_size, avail_size) = NFSPlugin._get_fs_sizes(prt) fsid = get_fsid(prt) fss.append( FileSystem(fsid, prt, total_size, avail_size, fsid, self._SYSID)) except OSError: pass return search_property(fss, search_key, search_value)
def fs_clone(self, src_fs, dest_fs_name, snapshot=None, flags=0): folder = src_fs.name.split('/')[0] dest = folder + '/' + dest_fs_name if snapshot is None: # User did not supply a snapshot, so we will create one for them name = src_fs.name.split('/')[0] snapshot = self.fs_snapshot_create( src_fs, name + "_clone_ss_" + md5(time.ctime()))[1] self._request("clone", "folder", [snapshot.name, dest]) pool_id = NexentaStor._get_pool_id(dest) pool_info = self._request("get_child_props", "volume", [pool_id, ""]) fs = FileSystem(dest, dest, NexentaStor._to_bytes(pool_info['size']), NexentaStor._to_bytes(pool_info['available']), pool_id, self.system.id) return None, fs