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


Python EnvironmentVip.ambiente_p44_txt方法代码示例

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


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

示例1: old_to_new

# 需要导入模块: from networkapi.ambiente.models import EnvironmentVip [as 别名]
# 或者: from networkapi.ambiente.models.EnvironmentVip import ambiente_p44_txt [as 别名]
def old_to_new(vip_request):

    from networkapi.ambiente.models import EnvironmentVip
    from networkapi.api_vip_request.models import VipRequest, VipRequestDSCP, VipRequestOptionVip, \
        VipRequestPort, VipRequestPortOptionVip, VipRequestPortPool
    from networkapi.requisicaovips.models import DsrL3_to_Vip, OptionVip, OptionVipEnvironmentVip, \
        VipPortToPool

    mp = vip_request.variables_to_map()
    try:

        try:
            ev = EnvironmentVip().get_by_values(
                mp['finalidade'], mp['cliente'], mp['ambiente'])
        except:
            ev = EnvironmentVip()
            ev.finalidade_txt = mp['finalidade']
            ev.cliente_txt = mp['cliente']
            ev.ambiente_p44_txt = mp['ambiente']
            ev.description = '%s - %s - %s' % (
                mp['finalidade'], mp['cliente'], mp['ambiente'])
            ev.save()
        finally:

            vp = VipRequest()
            vp.environmentvip = ev
            vp.id = vip_request.id
            vp.name = mp['host'] if mp.get('host') else None
            vp.business = mp['areanegocio'] if mp.get(
                'areanegocio') else vp.name
            vp.service = mp['nome_servico'] if mp.get(
                'nome_servico') else vp.name
            vp.ipv4 = vip_request.ip if vip_request.ip else None
            vp.ipv6 = vip_request.ipv6 if vip_request.ipv6 else None
            vp.created = vip_request.vip_criado
            vp.save()

            if mp.get('persistencia'):
                persistencia = mp['persistencia']
            else:
                persistencia = '(nenhum)'

            try:
                op_per = OptionVip.objects.filter(
                    tipo_opcao=u'Persistencia',
                    nome_opcao_txt=persistencia)[0]
                try:
                    opv = OptionVipEnvironmentVip.objects.get(
                        option=op_per,
                        environment=ev)
                except:
                    opv = OptionVipEnvironmentVip()
                    opv.option = op_per
                    opv.environment = ev
                    opv.save()
            except:
                op_per = OptionVip()
                op_per.tipo_opcao = u'Persistencia'
                op_per.nome_opcao_txt = persistencia
                op_per.save()
                opv = OptionVipEnvironmentVip()
                opv.option = op_per
                opv.environment = ev
                opv.save()
            finally:
                try:
                    vro = VipRequestOptionVip.objects.get(
                        optionvip=op_per,
                        vip_request=vp)
                except:
                    vro = VipRequestOptionVip()
                    vro.optionvip = op_per
                    vro.vip_request = vp
                    vro.save()

            if mp.get('timeout'):
                timeout = mp['timeout']
            else:
                timeout = '5'

            try:
                op_time = OptionVip.objects.filter(
                    tipo_opcao=u'timeout',
                    nome_opcao_txt=timeout)[0]
                try:
                    opv = OptionVipEnvironmentVip.objects.get(
                        option=op_time,
                        environment=ev)
                except:
                    opv = OptionVipEnvironmentVip()
                    opv.option = op_time
                    opv.environment = ev
                    opv.save()
            except:
                op_time = OptionVip()
                op_time.tipo_opcao = u'timeout'
                op_time.nome_opcao_txt = timeout
                op_time.save()
                opv = OptionVipEnvironmentVip()
                opv.option = op_time
#.........这里部分代码省略.........
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:103,代码来源:syncs.py


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