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


Python Equipamento.get_next_name_by_prefix方法代码示例

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


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

示例1: __post_virtual_group_equipment

# 需要导入模块: from networkapi.equipamento.models import Equipamento [as 别名]
# 或者: from networkapi.equipamento.models.Equipamento import get_next_name_by_prefix [as 别名]
    def __post_virtual_group_equipment(self, equipment_maps, vip_maps, user, resp_equipment_maps, vip_equipment_ip_map):
        try:
            for equipment_map in equipment_maps:
                equipment_prefixo = equipment_map.get('prefixo')
                if equipment_prefixo is None:
                    return self.response_error(105)

                name = Equipamento.get_next_name_by_prefix(equipment_prefixo)
                equipment_map['nome'] = name

                response = insert_equipment(equipment_map, user)
                if response[0] == 0:
                    equip_id = response[2].id

                    ip_map = equipment_map.get('ip')
                    if ip_map is None:
                        return self.response_error(3, u'Não existe valor para a tag ip do equipamento %s do XML de requisição.' % equipment_map.get('nome'))

                    ip_map['id_equipamento'] = equip_id

                    response_ip = insert_ip(ip_map, user)
                    if response_ip[0] == 0:

                        # Insere um IP para cada VIP e o relacionamento dele
                        # com equipamento
                        resp_vip_maps = []
                        for vip_map in vip_maps:
                            ip_vip_map = vip_map.get('ip_real', dict())
                            ip_vip_map['id_equipamento'] = equip_id

                            response_ip_vip = insert_ip(ip_vip_map, user)
                            if (response_ip_vip[0] == 0):
                                resp_vip_maps.append({'id': vip_map.get('id'),
                                                      'ip': response_ip_vip[1]})

                                ip = str(response_ip_vip[1].get('oct1')) + '.' + str(response_ip_vip[1].get('oct2')) + '.' + str(
                                    response_ip_vip[1].get('oct3')) + '.' + str(response_ip_vip[1].get('oct4'))

                                equipment_ip_map = {
                                    'ip': ip, 'nome_equipamento': equipment_map.get('nome')}

                                equipment_ip_maps = vip_equipment_ip_map.get(
                                    vip_map.get('id'))
                                if equipment_ip_maps is None:
                                    equipment_ip_maps = [equipment_ip_map]
                                else:
                                    equipment_ip_maps.append(equipment_ip_map)

                                vip_equipment_ip_map[
                                    vip_map.get('id')] = equipment_ip_maps
                            else:
                                return self.__treat_response_error(response_ip_vip)

                        resp_equipment_maps.append({'id': equip_id,
                                                    'nome': name,
                                                    'ip': response_ip[1],
                                                    'vips': {'vip': resp_vip_maps}})

                    else:
                        return self.__treat_response_error(response_ip)
                else:
                    return self.__treat_response_error(response)

        except InvalidGroupToEquipmentTypeError:
            return self.response_error(107)
        except TipoEquipamentoNotFoundError:
            return self.response_error(100)
        except ModeloNotFoundError:
            return self.response_error(101)
        except EquipamentoNameDuplicatedError:
            return self.response_error(149)
        except EGrupoNotFoundError:
            return self.response_error(102)

        return
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:77,代码来源:GrupoVirtualResource.py


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