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


Python Order.back_order方法代码示例

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


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

示例1: set_bandwidth_job

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import back_order [as 别名]
    def set_bandwidth_job():
        from models.order import Order 
        from models.product import Product  
        from models.exchange import Exchange 
        from client.rpc_client import TelnetRpcClient    
        from tornado.options import options
        import json 
        from util import encrypt_util
        Log.info(" [x] Requesting")  
        Log.info('set_bandwidth_job start at ', datetime.datetime.now())
        need_do = ''
        Log.info("请异步发送")
        orders = Order.get_working_orders()
        for order in orders:    
            product = Product.lookup(order['p_id'])
            exchange = Exchange.lookup(product['e_id'])  
            need_do = need_do+json.dumps({'switch_name':exchange['ename'],"vlan":product['vlan'], \
                            "port_name":product['port'], "host":exchange['ipAddress'], \
                            "bandwidth":order['bandwidth']})
            Order.finish_order(order['_id'])         
        need_back=''
        orders = Order.get_back_orders()
        for order in orders:
            product = Product.lookup(order['p_id'])
            exchange = Exchange.lookup(product['e_id'])  
            need_back = need_back+json.dumps({'switch_name':exchange['ename'],"vlan":product['vlan'], \
                            "port_name":product['port'], "host":exchange['ipAddress'], \
                            "bandwidth":order['bandwidth']})
            Order.back_order(order['_id'])
        orders = {}   
        flag = False  
        if(need_do!=''):
            orders['need_do']=need_do
            flag = True
        if(need_back!=''):
            orders['need_back']=need_back
            flag = True
        if(flag!=True):
            rpc = TelnetRpcClient(options.service_ip)
            encoded = encrypt_util.encode(str(orders))
            response = rpc.call("rpc_queue",encoded)
        Log.info('set_bandwidth_job end at ', datetime.datetime.now())
        Log.info(response)
#        rpc = TelnetRpcClient('192.168.0.2')
#        orders = Order.get_working_orders()
#        for order in orders:
#            product = Product.lookup(order['p_id'])
#            exchange = Exchange.lookup(product['e_id']) 
#            response = rpc.call(json.dumps({'switch_name':'TelnetManage3560', "vlan":product['vlan'],
#                            "port_name":product['port'], "host":exchange['ipAddress'], "bandwidth":product['ctype']*order['percent']/100}))
        print 'set_bandwidth_job end at ', datetime.datetime.now()
开发者ID:hc990,项目名称:let,代码行数:53,代码来源:bootstrap.py

示例2: TelnetRpcClient

# 需要导入模块: from models.order import Order [as 别名]
# 或者: from models.order.Order import back_order [as 别名]
orders = Order.get_working_orders()
for order in orders:    
    product = Product.lookup(order['p_id'])
    exchange = Exchange.lookup(product['e_id'])  
    need_do = need_do+json.dumps({'switch_name':exchange['ename'],"vlan":product['port'], \
                    "port_name":product['port'], "host":exchange['ipAddress'], \
                    "bandwidth":order['bandwidth'],"flag":1})
    Order.finish_order(order['_id'])         
need_back=''
orders = Order.get_back_orders()
for order in orders:
    product = Product.lookup(order['p_id'])
    exchange = Exchange.lookup(product['e_id'])
    need_back = need_back+json.dumps({'switch_name':exchange['ename'],"vlan":product['port'], \
                    "port_name":product['port'], "host":exchange['ipAddress'], \
                    "bandwidth":order['bandwidth'],"flag":0})
    Order.back_order(order['_id'])

orders = {"1":need_do,"0":need_back}  
encoded = encrypt_util.encode(str(orders))
response = rpc.call("rpc_queue",encoded)

print response
#        rpc = TelnetRpcClient('192.168.0.2')
#        orders = Order.get_working_orders()
#        for order in orders:
#            product = Product.lookup(order['p_id'])
#            exchange = Exchange.lookup(product['e_id']) 
#            response = rpc.call(json.dumps({'switch_name':'TelnetManage3560', "vlan":product['vlan'],
#                            "port_name":product['port'], "host":exchange['ipAddress'], "bandwidth":product['ctype']*order['percent']/100}))
print 'set_bandwidth_job end at ', datetime.datetime.now()
开发者ID:hc990,项目名称:let,代码行数:33,代码来源:test.py


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