node.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:esdc-ce 作者: erigones 项目源码 文件源码
def all_nictags(cls, clear_cache=False):
        """Return dictionary with of nictags {name:type}"""
        if clear_cache:
            cache.delete(NICTAGS_ALL_KEY)

        nictags = cache.get(NICTAGS_ALL_KEY)

        if not nictags:
            nodes = cls.objects.all()
            nictags = {}

            for node in nodes:
                for nic in node.nictags:
                    nic_name = nic['name']
                    nic_type = nic['type'].replace('aggr', 'normal')
                    # if nictag name is already present and types are not equal
                    if nic_name in nictags and nic_type != nictags[nic_name]:
                        raise ValueError('Duplicate NIC tag name with different type exists on another compute node!')

                    nictags[nic_name] = nic_type

            cache.set(NICTAGS_ALL_KEY, nictags, NICTAGS_ALL_EXPIRES)

        return nictags
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号