本文整理汇总了Python中nailgun.extensions.volume_manager.manager.only_disks函数的典型用法代码示例。如果您正苦于以下问题:Python only_disks函数的具体用法?Python only_disks怎么用?Python only_disks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了only_disks函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: all_free_space_except_os_for_volume
def all_free_space_except_os_for_volume(self, spaces, volume_name):
os_size = self.os_size(spaces)
reserved_size = self.reserved_size(spaces)
disk_sum_size = sum([disk["size"] for disk in only_disks(spaces)])
vg_size = 0
sum_lvm_meta = 0
for disk in only_disks(spaces):
for volume in disk["volumes"]:
if volume.get("vg") == volume_name or volume.get("name") == volume_name:
vg_size += volume["size"]
vg_size -= volume.get("lvm_meta_size", 0)
sum_lvm_meta += volume.get("lvm_meta_size", 0)
self.assertEqual(vg_size, disk_sum_size - os_size - reserved_size - sum_lvm_meta)
示例2: reserved_size
def reserved_size(self, spaces):
reserved_size = 0
for disk in only_disks(spaces):
reserved_size += DisksFormatConvertor.\
calculate_service_partitions_size(disk['volumes'])
return reserved_size
示例3: logical_volume_sizes_should_equal_all_phisical_volumes
def logical_volume_sizes_should_equal_all_phisical_volumes(self, spaces):
vg_sizes = {}
for vg in only_vg(spaces):
for volume in vg['volumes']:
vg_name = vg['id']
if not vg_sizes.get(vg_name):
vg_sizes[vg_name] = 0
vg_sizes[vg_name] += volume['size']
pv_sizes = {}
for disk in only_disks(spaces):
for volume in disk['volumes']:
# Skip cinder because it does not have
# logical volumes
if volume.get('vg') == 'cinder':
continue
if volume['type'] == 'pv':
vg_name = volume['vg']
if not pv_sizes.get(vg_name):
pv_sizes[vg_name] = 0
pv_sizes[vg_name] += volume['size']
pv_sizes[vg_name] -= volume['lvm_meta_size']
self.assertEqual(vg_sizes, pv_sizes)
示例4: volumes_sum_size
def volumes_sum_size(self, disks, vg):
sum_size = 0
for disk in only_disks(disks):
volumes = filter(lambda volume: volume.get("vg") == vg, disk["volumes"])
sum_size += sum(v["size"] for v in volumes)
self.non_zero_size(sum_size)
return sum_size
示例5: all_free_space_except_os_for_volume
def all_free_space_except_os_for_volume(self, spaces, volume_name):
os_size = self.os_size(spaces)
reserved_size = self.reserved_size(spaces)
disk_sum_size = sum([disk['size'] for disk in only_disks(spaces)])
vg_size = 0
sum_lvm_meta = 0
for disk in only_disks(spaces):
for volume in disk['volumes']:
if volume.get('vg') == volume_name or \
volume.get('name') == volume_name:
vg_size += volume['size']
vg_size -= volume.get('lvm_meta_size', 0)
sum_lvm_meta += volume.get('lvm_meta_size', 0)
self.assertEqual(
vg_size, disk_sum_size - os_size - reserved_size - sum_lvm_meta)
示例6: should_allocates_same_size
def should_allocates_same_size(self, volumes, same_size_volume_names):
disks = only_disks(volumes)
actual_volumes_size = {}
for disk in disks:
for volume in disk['volumes']:
name = volume.get('vg') or volume.get('name')
if not name:
continue
actual_volumes_size.setdefault(name, {})
actual_volumes_size[name].setdefault('size', 0)
actual_volumes_size[name].setdefault(
'type', volume.get('type'))
actual_volumes_size[name]['size'] += volume.get('size')
actual_volumes = [v for k, v in actual_volumes_size.iteritems()
if k in same_size_volume_names]
# All pv should have equal size
actual_pv_volumes = filter(
lambda volume: volume['type'] == 'pv', actual_volumes)
sum_pv_size = sum([volume['size'] for volume in actual_pv_volumes])
average_size = sum_pv_size / len(actual_pv_volumes)
for pv in actual_pv_volumes:
# In cases where all volumes are created on one disk and
# that disk has an odd-numbered size the volume sizes will
# differ by 1.
self.assertAlmostEqual(pv['size'], average_size, delta=1)
示例7: volumes_sum_size
def volumes_sum_size(self, disks, vg):
sum_size = 0
for disk in only_disks(disks):
volumes = filter(
lambda volume: volume.get('vg') == vg, disk['volumes']
)
sum_size += sum(v['size'] for v in volumes)
self.non_zero_size(sum_size)
return sum_size
示例8: test_get_default_attrs
def test_get_default_attrs(self):
self.env.create_node(api=False)
node_db = self.env.nodes[0]
volumes_from_api = self.get(node_db.id)
default_volumes = node_db.volume_manager.gen_volumes_info()
disks = only_disks(default_volumes)
self.assertEqual(len(disks), len(volumes_from_api))
示例9: glance_size
def glance_size(self, disks):
glance_sum_size = 0
for disk in only_disks(disks):
glance_volume = filter(
lambda volume: volume.get('vg') == 'image', disk['volumes']
)[0]
glance_sum_size += glance_volume['size']
self.non_zero_size(glance_sum_size)
return glance_sum_size
示例10: os_size
def os_size(self, disks, with_lvm_meta=True):
os_sum_size = 0
for disk in only_disks(disks):
os_volume = filter(lambda volume: volume.get("vg") == "os", disk["volumes"])[0]
os_sum_size += os_volume["size"]
if not with_lvm_meta:
os_sum_size -= os_volume["lvm_meta_size"]
self.non_zero_size(os_sum_size)
return os_sum_size
示例11: mysql_size
def mysql_size(self, disks):
mysql_sum_size = 0
for disk in only_disks(disks):
mysql_volume = filter(
lambda volume: volume.get('vg') == 'mysql', disk['volumes']
)[0]
mysql_sum_size += mysql_volume['size']
self.non_zero_size(mysql_sum_size)
return mysql_sum_size
示例12: os_size
def os_size(self, disks, with_lvm_meta=True):
os_sum_size = 0
for disk in only_disks(disks):
os_volume = filter(
lambda volume: volume.get('vg') == 'os', disk['volumes'])[0]
os_sum_size += os_volume['size']
if not with_lvm_meta:
os_sum_size -= os_volume['lvm_meta_size']
self.non_zero_size(os_sum_size)
return os_sum_size
示例13: all_free_space_except_os_disks_for_volume
def all_free_space_except_os_disks_for_volume(self, volume_manager, volume_name):
spaces = volume_manager.volumes
reserved_size = self.reserved_size(spaces)
disk_sum_size = sum([disk["size"] for disk in only_disks(spaces)])
boot_data_size = volume_manager.call_generator("calc_boot_size") + volume_manager.call_generator(
"calc_boot_records_size"
)
vg_size = 0
sum_lvm_meta = 0
for disk in only_disks(spaces):
for volume in disk["volumes"]:
# Exclude disks with OS vg as Ceph won't be there
if volume.get("vg") == "os" and volume.get("size", 0) > 0:
disk_sum_size -= disk["size"] - boot_data_size
if volume.get("vg") == volume_name or volume.get("name") == volume_name:
vg_size += volume["size"]
vg_size -= volume.get("lvm_meta_size", 0)
sum_lvm_meta += volume.get("lvm_meta_size", 0)
self.assertEqual(vg_size, disk_sum_size - reserved_size - sum_lvm_meta)
示例14: test_allocates_all_free_space_for_os_for_controller_role
def test_allocates_all_free_space_for_os_for_controller_role(self):
node = self.create_node('controller')
disks = only_disks(node.volume_manager.volumes)
disks_size_sum = sum([disk['size'] for disk in disks])
os_sum_size = self.os_size(disks)
glance_sum_size = self.glance_size(disks)
reserved_size = self.reserved_size(disks)
self.assertEqual(disks_size_sum - reserved_size,
os_sum_size + glance_sum_size)
self.logical_volume_sizes_should_equal_all_phisical_volumes(
node.attributes.volumes)
self.check_disk_size_equal_sum_of_all_volumes(node.attributes.volumes)
示例15: all_free_space_except_os_disks_for_volume
def all_free_space_except_os_disks_for_volume(self, volume_manager,
volume_name):
spaces = volume_manager.volumes
reserved_size = self.reserved_size(spaces)
disk_sum_size = sum([disk['size'] for disk in only_disks(spaces)])
boot_data_size = volume_manager.call_generator('calc_boot_size') + \
volume_manager.call_generator('calc_boot_records_size')
vg_size = 0
sum_lvm_meta = 0
for disk in only_disks(spaces):
for volume in disk['volumes']:
# Exclude disks with OS vg as Ceph won't be there
if volume.get('vg') == 'os' and volume.get('size', 0) > 0:
disk_sum_size -= (disk['size'] - boot_data_size)
if volume.get('vg') == volume_name or \
volume.get('name') == volume_name:
vg_size += volume['size']
vg_size -= volume.get('lvm_meta_size', 0)
sum_lvm_meta += volume.get('lvm_meta_size', 0)
self.assertEqual(
vg_size, disk_sum_size - reserved_size - sum_lvm_meta)