当前位置: 首页>>代码示例>>Python>>正文


Python General.remove_list_from_list方法代码示例

本文整理汇总了Python中ci.tests.general.general.General.remove_list_from_list方法的典型用法代码示例。如果您正苦于以下问题:Python General.remove_list_from_list方法的具体用法?Python General.remove_list_from_list怎么用?Python General.remove_list_from_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ci.tests.general.general.General的用法示例。


在下文中一共展示了General.remove_list_from_list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: remove_roles_from_config

# 需要导入模块: from ci.tests.general.general import General [as 别名]
# 或者: from ci.tests.general.general.General import remove_list_from_list [as 别名]
    def remove_roles_from_config(config, number_of_roles_to_remain=0):
        """

        :param config: Configuration file containing all of the required information
        :type config: dict

        :param number_of_roles_to_remain: how roles may still be defined on the partition. The first 'number_of_roles_to
        _remain' will remain.
        :type number_of_roles_to_remain: int

        :return: Returns a object with the partition guid and its roles
        :type: Object
        """
        collection = {}
        # Remove disk roles
        logger.info("Starting removal of disk roles")
        for key, value in config.iteritems():
            for disk_info in value['disks']:
                disk_name = disk_info['disk_name']
                logger.info("Fetching disk with diskname '{0}' for ip '{1}'".format(disk_name, key))
                disk = GeneralStorageRouter().get_disk_by_ip(disk_name, key)
                logger.info("Fetching partition of disk '{0}'".format(disk.guid))
                partition = GeneralDisk.partition_disk(disk)
                if number_of_roles_to_remain == 0:
                    # When number_of_roles_to_remain ==0, everything should have been removed
                    remaining_roles = []
                    logger.info("Removing roles '{0}' from partition '{1}'".format(remaining_roles, partition.guid))
                    GeneralDisk.adjust_disk_role(partition, remaining_roles, 'SET')
                    # Set back to pristine condition:
                    # Unmount partition
                    logger.info("Umounting disk {2}".format(partition.roles, partition.guid, disk_name))
                    TestDiskRoles._umount(partition.mountpoint)
                    # Remove from fstab
                    logger.info(
                        "Removing {0} from fstab".format(partition.mountpoint, partition.guid, disk_name))
                    FstabHelper().remove_by_mountpoint(partition.mountpoint)
                    # Remove filesystem
                    logger.info(
                        "Removing filesystem on partition {0} on disk {1}".format(partition.guid, disk_name))
                    alias = partition.aliases[0]
                    device = '/dev/{0}'.format(disk_name)
                    TestDiskRoles._remove_filesystem(device, alias)
                    # Remove partition from model
                    logger.info("Removing partition {0} on disk {1} from model".format(partition.guid, disk_name))
                    partition.delete()
                else:
                    if len(partition.roles) < number_of_roles_to_remain:
                        logger.warning("Number of roles that should remain exceed the number of roles that are present!"
                                       " Keeping all roles instead!")
                        roles_list = partition.roles
                    else:
                        roles_list = partition.roles[number_of_roles_to_remain:]
                    remaining_roles = General.remove_list_from_list(partition.roles, roles_list)
                    logger.info("Removing roles '{0}' from partition '{1}'".format(remaining_roles, partition.guid))
                    GeneralDisk.adjust_disk_role(partition, remaining_roles, 'SET')
                # Will test if the role is an empty list
                collection[partition.guid] = remaining_roles
        return collection
开发者ID:openvstorage,项目名称:integrationtests,代码行数:60,代码来源:disk_roles_test.py


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