예제 #1
0
    def generate_config(self, pool):
        config = {}
        #config['raw'] = pool.config
        config['guid'] = pool.config.guid
        config['scrub'] = pool.config.vdev_tree.scan_stats

        #config['raw'] = pool.config
        nr_of_vdevs = len(pool.config.vdev_tree.children)

        config['nr_of_vdevs'] = nr_of_vdevs

        vdevs = []
        for vdev_config in pool.config.vdev_tree.children:
            # Skip weird vdev types
            if vdev_config.type == 'hole':
                continue

            # Test if the VDEV has children
            vdev_children = []
            if vdev_config.children:
                for child in vdev_config.children:
                    vdev_children.append({
                        'type':
                        child.type,
                        'path':
                        child.path,
                        'name':
                        ''.join(child.path.split('/')[-1]),
                        'vdev_stats':
                        jsonify(child.vdev_stats, parse_enums=PARSE_BOTH)
                    })
            else:
                vdev_children.append({
                    'type':
                    vdev_config.type,
                    'path':
                    vdev_config.path,
                    'name':
                    ''.join(vdev_config.path.split('/')[-1]),
                    'vdev_stats':
                    jsonify(vdev_config.vdev_stats, parse_enums=PARSE_BOTH)
                })

            vdevs.append({
                'ashift':
                vdev_config.ashift,
                'nparity':
                vdev_config.nparity,
                'type':
                vdev_config.type,
                'vdev_stats':
                jsonify(vdev_config.vdev_stats, parse_enums=PARSE_BOTH),
                'children':
                vdev_children
            })

        config['vdevs'] = vdevs

        return config
예제 #2
0
파일: zfs.py 프로젝트: Brainiarc7/ZFSmond
	def get(self):
		pools = []
		for pool in ZPool.list():
			fs = []
			root_fs = ZDataset.get(pool.name)

			# Append the root filesystem
			root_fs._properties = jsonify(root_fs.properties)

			fs.append(
				{
					'name' : root_fs.name,
					'type': 'Pool',
					'available' : root_fs.properties['available'],
					'referenced' : root_fs.properties['referenced'],
					'used' : root_fs.properties['used'],
				})

			for sub_fs in root_fs.child_filesystems:
				# Snapshots
				snaps = []
				for sub_snap in sub_fs.child_snapshots:
					sub_snap._properties = jsonify(sub_snap.properties)

					snaps.append(
						{
							'name' : sub_snap.name,
							'referenced' : sub_snap.properties['referenced'],
							'used' : sub_snap.properties['used'],
						})
				sub_fs._properties = jsonify(sub_fs.properties)

				fs.append(
					{
						'name' : sub_fs.name,
						'type' : fs_type_to_str(sub_fs.type),
						'available' : sub_fs.properties['available'],
						'referenced' : sub_fs.properties['referenced'],
						'used' : sub_fs.properties['used'],
						'snaps' : snaps
					})
			pools.append({
				'name' : pool.name,
				'fs' : fs
			})
		return pools
예제 #3
0
파일: zfs.py 프로젝트: Brainiarc7/ZFSmond
	def generate_config(self, pool):
		config = {}
		#config['raw'] = pool.config
		config['guid'] = pool.config.guid
		config['scrub'] = pool.config.vdev_tree.scan_stats

		#config['raw'] = pool.config
		nr_of_vdevs = len(pool.config.vdev_tree.children)

		config['nr_of_vdevs'] = nr_of_vdevs

		vdevs = []
		for vdev_config in pool.config.vdev_tree.children:
			# Skip weird vdev types
			if vdev_config.type == 'hole':
				continue

			# Test if the VDEV has children
			vdev_children = []
			if vdev_config.children:
				for child in vdev_config.children:
					vdev_children.append({
							'type': child.type,
							'path': child.path,
							'name': ''.join(child.path.split('/')[-1]),
							'vdev_stats': jsonify(child.vdev_stats, parse_enums=PARSE_BOTH)
					})
			else:
				vdev_children.append({
						'type': vdev_config.type,
						'path': vdev_config.path,
						'name': ''.join(vdev_config.path.split('/')[-1]),
						'vdev_stats': jsonify(vdev_config.vdev_stats, parse_enums=PARSE_BOTH)
				})

			vdevs.append({
				'ashift' : vdev_config.ashift,
				'nparity' : vdev_config.nparity,
				'type' : vdev_config.type,
				'vdev_stats': jsonify(vdev_config.vdev_stats, parse_enums=PARSE_BOTH),
				'children' : vdev_children
			})

		config['vdevs'] = vdevs

		return config
예제 #4
0
    def get(self):
        pools = []
        for pool in ZPool.list():
            fs = []
            root_fs = ZDataset.get(pool.name)

            # Append the root filesystem
            root_fs._properties = jsonify(root_fs.properties)

            fs.append({
                'name': root_fs.name,
                'type': 'Pool',
                'available': root_fs.properties['available'],
                'referenced': root_fs.properties['referenced'],
                'used': root_fs.properties['used'],
            })

            for sub_fs in root_fs.child_filesystems:
                # Snapshots
                snaps = []
                for sub_snap in sub_fs.child_snapshots:
                    sub_snap._properties = jsonify(sub_snap.properties)

                    snaps.append({
                        'name':
                        sub_snap.name,
                        'referenced':
                        sub_snap.properties['referenced'],
                        'used':
                        sub_snap.properties['used'],
                    })
                sub_fs._properties = jsonify(sub_fs.properties)

                fs.append({
                    'name': sub_fs.name,
                    'type': fs_type_to_str(sub_fs.type),
                    'available': sub_fs.properties['available'],
                    'referenced': sub_fs.properties['referenced'],
                    'used': sub_fs.properties['used'],
                    'snaps': snaps
                })
            pools.append({'name': pool.name, 'fs': fs})
        return pools