本文整理汇总了Python中network.Network.get方法的典型用法代码示例。如果您正苦于以下问题:Python Network.get方法的具体用法?Python Network.get怎么用?Python Network.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network.Network
的用法示例。
在下文中一共展示了Network.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import get [as 别名]
def get(self, url, http_type="GET", post={}):
return Network.get(url, http_type, post)
示例2: network_process_cli
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import get [as 别名]
def network_process_cli(config, auth, opt):
if opt['--delimeter'] is None:
delimeter = " "
else:
delimeter = opt['--delimeter']
if opt['--format'] is None:
o_format = "text"
else:
o_format = opt['--format']
n = Network(
hostname=config.host,
auth=auth,
o_format=o_format,
delimeter=delimeter
)
if opt['list'] is True:
n.list_networks(include_extattrs=opt['--extattrs'])
elif opt['search'] is True:
n.search(
name=opt['<name>'],
site=opt['<site>'],
attribute=opt['<attribute>'],
value=opt['<value>'],
network=opt['--network'],
)
elif opt['get'] is True:
network = opt['<network>']
n.get(network)
elif opt['fixedaddresses'] is True:
network = opt['<network>']
n.fixedaddresses(network)
elif opt['option'] is True and opt['create']:
network_block = opt['<network_block>']
option_name = opt['<option>']
option_value = opt['<value>']
if '\-' in option_value:
option_value = option_value.replace('\-', '-')
n.create_option(network_block, option_name, option_value)
elif opt['attr'] is True and opt['create']:
network_block = opt['<network_block>']
attr_name = opt['<option>']
attr_value = opt['<value>']
n.create_attr(network_block, attr_name, attr_value)
elif opt['create'] is True:
if not opt['range']:
network = opt['<network>']
name = opt['<name>']
disable = opt['--disable']
if disable is None:
disable = True
if isinstance(disable, str):
if disable.upper() == 'TRUE':
disable = True
elif disable.upper() == 'FALSE':
disable = False
try:
members = opt['--members'].split(',')
except AttributeError:
members = []
n.create_network(
network,
name,
disable=disable,
members=members,
)
if n.api_out.has_error:
print "Unable to Create Network: %s" % network
sys.exit(2)
else:
print "Network Created Successfully"
n.get(network)
elif opt['range'] is True:
start = opt['<start>']
end = opt['<end>']
name = opt['<name>']
comment = opt['--comment']
disable = opt['--disable']
if disable is None:
disable = True
# Make a method out of this
# def parse_disable
if isinstance(disable, str):
if disable.upper() == 'TRUE':
disable = True
elif disable.upper() == 'FALSE':
disable = False
n.create_range(
name,
start,
end,
disable=disable,
)
#.........这里部分代码省略.........