repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
GNS3/gns3-server | gns3server/compute/vpcs/vpcs_vm.py | VPCSVM._vpcs_path | def _vpcs_path(self):
"""
Returns the VPCS executable path.
:returns: path to VPCS
"""
search_path = self._manager.config.get_section_config("VPCS").get("vpcs_path", "vpcs")
path = shutil.which(search_path)
# shutil.which return None if the path doesn't exists
... | python | def _vpcs_path(self):
"""
Returns the VPCS executable path.
:returns: path to VPCS
"""
search_path = self._manager.config.get_section_config("VPCS").get("vpcs_path", "vpcs")
path = shutil.which(search_path)
# shutil.which return None if the path doesn't exists
... | [
"def",
"_vpcs_path",
"(",
"self",
")",
":",
"search_path",
"=",
"self",
".",
"_manager",
".",
"config",
".",
"get_section_config",
"(",
"\"VPCS\"",
")",
".",
"get",
"(",
"\"vpcs_path\"",
",",
"\"vpcs\"",
")",
"path",
"=",
"shutil",
".",
"which",
"(",
"se... | Returns the VPCS executable path.
:returns: path to VPCS | [
"Returns",
"the",
"VPCS",
"executable",
"path",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L137-L149 | train |
GNS3/gns3-server | gns3server/compute/vpcs/vpcs_vm.py | VPCSVM.name | def name(self, new_name):
"""
Sets the name of this VPCS VM.
:param new_name: name
"""
if self.script_file:
content = self.startup_script
content = content.replace(self._name, new_name)
escaped_name = new_name.replace('\\', '')
co... | python | def name(self, new_name):
"""
Sets the name of this VPCS VM.
:param new_name: name
"""
if self.script_file:
content = self.startup_script
content = content.replace(self._name, new_name)
escaped_name = new_name.replace('\\', '')
co... | [
"def",
"name",
"(",
"self",
",",
"new_name",
")",
":",
"if",
"self",
".",
"script_file",
":",
"content",
"=",
"self",
".",
"startup_script",
"content",
"=",
"content",
".",
"replace",
"(",
"self",
".",
"_name",
",",
"new_name",
")",
"escaped_name",
"=",
... | Sets the name of this VPCS VM.
:param new_name: name | [
"Sets",
"the",
"name",
"of",
"this",
"VPCS",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L152-L166 | train |
GNS3/gns3-server | gns3server/compute/vpcs/vpcs_vm.py | VPCSVM.startup_script | def startup_script(self):
"""
Returns the content of the current startup script
"""
script_file = self.script_file
if script_file is None:
return None
try:
with open(script_file, "rb") as f:
return f.read().decode("utf-8", errors=... | python | def startup_script(self):
"""
Returns the content of the current startup script
"""
script_file = self.script_file
if script_file is None:
return None
try:
with open(script_file, "rb") as f:
return f.read().decode("utf-8", errors=... | [
"def",
"startup_script",
"(",
"self",
")",
":",
"script_file",
"=",
"self",
".",
"script_file",
"if",
"script_file",
"is",
"None",
":",
"return",
"None",
"try",
":",
"with",
"open",
"(",
"script_file",
",",
"\"rb\"",
")",
"as",
"f",
":",
"return",
"f",
... | Returns the content of the current startup script | [
"Returns",
"the",
"content",
"of",
"the",
"current",
"startup",
"script"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L169-L182 | train |
GNS3/gns3-server | gns3server/compute/vpcs/vpcs_vm.py | VPCSVM.startup_script | def startup_script(self, startup_script):
"""
Updates the startup script.
:param startup_script: content of the startup script
"""
try:
startup_script_path = os.path.join(self.working_dir, 'startup.vpc')
with open(startup_script_path, "w+", encoding='utf... | python | def startup_script(self, startup_script):
"""
Updates the startup script.
:param startup_script: content of the startup script
"""
try:
startup_script_path = os.path.join(self.working_dir, 'startup.vpc')
with open(startup_script_path, "w+", encoding='utf... | [
"def",
"startup_script",
"(",
"self",
",",
"startup_script",
")",
":",
"try",
":",
"startup_script_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"working_dir",
",",
"'startup.vpc'",
")",
"with",
"open",
"(",
"startup_script_path",
",",
"\"w+\... | Updates the startup script.
:param startup_script: content of the startup script | [
"Updates",
"the",
"startup",
"script",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L185-L201 | train |
GNS3/gns3-server | gns3server/compute/vpcs/vpcs_vm.py | VPCSVM._check_vpcs_version | def _check_vpcs_version(self):
"""
Checks if the VPCS executable version is >= 0.8b or == 0.6.1.
"""
try:
output = yield from subprocess_check_output(self._vpcs_path(), "-v", cwd=self.working_dir)
match = re.search("Welcome to Virtual PC Simulator, version ([0-9a-... | python | def _check_vpcs_version(self):
"""
Checks if the VPCS executable version is >= 0.8b or == 0.6.1.
"""
try:
output = yield from subprocess_check_output(self._vpcs_path(), "-v", cwd=self.working_dir)
match = re.search("Welcome to Virtual PC Simulator, version ([0-9a-... | [
"def",
"_check_vpcs_version",
"(",
"self",
")",
":",
"try",
":",
"output",
"=",
"yield",
"from",
"subprocess_check_output",
"(",
"self",
".",
"_vpcs_path",
"(",
")",
",",
"\"-v\"",
",",
"cwd",
"=",
"self",
".",
"working_dir",
")",
"match",
"=",
"re",
"."... | Checks if the VPCS executable version is >= 0.8b or == 0.6.1. | [
"Checks",
"if",
"the",
"VPCS",
"executable",
"version",
"is",
">",
"=",
"0",
".",
"8b",
"or",
"==",
"0",
".",
"6",
".",
"1",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L204-L219 | train |
GNS3/gns3-server | gns3server/compute/vpcs/vpcs_vm.py | VPCSVM.start | def start(self):
"""
Starts the VPCS process.
"""
yield from self._check_requirements()
if not self.is_running():
nio = self._ethernet_adapter.get_nio(0)
command = self._build_command()
try:
log.info("Starting VPCS: {}".format(... | python | def start(self):
"""
Starts the VPCS process.
"""
yield from self._check_requirements()
if not self.is_running():
nio = self._ethernet_adapter.get_nio(0)
command = self._build_command()
try:
log.info("Starting VPCS: {}".format(... | [
"def",
"start",
"(",
"self",
")",
":",
"yield",
"from",
"self",
".",
"_check_requirements",
"(",
")",
"if",
"not",
"self",
".",
"is_running",
"(",
")",
":",
"nio",
"=",
"self",
".",
"_ethernet_adapter",
".",
"get_nio",
"(",
"0",
")",
"command",
"=",
... | Starts the VPCS process. | [
"Starts",
"the",
"VPCS",
"process",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L222-L259 | train |
GNS3/gns3-server | gns3server/compute/vpcs/vpcs_vm.py | VPCSVM.stop | def stop(self):
"""
Stops the VPCS process.
"""
yield from self._stop_ubridge()
if self.is_running():
self._terminate_process()
if self._process.returncode is None:
try:
yield from wait_for_process_termination(self._pro... | python | def stop(self):
"""
Stops the VPCS process.
"""
yield from self._stop_ubridge()
if self.is_running():
self._terminate_process()
if self._process.returncode is None:
try:
yield from wait_for_process_termination(self._pro... | [
"def",
"stop",
"(",
"self",
")",
":",
"yield",
"from",
"self",
".",
"_stop_ubridge",
"(",
")",
"if",
"self",
".",
"is_running",
"(",
")",
":",
"self",
".",
"_terminate_process",
"(",
")",
"if",
"self",
".",
"_process",
".",
"returncode",
"is",
"None",
... | Stops the VPCS process. | [
"Stops",
"the",
"VPCS",
"process",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L276-L298 | train |
GNS3/gns3-server | gns3server/compute/vpcs/vpcs_vm.py | VPCSVM._terminate_process | def _terminate_process(self):
"""
Terminate the process if running
"""
log.info("Stopping VPCS instance {} PID={}".format(self.name, self._process.pid))
if sys.platform.startswith("win32"):
self._process.send_signal(signal.CTRL_BREAK_EVENT)
else:
... | python | def _terminate_process(self):
"""
Terminate the process if running
"""
log.info("Stopping VPCS instance {} PID={}".format(self.name, self._process.pid))
if sys.platform.startswith("win32"):
self._process.send_signal(signal.CTRL_BREAK_EVENT)
else:
... | [
"def",
"_terminate_process",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"\"Stopping VPCS instance {} PID={}\"",
".",
"format",
"(",
"self",
".",
"name",
",",
"self",
".",
"_process",
".",
"pid",
")",
")",
"if",
"sys",
".",
"platform",
".",
"startswith... | Terminate the process if running | [
"Terminate",
"the",
"process",
"if",
"running"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L309-L322 | train |
GNS3/gns3-server | gns3server/compute/vpcs/vpcs_vm.py | VPCSVM.read_vpcs_stdout | def read_vpcs_stdout(self):
"""
Reads the standard output of the VPCS process.
Only use when the process has been stopped or has crashed.
"""
output = ""
if self._vpcs_stdout_file:
try:
with open(self._vpcs_stdout_file, "rb") as file:
... | python | def read_vpcs_stdout(self):
"""
Reads the standard output of the VPCS process.
Only use when the process has been stopped or has crashed.
"""
output = ""
if self._vpcs_stdout_file:
try:
with open(self._vpcs_stdout_file, "rb") as file:
... | [
"def",
"read_vpcs_stdout",
"(",
"self",
")",
":",
"output",
"=",
"\"\"",
"if",
"self",
".",
"_vpcs_stdout_file",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"_vpcs_stdout_file",
",",
"\"rb\"",
")",
"as",
"file",
":",
"output",
"=",
"file",
".",
... | Reads the standard output of the VPCS process.
Only use when the process has been stopped or has crashed. | [
"Reads",
"the",
"standard",
"output",
"of",
"the",
"VPCS",
"process",
".",
"Only",
"use",
"when",
"the",
"process",
"has",
"been",
"stopped",
"or",
"has",
"crashed",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L324-L337 | train |
GNS3/gns3-server | gns3server/compute/vpcs/vpcs_vm.py | VPCSVM.script_file | def script_file(self):
"""
Returns the startup script file for this VPCS VM.
:returns: path to startup script file
"""
# use the default VPCS file if it exists
path = os.path.join(self.working_dir, 'startup.vpc')
if os.path.exists(path):
return path
... | python | def script_file(self):
"""
Returns the startup script file for this VPCS VM.
:returns: path to startup script file
"""
# use the default VPCS file if it exists
path = os.path.join(self.working_dir, 'startup.vpc')
if os.path.exists(path):
return path
... | [
"def",
"script_file",
"(",
"self",
")",
":",
"# use the default VPCS file if it exists",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"working_dir",
",",
"'startup.vpc'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",... | Returns the startup script file for this VPCS VM.
:returns: path to startup script file | [
"Returns",
"the",
"startup",
"script",
"file",
"for",
"this",
"VPCS",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vpcs/vpcs_vm.py#L539-L551 | train |
GNS3/gns3-server | gns3server/utils/interfaces.py | get_windows_interfaces | def get_windows_interfaces():
"""
Get Windows interfaces.
:returns: list of windows interfaces
"""
import win32com.client
import pywintypes
interfaces = []
try:
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
service = locator.ConnectServer(".", "root\... | python | def get_windows_interfaces():
"""
Get Windows interfaces.
:returns: list of windows interfaces
"""
import win32com.client
import pywintypes
interfaces = []
try:
locator = win32com.client.Dispatch("WbemScripting.SWbemLocator")
service = locator.ConnectServer(".", "root\... | [
"def",
"get_windows_interfaces",
"(",
")",
":",
"import",
"win32com",
".",
"client",
"import",
"pywintypes",
"interfaces",
"=",
"[",
"]",
"try",
":",
"locator",
"=",
"win32com",
".",
"client",
".",
"Dispatch",
"(",
"\"WbemScripting.SWbemLocator\"",
")",
"service... | Get Windows interfaces.
:returns: list of windows interfaces | [
"Get",
"Windows",
"interfaces",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/interfaces.py#L79-L119 | train |
GNS3/gns3-server | gns3server/utils/interfaces.py | has_netmask | def has_netmask(interface_name):
"""
Checks if an interface has a netmask.
:param interface: interface name
:returns: boolean
"""
for interface in interfaces():
if interface["name"] == interface_name:
if interface["netmask"] and len(interface["netmask"]) > 0:
... | python | def has_netmask(interface_name):
"""
Checks if an interface has a netmask.
:param interface: interface name
:returns: boolean
"""
for interface in interfaces():
if interface["name"] == interface_name:
if interface["netmask"] and len(interface["netmask"]) > 0:
... | [
"def",
"has_netmask",
"(",
"interface_name",
")",
":",
"for",
"interface",
"in",
"interfaces",
"(",
")",
":",
"if",
"interface",
"[",
"\"name\"",
"]",
"==",
"interface_name",
":",
"if",
"interface",
"[",
"\"netmask\"",
"]",
"and",
"len",
"(",
"interface",
... | Checks if an interface has a netmask.
:param interface: interface name
:returns: boolean | [
"Checks",
"if",
"an",
"interface",
"has",
"a",
"netmask",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/interfaces.py#L122-L135 | train |
GNS3/gns3-server | gns3server/utils/interfaces.py | is_interface_up | def is_interface_up(interface):
"""
Checks if an interface is up.
:param interface: interface name
:returns: boolean
"""
if sys.platform.startswith("linux"):
if interface not in psutil.net_if_addrs():
return False
import fcntl
SIOCGIFFLAGS = 0x8913
... | python | def is_interface_up(interface):
"""
Checks if an interface is up.
:param interface: interface name
:returns: boolean
"""
if sys.platform.startswith("linux"):
if interface not in psutil.net_if_addrs():
return False
import fcntl
SIOCGIFFLAGS = 0x8913
... | [
"def",
"is_interface_up",
"(",
"interface",
")",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"linux\"",
")",
":",
"if",
"interface",
"not",
"in",
"psutil",
".",
"net_if_addrs",
"(",
")",
":",
"return",
"False",
"import",
"fcntl",
"SIOCGIFF... | Checks if an interface is up.
:param interface: interface name
:returns: boolean | [
"Checks",
"if",
"an",
"interface",
"is",
"up",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/interfaces.py#L138-L165 | train |
GNS3/gns3-server | gns3server/utils/interfaces.py | interfaces | def interfaces():
"""
Gets the network interfaces on this server.
:returns: list of network interfaces
"""
results = []
if not sys.platform.startswith("win"):
net_if_addrs = psutil.net_if_addrs()
for interface in sorted(net_if_addrs.keys()):
ip_address = ""
... | python | def interfaces():
"""
Gets the network interfaces on this server.
:returns: list of network interfaces
"""
results = []
if not sys.platform.startswith("win"):
net_if_addrs = psutil.net_if_addrs()
for interface in sorted(net_if_addrs.keys()):
ip_address = ""
... | [
"def",
"interfaces",
"(",
")",
":",
"results",
"=",
"[",
"]",
"if",
"not",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"win\"",
")",
":",
"net_if_addrs",
"=",
"psutil",
".",
"net_if_addrs",
"(",
")",
"for",
"interface",
"in",
"sorted",
"(",
"net_... | Gets the network interfaces on this server.
:returns: list of network interfaces | [
"Gets",
"the",
"network",
"interfaces",
"on",
"this",
"server",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/interfaces.py#L192-L251 | train |
GNS3/gns3-server | gns3server/controller/gns3vm/vmware_gns3_vm.py | VMwareGNS3VM._set_vcpus_ram | def _set_vcpus_ram(self, vcpus, ram):
"""
Set the number of vCPU cores and amount of RAM for the GNS3 VM.
:param vcpus: number of vCPU cores
:param ram: amount of RAM
"""
# memory must be a multiple of 4 (VMware requirement)
if ram % 4 != 0:
raise GN... | python | def _set_vcpus_ram(self, vcpus, ram):
"""
Set the number of vCPU cores and amount of RAM for the GNS3 VM.
:param vcpus: number of vCPU cores
:param ram: amount of RAM
"""
# memory must be a multiple of 4 (VMware requirement)
if ram % 4 != 0:
raise GN... | [
"def",
"_set_vcpus_ram",
"(",
"self",
",",
"vcpus",
",",
"ram",
")",
":",
"# memory must be a multiple of 4 (VMware requirement)",
"if",
"ram",
"%",
"4",
"!=",
"0",
":",
"raise",
"GNS3VMError",
"(",
"\"Allocated memory {} for the GNS3 VM must be a multiple of 4\"",
".",
... | Set the number of vCPU cores and amount of RAM for the GNS3 VM.
:param vcpus: number of vCPU cores
:param ram: amount of RAM | [
"Set",
"the",
"number",
"of",
"vCPU",
"cores",
"and",
"amount",
"of",
"RAM",
"for",
"the",
"GNS3",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/gns3vm/vmware_gns3_vm.py#L63-L86 | train |
GNS3/gns3-server | gns3server/controller/gns3vm/vmware_gns3_vm.py | VMwareGNS3VM.list | def list(self):
"""
List all VMware VMs
"""
try:
return (yield from self._vmware_manager.list_vms())
except VMwareError as e:
raise GNS3VMError("Could not list VMware VMs: {}".format(str(e))) | python | def list(self):
"""
List all VMware VMs
"""
try:
return (yield from self._vmware_manager.list_vms())
except VMwareError as e:
raise GNS3VMError("Could not list VMware VMs: {}".format(str(e))) | [
"def",
"list",
"(",
"self",
")",
":",
"try",
":",
"return",
"(",
"yield",
"from",
"self",
".",
"_vmware_manager",
".",
"list_vms",
"(",
")",
")",
"except",
"VMwareError",
"as",
"e",
":",
"raise",
"GNS3VMError",
"(",
"\"Could not list VMware VMs: {}\"",
".",
... | List all VMware VMs | [
"List",
"all",
"VMware",
"VMs"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/gns3vm/vmware_gns3_vm.py#L113-L120 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM._read_vmx_file | def _read_vmx_file(self):
"""
Reads from the VMware VMX file corresponding to this VM.
"""
try:
self._vmx_pairs = self.manager.parse_vmware_file(self._vmx_path)
except OSError as e:
raise VMwareError('Could not read VMware VMX file "{}": {}'.format(self._... | python | def _read_vmx_file(self):
"""
Reads from the VMware VMX file corresponding to this VM.
"""
try:
self._vmx_pairs = self.manager.parse_vmware_file(self._vmx_path)
except OSError as e:
raise VMwareError('Could not read VMware VMX file "{}": {}'.format(self._... | [
"def",
"_read_vmx_file",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_vmx_pairs",
"=",
"self",
".",
"manager",
".",
"parse_vmware_file",
"(",
"self",
".",
"_vmx_path",
")",
"except",
"OSError",
"as",
"e",
":",
"raise",
"VMwareError",
"(",
"'Could not ... | Reads from the VMware VMX file corresponding to this VM. | [
"Reads",
"from",
"the",
"VMware",
"VMX",
"file",
"corresponding",
"to",
"this",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L107-L115 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM._write_vmx_file | def _write_vmx_file(self):
"""
Writes pairs to the VMware VMX file corresponding to this VM.
"""
try:
self.manager.write_vmx_file(self._vmx_path, self._vmx_pairs)
except OSError as e:
raise VMwareError('Could not write VMware VMX file "{}": {}'.format(sel... | python | def _write_vmx_file(self):
"""
Writes pairs to the VMware VMX file corresponding to this VM.
"""
try:
self.manager.write_vmx_file(self._vmx_path, self._vmx_pairs)
except OSError as e:
raise VMwareError('Could not write VMware VMX file "{}": {}'.format(sel... | [
"def",
"_write_vmx_file",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"manager",
".",
"write_vmx_file",
"(",
"self",
".",
"_vmx_path",
",",
"self",
".",
"_vmx_pairs",
")",
"except",
"OSError",
"as",
"e",
":",
"raise",
"VMwareError",
"(",
"'Could not wr... | Writes pairs to the VMware VMX file corresponding to this VM. | [
"Writes",
"pairs",
"to",
"the",
"VMware",
"VMX",
"file",
"corresponding",
"to",
"this",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L117-L125 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM.create | def create(self):
"""
Creates this VM and handle linked clones.
"""
if not self.linked_clone:
yield from self._check_duplicate_linked_clone()
yield from self.manager.check_vmrun_version()
if self.linked_clone and not os.path.exists(os.path.join(self.working_d... | python | def create(self):
"""
Creates this VM and handle linked clones.
"""
if not self.linked_clone:
yield from self._check_duplicate_linked_clone()
yield from self.manager.check_vmrun_version()
if self.linked_clone and not os.path.exists(os.path.join(self.working_d... | [
"def",
"create",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"linked_clone",
":",
"yield",
"from",
"self",
".",
"_check_duplicate_linked_clone",
"(",
")",
"yield",
"from",
"self",
".",
"manager",
".",
"check_vmrun_version",
"(",
")",
"if",
"self",
"."... | Creates this VM and handle linked clones. | [
"Creates",
"this",
"VM",
"and",
"handle",
"linked",
"clones",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L163-L233 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM._set_network_options | def _set_network_options(self):
"""
Set up VMware networking.
"""
# first some sanity checks
for adapter_number in range(0, self._adapters):
# we want the vmnet interface to be connected when starting the VM
connected = "ethernet{}.startConnected".format... | python | def _set_network_options(self):
"""
Set up VMware networking.
"""
# first some sanity checks
for adapter_number in range(0, self._adapters):
# we want the vmnet interface to be connected when starting the VM
connected = "ethernet{}.startConnected".format... | [
"def",
"_set_network_options",
"(",
"self",
")",
":",
"# first some sanity checks",
"for",
"adapter_number",
"in",
"range",
"(",
"0",
",",
"self",
".",
"_adapters",
")",
":",
"# we want the vmnet interface to be connected when starting the VM",
"connected",
"=",
"\"ethern... | Set up VMware networking. | [
"Set",
"up",
"VMware",
"networking",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L245-L311 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM._get_vnet | def _get_vnet(self, adapter_number):
"""
Return the vnet will use in ubridge
"""
vnet = "ethernet{}.vnet".format(adapter_number)
if vnet not in self._vmx_pairs:
raise VMwareError("vnet {} not in VMX file".format(vnet))
return vnet | python | def _get_vnet(self, adapter_number):
"""
Return the vnet will use in ubridge
"""
vnet = "ethernet{}.vnet".format(adapter_number)
if vnet not in self._vmx_pairs:
raise VMwareError("vnet {} not in VMX file".format(vnet))
return vnet | [
"def",
"_get_vnet",
"(",
"self",
",",
"adapter_number",
")",
":",
"vnet",
"=",
"\"ethernet{}.vnet\"",
".",
"format",
"(",
"adapter_number",
")",
"if",
"vnet",
"not",
"in",
"self",
".",
"_vmx_pairs",
":",
"raise",
"VMwareError",
"(",
"\"vnet {} not in VMX file\""... | Return the vnet will use in ubridge | [
"Return",
"the",
"vnet",
"will",
"use",
"in",
"ubridge"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L313-L320 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM._update_ubridge_connection | def _update_ubridge_connection(self, adapter_number, nio):
"""
Update a connection in uBridge.
:param nio: NIO instance
:param adapter_number: adapter number
"""
try:
bridge_name = self._get_vnet(adapter_number)
except VMwareError:
return ... | python | def _update_ubridge_connection(self, adapter_number, nio):
"""
Update a connection in uBridge.
:param nio: NIO instance
:param adapter_number: adapter number
"""
try:
bridge_name = self._get_vnet(adapter_number)
except VMwareError:
return ... | [
"def",
"_update_ubridge_connection",
"(",
"self",
",",
"adapter_number",
",",
"nio",
")",
":",
"try",
":",
"bridge_name",
"=",
"self",
".",
"_get_vnet",
"(",
"adapter_number",
")",
"except",
"VMwareError",
":",
"return",
"# vnet not yet available",
"yield",
"from"... | Update a connection in uBridge.
:param nio: NIO instance
:param adapter_number: adapter number | [
"Update",
"a",
"connection",
"in",
"uBridge",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L355-L366 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM.start | def start(self):
"""
Starts this VMware VM.
"""
if self.status == "started":
return
if (yield from self.is_running()):
raise VMwareError("The VM is already running in VMware")
ubridge_path = self.ubridge_path
if not ubridge_path or not o... | python | def start(self):
"""
Starts this VMware VM.
"""
if self.status == "started":
return
if (yield from self.is_running()):
raise VMwareError("The VM is already running in VMware")
ubridge_path = self.ubridge_path
if not ubridge_path or not o... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"status",
"==",
"\"started\"",
":",
"return",
"if",
"(",
"yield",
"from",
"self",
".",
"is_running",
"(",
")",
")",
":",
"raise",
"VMwareError",
"(",
"\"The VM is already running in VMware\"",
")",
... | Starts this VMware VM. | [
"Starts",
"this",
"VMware",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L426-L472 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM.stop | def stop(self):
"""
Stops this VMware VM.
"""
self._hw_virtualization = False
yield from self._stop_remote_console()
yield from self._stop_ubridge()
try:
if (yield from self.is_running()):
if self.acpi_shutdown:
# ... | python | def stop(self):
"""
Stops this VMware VM.
"""
self._hw_virtualization = False
yield from self._stop_remote_console()
yield from self._stop_ubridge()
try:
if (yield from self.is_running()):
if self.acpi_shutdown:
# ... | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"_hw_virtualization",
"=",
"False",
"yield",
"from",
"self",
".",
"_stop_remote_console",
"(",
")",
"yield",
"from",
"self",
".",
"_stop_ubridge",
"(",
")",
"try",
":",
"if",
"(",
"yield",
"from",
"self"... | Stops this VMware VM. | [
"Stops",
"this",
"VMware",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L475-L517 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM.suspend | def suspend(self):
"""
Suspends this VMware VM.
"""
if self.manager.host_type != "ws":
raise VMwareError("Pausing a VM is only supported by VMware Workstation")
yield from self._control_vm("pause")
self.status = "suspended"
log.info("VMware VM '{name}... | python | def suspend(self):
"""
Suspends this VMware VM.
"""
if self.manager.host_type != "ws":
raise VMwareError("Pausing a VM is only supported by VMware Workstation")
yield from self._control_vm("pause")
self.status = "suspended"
log.info("VMware VM '{name}... | [
"def",
"suspend",
"(",
"self",
")",
":",
"if",
"self",
".",
"manager",
".",
"host_type",
"!=",
"\"ws\"",
":",
"raise",
"VMwareError",
"(",
"\"Pausing a VM is only supported by VMware Workstation\"",
")",
"yield",
"from",
"self",
".",
"_control_vm",
"(",
"\"pause\"... | Suspends this VMware VM. | [
"Suspends",
"this",
"VMware",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L520-L529 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM.close | def close(self):
"""
Closes this VMware VM.
"""
if not (yield from super().close()):
return False
for adapter in self._ethernet_adapters.values():
if adapter is not None:
for nio in adapter.ports.values():
if nio and i... | python | def close(self):
"""
Closes this VMware VM.
"""
if not (yield from super().close()):
return False
for adapter in self._ethernet_adapters.values():
if adapter is not None:
for nio in adapter.ports.values():
if nio and i... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"(",
"yield",
"from",
"super",
"(",
")",
".",
"close",
"(",
")",
")",
":",
"return",
"False",
"for",
"adapter",
"in",
"self",
".",
"_ethernet_adapters",
".",
"values",
"(",
")",
":",
"if",
"adapte... | Closes this VMware VM. | [
"Closes",
"this",
"VMware",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L553-L573 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM.headless | def headless(self, headless):
"""
Sets either the VM will start in headless mode
:param headless: boolean
"""
if headless:
log.info("VMware VM '{name}' [{id}] has enabled the headless mode".format(name=self.name, id=self.id))
else:
log.info("VMwa... | python | def headless(self, headless):
"""
Sets either the VM will start in headless mode
:param headless: boolean
"""
if headless:
log.info("VMware VM '{name}' [{id}] has enabled the headless mode".format(name=self.name, id=self.id))
else:
log.info("VMwa... | [
"def",
"headless",
"(",
"self",
",",
"headless",
")",
":",
"if",
"headless",
":",
"log",
".",
"info",
"(",
"\"VMware VM '{name}' [{id}] has enabled the headless mode\"",
".",
"format",
"(",
"name",
"=",
"self",
".",
"name",
",",
"id",
"=",
"self",
".",
"id",... | Sets either the VM will start in headless mode
:param headless: boolean | [
"Sets",
"either",
"the",
"VM",
"will",
"start",
"in",
"headless",
"mode"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L586-L597 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM.vmx_path | def vmx_path(self, vmx_path):
"""
Sets the path to the vmx file.
:param vmx_path: VMware vmx file
"""
log.info("VMware VM '{name}' [{id}] has set the vmx file path to '{vmx}'".format(name=self.name, id=self.id, vmx=vmx_path))
self._vmx_path = vmx_path | python | def vmx_path(self, vmx_path):
"""
Sets the path to the vmx file.
:param vmx_path: VMware vmx file
"""
log.info("VMware VM '{name}' [{id}] has set the vmx file path to '{vmx}'".format(name=self.name, id=self.id, vmx=vmx_path))
self._vmx_path = vmx_path | [
"def",
"vmx_path",
"(",
"self",
",",
"vmx_path",
")",
":",
"log",
".",
"info",
"(",
"\"VMware VM '{name}' [{id}] has set the vmx file path to '{vmx}'\"",
".",
"format",
"(",
"name",
"=",
"self",
".",
"name",
",",
"id",
"=",
"self",
".",
"id",
",",
"vmx",
"="... | Sets the path to the vmx file.
:param vmx_path: VMware vmx file | [
"Sets",
"the",
"path",
"to",
"the",
"vmx",
"file",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L634-L642 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM.adapters | def adapters(self, adapters):
"""
Sets the number of Ethernet adapters for this VMware VM instance.
:param adapters: number of adapters
"""
# VMware VMs are limited to 10 adapters
if adapters > 10:
raise VMwareError("Number of adapters above the maximum supp... | python | def adapters(self, adapters):
"""
Sets the number of Ethernet adapters for this VMware VM instance.
:param adapters: number of adapters
"""
# VMware VMs are limited to 10 adapters
if adapters > 10:
raise VMwareError("Number of adapters above the maximum supp... | [
"def",
"adapters",
"(",
"self",
",",
"adapters",
")",
":",
"# VMware VMs are limited to 10 adapters",
"if",
"adapters",
">",
"10",
":",
"raise",
"VMwareError",
"(",
"\"Number of adapters above the maximum supported of 10\"",
")",
"self",
".",
"_ethernet_adapters",
".",
... | Sets the number of Ethernet adapters for this VMware VM instance.
:param adapters: number of adapters | [
"Sets",
"the",
"number",
"of",
"Ethernet",
"adapters",
"for",
"this",
"VMware",
"VM",
"instance",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L655-L673 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM.adapter_type | def adapter_type(self, adapter_type):
"""
Sets the adapter type for this VMware VM instance.
:param adapter_type: adapter type (string)
"""
self._adapter_type = adapter_type
log.info("VMware VM '{name}' [{id}]: adapter type changed to {adapter_type}".format(name=self.na... | python | def adapter_type(self, adapter_type):
"""
Sets the adapter type for this VMware VM instance.
:param adapter_type: adapter type (string)
"""
self._adapter_type = adapter_type
log.info("VMware VM '{name}' [{id}]: adapter type changed to {adapter_type}".format(name=self.na... | [
"def",
"adapter_type",
"(",
"self",
",",
"adapter_type",
")",
":",
"self",
".",
"_adapter_type",
"=",
"adapter_type",
"log",
".",
"info",
"(",
"\"VMware VM '{name}' [{id}]: adapter type changed to {adapter_type}\"",
".",
"format",
"(",
"name",
"=",
"self",
".",
"nam... | Sets the adapter type for this VMware VM instance.
:param adapter_type: adapter type (string) | [
"Sets",
"the",
"adapter",
"type",
"for",
"this",
"VMware",
"VM",
"instance",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L686-L696 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM.use_any_adapter | def use_any_adapter(self, use_any_adapter):
"""
Allows GNS3 to use any VMware adapter on this instance.
:param use_any_adapter: boolean
"""
if use_any_adapter:
log.info("VMware VM '{name}' [{id}] is allowed to use any adapter".format(name=self.name, id=self.id))
... | python | def use_any_adapter(self, use_any_adapter):
"""
Allows GNS3 to use any VMware adapter on this instance.
:param use_any_adapter: boolean
"""
if use_any_adapter:
log.info("VMware VM '{name}' [{id}] is allowed to use any adapter".format(name=self.name, id=self.id))
... | [
"def",
"use_any_adapter",
"(",
"self",
",",
"use_any_adapter",
")",
":",
"if",
"use_any_adapter",
":",
"log",
".",
"info",
"(",
"\"VMware VM '{name}' [{id}] is allowed to use any adapter\"",
".",
"format",
"(",
"name",
"=",
"self",
".",
"name",
",",
"id",
"=",
"... | Allows GNS3 to use any VMware adapter on this instance.
:param use_any_adapter: boolean | [
"Allows",
"GNS3",
"to",
"use",
"any",
"VMware",
"adapter",
"on",
"this",
"instance",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L709-L720 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM._get_pipe_name | def _get_pipe_name(self):
"""
Returns the pipe name to create a serial connection.
:returns: pipe path (string)
"""
if sys.platform.startswith("win"):
pipe_name = r"\\.\pipe\gns3_vmware\{}".format(self.id)
else:
pipe_name = os.path.join(tempfile.... | python | def _get_pipe_name(self):
"""
Returns the pipe name to create a serial connection.
:returns: pipe path (string)
"""
if sys.platform.startswith("win"):
pipe_name = r"\\.\pipe\gns3_vmware\{}".format(self.id)
else:
pipe_name = os.path.join(tempfile.... | [
"def",
"_get_pipe_name",
"(",
"self",
")",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"win\"",
")",
":",
"pipe_name",
"=",
"r\"\\\\.\\pipe\\gns3_vmware\\{}\"",
".",
"format",
"(",
"self",
".",
"id",
")",
"else",
":",
"pipe_name",
"=",
"os... | Returns the pipe name to create a serial connection.
:returns: pipe path (string) | [
"Returns",
"the",
"pipe",
"name",
"to",
"create",
"a",
"serial",
"connection",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L811-L826 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM._start_console | def _start_console(self):
"""
Starts remote console support for this VM.
"""
self._remote_pipe = yield from asyncio_open_serial(self._get_pipe_name())
server = AsyncioTelnetServer(reader=self._remote_pipe,
writer=self._remote_pipe,
... | python | def _start_console(self):
"""
Starts remote console support for this VM.
"""
self._remote_pipe = yield from asyncio_open_serial(self._get_pipe_name())
server = AsyncioTelnetServer(reader=self._remote_pipe,
writer=self._remote_pipe,
... | [
"def",
"_start_console",
"(",
"self",
")",
":",
"self",
".",
"_remote_pipe",
"=",
"yield",
"from",
"asyncio_open_serial",
"(",
"self",
".",
"_get_pipe_name",
"(",
")",
")",
"server",
"=",
"AsyncioTelnetServer",
"(",
"reader",
"=",
"self",
".",
"_remote_pipe",
... | Starts remote console support for this VM. | [
"Starts",
"remote",
"console",
"support",
"for",
"this",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L842-L851 | train |
GNS3/gns3-server | gns3server/compute/vmware/vmware_vm.py | VMwareVM._stop_remote_console | def _stop_remote_console(self):
"""
Stops remote console support for this VM.
"""
if self._telnet_server:
self._telnet_server.close()
yield from self._telnet_server.wait_closed()
self._remote_pipe.close()
self._telnet_server = None | python | def _stop_remote_console(self):
"""
Stops remote console support for this VM.
"""
if self._telnet_server:
self._telnet_server.close()
yield from self._telnet_server.wait_closed()
self._remote_pipe.close()
self._telnet_server = None | [
"def",
"_stop_remote_console",
"(",
"self",
")",
":",
"if",
"self",
".",
"_telnet_server",
":",
"self",
".",
"_telnet_server",
".",
"close",
"(",
")",
"yield",
"from",
"self",
".",
"_telnet_server",
".",
"wait_closed",
"(",
")",
"self",
".",
"_remote_pipe",
... | Stops remote console support for this VM. | [
"Stops",
"remote",
"console",
"support",
"for",
"this",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/vmware/vmware_vm.py#L854-L862 | train |
GNS3/gns3-server | gns3server/utils/path.py | get_default_project_directory | def get_default_project_directory():
"""
Return the default location for the project directory
depending of the operating system
"""
server_config = Config.instance().get_section_config("Server")
path = os.path.expanduser(server_config.get("projects_path", "~/GNS3/projects"))
path = os.path... | python | def get_default_project_directory():
"""
Return the default location for the project directory
depending of the operating system
"""
server_config = Config.instance().get_section_config("Server")
path = os.path.expanduser(server_config.get("projects_path", "~/GNS3/projects"))
path = os.path... | [
"def",
"get_default_project_directory",
"(",
")",
":",
"server_config",
"=",
"Config",
".",
"instance",
"(",
")",
".",
"get_section_config",
"(",
"\"Server\"",
")",
"path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"server_config",
".",
"get",
"(",
"\"... | Return the default location for the project directory
depending of the operating system | [
"Return",
"the",
"default",
"location",
"for",
"the",
"project",
"directory",
"depending",
"of",
"the",
"operating",
"system"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/path.py#L24-L37 | train |
GNS3/gns3-server | gns3server/utils/path.py | check_path_allowed | def check_path_allowed(path):
"""
If the server is non local raise an error if
the path is outside project directories
Raise a 403 in case of error
"""
config = Config.instance().get_section_config("Server")
project_directory = get_default_project_directory()
if len(os.path.commonpref... | python | def check_path_allowed(path):
"""
If the server is non local raise an error if
the path is outside project directories
Raise a 403 in case of error
"""
config = Config.instance().get_section_config("Server")
project_directory = get_default_project_directory()
if len(os.path.commonpref... | [
"def",
"check_path_allowed",
"(",
"path",
")",
":",
"config",
"=",
"Config",
".",
"instance",
"(",
")",
".",
"get_section_config",
"(",
"\"Server\"",
")",
"project_directory",
"=",
"get_default_project_directory",
"(",
")",
"if",
"len",
"(",
"os",
".",
"path",... | If the server is non local raise an error if
the path is outside project directories
Raise a 403 in case of error | [
"If",
"the",
"server",
"is",
"non",
"local",
"raise",
"an",
"error",
"if",
"the",
"path",
"is",
"outside",
"project",
"directories"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/path.py#L40-L55 | train |
GNS3/gns3-server | gns3server/compute/dynamips/nodes/ethernet_hub.py | EthernetHub.ports_mapping | def ports_mapping(self, ports):
"""
Set the ports on this hub
:param ports: ports info
"""
if ports != self._ports:
if len(self._mappings) > 0:
raise NodeError("Can't modify a hub already connected.")
port_number = 0
for port ... | python | def ports_mapping(self, ports):
"""
Set the ports on this hub
:param ports: ports info
"""
if ports != self._ports:
if len(self._mappings) > 0:
raise NodeError("Can't modify a hub already connected.")
port_number = 0
for port ... | [
"def",
"ports_mapping",
"(",
"self",
",",
"ports",
")",
":",
"if",
"ports",
"!=",
"self",
".",
"_ports",
":",
"if",
"len",
"(",
"self",
".",
"_mappings",
")",
">",
"0",
":",
"raise",
"NodeError",
"(",
"\"Can't modify a hub already connected.\"",
")",
"port... | Set the ports on this hub
:param ports: ports info | [
"Set",
"the",
"ports",
"on",
"this",
"hub"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_hub.py#L78-L94 | train |
GNS3/gns3-server | gns3server/compute/dynamips/nodes/ethernet_hub.py | EthernetHub.close | def close(self):
"""
Deletes this hub.
"""
for nio in self._nios:
if nio:
yield from nio.close()
try:
yield from Bridge.delete(self)
log.info('Ethernet hub "{name}" [{id}] has been deleted'.format(name=self._name, id=self._id)... | python | def close(self):
"""
Deletes this hub.
"""
for nio in self._nios:
if nio:
yield from nio.close()
try:
yield from Bridge.delete(self)
log.info('Ethernet hub "{name}" [{id}] has been deleted'.format(name=self._name, id=self._id)... | [
"def",
"close",
"(",
"self",
")",
":",
"for",
"nio",
"in",
"self",
".",
"_nios",
":",
"if",
"nio",
":",
"yield",
"from",
"nio",
".",
"close",
"(",
")",
"try",
":",
"yield",
"from",
"Bridge",
".",
"delete",
"(",
"self",
")",
"log",
".",
"info",
... | Deletes this hub. | [
"Deletes",
"this",
"hub",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_hub.py#L117-L134 | train |
GNS3/gns3-server | gns3server/compute/dynamips/nodes/ethernet_hub.py | EthernetHub.add_nio | def add_nio(self, nio, port_number):
"""
Adds a NIO as new port on this hub.
:param nio: NIO instance to add
:param port_number: port to allocate for the NIO
"""
if port_number not in [port["port_number"] for port in self._ports]:
raise DynamipsError("Port {... | python | def add_nio(self, nio, port_number):
"""
Adds a NIO as new port on this hub.
:param nio: NIO instance to add
:param port_number: port to allocate for the NIO
"""
if port_number not in [port["port_number"] for port in self._ports]:
raise DynamipsError("Port {... | [
"def",
"add_nio",
"(",
"self",
",",
"nio",
",",
"port_number",
")",
":",
"if",
"port_number",
"not",
"in",
"[",
"port",
"[",
"\"port_number\"",
"]",
"for",
"port",
"in",
"self",
".",
"_ports",
"]",
":",
"raise",
"DynamipsError",
"(",
"\"Port {} doesn't exi... | Adds a NIO as new port on this hub.
:param nio: NIO instance to add
:param port_number: port to allocate for the NIO | [
"Adds",
"a",
"NIO",
"as",
"new",
"port",
"on",
"this",
"hub",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_hub.py#L137-L157 | train |
GNS3/gns3-server | gns3server/compute/dynamips/nodes/ethernet_hub.py | EthernetHub.remove_nio | def remove_nio(self, port_number):
"""
Removes the specified NIO as member of this hub.
:param port_number: allocated port number
:returns: the NIO that was bound to the allocated port
"""
if port_number not in self._mappings:
raise DynamipsError("Port {} i... | python | def remove_nio(self, port_number):
"""
Removes the specified NIO as member of this hub.
:param port_number: allocated port number
:returns: the NIO that was bound to the allocated port
"""
if port_number not in self._mappings:
raise DynamipsError("Port {} i... | [
"def",
"remove_nio",
"(",
"self",
",",
"port_number",
")",
":",
"if",
"port_number",
"not",
"in",
"self",
".",
"_mappings",
":",
"raise",
"DynamipsError",
"(",
"\"Port {} is not allocated\"",
".",
"format",
"(",
"port_number",
")",
")",
"nio",
"=",
"self",
"... | Removes the specified NIO as member of this hub.
:param port_number: allocated port number
:returns: the NIO that was bound to the allocated port | [
"Removes",
"the",
"specified",
"NIO",
"as",
"member",
"of",
"this",
"hub",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_hub.py#L160-L183 | train |
GNS3/gns3-server | gns3server/compute/base_manager.py | BaseManager.instance | def instance(cls):
"""
Singleton to return only one instance of BaseManager.
:returns: instance of BaseManager
"""
if not hasattr(cls, "_instance") or cls._instance is None:
cls._instance = cls()
return cls._instance | python | def instance(cls):
"""
Singleton to return only one instance of BaseManager.
:returns: instance of BaseManager
"""
if not hasattr(cls, "_instance") or cls._instance is None:
cls._instance = cls()
return cls._instance | [
"def",
"instance",
"(",
"cls",
")",
":",
"if",
"not",
"hasattr",
"(",
"cls",
",",
"\"_instance\"",
")",
"or",
"cls",
".",
"_instance",
"is",
"None",
":",
"cls",
".",
"_instance",
"=",
"cls",
"(",
")",
"return",
"cls",
".",
"_instance"
] | Singleton to return only one instance of BaseManager.
:returns: instance of BaseManager | [
"Singleton",
"to",
"return",
"only",
"one",
"instance",
"of",
"BaseManager",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L78-L87 | train |
GNS3/gns3-server | gns3server/compute/base_manager.py | BaseManager.port_manager | def port_manager(self):
"""
Returns the port manager.
:returns: Port manager
"""
if self._port_manager is None:
self._port_manager = PortManager.instance()
return self._port_manager | python | def port_manager(self):
"""
Returns the port manager.
:returns: Port manager
"""
if self._port_manager is None:
self._port_manager = PortManager.instance()
return self._port_manager | [
"def",
"port_manager",
"(",
"self",
")",
":",
"if",
"self",
".",
"_port_manager",
"is",
"None",
":",
"self",
".",
"_port_manager",
"=",
"PortManager",
".",
"instance",
"(",
")",
"return",
"self",
".",
"_port_manager"
] | Returns the port manager.
:returns: Port manager | [
"Returns",
"the",
"port",
"manager",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L100-L108 | train |
GNS3/gns3-server | gns3server/compute/base_manager.py | BaseManager.convert_old_project | def convert_old_project(self, project, legacy_id, name):
"""
Convert projects made before version 1.3
:param project: Project instance
:param legacy_id: old identifier
:param name: node name
:returns: new identifier
"""
new_id = str(uuid4())
leg... | python | def convert_old_project(self, project, legacy_id, name):
"""
Convert projects made before version 1.3
:param project: Project instance
:param legacy_id: old identifier
:param name: node name
:returns: new identifier
"""
new_id = str(uuid4())
leg... | [
"def",
"convert_old_project",
"(",
"self",
",",
"project",
",",
"legacy_id",
",",
"name",
")",
":",
"new_id",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"legacy_project_files_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"project",
".",
"path",
",",
"... | Convert projects made before version 1.3
:param project: Project instance
:param legacy_id: old identifier
:param name: node name
:returns: new identifier | [
"Convert",
"projects",
"made",
"before",
"version",
"1",
".",
"3"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L175-L226 | train |
GNS3/gns3-server | gns3server/compute/base_manager.py | BaseManager.close_node | def close_node(self, node_id):
"""
Close a node
:param node_id: Node identifier
:returns: Node instance
"""
node = self.get_node(node_id)
if asyncio.iscoroutinefunction(node.close):
yield from node.close()
else:
node.close()
... | python | def close_node(self, node_id):
"""
Close a node
:param node_id: Node identifier
:returns: Node instance
"""
node = self.get_node(node_id)
if asyncio.iscoroutinefunction(node.close):
yield from node.close()
else:
node.close()
... | [
"def",
"close_node",
"(",
"self",
",",
"node_id",
")",
":",
"node",
"=",
"self",
".",
"get_node",
"(",
"node_id",
")",
"if",
"asyncio",
".",
"iscoroutinefunction",
"(",
"node",
".",
"close",
")",
":",
"yield",
"from",
"node",
".",
"close",
"(",
")",
... | Close a node
:param node_id: Node identifier
:returns: Node instance | [
"Close",
"a",
"node"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L291-L305 | train |
GNS3/gns3-server | gns3server/compute/base_manager.py | BaseManager.delete_node | def delete_node(self, node_id):
"""
Delete a node. The node working directory will be destroyed when a commit is received.
:param node_id: Node identifier
:returns: Node instance
"""
node = None
try:
node = self.get_node(node_id)
yield fr... | python | def delete_node(self, node_id):
"""
Delete a node. The node working directory will be destroyed when a commit is received.
:param node_id: Node identifier
:returns: Node instance
"""
node = None
try:
node = self.get_node(node_id)
yield fr... | [
"def",
"delete_node",
"(",
"self",
",",
"node_id",
")",
":",
"node",
"=",
"None",
"try",
":",
"node",
"=",
"self",
".",
"get_node",
"(",
"node_id",
")",
"yield",
"from",
"self",
".",
"close_node",
"(",
"node_id",
")",
"finally",
":",
"if",
"node",
":... | Delete a node. The node working directory will be destroyed when a commit is received.
:param node_id: Node identifier
:returns: Node instance | [
"Delete",
"a",
"node",
".",
"The",
"node",
"working",
"directory",
"will",
"be",
"destroyed",
"when",
"a",
"commit",
"is",
"received",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L330-L348 | train |
GNS3/gns3-server | gns3server/compute/base_manager.py | BaseManager.has_privileged_access | def has_privileged_access(executable):
"""
Check if an executable have the right to attach to Ethernet and TAP adapters.
:param executable: executable path
:returns: True or False
"""
if sys.platform.startswith("win"):
# do not check anything on Windows
... | python | def has_privileged_access(executable):
"""
Check if an executable have the right to attach to Ethernet and TAP adapters.
:param executable: executable path
:returns: True or False
"""
if sys.platform.startswith("win"):
# do not check anything on Windows
... | [
"def",
"has_privileged_access",
"(",
"executable",
")",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"win\"",
")",
":",
"# do not check anything on Windows",
"return",
"True",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"darwin\"",
")... | Check if an executable have the right to attach to Ethernet and TAP adapters.
:param executable: executable path
:returns: True or False | [
"Check",
"if",
"an",
"executable",
"have",
"the",
"right",
"to",
"attach",
"to",
"Ethernet",
"and",
"TAP",
"adapters",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L351-L386 | train |
GNS3/gns3-server | gns3server/compute/base_manager.py | BaseManager.get_abs_image_path | def get_abs_image_path(self, path):
"""
Get the absolute path of an image
:param path: file path
:return: file path
"""
if not path:
return ""
orig_path = path
server_config = self.config.get_section_config("Server")
img_directory = ... | python | def get_abs_image_path(self, path):
"""
Get the absolute path of an image
:param path: file path
:return: file path
"""
if not path:
return ""
orig_path = path
server_config = self.config.get_section_config("Server")
img_directory = ... | [
"def",
"get_abs_image_path",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"path",
":",
"return",
"\"\"",
"orig_path",
"=",
"path",
"server_config",
"=",
"self",
".",
"config",
".",
"get_section_config",
"(",
"\"Server\"",
")",
"img_directory",
"=",
"self... | Get the absolute path of an image
:param path: file path
:return: file path | [
"Get",
"the",
"absolute",
"path",
"of",
"an",
"image"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L430-L476 | train |
GNS3/gns3-server | gns3server/compute/base_manager.py | BaseManager._recursive_search_file_in_directory | def _recursive_search_file_in_directory(self, directory, searched_file):
"""
Search for a file in directory and is subdirectories
:returns: Path or None if not found
"""
s = os.path.split(searched_file)
for root, dirs, files in os.walk(directory):
for file i... | python | def _recursive_search_file_in_directory(self, directory, searched_file):
"""
Search for a file in directory and is subdirectories
:returns: Path or None if not found
"""
s = os.path.split(searched_file)
for root, dirs, files in os.walk(directory):
for file i... | [
"def",
"_recursive_search_file_in_directory",
"(",
"self",
",",
"directory",
",",
"searched_file",
")",
":",
"s",
"=",
"os",
".",
"path",
".",
"split",
"(",
"searched_file",
")",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"di... | Search for a file in directory and is subdirectories
:returns: Path or None if not found | [
"Search",
"for",
"a",
"file",
"in",
"directory",
"and",
"is",
"subdirectories"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L478-L493 | train |
GNS3/gns3-server | gns3server/compute/base_manager.py | BaseManager.get_relative_image_path | def get_relative_image_path(self, path):
"""
Get a path relative to images directory path
or an abspath if the path is not located inside
image directory
:param path: file path
:return: file path
"""
if not path:
return ""
path = forc... | python | def get_relative_image_path(self, path):
"""
Get a path relative to images directory path
or an abspath if the path is not located inside
image directory
:param path: file path
:return: file path
"""
if not path:
return ""
path = forc... | [
"def",
"get_relative_image_path",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"path",
":",
"return",
"\"\"",
"path",
"=",
"force_unix_path",
"(",
"self",
".",
"get_abs_image_path",
"(",
"path",
")",
")",
"img_directory",
"=",
"self",
".",
"get_images_di... | Get a path relative to images directory path
or an abspath if the path is not located inside
image directory
:param path: file path
:return: file path | [
"Get",
"a",
"path",
"relative",
"to",
"images",
"directory",
"path",
"or",
"an",
"abspath",
"if",
"the",
"path",
"is",
"not",
"located",
"inside",
"image",
"directory"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L495-L517 | train |
GNS3/gns3-server | gns3server/compute/base_manager.py | BaseManager.list_images | def list_images(self):
"""
Return the list of available images for this node type
:returns: Array of hash
"""
try:
return list_images(self._NODE_TYPE)
except OSError as e:
raise aiohttp.web.HTTPConflict(text="Can not list images {}".format(e)) | python | def list_images(self):
"""
Return the list of available images for this node type
:returns: Array of hash
"""
try:
return list_images(self._NODE_TYPE)
except OSError as e:
raise aiohttp.web.HTTPConflict(text="Can not list images {}".format(e)) | [
"def",
"list_images",
"(",
"self",
")",
":",
"try",
":",
"return",
"list_images",
"(",
"self",
".",
"_NODE_TYPE",
")",
"except",
"OSError",
"as",
"e",
":",
"raise",
"aiohttp",
".",
"web",
".",
"HTTPConflict",
"(",
"text",
"=",
"\"Can not list images {}\"",
... | Return the list of available images for this node type
:returns: Array of hash | [
"Return",
"the",
"list",
"of",
"available",
"images",
"for",
"this",
"node",
"type"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/base_manager.py#L520-L530 | train |
GNS3/gns3-server | gns3server/compute/dynamips/hypervisor.py | Hypervisor.start | def start(self):
"""
Starts the Dynamips hypervisor process.
"""
self._command = self._build_command()
env = os.environ.copy()
if sys.platform.startswith("win"):
# add the Npcap directory to $PATH to force Dynamips to use npcap DLL instead of Winpcap (if inst... | python | def start(self):
"""
Starts the Dynamips hypervisor process.
"""
self._command = self._build_command()
env = os.environ.copy()
if sys.platform.startswith("win"):
# add the Npcap directory to $PATH to force Dynamips to use npcap DLL instead of Winpcap (if inst... | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"_command",
"=",
"self",
".",
"_build_command",
"(",
")",
"env",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"win\"",
")",
":",
"# add... | Starts the Dynamips hypervisor process. | [
"Starts",
"the",
"Dynamips",
"hypervisor",
"process",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/hypervisor.py#L115-L141 | train |
GNS3/gns3-server | gns3server/compute/dynamips/hypervisor.py | Hypervisor.stop | def stop(self):
"""
Stops the Dynamips hypervisor process.
"""
if self.is_running():
log.info("Stopping Dynamips process PID={}".format(self._process.pid))
yield from DynamipsHypervisor.stop(self)
# give some time for the hypervisor to properly stop.
... | python | def stop(self):
"""
Stops the Dynamips hypervisor process.
"""
if self.is_running():
log.info("Stopping Dynamips process PID={}".format(self._process.pid))
yield from DynamipsHypervisor.stop(self)
# give some time for the hypervisor to properly stop.
... | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_running",
"(",
")",
":",
"log",
".",
"info",
"(",
"\"Stopping Dynamips process PID={}\"",
".",
"format",
"(",
"self",
".",
"_process",
".",
"pid",
")",
")",
"yield",
"from",
"DynamipsHypervisor",... | Stops the Dynamips hypervisor process. | [
"Stops",
"the",
"Dynamips",
"hypervisor",
"process",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/hypervisor.py#L144-L172 | train |
GNS3/gns3-server | gns3server/compute/dynamips/hypervisor.py | Hypervisor.read_stdout | def read_stdout(self):
"""
Reads the standard output of the Dynamips process.
Only use when the process has been stopped or has crashed.
"""
output = ""
if self._stdout_file and os.access(self._stdout_file, os.R_OK):
try:
with open(self._stdou... | python | def read_stdout(self):
"""
Reads the standard output of the Dynamips process.
Only use when the process has been stopped or has crashed.
"""
output = ""
if self._stdout_file and os.access(self._stdout_file, os.R_OK):
try:
with open(self._stdou... | [
"def",
"read_stdout",
"(",
"self",
")",
":",
"output",
"=",
"\"\"",
"if",
"self",
".",
"_stdout_file",
"and",
"os",
".",
"access",
"(",
"self",
".",
"_stdout_file",
",",
"os",
".",
"R_OK",
")",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"_s... | Reads the standard output of the Dynamips process.
Only use when the process has been stopped or has crashed. | [
"Reads",
"the",
"standard",
"output",
"of",
"the",
"Dynamips",
"process",
".",
"Only",
"use",
"when",
"the",
"process",
"has",
"been",
"stopped",
"or",
"has",
"crashed",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/hypervisor.py#L174-L187 | train |
GNS3/gns3-server | gns3server/compute/dynamips/adapters/adapter.py | Adapter.install_wic | def install_wic(self, wic_slot_id, wic):
"""
Installs a WIC on this adapter.
:param wic_slot_id: WIC slot ID (integer)
:param wic: WIC instance
"""
self._wics[wic_slot_id] = wic
# Dynamips WICs ports start on a multiple of 16 + port number
# WIC1 port 1... | python | def install_wic(self, wic_slot_id, wic):
"""
Installs a WIC on this adapter.
:param wic_slot_id: WIC slot ID (integer)
:param wic: WIC instance
"""
self._wics[wic_slot_id] = wic
# Dynamips WICs ports start on a multiple of 16 + port number
# WIC1 port 1... | [
"def",
"install_wic",
"(",
"self",
",",
"wic_slot_id",
",",
"wic",
")",
":",
"self",
".",
"_wics",
"[",
"wic_slot_id",
"]",
"=",
"wic",
"# Dynamips WICs ports start on a multiple of 16 + port number",
"# WIC1 port 1 = 16, WIC1 port 2 = 17",
"# WIC2 port 1 = 32, WIC2 port 2 = ... | Installs a WIC on this adapter.
:param wic_slot_id: WIC slot ID (integer)
:param wic: WIC instance | [
"Installs",
"a",
"WIC",
"on",
"this",
"adapter",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/adapters/adapter.py#L70-L87 | train |
GNS3/gns3-server | gns3server/controller/link.py | Link.update_filters | def update_filters(self, filters):
"""
Modify the filters list.
Filter with value 0 will be dropped because not active
"""
new_filters = {}
for (filter, values) in filters.items():
new_values = []
for value in values:
if isinstance... | python | def update_filters(self, filters):
"""
Modify the filters list.
Filter with value 0 will be dropped because not active
"""
new_filters = {}
for (filter, values) in filters.items():
new_values = []
for value in values:
if isinstance... | [
"def",
"update_filters",
"(",
"self",
",",
"filters",
")",
":",
"new_filters",
"=",
"{",
"}",
"for",
"(",
"filter",
",",
"values",
")",
"in",
"filters",
".",
"items",
"(",
")",
":",
"new_values",
"=",
"[",
"]",
"for",
"value",
"in",
"values",
":",
... | Modify the filters list.
Filter with value 0 will be dropped because not active | [
"Modify",
"the",
"filters",
"list",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/link.py#L152-L175 | train |
GNS3/gns3-server | gns3server/controller/link.py | Link.add_node | def add_node(self, node, adapter_number, port_number, label=None, dump=True):
"""
Add a node to the link
:param dump: Dump project on disk
"""
port = node.get_port(adapter_number, port_number)
if port is None:
raise aiohttp.web.HTTPNotFound(text="Port {}/{} ... | python | def add_node(self, node, adapter_number, port_number, label=None, dump=True):
"""
Add a node to the link
:param dump: Dump project on disk
"""
port = node.get_port(adapter_number, port_number)
if port is None:
raise aiohttp.web.HTTPNotFound(text="Port {}/{} ... | [
"def",
"add_node",
"(",
"self",
",",
"node",
",",
"adapter_number",
",",
"port_number",
",",
"label",
"=",
"None",
",",
"dump",
"=",
"True",
")",
":",
"port",
"=",
"node",
".",
"get_port",
"(",
"adapter_number",
",",
"port_number",
")",
"if",
"port",
"... | Add a node to the link
:param dump: Dump project on disk | [
"Add",
"a",
"node",
"to",
"the",
"link"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/link.py#L193-L249 | train |
GNS3/gns3-server | gns3server/controller/link.py | Link.delete | def delete(self):
"""
Delete the link
"""
for n in self._nodes:
# It could be different of self if we rollback an already existing link
if n["port"].link == self:
n["port"].link = None
n["node"].remove_link(self) | python | def delete(self):
"""
Delete the link
"""
for n in self._nodes:
# It could be different of self if we rollback an already existing link
if n["port"].link == self:
n["port"].link = None
n["node"].remove_link(self) | [
"def",
"delete",
"(",
"self",
")",
":",
"for",
"n",
"in",
"self",
".",
"_nodes",
":",
"# It could be different of self if we rollback an already existing link",
"if",
"n",
"[",
"\"port\"",
"]",
".",
"link",
"==",
"self",
":",
"n",
"[",
"\"port\"",
"]",
".",
... | Delete the link | [
"Delete",
"the",
"link"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/link.py#L279-L287 | train |
GNS3/gns3-server | gns3server/controller/link.py | Link.start_capture | def start_capture(self, data_link_type="DLT_EN10MB", capture_file_name=None):
"""
Start capture on the link
:returns: Capture object
"""
self._capturing = True
self._capture_file_name = capture_file_name
self._streaming_pcap = asyncio.async(self._start_streaming... | python | def start_capture(self, data_link_type="DLT_EN10MB", capture_file_name=None):
"""
Start capture on the link
:returns: Capture object
"""
self._capturing = True
self._capture_file_name = capture_file_name
self._streaming_pcap = asyncio.async(self._start_streaming... | [
"def",
"start_capture",
"(",
"self",
",",
"data_link_type",
"=",
"\"DLT_EN10MB\"",
",",
"capture_file_name",
"=",
"None",
")",
":",
"self",
".",
"_capturing",
"=",
"True",
"self",
".",
"_capture_file_name",
"=",
"capture_file_name",
"self",
".",
"_streaming_pcap",... | Start capture on the link
:returns: Capture object | [
"Start",
"capture",
"on",
"the",
"link"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/link.py#L290-L300 | train |
GNS3/gns3-server | gns3server/controller/link.py | Link._start_streaming_pcap | def _start_streaming_pcap(self):
"""
Dump a pcap file on disk
"""
if os.path.exists(self.capture_file_path):
try:
os.remove(self.capture_file_path)
except OSError as e:
raise aiohttp.web.HTTPConflict(text="Could not delete old capt... | python | def _start_streaming_pcap(self):
"""
Dump a pcap file on disk
"""
if os.path.exists(self.capture_file_path):
try:
os.remove(self.capture_file_path)
except OSError as e:
raise aiohttp.web.HTTPConflict(text="Could not delete old capt... | [
"def",
"_start_streaming_pcap",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"capture_file_path",
")",
":",
"try",
":",
"os",
".",
"remove",
"(",
"self",
".",
"capture_file_path",
")",
"except",
"OSError",
"as",
"e",
... | Dump a pcap file on disk | [
"Dump",
"a",
"pcap",
"file",
"on",
"disk"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/link.py#L303-L336 | train |
GNS3/gns3-server | gns3server/controller/link.py | Link.stop_capture | def stop_capture(self):
"""
Stop capture on the link
"""
self._capturing = False
self._project.controller.notification.emit("link.updated", self.__json__()) | python | def stop_capture(self):
"""
Stop capture on the link
"""
self._capturing = False
self._project.controller.notification.emit("link.updated", self.__json__()) | [
"def",
"stop_capture",
"(",
"self",
")",
":",
"self",
".",
"_capturing",
"=",
"False",
"self",
".",
"_project",
".",
"controller",
".",
"notification",
".",
"emit",
"(",
"\"link.updated\"",
",",
"self",
".",
"__json__",
"(",
")",
")"
] | Stop capture on the link | [
"Stop",
"capture",
"on",
"the",
"link"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/link.py#L339-L345 | train |
GNS3/gns3-server | gns3server/controller/link.py | Link.capture_file_path | def capture_file_path(self):
"""
Get the path of the capture
"""
if self._capture_file_name:
return os.path.join(self._project.captures_directory, self._capture_file_name)
else:
return None | python | def capture_file_path(self):
"""
Get the path of the capture
"""
if self._capture_file_name:
return os.path.join(self._project.captures_directory, self._capture_file_name)
else:
return None | [
"def",
"capture_file_path",
"(",
"self",
")",
":",
"if",
"self",
".",
"_capture_file_name",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_project",
".",
"captures_directory",
",",
"self",
".",
"_capture_file_name",
")",
"else",
":",
"r... | Get the path of the capture | [
"Get",
"the",
"path",
"of",
"the",
"capture"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/link.py#L388-L396 | train |
GNS3/gns3-server | gns3server/compute/dynamips/dynamips_hypervisor.py | DynamipsHypervisor.connect | def connect(self, timeout=10):
"""
Connects to the hypervisor.
"""
# connect to a local address by default
# if listening to all addresses (IPv4 or IPv6)
if self._host == "0.0.0.0":
host = "127.0.0.1"
elif self._host == "::":
host = "::1"
... | python | def connect(self, timeout=10):
"""
Connects to the hypervisor.
"""
# connect to a local address by default
# if listening to all addresses (IPv4 or IPv6)
if self._host == "0.0.0.0":
host = "127.0.0.1"
elif self._host == "::":
host = "::1"
... | [
"def",
"connect",
"(",
"self",
",",
"timeout",
"=",
"10",
")",
":",
"# connect to a local address by default",
"# if listening to all addresses (IPv4 or IPv6)",
"if",
"self",
".",
"_host",
"==",
"\"0.0.0.0\"",
":",
"host",
"=",
"\"127.0.0.1\"",
"elif",
"self",
".",
... | Connects to the hypervisor. | [
"Connects",
"to",
"the",
"hypervisor",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/dynamips_hypervisor.py#L63-L102 | train |
GNS3/gns3-server | gns3server/compute/dynamips/dynamips_hypervisor.py | DynamipsHypervisor.set_working_dir | def set_working_dir(self, working_dir):
"""
Sets the working directory for this hypervisor.
:param working_dir: path to the working directory
"""
# encase working_dir in quotes to protect spaces in the path
yield from self.send('hypervisor working_dir "{}"'.format(worki... | python | def set_working_dir(self, working_dir):
"""
Sets the working directory for this hypervisor.
:param working_dir: path to the working directory
"""
# encase working_dir in quotes to protect spaces in the path
yield from self.send('hypervisor working_dir "{}"'.format(worki... | [
"def",
"set_working_dir",
"(",
"self",
",",
"working_dir",
")",
":",
"# encase working_dir in quotes to protect spaces in the path",
"yield",
"from",
"self",
".",
"send",
"(",
"'hypervisor working_dir \"{}\"'",
".",
"format",
"(",
"working_dir",
")",
")",
"self",
".",
... | Sets the working directory for this hypervisor.
:param working_dir: path to the working directory | [
"Sets",
"the",
"working",
"directory",
"for",
"this",
"hypervisor",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/dynamips_hypervisor.py#L152-L162 | train |
GNS3/gns3-server | gns3server/utils/asyncio/embed_shell.py | create_stdin_shell | def create_stdin_shell(shell, loop=None):
"""
Run a shell application with a stdin frontend
:param application: An EmbedShell instance
:param loop: The event loop
:returns: Telnet server
"""
@asyncio.coroutine
def feed_stdin(loop, reader, shell):
history = InMemoryHistory()
... | python | def create_stdin_shell(shell, loop=None):
"""
Run a shell application with a stdin frontend
:param application: An EmbedShell instance
:param loop: The event loop
:returns: Telnet server
"""
@asyncio.coroutine
def feed_stdin(loop, reader, shell):
history = InMemoryHistory()
... | [
"def",
"create_stdin_shell",
"(",
"shell",
",",
"loop",
"=",
"None",
")",
":",
"@",
"asyncio",
".",
"coroutine",
"def",
"feed_stdin",
"(",
"loop",
",",
"reader",
",",
"shell",
")",
":",
"history",
"=",
"InMemoryHistory",
"(",
")",
"completer",
"=",
"Word... | Run a shell application with a stdin frontend
:param application: An EmbedShell instance
:param loop: The event loop
:returns: Telnet server | [
"Run",
"a",
"shell",
"application",
"with",
"a",
"stdin",
"frontend"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/embed_shell.py#L300-L335 | train |
GNS3/gns3-server | gns3server/utils/asyncio/embed_shell.py | ShellConnection.reset | def reset(self):
""" Resets terminal screen"""
self._cli.reset()
self._cli.buffers[DEFAULT_BUFFER].reset()
self._cli.renderer.request_absolute_cursor_position()
self._cli._redraw() | python | def reset(self):
""" Resets terminal screen"""
self._cli.reset()
self._cli.buffers[DEFAULT_BUFFER].reset()
self._cli.renderer.request_absolute_cursor_position()
self._cli._redraw() | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"_cli",
".",
"reset",
"(",
")",
"self",
".",
"_cli",
".",
"buffers",
"[",
"DEFAULT_BUFFER",
"]",
".",
"reset",
"(",
")",
"self",
".",
"_cli",
".",
"renderer",
".",
"request_absolute_cursor_position",
... | Resets terminal screen | [
"Resets",
"terminal",
"screen"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/embed_shell.py#L267-L272 | train |
GNS3/gns3-server | gns3server/compute/project_manager.py | ProjectManager.get_project | def get_project(self, project_id):
"""
Returns a Project instance.
:param project_id: Project identifier
:returns: Project instance
"""
try:
UUID(project_id, version=4)
except ValueError:
raise aiohttp.web.HTTPBadRequest(text="Project ID... | python | def get_project(self, project_id):
"""
Returns a Project instance.
:param project_id: Project identifier
:returns: Project instance
"""
try:
UUID(project_id, version=4)
except ValueError:
raise aiohttp.web.HTTPBadRequest(text="Project ID... | [
"def",
"get_project",
"(",
"self",
",",
"project_id",
")",
":",
"try",
":",
"UUID",
"(",
"project_id",
",",
"version",
"=",
"4",
")",
"except",
"ValueError",
":",
"raise",
"aiohttp",
".",
"web",
".",
"HTTPBadRequest",
"(",
"text",
"=",
"\"Project ID {} is ... | Returns a Project instance.
:param project_id: Project identifier
:returns: Project instance | [
"Returns",
"a",
"Project",
"instance",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project_manager.py#L60-L76 | train |
GNS3/gns3-server | gns3server/compute/project_manager.py | ProjectManager._check_available_disk_space | def _check_available_disk_space(self, project):
"""
Sends a warning notification if disk space is getting low.
:param project: project instance
"""
try:
used_disk_space = psutil.disk_usage(project.path).percent
except FileNotFoundError:
log.warni... | python | def _check_available_disk_space(self, project):
"""
Sends a warning notification if disk space is getting low.
:param project: project instance
"""
try:
used_disk_space = psutil.disk_usage(project.path).percent
except FileNotFoundError:
log.warni... | [
"def",
"_check_available_disk_space",
"(",
"self",
",",
"project",
")",
":",
"try",
":",
"used_disk_space",
"=",
"psutil",
".",
"disk_usage",
"(",
"project",
".",
"path",
")",
".",
"percent",
"except",
"FileNotFoundError",
":",
"log",
".",
"warning",
"(",
"'... | Sends a warning notification if disk space is getting low.
:param project: project instance | [
"Sends",
"a",
"warning",
"notification",
"if",
"disk",
"space",
"is",
"getting",
"low",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project_manager.py#L78-L96 | train |
GNS3/gns3-server | gns3server/compute/project_manager.py | ProjectManager.create_project | def create_project(self, name=None, project_id=None, path=None):
"""
Create a project and keep a references to it in project manager.
See documentation of Project for arguments
"""
if project_id is not None and project_id in self._projects:
return self._projects[pro... | python | def create_project(self, name=None, project_id=None, path=None):
"""
Create a project and keep a references to it in project manager.
See documentation of Project for arguments
"""
if project_id is not None and project_id in self._projects:
return self._projects[pro... | [
"def",
"create_project",
"(",
"self",
",",
"name",
"=",
"None",
",",
"project_id",
"=",
"None",
",",
"path",
"=",
"None",
")",
":",
"if",
"project_id",
"is",
"not",
"None",
"and",
"project_id",
"in",
"self",
".",
"_projects",
":",
"return",
"self",
"."... | Create a project and keep a references to it in project manager.
See documentation of Project for arguments | [
"Create",
"a",
"project",
"and",
"keep",
"a",
"references",
"to",
"it",
"in",
"project",
"manager",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project_manager.py#L98-L110 | train |
GNS3/gns3-server | gns3server/compute/project_manager.py | ProjectManager.remove_project | def remove_project(self, project_id):
"""
Removes a Project instance from the list of projects in use.
:param project_id: Project identifier
"""
if project_id not in self._projects:
raise aiohttp.web.HTTPNotFound(text="Project ID {} doesn't exist".format(project_id)... | python | def remove_project(self, project_id):
"""
Removes a Project instance from the list of projects in use.
:param project_id: Project identifier
"""
if project_id not in self._projects:
raise aiohttp.web.HTTPNotFound(text="Project ID {} doesn't exist".format(project_id)... | [
"def",
"remove_project",
"(",
"self",
",",
"project_id",
")",
":",
"if",
"project_id",
"not",
"in",
"self",
".",
"_projects",
":",
"raise",
"aiohttp",
".",
"web",
".",
"HTTPNotFound",
"(",
"text",
"=",
"\"Project ID {} doesn't exist\"",
".",
"format",
"(",
"... | Removes a Project instance from the list of projects in use.
:param project_id: Project identifier | [
"Removes",
"a",
"Project",
"instance",
"from",
"the",
"list",
"of",
"projects",
"in",
"use",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project_manager.py#L112-L121 | train |
GNS3/gns3-server | gns3server/compute/project_manager.py | ProjectManager.check_hardware_virtualization | def check_hardware_virtualization(self, source_node):
"""
Checks if hardware virtualization can be used.
:returns: boolean
"""
for project in self._projects.values():
for node in project.nodes:
if node == source_node:
continue
... | python | def check_hardware_virtualization(self, source_node):
"""
Checks if hardware virtualization can be used.
:returns: boolean
"""
for project in self._projects.values():
for node in project.nodes:
if node == source_node:
continue
... | [
"def",
"check_hardware_virtualization",
"(",
"self",
",",
"source_node",
")",
":",
"for",
"project",
"in",
"self",
".",
"_projects",
".",
"values",
"(",
")",
":",
"for",
"node",
"in",
"project",
".",
"nodes",
":",
"if",
"node",
"==",
"source_node",
":",
... | Checks if hardware virtualization can be used.
:returns: boolean | [
"Checks",
"if",
"hardware",
"virtualization",
"can",
"be",
"used",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project_manager.py#L123-L136 | train |
GNS3/gns3-server | gns3server/compute/builtin/nodes/cloud.py | Cloud.ports_mapping | def ports_mapping(self, ports):
"""
Set the ports on this cloud.
:param ports: ports info
"""
if ports != self._ports_mapping:
if len(self._nios) > 0:
raise NodeError("Can't modify a cloud already connected.")
port_number = 0
... | python | def ports_mapping(self, ports):
"""
Set the ports on this cloud.
:param ports: ports info
"""
if ports != self._ports_mapping:
if len(self._nios) > 0:
raise NodeError("Can't modify a cloud already connected.")
port_number = 0
... | [
"def",
"ports_mapping",
"(",
"self",
",",
"ports",
")",
":",
"if",
"ports",
"!=",
"self",
".",
"_ports_mapping",
":",
"if",
"len",
"(",
"self",
".",
"_nios",
")",
">",
"0",
":",
"raise",
"NodeError",
"(",
"\"Can't modify a cloud already connected.\"",
")",
... | Set the ports on this cloud.
:param ports: ports info | [
"Set",
"the",
"ports",
"on",
"this",
"cloud",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/builtin/nodes/cloud.py#L103-L119 | train |
GNS3/gns3-server | gns3server/compute/builtin/nodes/cloud.py | Cloud.close | def close(self):
"""
Closes this cloud.
"""
if not (yield from super().close()):
return False
for nio in self._nios.values():
if nio and isinstance(nio, NIOUDP):
self.manager.port_manager.release_udp_port(nio.lport, self._project)
... | python | def close(self):
"""
Closes this cloud.
"""
if not (yield from super().close()):
return False
for nio in self._nios.values():
if nio and isinstance(nio, NIOUDP):
self.manager.port_manager.release_udp_port(nio.lport, self._project)
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"(",
"yield",
"from",
"super",
"(",
")",
".",
"close",
"(",
")",
")",
":",
"return",
"False",
"for",
"nio",
"in",
"self",
".",
"_nios",
".",
"values",
"(",
")",
":",
"if",
"nio",
"and",
"isins... | Closes this cloud. | [
"Closes",
"this",
"cloud",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/builtin/nodes/cloud.py#L146-L159 | train |
GNS3/gns3-server | gns3server/compute/builtin/nodes/cloud.py | Cloud._add_linux_ethernet | def _add_linux_ethernet(self, port_info, bridge_name):
"""
Use raw sockets on Linux.
If interface is a bridge we connect a tap to it
"""
interface = port_info["interface"]
if gns3server.utils.interfaces.is_interface_bridge(interface):
network_interfaces = [i... | python | def _add_linux_ethernet(self, port_info, bridge_name):
"""
Use raw sockets on Linux.
If interface is a bridge we connect a tap to it
"""
interface = port_info["interface"]
if gns3server.utils.interfaces.is_interface_bridge(interface):
network_interfaces = [i... | [
"def",
"_add_linux_ethernet",
"(",
"self",
",",
"port_info",
",",
"bridge_name",
")",
":",
"interface",
"=",
"port_info",
"[",
"\"interface\"",
"]",
"if",
"gns3server",
".",
"utils",
".",
"interfaces",
".",
"is_interface_bridge",
"(",
"interface",
")",
":",
"n... | Use raw sockets on Linux.
If interface is a bridge we connect a tap to it | [
"Use",
"raw",
"sockets",
"on",
"Linux",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/builtin/nodes/cloud.py#L245-L265 | train |
GNS3/gns3-server | gns3server/compute/builtin/nodes/cloud.py | Cloud.add_nio | def add_nio(self, nio, port_number):
"""
Adds a NIO as new port on this cloud.
:param nio: NIO instance to add
:param port_number: port to allocate for the NIO
"""
if port_number in self._nios:
raise NodeError("Port {} isn't free".format(port_number))
... | python | def add_nio(self, nio, port_number):
"""
Adds a NIO as new port on this cloud.
:param nio: NIO instance to add
:param port_number: port to allocate for the NIO
"""
if port_number in self._nios:
raise NodeError("Port {} isn't free".format(port_number))
... | [
"def",
"add_nio",
"(",
"self",
",",
"nio",
",",
"port_number",
")",
":",
"if",
"port_number",
"in",
"self",
".",
"_nios",
":",
"raise",
"NodeError",
"(",
"\"Port {} isn't free\"",
".",
"format",
"(",
"port_number",
")",
")",
"log",
".",
"info",
"(",
"'Cl... | Adds a NIO as new port on this cloud.
:param nio: NIO instance to add
:param port_number: port to allocate for the NIO | [
"Adds",
"a",
"NIO",
"as",
"new",
"port",
"on",
"this",
"cloud",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/builtin/nodes/cloud.py#L288-L317 | train |
GNS3/gns3-server | gns3server/compute/builtin/nodes/cloud.py | Cloud.update_nio | def update_nio(self, port_number, nio):
"""
Update an nio on this node
:param nio: NIO instance to add
:param port_number: port to allocate for the NIO
"""
bridge_name = "{}-{}".format(self._id, port_number)
if self._ubridge_hypervisor and self._ubridge_hypervis... | python | def update_nio(self, port_number, nio):
"""
Update an nio on this node
:param nio: NIO instance to add
:param port_number: port to allocate for the NIO
"""
bridge_name = "{}-{}".format(self._id, port_number)
if self._ubridge_hypervisor and self._ubridge_hypervis... | [
"def",
"update_nio",
"(",
"self",
",",
"port_number",
",",
"nio",
")",
":",
"bridge_name",
"=",
"\"{}-{}\"",
".",
"format",
"(",
"self",
".",
"_id",
",",
"port_number",
")",
"if",
"self",
".",
"_ubridge_hypervisor",
"and",
"self",
".",
"_ubridge_hypervisor",... | Update an nio on this node
:param nio: NIO instance to add
:param port_number: port to allocate for the NIO | [
"Update",
"an",
"nio",
"on",
"this",
"node"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/builtin/nodes/cloud.py#L320-L330 | train |
GNS3/gns3-server | gns3server/compute/builtin/nodes/cloud.py | Cloud.remove_nio | def remove_nio(self, port_number):
"""
Removes the specified NIO as member of cloud.
:param port_number: allocated port number
:returns: the NIO that was bound to the allocated port
"""
if port_number not in self._nios:
raise NodeError("Port {} is not alloc... | python | def remove_nio(self, port_number):
"""
Removes the specified NIO as member of cloud.
:param port_number: allocated port number
:returns: the NIO that was bound to the allocated port
"""
if port_number not in self._nios:
raise NodeError("Port {} is not alloc... | [
"def",
"remove_nio",
"(",
"self",
",",
"port_number",
")",
":",
"if",
"port_number",
"not",
"in",
"self",
".",
"_nios",
":",
"raise",
"NodeError",
"(",
"\"Port {} is not allocated\"",
".",
"format",
"(",
"port_number",
")",
")",
"nio",
"=",
"self",
".",
"_... | Removes the specified NIO as member of cloud.
:param port_number: allocated port number
:returns: the NIO that was bound to the allocated port | [
"Removes",
"the",
"specified",
"NIO",
"as",
"member",
"of",
"cloud",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/builtin/nodes/cloud.py#L344-L369 | train |
GNS3/gns3-server | gns3server/run.py | pid_lock | def pid_lock(path):
"""
Write the file in a file on the system.
Check if the process is not already running.
"""
if os.path.exists(path):
pid = None
try:
with open(path) as f:
try:
pid = int(f.read())
os.kill(pid, 0... | python | def pid_lock(path):
"""
Write the file in a file on the system.
Check if the process is not already running.
"""
if os.path.exists(path):
pid = None
try:
with open(path) as f:
try:
pid = int(f.read())
os.kill(pid, 0... | [
"def",
"pid_lock",
"(",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"pid",
"=",
"None",
"try",
":",
"with",
"open",
"(",
"path",
")",
"as",
"f",
":",
"try",
":",
"pid",
"=",
"int",
"(",
"f",
".",
"read",
... | Write the file in a file on the system.
Check if the process is not already running. | [
"Write",
"the",
"file",
"in",
"a",
"file",
"on",
"the",
"system",
".",
"Check",
"if",
"the",
"process",
"is",
"not",
"already",
"running",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/run.py#L151-L179 | train |
GNS3/gns3-server | gns3server/run.py | kill_ghosts | def kill_ghosts():
"""
Kill process from previous GNS3 session
"""
detect_process = ["vpcs", "ubridge", "dynamips"]
for proc in psutil.process_iter():
try:
name = proc.name().lower().split(".")[0]
if name in detect_process:
proc.kill()
... | python | def kill_ghosts():
"""
Kill process from previous GNS3 session
"""
detect_process = ["vpcs", "ubridge", "dynamips"]
for proc in psutil.process_iter():
try:
name = proc.name().lower().split(".")[0]
if name in detect_process:
proc.kill()
... | [
"def",
"kill_ghosts",
"(",
")",
":",
"detect_process",
"=",
"[",
"\"vpcs\"",
",",
"\"ubridge\"",
",",
"\"dynamips\"",
"]",
"for",
"proc",
"in",
"psutil",
".",
"process_iter",
"(",
")",
":",
"try",
":",
"name",
"=",
"proc",
".",
"name",
"(",
")",
".",
... | Kill process from previous GNS3 session | [
"Kill",
"process",
"from",
"previous",
"GNS3",
"session"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/run.py#L182-L194 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.qemu_path | def qemu_path(self, qemu_path):
"""
Sets the QEMU binary path this QEMU VM.
:param qemu_path: QEMU path
"""
if qemu_path and os.pathsep not in qemu_path:
if sys.platform.startswith("win") and ".exe" not in qemu_path.lower():
qemu_path += "w.exe"
... | python | def qemu_path(self, qemu_path):
"""
Sets the QEMU binary path this QEMU VM.
:param qemu_path: QEMU path
"""
if qemu_path and os.pathsep not in qemu_path:
if sys.platform.startswith("win") and ".exe" not in qemu_path.lower():
qemu_path += "w.exe"
... | [
"def",
"qemu_path",
"(",
"self",
",",
"qemu_path",
")",
":",
"if",
"qemu_path",
"and",
"os",
".",
"pathsep",
"not",
"in",
"qemu_path",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"win\"",
")",
"and",
"\".exe\"",
"not",
"in",
"qemu_path",... | Sets the QEMU binary path this QEMU VM.
:param qemu_path: QEMU path | [
"Sets",
"the",
"QEMU",
"binary",
"path",
"this",
"QEMU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L146-L178 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM._disk_setter | def _disk_setter(self, variable, value):
"""
Use by disk image setter for checking and apply modifications
:param variable: Variable name in the class
:param value: New disk value
"""
value = self.manager.get_abs_image_path(value)
if not self.linked_clone:
... | python | def _disk_setter(self, variable, value):
"""
Use by disk image setter for checking and apply modifications
:param variable: Variable name in the class
:param value: New disk value
"""
value = self.manager.get_abs_image_path(value)
if not self.linked_clone:
... | [
"def",
"_disk_setter",
"(",
"self",
",",
"variable",
",",
"value",
")",
":",
"value",
"=",
"self",
".",
"manager",
".",
"get_abs_image_path",
"(",
"value",
")",
"if",
"not",
"self",
".",
"linked_clone",
":",
"for",
"node",
"in",
"self",
".",
"manager",
... | Use by disk image setter for checking and apply modifications
:param variable: Variable name in the class
:param value: New disk value | [
"Use",
"by",
"disk",
"image",
"setter",
"for",
"checking",
"and",
"apply",
"modifications"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L203-L219 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.hdc_disk_interface | def hdc_disk_interface(self, hdc_disk_interface):
"""
Sets the hdc disk interface for this QEMU VM.
:param hdc_disk_interface: QEMU hdc disk interface
"""
self._hdc_disk_interface = hdc_disk_interface
log.info('QEMU VM "{name}" [{id}] has set the QEMU hdc disk interface... | python | def hdc_disk_interface(self, hdc_disk_interface):
"""
Sets the hdc disk interface for this QEMU VM.
:param hdc_disk_interface: QEMU hdc disk interface
"""
self._hdc_disk_interface = hdc_disk_interface
log.info('QEMU VM "{name}" [{id}] has set the QEMU hdc disk interface... | [
"def",
"hdc_disk_interface",
"(",
"self",
",",
"hdc_disk_interface",
")",
":",
"self",
".",
"_hdc_disk_interface",
"=",
"hdc_disk_interface",
"log",
".",
"info",
"(",
"'QEMU VM \"{name}\" [{id}] has set the QEMU hdc disk interface to {interface}'",
".",
"format",
"(",
"name... | Sets the hdc disk interface for this QEMU VM.
:param hdc_disk_interface: QEMU hdc disk interface | [
"Sets",
"the",
"hdc",
"disk",
"interface",
"for",
"this",
"QEMU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L357-L367 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.hdd_disk_interface | def hdd_disk_interface(self, hdd_disk_interface):
"""
Sets the hdd disk interface for this QEMU VM.
:param hdd_disk_interface: QEMU hdd disk interface
"""
self._hdd_disk_interface = hdd_disk_interface
log.info('QEMU VM "{name}" [{id}] has set the QEMU hdd disk interface... | python | def hdd_disk_interface(self, hdd_disk_interface):
"""
Sets the hdd disk interface for this QEMU VM.
:param hdd_disk_interface: QEMU hdd disk interface
"""
self._hdd_disk_interface = hdd_disk_interface
log.info('QEMU VM "{name}" [{id}] has set the QEMU hdd disk interface... | [
"def",
"hdd_disk_interface",
"(",
"self",
",",
"hdd_disk_interface",
")",
":",
"self",
".",
"_hdd_disk_interface",
"=",
"hdd_disk_interface",
"log",
".",
"info",
"(",
"'QEMU VM \"{name}\" [{id}] has set the QEMU hdd disk interface to {interface}'",
".",
"format",
"(",
"name... | Sets the hdd disk interface for this QEMU VM.
:param hdd_disk_interface: QEMU hdd disk interface | [
"Sets",
"the",
"hdd",
"disk",
"interface",
"for",
"this",
"QEMU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L380-L390 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.cdrom_image | def cdrom_image(self, cdrom_image):
"""
Sets the cdrom image for this QEMU VM.
:param cdrom_image: QEMU cdrom image path
"""
self._cdrom_image = self.manager.get_abs_image_path(cdrom_image)
log.info('QEMU VM "{name}" [{id}] has set the QEMU cdrom image path to {cdrom_ima... | python | def cdrom_image(self, cdrom_image):
"""
Sets the cdrom image for this QEMU VM.
:param cdrom_image: QEMU cdrom image path
"""
self._cdrom_image = self.manager.get_abs_image_path(cdrom_image)
log.info('QEMU VM "{name}" [{id}] has set the QEMU cdrom image path to {cdrom_ima... | [
"def",
"cdrom_image",
"(",
"self",
",",
"cdrom_image",
")",
":",
"self",
".",
"_cdrom_image",
"=",
"self",
".",
"manager",
".",
"get_abs_image_path",
"(",
"cdrom_image",
")",
"log",
".",
"info",
"(",
"'QEMU VM \"{name}\" [{id}] has set the QEMU cdrom image path to {cd... | Sets the cdrom image for this QEMU VM.
:param cdrom_image: QEMU cdrom image path | [
"Sets",
"the",
"cdrom",
"image",
"for",
"this",
"QEMU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L403-L412 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.bios_image | def bios_image(self, bios_image):
"""
Sets the bios image for this QEMU VM.
:param bios_image: QEMU bios image path
"""
self._bios_image = self.manager.get_abs_image_path(bios_image)
log.info('QEMU VM "{name}" [{id}] has set the QEMU bios image path to {bios_image}'.form... | python | def bios_image(self, bios_image):
"""
Sets the bios image for this QEMU VM.
:param bios_image: QEMU bios image path
"""
self._bios_image = self.manager.get_abs_image_path(bios_image)
log.info('QEMU VM "{name}" [{id}] has set the QEMU bios image path to {bios_image}'.form... | [
"def",
"bios_image",
"(",
"self",
",",
"bios_image",
")",
":",
"self",
".",
"_bios_image",
"=",
"self",
".",
"manager",
".",
"get_abs_image_path",
"(",
"bios_image",
")",
"log",
".",
"info",
"(",
"'QEMU VM \"{name}\" [{id}] has set the QEMU bios image path to {bios_im... | Sets the bios image for this QEMU VM.
:param bios_image: QEMU bios image path | [
"Sets",
"the",
"bios",
"image",
"for",
"this",
"QEMU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L425-L434 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.boot_priority | def boot_priority(self, boot_priority):
"""
Sets the boot priority for this QEMU VM.
:param boot_priority: QEMU boot priority
"""
self._boot_priority = boot_priority
log.info('QEMU VM "{name}" [{id}] has set the boot priority to {boot_priority}'.format(name=self._name,
... | python | def boot_priority(self, boot_priority):
"""
Sets the boot priority for this QEMU VM.
:param boot_priority: QEMU boot priority
"""
self._boot_priority = boot_priority
log.info('QEMU VM "{name}" [{id}] has set the boot priority to {boot_priority}'.format(name=self._name,
... | [
"def",
"boot_priority",
"(",
"self",
",",
"boot_priority",
")",
":",
"self",
".",
"_boot_priority",
"=",
"boot_priority",
"log",
".",
"info",
"(",
"'QEMU VM \"{name}\" [{id}] has set the boot priority to {boot_priority}'",
".",
"format",
"(",
"name",
"=",
"self",
".",... | Sets the boot priority for this QEMU VM.
:param boot_priority: QEMU boot priority | [
"Sets",
"the",
"boot",
"priority",
"for",
"this",
"QEMU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L447-L457 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.adapters | def adapters(self, adapters):
"""
Sets the number of Ethernet adapters for this QEMU VM.
:param adapters: number of adapters
"""
self._ethernet_adapters.clear()
for adapter_number in range(0, adapters):
self._ethernet_adapters.append(EthernetAdapter())
... | python | def adapters(self, adapters):
"""
Sets the number of Ethernet adapters for this QEMU VM.
:param adapters: number of adapters
"""
self._ethernet_adapters.clear()
for adapter_number in range(0, adapters):
self._ethernet_adapters.append(EthernetAdapter())
... | [
"def",
"adapters",
"(",
"self",
",",
"adapters",
")",
":",
"self",
".",
"_ethernet_adapters",
".",
"clear",
"(",
")",
"for",
"adapter_number",
"in",
"range",
"(",
"0",
",",
"adapters",
")",
":",
"self",
".",
"_ethernet_adapters",
".",
"append",
"(",
"Eth... | Sets the number of Ethernet adapters for this QEMU VM.
:param adapters: number of adapters | [
"Sets",
"the",
"number",
"of",
"Ethernet",
"adapters",
"for",
"this",
"QEMU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L477-L490 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.mac_address | def mac_address(self, mac_address):
"""
Sets the MAC address for this QEMU VM.
:param mac_address: MAC address
"""
if not mac_address:
# use the node UUID to generate a random MAC address
self._mac_address = "52:%s:%s:%s:%s:00" % (self.project.id[-4:-2],... | python | def mac_address(self, mac_address):
"""
Sets the MAC address for this QEMU VM.
:param mac_address: MAC address
"""
if not mac_address:
# use the node UUID to generate a random MAC address
self._mac_address = "52:%s:%s:%s:%s:00" % (self.project.id[-4:-2],... | [
"def",
"mac_address",
"(",
"self",
",",
"mac_address",
")",
":",
"if",
"not",
"mac_address",
":",
"# use the node UUID to generate a random MAC address",
"self",
".",
"_mac_address",
"=",
"\"52:%s:%s:%s:%s:00\"",
"%",
"(",
"self",
".",
"project",
".",
"id",
"[",
"... | Sets the MAC address for this QEMU VM.
:param mac_address: MAC address | [
"Sets",
"the",
"MAC",
"address",
"for",
"this",
"QEMU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L527-L542 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.legacy_networking | def legacy_networking(self, legacy_networking):
"""
Sets either QEMU legacy networking commands are used.
:param legacy_networking: boolean
"""
if legacy_networking:
log.info('QEMU VM "{name}" [{id}] has enabled legacy networking'.format(name=self._name, id=self._id... | python | def legacy_networking(self, legacy_networking):
"""
Sets either QEMU legacy networking commands are used.
:param legacy_networking: boolean
"""
if legacy_networking:
log.info('QEMU VM "{name}" [{id}] has enabled legacy networking'.format(name=self._name, id=self._id... | [
"def",
"legacy_networking",
"(",
"self",
",",
"legacy_networking",
")",
":",
"if",
"legacy_networking",
":",
"log",
".",
"info",
"(",
"'QEMU VM \"{name}\" [{id}] has enabled legacy networking'",
".",
"format",
"(",
"name",
"=",
"self",
".",
"_name",
",",
"id",
"="... | Sets either QEMU legacy networking commands are used.
:param legacy_networking: boolean | [
"Sets",
"either",
"QEMU",
"legacy",
"networking",
"commands",
"are",
"used",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L555-L566 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.acpi_shutdown | def acpi_shutdown(self, acpi_shutdown):
"""
Sets either this QEMU VM can be ACPI shutdown.
:param acpi_shutdown: boolean
"""
if acpi_shutdown:
log.info('QEMU VM "{name}" [{id}] has enabled ACPI shutdown'.format(name=self._name, id=self._id))
else:
... | python | def acpi_shutdown(self, acpi_shutdown):
"""
Sets either this QEMU VM can be ACPI shutdown.
:param acpi_shutdown: boolean
"""
if acpi_shutdown:
log.info('QEMU VM "{name}" [{id}] has enabled ACPI shutdown'.format(name=self._name, id=self._id))
else:
... | [
"def",
"acpi_shutdown",
"(",
"self",
",",
"acpi_shutdown",
")",
":",
"if",
"acpi_shutdown",
":",
"log",
".",
"info",
"(",
"'QEMU VM \"{name}\" [{id}] has enabled ACPI shutdown'",
".",
"format",
"(",
"name",
"=",
"self",
".",
"_name",
",",
"id",
"=",
"self",
".... | Sets either this QEMU VM can be ACPI shutdown.
:param acpi_shutdown: boolean | [
"Sets",
"either",
"this",
"QEMU",
"VM",
"can",
"be",
"ACPI",
"shutdown",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L579-L590 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.cpu_throttling | def cpu_throttling(self, cpu_throttling):
"""
Sets the percentage of CPU allowed.
:param cpu_throttling: integer
"""
log.info('QEMU VM "{name}" [{id}] has set the percentage of CPU allowed to {cpu}'.format(name=self._name,
... | python | def cpu_throttling(self, cpu_throttling):
"""
Sets the percentage of CPU allowed.
:param cpu_throttling: integer
"""
log.info('QEMU VM "{name}" [{id}] has set the percentage of CPU allowed to {cpu}'.format(name=self._name,
... | [
"def",
"cpu_throttling",
"(",
"self",
",",
"cpu_throttling",
")",
":",
"log",
".",
"info",
"(",
"'QEMU VM \"{name}\" [{id}] has set the percentage of CPU allowed to {cpu}'",
".",
"format",
"(",
"name",
"=",
"self",
".",
"_name",
",",
"id",
"=",
"self",
".",
"_id",... | Sets the percentage of CPU allowed.
:param cpu_throttling: integer | [
"Sets",
"the",
"percentage",
"of",
"CPU",
"allowed",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L603-L616 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.process_priority | def process_priority(self, process_priority):
"""
Sets the process priority.
:param process_priority: string
"""
log.info('QEMU VM "{name}" [{id}] has set the process priority to {priority}'.format(name=self._name,
... | python | def process_priority(self, process_priority):
"""
Sets the process priority.
:param process_priority: string
"""
log.info('QEMU VM "{name}" [{id}] has set the process priority to {priority}'.format(name=self._name,
... | [
"def",
"process_priority",
"(",
"self",
",",
"process_priority",
")",
":",
"log",
".",
"info",
"(",
"'QEMU VM \"{name}\" [{id}] has set the process priority to {priority}'",
".",
"format",
"(",
"name",
"=",
"self",
".",
"_name",
",",
"id",
"=",
"self",
".",
"_id",... | Sets the process priority.
:param process_priority: string | [
"Sets",
"the",
"process",
"priority",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L629-L639 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.cpus | def cpus(self, cpus):
"""
Sets the number of vCPUs this QEMU VM.
:param cpus: number of vCPUs.
"""
log.info('QEMU VM "{name}" [{id}] has set the number of vCPUs to {cpus}'.format(name=self._name, id=self._id, cpus=cpus))
self._cpus = cpus | python | def cpus(self, cpus):
"""
Sets the number of vCPUs this QEMU VM.
:param cpus: number of vCPUs.
"""
log.info('QEMU VM "{name}" [{id}] has set the number of vCPUs to {cpus}'.format(name=self._name, id=self._id, cpus=cpus))
self._cpus = cpus | [
"def",
"cpus",
"(",
"self",
",",
"cpus",
")",
":",
"log",
".",
"info",
"(",
"'QEMU VM \"{name}\" [{id}] has set the number of vCPUs to {cpus}'",
".",
"format",
"(",
"name",
"=",
"self",
".",
"_name",
",",
"id",
"=",
"self",
".",
"_id",
",",
"cpus",
"=",
"c... | Sets the number of vCPUs this QEMU VM.
:param cpus: number of vCPUs. | [
"Sets",
"the",
"number",
"of",
"vCPUs",
"this",
"QEMU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L673-L681 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.options | def options(self, options):
"""
Sets the options for this QEMU VM.
:param options: QEMU options
"""
log.info('QEMU VM "{name}" [{id}] has set the QEMU options to {options}'.format(name=self._name,
... | python | def options(self, options):
"""
Sets the options for this QEMU VM.
:param options: QEMU options
"""
log.info('QEMU VM "{name}" [{id}] has set the QEMU options to {options}'.format(name=self._name,
... | [
"def",
"options",
"(",
"self",
",",
"options",
")",
":",
"log",
".",
"info",
"(",
"'QEMU VM \"{name}\" [{id}] has set the QEMU options to {options}'",
".",
"format",
"(",
"name",
"=",
"self",
".",
"_name",
",",
"id",
"=",
"self",
".",
"_id",
",",
"options",
... | Sets the options for this QEMU VM.
:param options: QEMU options | [
"Sets",
"the",
"options",
"for",
"this",
"QEMU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L694-L714 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.initrd | def initrd(self, initrd):
"""
Sets the initrd path for this QEMU VM.
:param initrd: QEMU initrd path
"""
initrd = self.manager.get_abs_image_path(initrd)
log.info('QEMU VM "{name}" [{id}] has set the QEMU initrd path to {initrd}'.format(name=self._name,
... | python | def initrd(self, initrd):
"""
Sets the initrd path for this QEMU VM.
:param initrd: QEMU initrd path
"""
initrd = self.manager.get_abs_image_path(initrd)
log.info('QEMU VM "{name}" [{id}] has set the QEMU initrd path to {initrd}'.format(name=self._name,
... | [
"def",
"initrd",
"(",
"self",
",",
"initrd",
")",
":",
"initrd",
"=",
"self",
".",
"manager",
".",
"get_abs_image_path",
"(",
"initrd",
")",
"log",
".",
"info",
"(",
"'QEMU VM \"{name}\" [{id}] has set the QEMU initrd path to {initrd}'",
".",
"format",
"(",
"name"... | Sets the initrd path for this QEMU VM.
:param initrd: QEMU initrd path | [
"Sets",
"the",
"initrd",
"path",
"for",
"this",
"QEMU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L727-L741 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.kernel_image | def kernel_image(self, kernel_image):
"""
Sets the kernel image path for this QEMU VM.
:param kernel_image: QEMU kernel image path
"""
kernel_image = self.manager.get_abs_image_path(kernel_image)
log.info('QEMU VM "{name}" [{id}] has set the QEMU kernel image path to {k... | python | def kernel_image(self, kernel_image):
"""
Sets the kernel image path for this QEMU VM.
:param kernel_image: QEMU kernel image path
"""
kernel_image = self.manager.get_abs_image_path(kernel_image)
log.info('QEMU VM "{name}" [{id}] has set the QEMU kernel image path to {k... | [
"def",
"kernel_image",
"(",
"self",
",",
"kernel_image",
")",
":",
"kernel_image",
"=",
"self",
".",
"manager",
".",
"get_abs_image_path",
"(",
"kernel_image",
")",
"log",
".",
"info",
"(",
"'QEMU VM \"{name}\" [{id}] has set the QEMU kernel image path to {kernel_image}'"... | Sets the kernel image path for this QEMU VM.
:param kernel_image: QEMU kernel image path | [
"Sets",
"the",
"kernel",
"image",
"path",
"for",
"this",
"QEMU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L754-L765 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.kernel_command_line | def kernel_command_line(self, kernel_command_line):
"""
Sets the kernel command line for this QEMU VM.
:param kernel_command_line: QEMU kernel command line
"""
log.info('QEMU VM "{name}" [{id}] has set the QEMU kernel command line to {kernel_command_line}'.format(name=self._nam... | python | def kernel_command_line(self, kernel_command_line):
"""
Sets the kernel command line for this QEMU VM.
:param kernel_command_line: QEMU kernel command line
"""
log.info('QEMU VM "{name}" [{id}] has set the QEMU kernel command line to {kernel_command_line}'.format(name=self._nam... | [
"def",
"kernel_command_line",
"(",
"self",
",",
"kernel_command_line",
")",
":",
"log",
".",
"info",
"(",
"'QEMU VM \"{name}\" [{id}] has set the QEMU kernel command line to {kernel_command_line}'",
".",
"format",
"(",
"name",
"=",
"self",
".",
"_name",
",",
"id",
"=",
... | Sets the kernel command line for this QEMU VM.
:param kernel_command_line: QEMU kernel command line | [
"Sets",
"the",
"kernel",
"command",
"line",
"for",
"this",
"QEMU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L778-L788 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM._set_process_priority | def _set_process_priority(self):
"""
Changes the process priority
"""
if self._process_priority == "normal":
return
if sys.platform.startswith("win"):
try:
import win32api
import win32con
import win32proces... | python | def _set_process_priority(self):
"""
Changes the process priority
"""
if self._process_priority == "normal":
return
if sys.platform.startswith("win"):
try:
import win32api
import win32con
import win32proces... | [
"def",
"_set_process_priority",
"(",
"self",
")",
":",
"if",
"self",
".",
"_process_priority",
"==",
"\"normal\"",
":",
"return",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"win\"",
")",
":",
"try",
":",
"import",
"win32api",
"import",
"win32con... | Changes the process priority | [
"Changes",
"the",
"process",
"priority"
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L791-L842 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM._stop_cpulimit | def _stop_cpulimit(self):
"""
Stops the cpulimit process.
"""
if self._cpulimit_process and self._cpulimit_process.returncode is None:
self._cpulimit_process.kill()
try:
self._process.wait(3)
except subprocess.TimeoutExpired:
... | python | def _stop_cpulimit(self):
"""
Stops the cpulimit process.
"""
if self._cpulimit_process and self._cpulimit_process.returncode is None:
self._cpulimit_process.kill()
try:
self._process.wait(3)
except subprocess.TimeoutExpired:
... | [
"def",
"_stop_cpulimit",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cpulimit_process",
"and",
"self",
".",
"_cpulimit_process",
".",
"returncode",
"is",
"None",
":",
"self",
".",
"_cpulimit_process",
".",
"kill",
"(",
")",
"try",
":",
"self",
".",
"_proce... | Stops the cpulimit process. | [
"Stops",
"the",
"cpulimit",
"process",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L844-L854 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM._set_cpu_throttling | def _set_cpu_throttling(self):
"""
Limits the CPU usage for current QEMU process.
"""
if not self.is_running():
return
try:
if sys.platform.startswith("win") and hasattr(sys, "frozen"):
cpulimit_exec = os.path.join(os.path.dirname(os.path... | python | def _set_cpu_throttling(self):
"""
Limits the CPU usage for current QEMU process.
"""
if not self.is_running():
return
try:
if sys.platform.startswith("win") and hasattr(sys, "frozen"):
cpulimit_exec = os.path.join(os.path.dirname(os.path... | [
"def",
"_set_cpu_throttling",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_running",
"(",
")",
":",
"return",
"try",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"\"win\"",
")",
"and",
"hasattr",
"(",
"sys",
",",
"\"frozen\"",
")"... | Limits the CPU usage for current QEMU process. | [
"Limits",
"the",
"CPU",
"usage",
"for",
"current",
"QEMU",
"process",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L856-L874 | train |
GNS3/gns3-server | gns3server/compute/qemu/qemu_vm.py | QemuVM.stop | def stop(self):
"""
Stops this QEMU VM.
"""
yield from self._stop_ubridge()
with (yield from self._execute_lock):
# stop the QEMU process
self._hw_virtualization = False
if self.is_running():
log.info('Stopping QEMU VM "{}" PID... | python | def stop(self):
"""
Stops this QEMU VM.
"""
yield from self._stop_ubridge()
with (yield from self._execute_lock):
# stop the QEMU process
self._hw_virtualization = False
if self.is_running():
log.info('Stopping QEMU VM "{}" PID... | [
"def",
"stop",
"(",
"self",
")",
":",
"yield",
"from",
"self",
".",
"_stop_ubridge",
"(",
")",
"with",
"(",
"yield",
"from",
"self",
".",
"_execute_lock",
")",
":",
"# stop the QEMU process",
"self",
".",
"_hw_virtualization",
"=",
"False",
"if",
"self",
"... | Stops this QEMU VM. | [
"Stops",
"this",
"QEMU",
"VM",
"."
] | a221678448fb5d24e977ef562f81d56aacc89ab1 | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/qemu_vm.py#L962-L992 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.