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


Python DBManager.execute_sql_command方法代码示例

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


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

示例1: main

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import execute_sql_command [as 别名]

#.........这里部分代码省略.........
        parser.set_defaults(outfile="./out.txt", infile="./in.txt",role="ovs-host",controllerip="",interip="")
   
   
        dbmanager   =   DBManager(debug=DEBUG)
        hostmanager =   HostManager(dbmanager)
        networkmanager = NetworkManager(dbmanager,hostmanager,DEBUG)
                   
        # process options
        (opts, args) = parser.parse_args(argv)
        
        if opts.list :
            if opts.list == "all" :
                dbmanager.list_DB_element("host")
                dbmanager.list_DB_element("topology")
                dbmanager.list_DB_element("link")
                dbmanager.list_DB_element("node")
                dbmanager.list_DB_element("sflow")
     
            
            elif opts.list == "host":
                dbmanager.list_DB_element("host")
                
            
            elif opts.list == "topology":
                dbmanager.list_DB_element("topology")
                
            elif opts.list == "link":
                dbmanager.list_DB_element("link")
                
            elif opts.list == "node":
                dbmanager.list_DB_element("node")
                
            elif opts.list == "sflow":
                dbmanager.list_DB_element("sflow")
     
        if opts.parse :
            topologyparser = Parser(dbmanager,opts.parse,DEBUG)
            topologyparser.parse_topology()
               
        if opts.flow:
            networkmanager.get_route_table(opts.flow)

        if opts.show:
            networkmanager.draw_network(opts.show)
    
        if opts.experimental:
            if opts.create_ovs_target:
                print("create ovs")
                networkmanager.generate_OVS_network(opts.topology, opts.create_ovs_target)
            elif opts.clear_ovs_target:
                print("clear ovs")
                print(opts.clear_ovs_target)
                networkmanager.remove_OVS_network(opts.clear_ovs_target)
            elif opts.create_sflow_target:
                print("create sflow agents")
                node_data = None
                if (opts.sampling != None):
                    with open(opts.sampling) as json_file:
                        input_data = json.load(json_file)
                        node_data = input_data["nodes"]
                networkmanager.create_sflow_agnets(opts.create_sflow_target,node_data)
                print(opts.create_sflow_target)
                
            elif opts.clear_sflow_target:
                print("clear sflow agents")
                networkmanager.clear_sflow_agnets(opts.clear_sflow_target)
                print(opts.clear_sflow_target)  
        
        if opts.clear :
            if opts.clear == "all":
                hostmanager.clear_hosts()
                dbmanager.execute_sql_command("drop table topology")
                dbmanager.execute_sql_command("drop table link")
                dbmanager.execute_sql_command("drop table node")
                dbmanager.execute_sql_command("drop table sflow")
            elif opts.clear == "host":
                hostmanager.clear_hosts()
            elif opts.clear == "topology":
                dbmanager.execute_sql_command("drop table topology")
            elif opts.clear == "link":
                dbmanager.execute_sql_command("drop table link")
            elif opts.clear == "node":
                dbmanager.execute_sql_command("drop table node")
            elif opts.clear == "sflow":
                dbmanager.execute_sql_command("drop table sflow")
            
        if opts.register_host:
            hostmanager.register_host(opts.hostip,opts.controllerip,opts.userid,opts.password,"None",opts.interip)
 
        # MAIN BODY #
        if len(argv) == 0:
           parser.print_help()
           
        
            
    except Exception, e:
        indent = len(program_name) * " "
        sys.stderr.write(program_name + ": " + repr(e) + "\n")
        sys.stderr.write(indent + "  for help use --help")
        return 2
开发者ID:jax0701,项目名称:snm,代码行数:104,代码来源:snm.py


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