• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python manager.only_disks函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nailgun.volumes.manager.only_disks函数的典型用法代码示例。如果您正苦于以下问题:Python only_disks函数的具体用法?Python only_disks怎么用?Python only_disks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了only_disks函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
        vg_size = 0
        disk_sum_size = sum([disk['size'] for disk in only_disks(spaces)])
        for disk in only_disks(spaces):
            for volume in disk['volumes']:
                if volume.get('vg') == volume_name:
                    vg_size += volume['size']

        self.assertEquals(
            vg_size, disk_sum_size - os_size - reserved_size)
开发者ID:zhangjinnan,项目名称:fuelweb,代码行数:12,代码来源:test_node_disks.py


示例2: 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)
开发者ID:ustbgaofan,项目名称:fuel-web,代码行数:28,代码来源:test_node_disks.py


示例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.assertEquals(vg_sizes, pv_sizes)
开发者ID:ustbgaofan,项目名称:fuel-web,代码行数:26,代码来源:test_node_disks.py


示例4: 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.assertEquals(
            vg_size, disk_sum_size - os_size - reserved_size - sum_lvm_meta)
开发者ID:ustbgaofan,项目名称:fuel-web,代码行数:16,代码来源:test_node_disks.py


示例5: 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
开发者ID:ustbgaofan,项目名称:fuel-web,代码行数:7,代码来源:test_node_disks.py


示例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:
            self.assertEqual(pv['size'], average_size)
开发者ID:dshulyak,项目名称:fuel-web,代码行数:25,代码来源:test_node_disks.py


示例7: 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 = {}
        test = 0
        for disk in only_disks(spaces):
            for volume in disk['volumes']:
                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']
                elif volume['type'] == 'lvm_meta':
                    vg_name = volume['name']
                    if not pv_sizes.get(vg_name):
                        pv_sizes[vg_name] = 0

                    pv_sizes[vg_name] -= volume['size']

        self.assertEquals(vg_sizes, pv_sizes)
开发者ID:zhangjinnan,项目名称:fuelweb,代码行数:27,代码来源:test_node_disks.py


示例8: test_get_default_attrs

    def test_get_default_attrs(self):
        self.env.create_node(api=True)
        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.assertEquals(len(disks), len(volumes_from_api))
开发者ID:ustbgaofan,项目名称:fuel-web,代码行数:9,代码来源:test_node_disks.py


示例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
开发者ID:ustbgaofan,项目名称:fuel-web,代码行数:10,代码来源:test_node_disks.py


示例10: os_size

    def os_size(self, disks):
        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']

        self.non_zero_size(os_sum_size)
        return os_sum_size
开发者ID:zhangjinnan,项目名称:fuelweb,代码行数:10,代码来源:test_node_disks.py


示例11: 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
开发者ID:ustbgaofan,项目名称:fuel-web,代码行数:11,代码来源:test_node_disks.py


示例12: 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.assertEquals(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)
开发者ID:ustbgaofan,项目名称:fuel-web,代码行数:13,代码来源:test_node_disks.py


示例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.assertEquals(
            vg_size, disk_sum_size - reserved_size - sum_lvm_meta)
开发者ID:ustbgaofan,项目名称:fuel-web,代码行数:23,代码来源:test_node_disks.py


示例14: check_disk_size_equal_sum_of_all_volumes

    def check_disk_size_equal_sum_of_all_volumes(self, spaces):
        for disk in only_disks(spaces):
            volumes_size = sum(
                [volume.get('size', 0) for volume in disk['volumes']])

            self.assertEquals(volumes_size, disk['size'])
开发者ID:ustbgaofan,项目名称:fuel-web,代码行数:6,代码来源:test_node_disks.py



注:本文中的nailgun.volumes.manager.only_disks函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python name.get_person_name函数代码示例发布时间:2022-05-27
下一篇:
Python manager.calc_glance_cache_size函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap