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


Python Model.getLvsManagerConfigVipInstanceInfo方法代码示例

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


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

示例1: get

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import getLvsManagerConfigVipInstanceInfo [as 别名]
 def get(self):
     '''
     get rs list
     '''
     id = self.get_argument("id",None)
     handler = Model('LvsManagerConfig')
     vipinstanceinfo =  handler.getLvsManagerConfigVipInstanceInfo(id)
     for index,rs in enumerate(vipinstanceinfo['rs']):
         rs['index'] = index
         rs['port'] = ','.join(rs['port'])
     self.write(json.dumps(vipinstanceinfo['rs']))
开发者ID:sjqzhang,项目名称:lvs-manager,代码行数:13,代码来源:control.py

示例2: get

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import getLvsManagerConfigVipInstanceInfo [as 别名]
 def get(self):
     '''
     show vip instance edit page
     '''
     id = self.get_argument("id",None)
     handler = Model('LvsManagerConfig')
     vipinstanceinfo =  handler.getLvsManagerConfigVipInstanceInfo(id)
     vipinstanceinfo['mailto'] = ','.join(vipinstanceinfo['mailto'])
     vipgroup = vipinstanceinfo['vip_group']
     vipgrouplist = ["%s:%s"%(vip['vip'],vip['port']) for vip in vipgroup ]
     vipinstanceinfo['vip_group'] = ','.join(vipgrouplist)
     for index,rs in enumerate(vipinstanceinfo['rs']):
         rs['index'] = index
         rs['port'] = ','.join(rs['port'])
     self.render2('lvsmanager_deploy_edit.html',vipinstance = vipinstanceinfo)
开发者ID:Quanse,项目名称:lvs-manager,代码行数:17,代码来源:control.py

示例3: editLvsManagerConfig

# 需要导入模块: from model import Model [as 别名]
# 或者: from model.Model import getLvsManagerConfigVipInstanceInfo [as 别名]

#.........这里部分代码省略.........

        vip_tpl='''
        {
            "vip": "%s",
            "port": "%s"
        }
        '''

        insert_tpl='''
        {
            "mailto": [
                "[email protected]"
            ],
            "owners": "韦浩",
            "protocol": "TCP",
            "quorum": "1",
            "rs": [

                {rss}
            ],
            "vip_instance": "{module}",
            "descript": "{business}",
            "persistence_timeout": "{persistence_timeout}",
            "hysteresis": "0",
            "delay_loop": "6",
            "vip_group": [
                {vips}
            ],
            "alpha": true,
            "lb_kind": "FNAT",
            "cluster_id": "{cluster_id}",
            "omega": true,
            "sync_proxy": true,
            "lb_algo": "wrr"
        }'''

        data=json.loads(self.get_argument('data','{}'))
        if len(data)==0:
            result['message']='invalid data'
            return
        id=''
        all_lines={'ct':'电信','cu':'联通','cm':'移动'}
        all_rooms={'ns':'南沙','bj':'北京','wx':'无锡','hk':'香港'}
        rs=data.get('rs',[])
        room=data.get('room','')
        line=data.get('line','')
        vip=data.get('vip',[])
        business=data.get('business',[])
        module=data.get('module','')
        special=int(data.get('special','0'))
        if special:
            cluster_id='%s_%s_lvs_cluster_%s'% (room,line,business)
        else:
            cluster_id='%s_%s_lvs_cluster'% (room,line)
        cluster_flag=False
        for cluster in cluster_list:
            if str(cluster['id'])==str(cluster_id):
                cluster_flag=True
                break
        if not cluster_flag:
            result['message']='cluster %s not found,please contact manager!' % (cluster_id)
            return


        persistence_timeout=data.get('persistence_timeout','600')
        if not room in all_rooms:
            result['message']='room must be in [%s]' % ','.join(all_rooms.keys())
            return
        if not line in all_lines:
            result['message']='line must be in [%s]' % ','.join(all_lines.keys())
            return
        rs_list=[]
        vip_list=[]
        for r in rs:
            tmp=str(r).split(':')
            rs_list.append( rs_tpl % (tmp[0],tmp[0],tmp[1] ))
        for v in vip:
            tmp=str(v).split(':')
            vip_list.append( vip_tpl % (tmp[0],tmp[1] ))

        dict_data={'rss':','.join(rs_list),'vips':','.join(vip_list),'cluster_id':cluster_id,
                   'business':business,'module':module,'persistence_timeout':persistence_timeout}
        if 'id' in data:
            id=str(data['id'])
        data= json.loads(self._replace(insert_tpl,dict_data))

        lvs=Model('LvsManagerConfig')
        if id=='':
            id=lvs.insertLvsManagerConfigVipInstance2(data)
        else:
            try:
                info= lvs.getLvsManagerConfigVipInstanceInfo(id)
                if len(info)==0:
                    result['message']='cluster %s not found ' % cluster_id
                    return
                id=lvs.UpdateLvsManagerConfigVipInstance(id,data)
            except Exception as er:
                id=False
                result['message']=str(er)
        result['data']=str(id)
开发者ID:sjqzhang,项目名称:lvs-manager,代码行数:104,代码来源:webapi.py


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