本文整理匯總了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