當前位置: 首頁>>代碼示例>>Python>>正文


Python Order.get_working_orders方法代碼示例

本文整理匯總了Python中models.order.Order.get_working_orders方法的典型用法代碼示例。如果您正苦於以下問題:Python Order.get_working_orders方法的具體用法?Python Order.get_working_orders怎麽用?Python Order.get_working_orders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.order.Order的用法示例。


在下文中一共展示了Order.get_working_orders方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: job_package

# 需要導入模塊: from models.order import Order [as 別名]
# 或者: from models.order.Order import get_working_orders [as 別名]
def job_package():
#       Log.info("請異步發送")
        need_do = ''
        orders = Order.get_working_orders()
        for order in orders:
            product = Product.lookup(order['p_id'])
            exchange = Exchange.get_exchange(order['e_id'])
            packages = Package.getPackageByName(order['package_id'])
            for package in packages:
                need_do = need_do+json.dumps({'port':product['port'],'bandwidth':order['bandwidth'],\
                           'status':order['status'],'port_name':product['port'], 'ipAddress':exchange['ipAddress'], \
                          'package_id':package['package_name']})
#             Order.finish_order(order['_id'])   
                                
        need_back=''
        orders = Order.get_back_orders()
        for order in orders:
             custom_time = order['custom_time']
             product = Product.lookup(order['p_id'])
             exchange = Exchange.look(order['e_id'])
             packages = Package.getPackageByName(order['package_id'])
             for package in packages:
                 need_back = need_back+json.dumps({'port':product['port'],'ex_bandwidth':order['bandwidth'],\
                           'status':order['status'],'port_name':product['port'], 'ipAddress':exchange['ipAddress'], \
                          'package_id':package['package_name']})
#              Order.back_order(order['_id'])
        print 'set_package_job end at ',datetime.datetime.now()
開發者ID:hc990,項目名稱:let,代碼行數:29,代碼來源:schedulePackage_job.py

示例2: set_bandwidth_job

# 需要導入模塊: from models.order import Order [as 別名]
# 或者: from models.order.Order import get_working_orders [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

示例3: TelnetRpcClient

# 需要導入模塊: from models.order import Order [as 別名]
# 或者: from models.order.Order import get_working_orders [as 別名]
Mongo.create(host=options.db_host, port=options.db_port)

from models.order import Order 
from models.product import Product  
from models.exchange import Exchange 
from client.rpc_client import TelnetRpcClient    

import json,datetime
from util import encrypt_util


rpc = TelnetRpcClient(options.service_ip)   
need_do = ''

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})
開發者ID:hc990,項目名稱:let,代碼行數:32,代碼來源:test.py

示例4: main

# 需要導入模塊: from models.order import Order [as 別名]
# 或者: from models.order.Order import get_working_orders [as 別名]
def main():

    from models.product import Product
    from models.order import Order
    from models.package import Package

    #     from views.paginator import Paginator
    from models.exchange import Exchange

    #
    #     from datetime import datetime
    #     start = datetime(2010, 4, 1)
    #     end = datetime(2015, 5, 1)
    #
    for exchange in Exchange.get_status_exchanges(1):
        need_do = []
        orders = Order.get_working_orders(1, exchange["_id"])
        for order in orders:
            print order["custom_time"]
            product = Product.lookup(order["p_id"])
            exchange = Exchange.get_exchange(order["e_id"])
            package = Package.lookup(order["package_id"])

            #               need_do = need_do + json.dumps({'switch_name':exchange['ename'],'port':product['port'], 'bandwidth':order['bandwidth'], \
            #                           'port_name':product['port'], 'ipAddress':exchange['ipAddress'],'o_id':order['_id'] })
            need_do.append(
                json.dumps(
                    {
                        "switch_name": exchange["ename"],
                        "port": product["port"],
                        "port_name": product["port"],
                        "host": exchange["ipAddress"],
                        "bandwidth": order["bandwidth"],
                    }
                )
            )
            if len(need_do) > 0:
                cmd = json.dumps({"switch_name": exchange["ename"], "host": exchange["ipAddress"], "orders": need_do})

    #                     print cmd
    print len(cmd)
    print cmd
    print "-----------"
    keys = json.loads(cmd)
    print keys["host"]
    print keys["orders"]

    ##################################################
    #     if read(key_file):
    #             keys = json.loads(encrypt_util.decode(body))
    if 1 == 1:
        keys = json.loads(cmd)
        host = keys["host"]
        username, password = json.loads(read(key_file))[host]  # here is the switch address
        values = keys["orders"]
        switch_name = keys["switch_name"]
        ###################################################################
        #             switch_name = keys['switch_name']
        #             port_name = keys['port_name']
        #             bandwidth = keys['bandwidth']
        #             vlan = keys['vlan']
        response = do_command(switch_name, host, username, password, values)
開發者ID:hc990,項目名稱:let,代碼行數:64,代碼來源:db_test.py


注:本文中的models.order.Order.get_working_orders方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。