本文整理匯總了Python中DBManager.DBManager.list_DB_element方法的典型用法代碼示例。如果您正苦於以下問題:Python DBManager.list_DB_element方法的具體用法?Python DBManager.list_DB_element怎麽用?Python DBManager.list_DB_element使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DBManager.DBManager
的用法示例。
在下文中一共展示了DBManager.list_DB_element方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from DBManager import DBManager [as 別名]
# 或者: from DBManager.DBManager import list_DB_element [as 別名]
def main(argv=None):
'''Command line options.'''
program_name = os.path.basename(sys.argv[0])
program_version = "v0.2"
program_build_date = "%s" % __updated__
program_version_string = '%%prog %s (%s)' % (program_version, program_build_date)
#program_usage = '''usage: spam two eggs''' # optional - will be autogenerated by optparse
program_longdesc = '''''' # optional - give further explanation about what the program does
program_license = "Copyright 2014 user_name (organization_name) \
Licensed under the Apache License 2.0\nhttp://www.apache.org/licenses/LICENSE-2.0"
if argv is None:
argv = sys.argv[1:]
try:
# setup option parser
usage= "\t-e --create-ovs=IPADDRESS -t=TOPOLOGYNAME (create OVS network)\n\t-p tcl/r10.tcl (parse r10.tcl file and save database)\n\t-s r20 (show the graph of r20 topology)"
parser = OptionParser(version=program_version_string, epilog=program_longdesc, description=program_license,usage=usage)
parser.add_option("-i", "--in", dest="infile", help="set input path [default: %default]", metavar="FILE")
parser.add_option("-o", "--out", dest="outfile", help="set output path [default: %default]", metavar="FILE")
parser.add_option("-l", dest="list", help="list elements of database [all, host, topology, link, node, sflow]");
parser.add_option("-s", "--show", dest="show", help="show a network graph of topology",metavar="topology");
parser.add_option("-c","--clear", dest="clear", help="clear entries on the inputted argument [all, host, topology, link, node, sflow]",metavar="element");
parser.add_option("-p", dest="parse", help="parse Brite topology file", metavar="FILE")
parser.add_option("-f", "--flow", dest="flow", help="get a routing table of sdn controller ",metavar="IP-address of SDN controller");
#parser.add_option("-a", "--alarm", action="store_true",dest="alarm",default=False, help="get the alarm number from IDS ");
eostgroup = OptionGroup(parser, "Experiment options")
eostgroup.add_option("-e", action="store_true", dest="experimental",default=False, help="create virtual SDN network")
eostgroup.add_option("-j", dest="sampling", help="set sampling configuration json file", metavar="FILE")
eostgroup.add_option("-t", "--topology", dest="topology", help="set topology ", metavar="NAME")
eostgroup.add_option("--create-ovs", dest="create_ovs_target", help="create OVS network at the target host",metavar="TARGET-IP-ADDRESS")
eostgroup.add_option("--clear-ovs", dest="clear_ovs_target", help="clear OVS network at the target host",metavar="TARGET-IP-ADDRESS")
eostgroup.add_option("--create-sflow", dest="create_sflow_target", help="create sflow agnets at the target host",metavar="TARGET-IP-ADDRESS")
eostgroup.add_option("--clear-sflow", dest="clear_sflow_target", help="clear sflow agnets at the target host",metavar="TARGET-IP-ADDRESS")
parser.add_option_group(eostgroup)
hostgroup = OptionGroup(parser, "Host registration options")
hostgroup.add_option("-r", "--register-host", action="store_true", dest="register_host",default=False, help="register host")
hostgroup.add_option("--host-ip", dest="hostip", help="set machine ip address", metavar="IP-ADDRESS")
hostgroup.add_option("--user-id", dest="userid", help="set user id")
hostgroup.add_option("--password", dest="password", help="set user password")
hostgroup.add_option("--controller-ip", dest="controllerip", help="set SDN controller ip")
hostgroup.add_option("--inter-ip", dest="interip", help="set the internal ip of the host")
parser.add_option_group(hostgroup)
# set defaults
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)
#.........這裏部分代碼省略.........