本文整理汇总了Python中gns3server.compute.builtin.Builtin类的典型用法代码示例。如果您正苦于以下问题:Python Builtin类的具体用法?Python Builtin怎么用?Python Builtin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Builtin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stream_pcap_file
async def stream_pcap_file(request, response):
builtin_manager = Builtin.instance()
node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
port_number = int(request.match_info["port_number"])
nio = node.get_nio(port_number)
await builtin_manager.stream_pcap_file(nio, node.project.id, request, response)
示例2: delete_nio
def delete_nio(request, response):
builtin_manager = Builtin.instance()
node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
port_number = int(request.match_info["port_number"])
yield from node.remove_nio(port_number)
response.set_status(204)
示例3: stop_capture
async def stop_capture(request, response):
builtin_manager = Builtin.instance()
node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
port_number = int(request.match_info["port_number"])
await node.stop_capture(port_number)
response.set_status(204)
示例4: start_capture
async def start_capture(request, response):
builtin_manager = Builtin.instance()
node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
port_number = int(request.match_info["port_number"])
pcap_file_path = os.path.join(node.project.capture_working_directory(), request.json["capture_file_name"])
await node.start_capture(port_number, pcap_file_path, request.json["data_link_type"])
response.json({"pcap_file_path": pcap_file_path})
示例5: update
def update(request, response):
builtin_manager = Builtin.instance()
node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
for name, value in request.json.items():
if hasattr(node, name) and getattr(node, name) != value:
setattr(node, name, value)
node.updated()
response.json(node)
示例6: create_nio
async def create_nio(request, response):
builtin_manager = Builtin.instance()
node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
nio = builtin_manager.create_nio(request.json)
port_number = int(request.match_info["port_number"])
await node.add_nio(nio, port_number)
response.set_status(201)
response.json(nio)
示例7: create
async def create(request, response):
builtin_manager = Builtin.instance()
node = await builtin_manager.create_node(request.json.pop("name"),
request.match_info["project_id"],
request.json.get("node_id"),
node_type="nat",
ports=request.json.get("ports_mapping"))
response.set_status(201)
response.json(node)
示例8: update_nio
def update_nio(request, response):
builtin_manager = Builtin.instance()
node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
nio = node.nios[int(request.match_info["adapter_number"])]
if "filters" in request.json and nio:
nio.filters = request.json["filters"]
yield from node.update_nio(int(request.match_info["port_number"]), nio)
response.set_status(201)
response.json(request.json)
示例9: update_nio
async def update_nio(request, response):
builtin_manager = Builtin.instance()
node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
port_number = int(request.match_info["port_number"])
nio = node.get_nio(port_number)
if "filters" in request.json:
nio.filters = request.json["filters"]
await node.update_nio(port_number, nio)
response.set_status(201)
response.json(request.json)
示例10: update_nio
def update_nio(request, response):
builtin_manager = Builtin.instance()
node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
adapter_number = int(request.match_info["adapter_number"])
try:
nio = node.nios[adapter_number]
except KeyError:
raise HTTPConflict(text="NIO `{}` doesn't exist".format(adapter_number))
if "filters" in request.json and nio:
nio.filters = request.json["filters"]
yield from node.update_nio(int(request.match_info["port_number"]), nio)
response.set_status(201)
response.json(request.json)
示例11: create
async def create(request, response):
builtin_manager = Builtin.instance()
node = await builtin_manager.create_node(request.json.pop("name"),
request.match_info["project_id"],
request.json.get("node_id"),
node_type="cloud",
ports=request.json.get("ports_mapping"))
# add the remote console settings
node.remote_console_host = request.json.get("remote_console_host", node.remote_console_host)
node.remote_console_port = request.json.get("remote_console_port", node.remote_console_port)
node.remote_console_type = request.json.get("remote_console_type", node.remote_console_type)
node.remote_console_http_path = request.json.get("remote_console_http_path", node.remote_console_http_path)
response.set_status(201)
response.json(node)
示例12: show
def show(request, response):
builtin_manager = Builtin.instance()
node = builtin_manager.get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
response.json(node)
示例13: suspend
def suspend(request, response):
Builtin.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
response.set_status(204)
示例14: delete
async def delete(request, response):
builtin_manager = Builtin.instance()
await builtin_manager.delete_node(request.match_info["node_id"])
response.set_status(204)
示例15: start
async def start(request, response):
node = Builtin.instance().get_node(request.match_info["node_id"], project_id=request.match_info["project_id"])
await node.start()
response.set_status(204)