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/controller/compute.py
Compute.interfaces
def interfaces(self): """ Get the list of network on compute """ if not self._interfaces_cache: response = yield from self.get("/network/interfaces") self._interfaces_cache = response.json return self._interfaces_cache
python
def interfaces(self): """ Get the list of network on compute """ if not self._interfaces_cache: response = yield from self.get("/network/interfaces") self._interfaces_cache = response.json return self._interfaces_cache
[ "def", "interfaces", "(", "self", ")", ":", "if", "not", "self", ".", "_interfaces_cache", ":", "response", "=", "yield", "from", "self", ".", "get", "(", "\"/network/interfaces\"", ")", "self", ".", "_interfaces_cache", "=", "response", ".", "json", "return...
Get the list of network on compute
[ "Get", "the", "list", "of", "network", "on", "compute" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/compute.py#L141-L148
train
GNS3/gns3-server
gns3server/controller/compute.py
Compute.stream_file
def stream_file(self, project, path): """ Read file of a project and stream it :param project: A project object :param path: The path of the file in the project :returns: A file stream """ # Due to Python 3.4 limitation we can't use with and asyncio # ht...
python
def stream_file(self, project, path): """ Read file of a project and stream it :param project: A project object :param path: The path of the file in the project :returns: A file stream """ # Due to Python 3.4 limitation we can't use with and asyncio # ht...
[ "def", "stream_file", "(", "self", ",", "project", ",", "path", ")", ":", "# Due to Python 3.4 limitation we can't use with and asyncio", "# https://www.python.org/dev/peps/pep-0492/", "# that why we wrap the answer", "class", "StreamResponse", ":", "def", "__init__", "(", "sel...
Read file of a project and stream it :param project: A project object :param path: The path of the file in the project :returns: A file stream
[ "Read", "file", "of", "a", "project", "and", "stream", "it" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/compute.py#L340-L373
train
GNS3/gns3-server
gns3server/controller/compute.py
Compute.connect
def connect(self): """ Check if remote server is accessible """ if not self._connected and not self._closed: try: log.info("Connecting to compute '{}'".format(self._id)) response = yield from self._run_http_query("GET", "/capabilities") ...
python
def connect(self): """ Check if remote server is accessible """ if not self._connected and not self._closed: try: log.info("Connecting to compute '{}'".format(self._id)) response = yield from self._run_http_query("GET", "/capabilities") ...
[ "def", "connect", "(", "self", ")", ":", "if", "not", "self", ".", "_connected", "and", "not", "self", ".", "_closed", ":", "try", ":", "log", ".", "info", "(", "\"Connecting to compute '{}'\"", ".", "format", "(", "self", ".", "_id", ")", ")", "respon...
Check if remote server is accessible
[ "Check", "if", "remote", "server", "is", "accessible" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/compute.py#L401-L440
train
GNS3/gns3-server
gns3server/controller/compute.py
Compute._connect_notification
def _connect_notification(self): """ Connect to the notification stream """ try: self._ws = yield from self._session().ws_connect(self._getUrl("/notifications/ws"), auth=self._auth) except (aiohttp.WSServerHandshakeError, aiohttp.ClientResponseError): self...
python
def _connect_notification(self): """ Connect to the notification stream """ try: self._ws = yield from self._session().ws_connect(self._getUrl("/notifications/ws"), auth=self._auth) except (aiohttp.WSServerHandshakeError, aiohttp.ClientResponseError): self...
[ "def", "_connect_notification", "(", "self", ")", ":", "try", ":", "self", ".", "_ws", "=", "yield", "from", "self", ".", "_session", "(", ")", ".", "ws_connect", "(", "self", ".", "_getUrl", "(", "\"/notifications/ws\"", ")", ",", "auth", "=", "self", ...
Connect to the notification stream
[ "Connect", "to", "the", "notification", "stream" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/compute.py#L443-L479
train
GNS3/gns3-server
gns3server/controller/compute.py
Compute.forward
def forward(self, method, type, path, data=None): """ Forward a call to the emulator on compute """ try: action = "/{}/{}".format(type, path) res = yield from self.http_query(method, action, data=data, timeout=None) except aiohttp.ServerDisconnectedError: ...
python
def forward(self, method, type, path, data=None): """ Forward a call to the emulator on compute """ try: action = "/{}/{}".format(type, path) res = yield from self.http_query(method, action, data=data, timeout=None) except aiohttp.ServerDisconnectedError: ...
[ "def", "forward", "(", "self", ",", "method", ",", "type", ",", "path", ",", "data", "=", "None", ")", ":", "try", ":", "action", "=", "\"/{}/{}\"", ".", "format", "(", "type", ",", "path", ")", "res", "=", "yield", "from", "self", ".", "http_query...
Forward a call to the emulator on compute
[ "Forward", "a", "call", "to", "the", "emulator", "on", "compute" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/compute.py#L604-L614
train
GNS3/gns3-server
gns3server/controller/compute.py
Compute.images
def images(self, type): """ Return the list of images available for this type on controller and on the compute node. """ images = [] res = yield from self.http_query("GET", "/{}/images".format(type), timeout=None) images = res.json try: if ty...
python
def images(self, type): """ Return the list of images available for this type on controller and on the compute node. """ images = [] res = yield from self.http_query("GET", "/{}/images".format(type), timeout=None) images = res.json try: if ty...
[ "def", "images", "(", "self", ",", "type", ")", ":", "images", "=", "[", "]", "res", "=", "yield", "from", "self", ".", "http_query", "(", "\"GET\"", ",", "\"/{}/images\"", ".", "format", "(", "type", ")", ",", "timeout", "=", "None", ")", "images", ...
Return the list of images available for this type on controller and on the compute node.
[ "Return", "the", "list", "of", "images", "available", "for", "this", "type", "on", "controller", "and", "on", "the", "compute", "node", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/compute.py#L617-L637
train
GNS3/gns3-server
gns3server/controller/compute.py
Compute.list_files
def list_files(self, project): """ List files in the project on computes """ path = "/projects/{}/files".format(project.id) res = yield from self.http_query("GET", path, timeout=120) return res.json
python
def list_files(self, project): """ List files in the project on computes """ path = "/projects/{}/files".format(project.id) res = yield from self.http_query("GET", path, timeout=120) return res.json
[ "def", "list_files", "(", "self", ",", "project", ")", ":", "path", "=", "\"/projects/{}/files\"", ".", "format", "(", "project", ".", "id", ")", "res", "=", "yield", "from", "self", ".", "http_query", "(", "\"GET\"", ",", "path", ",", "timeout", "=", ...
List files in the project on computes
[ "List", "files", "in", "the", "project", "on", "computes" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/compute.py#L640-L646
train
GNS3/gns3-server
gns3server/controller/compute.py
Compute.get_ip_on_same_subnet
def get_ip_on_same_subnet(self, other_compute): """ Try to found the best ip for communication from one compute to another :returns: Tuple (ip_for_this_compute, ip_for_other_compute) """ if other_compute == self: return (self.host_ip, self.host_ip) #...
python
def get_ip_on_same_subnet(self, other_compute): """ Try to found the best ip for communication from one compute to another :returns: Tuple (ip_for_this_compute, ip_for_other_compute) """ if other_compute == self: return (self.host_ip, self.host_ip) #...
[ "def", "get_ip_on_same_subnet", "(", "self", ",", "other_compute", ")", ":", "if", "other_compute", "==", "self", ":", "return", "(", "self", ".", "host_ip", ",", "self", ".", "host_ip", ")", "# Perhaps the user has correct network gateway, we trust him", "if", "(",...
Try to found the best ip for communication from one compute to another :returns: Tuple (ip_for_this_compute, ip_for_other_compute)
[ "Try", "to", "found", "the", "best", "ip", "for", "communication", "from", "one", "compute", "to", "another" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/compute.py#L649-L693
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/frame_relay_switch.py
FrameRelaySwitch.add_nio
def add_nio(self, nio, port_number): """ Adds a NIO as new port on Frame Relay switch. :param nio: NIO instance to add :param port_number: port to allocate for the NIO """ if port_number in self._nios: raise DynamipsError("Port {} isn't free".format(port_num...
python
def add_nio(self, nio, port_number): """ Adds a NIO as new port on Frame Relay switch. :param nio: NIO instance to add :param port_number: port to allocate for the NIO """ if port_number in self._nios: raise DynamipsError("Port {} isn't free".format(port_num...
[ "def", "add_nio", "(", "self", ",", "nio", ",", "port_number", ")", ":", "if", "port_number", "in", "self", ".", "_nios", ":", "raise", "DynamipsError", "(", "\"Port {} isn't free\"", ".", "format", "(", "port_number", ")", ")", "log", ".", "info", "(", ...
Adds a NIO as new port on Frame Relay switch. :param nio: NIO instance to add :param port_number: port to allocate for the NIO
[ "Adds", "a", "NIO", "as", "new", "port", "on", "Frame", "Relay", "switch", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/frame_relay_switch.py#L160-L177
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/frame_relay_switch.py
FrameRelaySwitch.remove_nio
def remove_nio(self, port_number): """ Removes the specified NIO as member of this Frame Relay switch. :param port_number: allocated port number :returns: the NIO that was bound to the allocated port """ if port_number not in self._nios: raise DynamipsError...
python
def remove_nio(self, port_number): """ Removes the specified NIO as member of this Frame Relay switch. :param port_number: allocated port number :returns: the NIO that was bound to the allocated port """ if port_number not in self._nios: raise DynamipsError...
[ "def", "remove_nio", "(", "self", ",", "port_number", ")", ":", "if", "port_number", "not", "in", "self", ".", "_nios", ":", "raise", "DynamipsError", "(", "\"Port {} is not allocated\"", ".", "format", "(", "port_number", ")", ")", "# remove VCs mapped with the p...
Removes the specified NIO as member of this Frame Relay switch. :param port_number: allocated port number :returns: the NIO that was bound to the allocated port
[ "Removes", "the", "specified", "NIO", "as", "member", "of", "this", "Frame", "Relay", "switch", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/frame_relay_switch.py#L180-L216
train
GNS3/gns3-server
gns3server/main.py
main
def main(): """ Entry point for GNS3 server """ if not sys.platform.startswith("win"): if "--daemon" in sys.argv: daemonize() from gns3server.run import run run()
python
def main(): """ Entry point for GNS3 server """ if not sys.platform.startswith("win"): if "--daemon" in sys.argv: daemonize() from gns3server.run import run run()
[ "def", "main", "(", ")", ":", "if", "not", "sys", ".", "platform", ".", "startswith", "(", "\"win\"", ")", ":", "if", "\"--daemon\"", "in", "sys", ".", "argv", ":", "daemonize", "(", ")", "from", "gns3server", ".", "run", "import", "run", "run", "(",...
Entry point for GNS3 server
[ "Entry", "point", "for", "GNS3", "server" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/main.py#L74-L83
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM._get_free_display_port
def _get_free_display_port(self): """ Search a free display port """ display = 100 if not os.path.exists("/tmp/.X11-unix/"): return display while True: if not os.path.exists("/tmp/.X11-unix/X{}".format(display)): return display ...
python
def _get_free_display_port(self): """ Search a free display port """ display = 100 if not os.path.exists("/tmp/.X11-unix/"): return display while True: if not os.path.exists("/tmp/.X11-unix/X{}".format(display)): return display ...
[ "def", "_get_free_display_port", "(", "self", ")", ":", "display", "=", "100", "if", "not", "os", ".", "path", ".", "exists", "(", "\"/tmp/.X11-unix/\"", ")", ":", "return", "display", "while", "True", ":", "if", "not", "os", ".", "path", ".", "exists", ...
Search a free display port
[ "Search", "a", "free", "display", "port" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L120-L130
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM.create
def create(self): """Creates the Docker container.""" try: image_infos = yield from self._get_image_information() except DockerHttp404Error: log.info("Image %s is missing pulling it from docker hub", self._image) yield from self.pull_image(self._image) ...
python
def create(self): """Creates the Docker container.""" try: image_infos = yield from self._get_image_information() except DockerHttp404Error: log.info("Image %s is missing pulling it from docker hub", self._image) yield from self.pull_image(self._image) ...
[ "def", "create", "(", "self", ")", ":", "try", ":", "image_infos", "=", "yield", "from", "self", ".", "_get_image_information", "(", ")", "except", "DockerHttp404Error", ":", "log", ".", "info", "(", "\"Image %s is missing pulling it from docker hub\"", ",", "self...
Creates the Docker container.
[ "Creates", "the", "Docker", "container", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L268-L332
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM.update
def update(self): """ Destroy an recreate the container with the new settings """ # We need to save the console and state and restore it console = self.console aux = self.aux state = yield from self._get_container_state() yield from self.reset() y...
python
def update(self): """ Destroy an recreate the container with the new settings """ # We need to save the console and state and restore it console = self.console aux = self.aux state = yield from self._get_container_state() yield from self.reset() y...
[ "def", "update", "(", "self", ")", ":", "# We need to save the console and state and restore it", "console", "=", "self", ".", "console", "aux", "=", "self", ".", "aux", "state", "=", "yield", "from", "self", ".", "_get_container_state", "(", ")", "yield", "from...
Destroy an recreate the container with the new settings
[ "Destroy", "an", "recreate", "the", "container", "with", "the", "new", "settings" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L335-L349
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM.start
def start(self): """Starts this Docker container.""" try: state = yield from self._get_container_state() except DockerHttp404Error: raise DockerError("Docker container '{name}' with ID {cid} does not exist or is not ready yet. Please try again in a few seconds.".format(n...
python
def start(self): """Starts this Docker container.""" try: state = yield from self._get_container_state() except DockerHttp404Error: raise DockerError("Docker container '{name}' with ID {cid} does not exist or is not ready yet. Please try again in a few seconds.".format(n...
[ "def", "start", "(", "self", ")", ":", "try", ":", "state", "=", "yield", "from", "self", ".", "_get_container_state", "(", ")", "except", "DockerHttp404Error", ":", "raise", "DockerError", "(", "\"Docker container '{name}' with ID {cid} does not exist or is not ready y...
Starts this Docker container.
[ "Starts", "this", "Docker", "container", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L352-L399
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM._start_aux
def _start_aux(self): """ Start an auxilary console """ # We can not use the API because docker doesn't expose a websocket api for exec # https://github.com/GNS3/gns3-gui/issues/1039 process = yield from asyncio.subprocess.create_subprocess_exec( "docker", "e...
python
def _start_aux(self): """ Start an auxilary console """ # We can not use the API because docker doesn't expose a websocket api for exec # https://github.com/GNS3/gns3-gui/issues/1039 process = yield from asyncio.subprocess.create_subprocess_exec( "docker", "e...
[ "def", "_start_aux", "(", "self", ")", ":", "# We can not use the API because docker doesn't expose a websocket api for exec", "# https://github.com/GNS3/gns3-gui/issues/1039", "process", "=", "yield", "from", "asyncio", ".", "subprocess", ".", "create_subprocess_exec", "(", "\"d...
Start an auxilary console
[ "Start", "an", "auxilary", "console" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L402-L416
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM._fix_permissions
def _fix_permissions(self): """ Because docker run as root we need to fix permission and ownership to allow user to interact with it from their filesystem and do operation like file delete """ state = yield from self._get_container_state() if state == "stopped" or state ...
python
def _fix_permissions(self): """ Because docker run as root we need to fix permission and ownership to allow user to interact with it from their filesystem and do operation like file delete """ state = yield from self._get_container_state() if state == "stopped" or state ...
[ "def", "_fix_permissions", "(", "self", ")", ":", "state", "=", "yield", "from", "self", ".", "_get_container_state", "(", ")", "if", "state", "==", "\"stopped\"", "or", "state", "==", "\"exited\"", ":", "# We need to restart it to fix permissions", "yield", "from...
Because docker run as root we need to fix permission and ownership to allow user to interact with it from their filesystem and do operation like file delete
[ "Because", "docker", "run", "as", "root", "we", "need", "to", "fix", "permission", "and", "ownership", "to", "allow", "user", "to", "interact", "with", "it", "from", "their", "filesystem", "and", "do", "operation", "like", "file", "delete" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L419-L448
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM._start_vnc
def _start_vnc(self): """ Start a VNC server for this container """ self._display = self._get_free_display_port() if shutil.which("Xvfb") is None or shutil.which("x11vnc") is None: raise DockerError("Please install Xvfb and x11vnc before using the VNC support") ...
python
def _start_vnc(self): """ Start a VNC server for this container """ self._display = self._get_free_display_port() if shutil.which("Xvfb") is None or shutil.which("x11vnc") is None: raise DockerError("Please install Xvfb and x11vnc before using the VNC support") ...
[ "def", "_start_vnc", "(", "self", ")", ":", "self", ".", "_display", "=", "self", ".", "_get_free_display_port", "(", ")", "if", "shutil", ".", "which", "(", "\"Xvfb\"", ")", "is", "None", "or", "shutil", ".", "which", "(", "\"x11vnc\"", ")", "is", "No...
Start a VNC server for this container
[ "Start", "a", "VNC", "server", "for", "this", "container" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L451-L464
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM._start_http
def _start_http(self): """ Start an HTTP tunnel to container localhost. It's not perfect but the only way we have to inject network packet is using nc. """ log.debug("Forward HTTP for %s to %d", self.name, self._console_http_port) command = ["docker", "exec", "-i", self._...
python
def _start_http(self): """ Start an HTTP tunnel to container localhost. It's not perfect but the only way we have to inject network packet is using nc. """ log.debug("Forward HTTP for %s to %d", self.name, self._console_http_port) command = ["docker", "exec", "-i", self._...
[ "def", "_start_http", "(", "self", ")", ":", "log", ".", "debug", "(", "\"Forward HTTP for %s to %d\"", ",", "self", ".", "name", ",", "self", ".", "_console_http_port", ")", "command", "=", "[", "\"docker\"", ",", "\"exec\"", ",", "\"-i\"", ",", "self", "...
Start an HTTP tunnel to container localhost. It's not perfect but the only way we have to inject network packet is using nc.
[ "Start", "an", "HTTP", "tunnel", "to", "container", "localhost", ".", "It", "s", "not", "perfect", "but", "the", "only", "way", "we", "have", "to", "inject", "network", "packet", "is", "using", "nc", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L467-L485
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM._start_console
def _start_console(self): """ Start streaming the console via telnet """ class InputStream: def __init__(self): self._data = b"" def write(self, data): self._data += data @asyncio.coroutine def drain(self...
python
def _start_console(self): """ Start streaming the console via telnet """ class InputStream: def __init__(self): self._data = b"" def write(self, data): self._data += data @asyncio.coroutine def drain(self...
[ "def", "_start_console", "(", "self", ")", ":", "class", "InputStream", ":", "def", "__init__", "(", "self", ")", ":", "self", ".", "_data", "=", "b\"\"", "def", "write", "(", "self", ",", "data", ")", ":", "self", ".", "_data", "+=", "data", "@", ...
Start streaming the console via telnet
[ "Start", "streaming", "the", "console", "via", "telnet" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L488-L518
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM._read_console_output
def _read_console_output(self, ws, out): """ Read Websocket and forward it to the telnet :param ws: Websocket connection :param out: Output stream """ while True: msg = yield from ws.receive() if msg.tp == aiohttp.WSMsgType.text: ...
python
def _read_console_output(self, ws, out): """ Read Websocket and forward it to the telnet :param ws: Websocket connection :param out: Output stream """ while True: msg = yield from ws.receive() if msg.tp == aiohttp.WSMsgType.text: ...
[ "def", "_read_console_output", "(", "self", ",", "ws", ",", "out", ")", ":", "while", "True", ":", "msg", "=", "yield", "from", "ws", ".", "receive", "(", ")", "if", "msg", ".", "tp", "==", "aiohttp", ".", "WSMsgType", ".", "text", ":", "out", ".",...
Read Websocket and forward it to the telnet :param ws: Websocket connection :param out: Output stream
[ "Read", "Websocket", "and", "forward", "it", "to", "the", "telnet" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L521-L541
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM.is_running
def is_running(self): """Checks if the container is running. :returns: True or False :rtype: bool """ state = yield from self._get_container_state() if state == "running": return True if self.status == "started": # The container crashed we need to cl...
python
def is_running(self): """Checks if the container is running. :returns: True or False :rtype: bool """ state = yield from self._get_container_state() if state == "running": return True if self.status == "started": # The container crashed we need to cl...
[ "def", "is_running", "(", "self", ")", ":", "state", "=", "yield", "from", "self", ".", "_get_container_state", "(", ")", "if", "state", "==", "\"running\"", ":", "return", "True", "if", "self", ".", "status", "==", "\"started\"", ":", "# The container crash...
Checks if the container is running. :returns: True or False :rtype: bool
[ "Checks", "if", "the", "container", "is", "running", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L544-L555
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM.restart
def restart(self): """Restart this Docker container.""" yield from self.manager.query("POST", "containers/{}/restart".format(self._cid)) log.info("Docker container '{name}' [{image}] restarted".format( name=self._name, image=self._image))
python
def restart(self): """Restart this Docker container.""" yield from self.manager.query("POST", "containers/{}/restart".format(self._cid)) log.info("Docker container '{name}' [{image}] restarted".format( name=self._name, image=self._image))
[ "def", "restart", "(", "self", ")", ":", "yield", "from", "self", ".", "manager", ".", "query", "(", "\"POST\"", ",", "\"containers/{}/restart\"", ".", "format", "(", "self", ".", "_cid", ")", ")", "log", ".", "info", "(", "\"Docker container '{name}' [{imag...
Restart this Docker container.
[ "Restart", "this", "Docker", "container", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L558-L562
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM._clean_servers
def _clean_servers(self): """ Clean the list of running console servers """ if len(self._telnet_servers) > 0: for telnet_server in self._telnet_servers: telnet_server.close() yield from telnet_server.wait_closed() self._telnet_serve...
python
def _clean_servers(self): """ Clean the list of running console servers """ if len(self._telnet_servers) > 0: for telnet_server in self._telnet_servers: telnet_server.close() yield from telnet_server.wait_closed() self._telnet_serve...
[ "def", "_clean_servers", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_telnet_servers", ")", ">", "0", ":", "for", "telnet_server", "in", "self", ".", "_telnet_servers", ":", "telnet_server", ".", "close", "(", ")", "yield", "from", "telnet_serve...
Clean the list of running console servers
[ "Clean", "the", "list", "of", "running", "console", "servers" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L565-L573
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM.stop
def stop(self): """Stops this Docker container.""" try: yield from self._clean_servers() yield from self._stop_ubridge() try: state = yield from self._get_container_state() except DockerHttp404Error: self.status = "stopped...
python
def stop(self): """Stops this Docker container.""" try: yield from self._clean_servers() yield from self._stop_ubridge() try: state = yield from self._get_container_state() except DockerHttp404Error: self.status = "stopped...
[ "def", "stop", "(", "self", ")", ":", "try", ":", "yield", "from", "self", ".", "_clean_servers", "(", ")", "yield", "from", "self", ".", "_stop_ubridge", "(", ")", "try", ":", "state", "=", "yield", "from", "self", ".", "_get_container_state", "(", ")...
Stops this Docker container.
[ "Stops", "this", "Docker", "container", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L576-L607
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM.pause
def pause(self): """Pauses this Docker container.""" yield from self.manager.query("POST", "containers/{}/pause".format(self._cid)) self.status = "suspended" log.info("Docker container '{name}' [{image}] paused".format(name=self._name, image=self._image))
python
def pause(self): """Pauses this Docker container.""" yield from self.manager.query("POST", "containers/{}/pause".format(self._cid)) self.status = "suspended" log.info("Docker container '{name}' [{image}] paused".format(name=self._name, image=self._image))
[ "def", "pause", "(", "self", ")", ":", "yield", "from", "self", ".", "manager", ".", "query", "(", "\"POST\"", ",", "\"containers/{}/pause\"", ".", "format", "(", "self", ".", "_cid", ")", ")", "self", ".", "status", "=", "\"suspended\"", "log", ".", "...
Pauses this Docker container.
[ "Pauses", "this", "Docker", "container", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L610-L614
train
GNS3/gns3-server
gns3server/compute/docker/docker_vm.py
DockerVM._get_log
def _get_log(self): """ Return the log from the container :returns: string """ result = yield from self.manager.query("GET", "containers/{}/logs".format(self._cid), params={"stderr": 1, "stdout": 1}) return result
python
def _get_log(self): """ Return the log from the container :returns: string """ result = yield from self.manager.query("GET", "containers/{}/logs".format(self._cid), params={"stderr": 1, "stdout": 1}) return result
[ "def", "_get_log", "(", "self", ")", ":", "result", "=", "yield", "from", "self", ".", "manager", ".", "query", "(", "\"GET\"", ",", "\"containers/{}/logs\"", ".", "format", "(", "self", ".", "_cid", ")", ",", "params", "=", "{", "\"stderr\"", ":", "1"...
Return the log from the container :returns: string
[ "Return", "the", "log", "from", "the", "container" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/docker_vm.py#L916-L924
train
GNS3/gns3-server
gns3server/compute/iou/utils/application_id.py
get_next_application_id
def get_next_application_id(nodes): """ Calculates free application_id from given nodes :param nodes: :raises IOUError when exceeds number :return: integer first free id """ used = set([n.application_id for n in nodes]) pool = set(range(1, 512)) try: return (pool - used).pop...
python
def get_next_application_id(nodes): """ Calculates free application_id from given nodes :param nodes: :raises IOUError when exceeds number :return: integer first free id """ used = set([n.application_id for n in nodes]) pool = set(range(1, 512)) try: return (pool - used).pop...
[ "def", "get_next_application_id", "(", "nodes", ")", ":", "used", "=", "set", "(", "[", "n", ".", "application_id", "for", "n", "in", "nodes", "]", ")", "pool", "=", "set", "(", "range", "(", "1", ",", "512", ")", ")", "try", ":", "return", "(", ...
Calculates free application_id from given nodes :param nodes: :raises IOUError when exceeds number :return: integer first free id
[ "Calculates", "free", "application_id", "from", "given", "nodes" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/utils/application_id.py#L24-L37
train
GNS3/gns3-server
gns3server/config.py
Config.clear
def clear(self): """Restart with a clean config""" self._config = configparser.RawConfigParser() # Override config from command line even if we modify the config file and live reload it. self._override_config = {} self.read_config()
python
def clear(self): """Restart with a clean config""" self._config = configparser.RawConfigParser() # Override config from command line even if we modify the config file and live reload it. self._override_config = {} self.read_config()
[ "def", "clear", "(", "self", ")", ":", "self", ".", "_config", "=", "configparser", ".", "RawConfigParser", "(", ")", "# Override config from command line even if we modify the config file and live reload it.", "self", ".", "_override_config", "=", "{", "}", "self", "."...
Restart with a clean config
[ "Restart", "with", "a", "clean", "config" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/config.py#L137-L143
train
GNS3/gns3-server
gns3server/config.py
Config.read_config
def read_config(self): """ Read the configuration files. """ try: parsed_files = self._config.read(self._files, encoding="utf-8") except configparser.Error as e: log.error("Can't parse configuration file: %s", str(e)) return if not par...
python
def read_config(self): """ Read the configuration files. """ try: parsed_files = self._config.read(self._files, encoding="utf-8") except configparser.Error as e: log.error("Can't parse configuration file: %s", str(e)) return if not par...
[ "def", "read_config", "(", "self", ")", ":", "try", ":", "parsed_files", "=", "self", ".", "_config", ".", "read", "(", "self", ".", "_files", ",", "encoding", "=", "\"utf-8\"", ")", "except", "configparser", ".", "Error", "as", "e", ":", "log", ".", ...
Read the configuration files.
[ "Read", "the", "configuration", "files", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/config.py#L169-L184
train
GNS3/gns3-server
gns3server/config.py
Config.get_section_config
def get_section_config(self, section): """ Get a specific configuration section. Returns the default section if none can be found. :returns: configparser section """ if section not in self._config: return self._config["DEFAULT"] return self._config[s...
python
def get_section_config(self, section): """ Get a specific configuration section. Returns the default section if none can be found. :returns: configparser section """ if section not in self._config: return self._config["DEFAULT"] return self._config[s...
[ "def", "get_section_config", "(", "self", ",", "section", ")", ":", "if", "section", "not", "in", "self", ".", "_config", ":", "return", "self", ".", "_config", "[", "\"DEFAULT\"", "]", "return", "self", ".", "_config", "[", "section", "]" ]
Get a specific configuration section. Returns the default section if none can be found. :returns: configparser section
[ "Get", "a", "specific", "configuration", "section", ".", "Returns", "the", "default", "section", "if", "none", "can", "be", "found", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/config.py#L195-L205
train
GNS3/gns3-server
gns3server/config.py
Config.set_section_config
def set_section_config(self, section, content): """ Set a specific configuration section. It's not dumped on the disk. :param section: Section name :param content: A dictionary with section content """ if not self._config.has_section(section): self._...
python
def set_section_config(self, section, content): """ Set a specific configuration section. It's not dumped on the disk. :param section: Section name :param content: A dictionary with section content """ if not self._config.has_section(section): self._...
[ "def", "set_section_config", "(", "self", ",", "section", ",", "content", ")", ":", "if", "not", "self", ".", "_config", ".", "has_section", "(", "section", ")", ":", "self", ".", "_config", ".", "add_section", "(", "section", ")", "for", "key", "in", ...
Set a specific configuration section. It's not dumped on the disk. :param section: Section name :param content: A dictionary with section content
[ "Set", "a", "specific", "configuration", "section", ".", "It", "s", "not", "dumped", "on", "the", "disk", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/config.py#L207-L222
train
GNS3/gns3-server
gns3server/config.py
Config.set
def set(self, section, key, value): """ Set a config value. It's not dumped on the disk. If the section doesn't exists the section is created """ conf = self.get_section_config(section) if isinstance(value, bool): conf[key] = str(value) else:...
python
def set(self, section, key, value): """ Set a config value. It's not dumped on the disk. If the section doesn't exists the section is created """ conf = self.get_section_config(section) if isinstance(value, bool): conf[key] = str(value) else:...
[ "def", "set", "(", "self", ",", "section", ",", "key", ",", "value", ")", ":", "conf", "=", "self", ".", "get_section_config", "(", "section", ")", "if", "isinstance", "(", "value", ",", "bool", ")", ":", "conf", "[", "key", "]", "=", "str", "(", ...
Set a config value. It's not dumped on the disk. If the section doesn't exists the section is created
[ "Set", "a", "config", "value", ".", "It", "s", "not", "dumped", "on", "the", "disk", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/config.py#L224-L237
train
GNS3/gns3-server
gns3server/config.py
Config.instance
def instance(*args, **kwargs): """ Singleton to return only one instance of Config. :returns: instance of Config """ if not hasattr(Config, "_instance") or Config._instance is None: Config._instance = Config(*args, **kwargs) return Config._instance
python
def instance(*args, **kwargs): """ Singleton to return only one instance of Config. :returns: instance of Config """ if not hasattr(Config, "_instance") or Config._instance is None: Config._instance = Config(*args, **kwargs) return Config._instance
[ "def", "instance", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "hasattr", "(", "Config", ",", "\"_instance\"", ")", "or", "Config", ".", "_instance", "is", "None", ":", "Config", ".", "_instance", "=", "Config", "(", "*", "args"...
Singleton to return only one instance of Config. :returns: instance of Config
[ "Singleton", "to", "return", "only", "one", "instance", "of", "Config", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/config.py#L240-L249
train
GNS3/gns3-server
gns3server/utils/asyncio/__init__.py
wait_run_in_executor
def wait_run_in_executor(func, *args, **kwargs): """ Run blocking code in a different thread and wait for the result. :param func: Run this function in a different thread :param args: Parameters of the function :param kwargs: Keyword parameters of the function :returns: Return the result of...
python
def wait_run_in_executor(func, *args, **kwargs): """ Run blocking code in a different thread and wait for the result. :param func: Run this function in a different thread :param args: Parameters of the function :param kwargs: Keyword parameters of the function :returns: Return the result of...
[ "def", "wait_run_in_executor", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "future", "=", "loop", ".", "run_in_executor", "(", "None", ",", "functools", ".", "partial", "(", ...
Run blocking code in a different thread and wait for the result. :param func: Run this function in a different thread :param args: Parameters of the function :param kwargs: Keyword parameters of the function :returns: Return the result of the function
[ "Run", "blocking", "code", "in", "a", "different", "thread", "and", "wait", "for", "the", "result", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/__init__.py#L26-L40
train
GNS3/gns3-server
gns3server/utils/asyncio/__init__.py
subprocess_check_output
def subprocess_check_output(*args, cwd=None, env=None, stderr=False): """ Run a command and capture output :param *args: List of command arguments :param cwd: Current working directory :param env: Command environment :param stderr: Read on stderr :returns: Command output """ if std...
python
def subprocess_check_output(*args, cwd=None, env=None, stderr=False): """ Run a command and capture output :param *args: List of command arguments :param cwd: Current working directory :param env: Command environment :param stderr: Read on stderr :returns: Command output """ if std...
[ "def", "subprocess_check_output", "(", "*", "args", ",", "cwd", "=", "None", ",", "env", "=", "None", ",", "stderr", "=", "False", ")", ":", "if", "stderr", ":", "proc", "=", "yield", "from", "asyncio", ".", "create_subprocess_exec", "(", "*", "args", ...
Run a command and capture output :param *args: List of command arguments :param cwd: Current working directory :param env: Command environment :param stderr: Read on stderr :returns: Command output
[ "Run", "a", "command", "and", "capture", "output" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/__init__.py#L44-L66
train
GNS3/gns3-server
gns3server/utils/asyncio/__init__.py
wait_for_process_termination
def wait_for_process_termination(process, timeout=10): """ Wait for a process terminate, and raise asyncio.TimeoutError in case of timeout. In theory this can be implemented by just: yield from asyncio.wait_for(self._iou_process.wait(), timeout=100) But it's broken before Python 3.4: http:...
python
def wait_for_process_termination(process, timeout=10): """ Wait for a process terminate, and raise asyncio.TimeoutError in case of timeout. In theory this can be implemented by just: yield from asyncio.wait_for(self._iou_process.wait(), timeout=100) But it's broken before Python 3.4: http:...
[ "def", "wait_for_process_termination", "(", "process", ",", "timeout", "=", "10", ")", ":", "if", "sys", ".", "version_info", ">=", "(", "3", ",", "5", ")", ":", "try", ":", "yield", "from", "asyncio", ".", "wait_for", "(", "process", ".", "wait", "(",...
Wait for a process terminate, and raise asyncio.TimeoutError in case of timeout. In theory this can be implemented by just: yield from asyncio.wait_for(self._iou_process.wait(), timeout=100) But it's broken before Python 3.4: http://bugs.python.org/issue23140 :param process: An asyncio subpro...
[ "Wait", "for", "a", "process", "terminate", "and", "raise", "asyncio", ".", "TimeoutError", "in", "case", "of", "timeout", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/__init__.py#L69-L95
train
GNS3/gns3-server
gns3server/utils/asyncio/__init__.py
locked_coroutine
def locked_coroutine(f): """ Method decorator that replace asyncio.coroutine that warranty that this specific method of this class instance will not we executed twice at the same time """ @asyncio.coroutine def new_function(*args, **kwargs): # In the instance of the class we will st...
python
def locked_coroutine(f): """ Method decorator that replace asyncio.coroutine that warranty that this specific method of this class instance will not we executed twice at the same time """ @asyncio.coroutine def new_function(*args, **kwargs): # In the instance of the class we will st...
[ "def", "locked_coroutine", "(", "f", ")", ":", "@", "asyncio", ".", "coroutine", "def", "new_function", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# In the instance of the class we will store", "# a lock has an attribute.", "lock_var_name", "=", "\"__\"",...
Method decorator that replace asyncio.coroutine that warranty that this specific method of this class instance will not we executed twice at the same time
[ "Method", "decorator", "that", "replace", "asyncio", ".", "coroutine", "that", "warranty", "that", "this", "specific", "method", "of", "this", "class", "instance", "will", "not", "we", "executed", "twice", "at", "the", "same", "time" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/__init__.py#L142-L160
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/bridge.py
Bridge.set_name
def set_name(self, new_name): """ Renames this bridge. :param new_name: New name for this bridge """ yield from self._hypervisor.send('nio_bridge rename "{name}" "{new_name}"'.format(name=self._name, ...
python
def set_name(self, new_name): """ Renames this bridge. :param new_name: New name for this bridge """ yield from self._hypervisor.send('nio_bridge rename "{name}" "{new_name}"'.format(name=self._name, ...
[ "def", "set_name", "(", "self", ",", "new_name", ")", ":", "yield", "from", "self", ".", "_hypervisor", ".", "send", "(", "'nio_bridge rename \"{name}\" \"{new_name}\"'", ".", "format", "(", "name", "=", "self", ".", "_name", ",", "new_name", "=", "new_name", ...
Renames this bridge. :param new_name: New name for this bridge
[ "Renames", "this", "bridge", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/bridge.py#L55-L65
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/bridge.py
Bridge.delete
def delete(self): """ Deletes this bridge. """ if self._hypervisor and self in self._hypervisor.devices: self._hypervisor.devices.remove(self) if self._hypervisor and not self._hypervisor.devices: yield from self._hypervisor.send('nio_bridge delete "{}"'....
python
def delete(self): """ Deletes this bridge. """ if self._hypervisor and self in self._hypervisor.devices: self._hypervisor.devices.remove(self) if self._hypervisor and not self._hypervisor.devices: yield from self._hypervisor.send('nio_bridge delete "{}"'....
[ "def", "delete", "(", "self", ")", ":", "if", "self", ".", "_hypervisor", "and", "self", "in", "self", ".", "_hypervisor", ".", "devices", ":", "self", ".", "_hypervisor", ".", "devices", ".", "remove", "(", "self", ")", "if", "self", ".", "_hypervisor...
Deletes this bridge.
[ "Deletes", "this", "bridge", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/bridge.py#L78-L86
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/bridge.py
Bridge.add_nio
def add_nio(self, nio): """ Adds a NIO as new port on this bridge. :param nio: NIO instance to add """ yield from self._hypervisor.send('nio_bridge add_nio "{name}" {nio}'.format(name=self._name, nio=nio)) self._nios.append(nio)
python
def add_nio(self, nio): """ Adds a NIO as new port on this bridge. :param nio: NIO instance to add """ yield from self._hypervisor.send('nio_bridge add_nio "{name}" {nio}'.format(name=self._name, nio=nio)) self._nios.append(nio)
[ "def", "add_nio", "(", "self", ",", "nio", ")", ":", "yield", "from", "self", ".", "_hypervisor", ".", "send", "(", "'nio_bridge add_nio \"{name}\" {nio}'", ".", "format", "(", "name", "=", "self", ".", "_name", ",", "nio", "=", "nio", ")", ")", "self", ...
Adds a NIO as new port on this bridge. :param nio: NIO instance to add
[ "Adds", "a", "NIO", "as", "new", "port", "on", "this", "bridge", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/bridge.py#L89-L97
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/bridge.py
Bridge.remove_nio
def remove_nio(self, nio): """ Removes the specified NIO as member of this bridge. :param nio: NIO instance to remove """ if self._hypervisor: yield from self._hypervisor.send('nio_bridge remove_nio "{name}" {nio}'.format(name=self._name, nio=nio)) self._nios...
python
def remove_nio(self, nio): """ Removes the specified NIO as member of this bridge. :param nio: NIO instance to remove """ if self._hypervisor: yield from self._hypervisor.send('nio_bridge remove_nio "{name}" {nio}'.format(name=self._name, nio=nio)) self._nios...
[ "def", "remove_nio", "(", "self", ",", "nio", ")", ":", "if", "self", ".", "_hypervisor", ":", "yield", "from", "self", ".", "_hypervisor", ".", "send", "(", "'nio_bridge remove_nio \"{name}\" {nio}'", ".", "format", "(", "name", "=", "self", ".", "_name", ...
Removes the specified NIO as member of this bridge. :param nio: NIO instance to remove
[ "Removes", "the", "specified", "NIO", "as", "member", "of", "this", "bridge", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/bridge.py#L100-L108
train
GNS3/gns3-server
gns3server/controller/import_project.py
_move_node_file
def _move_node_file(path, old_id, new_id): """ Move the files from a node when changing his id :param path: Path of the project :param old_id: ID before change :param new_id: New node UUID """ root = os.path.join(path, "project-files") if os.path.exists(root): for dirname in os....
python
def _move_node_file(path, old_id, new_id): """ Move the files from a node when changing his id :param path: Path of the project :param old_id: ID before change :param new_id: New node UUID """ root = os.path.join(path, "project-files") if os.path.exists(root): for dirname in os....
[ "def", "_move_node_file", "(", "path", ",", "old_id", ",", "new_id", ")", ":", "root", "=", "os", ".", "path", ".", "join", "(", "path", ",", "\"project-files\"", ")", "if", "os", ".", "path", ".", "exists", "(", "root", ")", ":", "for", "dirname", ...
Move the files from a node when changing his id :param path: Path of the project :param old_id: ID before change :param new_id: New node UUID
[ "Move", "the", "files", "from", "a", "node", "when", "changing", "his", "id" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/import_project.py#L157-L172
train
GNS3/gns3-server
gns3server/controller/import_project.py
_move_files_to_compute
def _move_files_to_compute(compute, project_id, directory, files_path): """ Move the files to a remote compute """ location = os.path.join(directory, files_path) if os.path.exists(location): for (dirpath, dirnames, filenames) in os.walk(location): for filename in filenames: ...
python
def _move_files_to_compute(compute, project_id, directory, files_path): """ Move the files to a remote compute """ location = os.path.join(directory, files_path) if os.path.exists(location): for (dirpath, dirnames, filenames) in os.walk(location): for filename in filenames: ...
[ "def", "_move_files_to_compute", "(", "compute", ",", "project_id", ",", "directory", ",", "files_path", ")", ":", "location", "=", "os", ".", "path", ".", "join", "(", "directory", ",", "files_path", ")", "if", "os", ".", "path", ".", "exists", "(", "lo...
Move the files to a remote compute
[ "Move", "the", "files", "to", "a", "remote", "compute" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/import_project.py#L176-L187
train
GNS3/gns3-server
gns3server/controller/import_project.py
_upload_file
def _upload_file(compute, project_id, file_path, path): """ Upload a file to a remote project :param file_path: File path on the controller file system :param path: File path on the remote system relative to project directory """ path = "/projects/{}/files/{}".format(project_id, path.replace("\...
python
def _upload_file(compute, project_id, file_path, path): """ Upload a file to a remote project :param file_path: File path on the controller file system :param path: File path on the remote system relative to project directory """ path = "/projects/{}/files/{}".format(project_id, path.replace("\...
[ "def", "_upload_file", "(", "compute", ",", "project_id", ",", "file_path", ",", "path", ")", ":", "path", "=", "\"/projects/{}/files/{}\"", ".", "format", "(", "project_id", ",", "path", ".", "replace", "(", "\"\\\\\"", ",", "\"/\"", ")", ")", "with", "op...
Upload a file to a remote project :param file_path: File path on the controller file system :param path: File path on the remote system relative to project directory
[ "Upload", "a", "file", "to", "a", "remote", "project" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/import_project.py#L191-L200
train
GNS3/gns3-server
gns3server/controller/import_project.py
_import_images
def _import_images(controller, path): """ Copy images to the images directory or delete them if they already exists. """ image_dir = controller.images_path() root = os.path.join(path, "images") for (dirpath, dirnames, filenames) in os.walk(root): for filename in filenames: ...
python
def _import_images(controller, path): """ Copy images to the images directory or delete them if they already exists. """ image_dir = controller.images_path() root = os.path.join(path, "images") for (dirpath, dirnames, filenames) in os.walk(root): for filename in filenames: ...
[ "def", "_import_images", "(", "controller", ",", "path", ")", ":", "image_dir", "=", "controller", ".", "images_path", "(", ")", "root", "=", "os", ".", "path", ".", "join", "(", "path", ",", "\"images\"", ")", "for", "(", "dirpath", ",", "dirnames", "...
Copy images to the images directory or delete them if they already exists.
[ "Copy", "images", "to", "the", "images", "directory", "or", "delete", "them", "if", "they", "already", "exists", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/import_project.py#L203-L216
train
GNS3/gns3-server
gns3server/utils/windows_loopback.py
parse_add_loopback
def parse_add_loopback(): """ Validate params when adding a loopback adapter """ class Add(argparse.Action): def __call__(self, parser, args, values, option_string=None): try: ipaddress.IPv4Interface("{}/{}".format(values[1], values[2])) except ipaddress...
python
def parse_add_loopback(): """ Validate params when adding a loopback adapter """ class Add(argparse.Action): def __call__(self, parser, args, values, option_string=None): try: ipaddress.IPv4Interface("{}/{}".format(values[1], values[2])) except ipaddress...
[ "def", "parse_add_loopback", "(", ")", ":", "class", "Add", "(", "argparse", ".", "Action", ")", ":", "def", "__call__", "(", "self", ",", "parser", ",", "args", ",", "values", ",", "option_string", "=", "None", ")", ":", "try", ":", "ipaddress", ".", ...
Validate params when adding a loopback adapter
[ "Validate", "params", "when", "adding", "a", "loopback", "adapter" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/windows_loopback.py#L31-L46
train
GNS3/gns3-server
gns3server/utils/windows_loopback.py
main
def main(): """ Entry point for the Windows loopback tool. """ parser = argparse.ArgumentParser(description='%(prog)s add/remove Windows loopback adapters') parser.add_argument('-a', "--add", nargs=3, action=parse_add_loopback(), help="add a Windows loopback adapter") parser.add_argument("-r", ...
python
def main(): """ Entry point for the Windows loopback tool. """ parser = argparse.ArgumentParser(description='%(prog)s add/remove Windows loopback adapters') parser.add_argument('-a', "--add", nargs=3, action=parse_add_loopback(), help="add a Windows loopback adapter") parser.add_argument("-r", ...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'%(prog)s add/remove Windows loopback adapters'", ")", "parser", ".", "add_argument", "(", "'-a'", ",", "\"--add\"", ",", "nargs", "=", "3", ",", "action", ...
Entry point for the Windows loopback tool.
[ "Entry", "point", "for", "the", "Windows", "loopback", "tool", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/windows_loopback.py#L105-L134
train
GNS3/gns3-server
gns3server/utils/picture.py
_svg_convert_size
def _svg_convert_size(size): """ Convert svg size to the px version :param size: String with the size """ # https://www.w3.org/TR/SVG/coords.html#Units conversion_table = { "pt": 1.25, "pc": 15, "mm": 3.543307, "cm": 35.43307, "in": 90, "px": 1 ...
python
def _svg_convert_size(size): """ Convert svg size to the px version :param size: String with the size """ # https://www.w3.org/TR/SVG/coords.html#Units conversion_table = { "pt": 1.25, "pc": 15, "mm": 3.543307, "cm": 35.43307, "in": 90, "px": 1 ...
[ "def", "_svg_convert_size", "(", "size", ")", ":", "# https://www.w3.org/TR/SVG/coords.html#Units", "conversion_table", "=", "{", "\"pt\"", ":", "1.25", ",", "\"pc\"", ":", "15", ",", "\"mm\"", ":", "3.543307", ",", "\"cm\"", ":", "35.43307", ",", "\"in\"", ":",...
Convert svg size to the px version :param size: String with the size
[ "Convert", "svg", "size", "to", "the", "px", "version" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/picture.py#L114-L134
train
GNS3/gns3-server
gns3server/utils/images.py
list_images
def list_images(type): """ Scan directories for available image for a type :param type: emulator type (dynamips, qemu, iou) """ files = set() images = [] server_config = Config.instance().get_section_config("Server") general_images_directory = os.path.expanduser(server_config.get("imag...
python
def list_images(type): """ Scan directories for available image for a type :param type: emulator type (dynamips, qemu, iou) """ files = set() images = [] server_config = Config.instance().get_section_config("Server") general_images_directory = os.path.expanduser(server_config.get("imag...
[ "def", "list_images", "(", "type", ")", ":", "files", "=", "set", "(", ")", "images", "=", "[", "]", "server_config", "=", "Config", ".", "instance", "(", ")", ".", "get_section_config", "(", "\"Server\"", ")", "general_images_directory", "=", "os", ".", ...
Scan directories for available image for a type :param type: emulator type (dynamips, qemu, iou)
[ "Scan", "directories", "for", "available", "image", "for", "a", "type" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/images.py#L29-L87
train
GNS3/gns3-server
gns3server/utils/images.py
_os_walk
def _os_walk(directory, recurse=True, **kwargs): """ Work like os.walk but if recurse is False just list current directory """ if recurse: for root, dirs, files in os.walk(directory, **kwargs): yield root, dirs, files else: files = [] for filename in os.listdir(di...
python
def _os_walk(directory, recurse=True, **kwargs): """ Work like os.walk but if recurse is False just list current directory """ if recurse: for root, dirs, files in os.walk(directory, **kwargs): yield root, dirs, files else: files = [] for filename in os.listdir(di...
[ "def", "_os_walk", "(", "directory", ",", "recurse", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "recurse", ":", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "directory", ",", "*", "*", "kwargs", ")", ":", "yi...
Work like os.walk but if recurse is False just list current directory
[ "Work", "like", "os", ".", "walk", "but", "if", "recurse", "is", "False", "just", "list", "current", "directory" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/images.py#L90-L102
train
GNS3/gns3-server
gns3server/utils/images.py
images_directories
def images_directories(type): """ Return all directory where we will look for images by priority :param type: Type of emulator """ server_config = Config.instance().get_section_config("Server") paths = [] img_dir = os.path.expanduser(server_config.get("images_path", "~/GNS3/images")) ...
python
def images_directories(type): """ Return all directory where we will look for images by priority :param type: Type of emulator """ server_config = Config.instance().get_section_config("Server") paths = [] img_dir = os.path.expanduser(server_config.get("images_path", "~/GNS3/images")) ...
[ "def", "images_directories", "(", "type", ")", ":", "server_config", "=", "Config", ".", "instance", "(", ")", ".", "get_section_config", "(", "\"Server\"", ")", "paths", "=", "[", "]", "img_dir", "=", "os", ".", "path", ".", "expanduser", "(", "server_con...
Return all directory where we will look for images by priority :param type: Type of emulator
[ "Return", "all", "directory", "where", "we", "will", "look", "for", "images", "by", "priority" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/images.py#L121-L143
train
GNS3/gns3-server
gns3server/utils/images.py
md5sum
def md5sum(path): """ Return the md5sum of an image and cache it on disk :param path: Path to the image :returns: Digest of the image """ if path is None or len(path) == 0 or not os.path.exists(path): return None try: with open(path + '.md5sum') as f: md5 = f.r...
python
def md5sum(path): """ Return the md5sum of an image and cache it on disk :param path: Path to the image :returns: Digest of the image """ if path is None or len(path) == 0 or not os.path.exists(path): return None try: with open(path + '.md5sum') as f: md5 = f.r...
[ "def", "md5sum", "(", "path", ")", ":", "if", "path", "is", "None", "or", "len", "(", "path", ")", "==", "0", "or", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "return", "None", "try", ":", "with", "open", "(", "path", "+", ...
Return the md5sum of an image and cache it on disk :param path: Path to the image :returns: Digest of the image
[ "Return", "the", "md5sum", "of", "an", "image", "and", "cache", "it", "on", "disk" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/images.py#L146-L185
train
GNS3/gns3-server
gns3server/utils/images.py
remove_checksum
def remove_checksum(path): """ Remove the checksum of an image from cache if exists """ path = '{}.md5sum'.format(path) if os.path.exists(path): os.remove(path)
python
def remove_checksum(path): """ Remove the checksum of an image from cache if exists """ path = '{}.md5sum'.format(path) if os.path.exists(path): os.remove(path)
[ "def", "remove_checksum", "(", "path", ")", ":", "path", "=", "'{}.md5sum'", ".", "format", "(", "path", ")", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "os", ".", "remove", "(", "path", ")" ]
Remove the checksum of an image from cache if exists
[ "Remove", "the", "checksum", "of", "an", "image", "from", "cache", "if", "exists" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/images.py#L188-L195
train
GNS3/gns3-server
gns3server/compute/project.py
Project.record_tcp_port
def record_tcp_port(self, port): """ Associate a reserved TCP port number with this project. :param port: TCP port number """ if port not in self._used_tcp_ports: self._used_tcp_ports.add(port)
python
def record_tcp_port(self, port): """ Associate a reserved TCP port number with this project. :param port: TCP port number """ if port not in self._used_tcp_ports: self._used_tcp_ports.add(port)
[ "def", "record_tcp_port", "(", "self", ",", "port", ")", ":", "if", "port", "not", "in", "self", ".", "_used_tcp_ports", ":", "self", ".", "_used_tcp_ports", ".", "add", "(", "port", ")" ]
Associate a reserved TCP port number with this project. :param port: TCP port number
[ "Associate", "a", "reserved", "TCP", "port", "number", "with", "this", "project", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project.py#L134-L142
train
GNS3/gns3-server
gns3server/compute/project.py
Project.record_udp_port
def record_udp_port(self, port): """ Associate a reserved UDP port number with this project. :param port: UDP port number """ if port not in self._used_udp_ports: self._used_udp_ports.add(port)
python
def record_udp_port(self, port): """ Associate a reserved UDP port number with this project. :param port: UDP port number """ if port not in self._used_udp_ports: self._used_udp_ports.add(port)
[ "def", "record_udp_port", "(", "self", ",", "port", ")", ":", "if", "port", "not", "in", "self", ".", "_used_udp_ports", ":", "self", ".", "_used_udp_ports", ".", "add", "(", "port", ")" ]
Associate a reserved UDP port number with this project. :param port: UDP port number
[ "Associate", "a", "reserved", "UDP", "port", "number", "with", "this", "project", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project.py#L144-L152
train
GNS3/gns3-server
gns3server/compute/project.py
Project.remove_tcp_port
def remove_tcp_port(self, port): """ Removes an associated TCP port number from this project. :param port: TCP port number """ if port in self._used_tcp_ports: self._used_tcp_ports.remove(port)
python
def remove_tcp_port(self, port): """ Removes an associated TCP port number from this project. :param port: TCP port number """ if port in self._used_tcp_ports: self._used_tcp_ports.remove(port)
[ "def", "remove_tcp_port", "(", "self", ",", "port", ")", ":", "if", "port", "in", "self", ".", "_used_tcp_ports", ":", "self", ".", "_used_tcp_ports", ".", "remove", "(", "port", ")" ]
Removes an associated TCP port number from this project. :param port: TCP port number
[ "Removes", "an", "associated", "TCP", "port", "number", "from", "this", "project", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project.py#L154-L162
train
GNS3/gns3-server
gns3server/compute/project.py
Project.remove_udp_port
def remove_udp_port(self, port): """ Removes an associated UDP port number from this project. :param port: UDP port number """ if port in self._used_udp_ports: self._used_udp_ports.remove(port)
python
def remove_udp_port(self, port): """ Removes an associated UDP port number from this project. :param port: UDP port number """ if port in self._used_udp_ports: self._used_udp_ports.remove(port)
[ "def", "remove_udp_port", "(", "self", ",", "port", ")", ":", "if", "port", "in", "self", ".", "_used_udp_ports", ":", "self", ".", "_used_udp_ports", ".", "remove", "(", "port", ")" ]
Removes an associated UDP port number from this project. :param port: UDP port number
[ "Removes", "an", "associated", "UDP", "port", "number", "from", "this", "project", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project.py#L164-L172
train
GNS3/gns3-server
gns3server/compute/project.py
Project.module_working_directory
def module_working_directory(self, module_name): """ Returns a working directory for the module The directory is created if the directory doesn't exist. :param module_name: name for the module :returns: working directory """ workdir = self.module_working_path(mo...
python
def module_working_directory(self, module_name): """ Returns a working directory for the module The directory is created if the directory doesn't exist. :param module_name: name for the module :returns: working directory """ workdir = self.module_working_path(mo...
[ "def", "module_working_directory", "(", "self", ",", "module_name", ")", ":", "workdir", "=", "self", ".", "module_working_path", "(", "module_name", ")", "if", "not", "self", ".", "_deleted", ":", "try", ":", "os", ".", "makedirs", "(", "workdir", ",", "e...
Returns a working directory for the module The directory is created if the directory doesn't exist. :param module_name: name for the module :returns: working directory
[ "Returns", "a", "working", "directory", "for", "the", "module", "The", "directory", "is", "created", "if", "the", "directory", "doesn", "t", "exist", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project.py#L174-L189
train
GNS3/gns3-server
gns3server/compute/project.py
Project.node_working_directory
def node_working_directory(self, node): """ Returns a working directory for a specific node. If the directory doesn't exist, the directory is created. :param node: Node instance :returns: Node working directory """ workdir = self.node_working_path(node) ...
python
def node_working_directory(self, node): """ Returns a working directory for a specific node. If the directory doesn't exist, the directory is created. :param node: Node instance :returns: Node working directory """ workdir = self.node_working_path(node) ...
[ "def", "node_working_directory", "(", "self", ",", "node", ")", ":", "workdir", "=", "self", ".", "node_working_path", "(", "node", ")", "if", "not", "self", ".", "_deleted", ":", "try", ":", "os", ".", "makedirs", "(", "workdir", ",", "exist_ok", "=", ...
Returns a working directory for a specific node. If the directory doesn't exist, the directory is created. :param node: Node instance :returns: Node working directory
[ "Returns", "a", "working", "directory", "for", "a", "specific", "node", ".", "If", "the", "directory", "doesn", "t", "exist", "the", "directory", "is", "created", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project.py#L200-L216
train
GNS3/gns3-server
gns3server/compute/project.py
Project.capture_working_directory
def capture_working_directory(self): """ Returns a working directory where to temporary store packet capture files. :returns: path to the directory """ workdir = os.path.join(self._path, "tmp", "captures") if not self._deleted: try: os.makedi...
python
def capture_working_directory(self): """ Returns a working directory where to temporary store packet capture files. :returns: path to the directory """ workdir = os.path.join(self._path, "tmp", "captures") if not self._deleted: try: os.makedi...
[ "def", "capture_working_directory", "(", "self", ")", ":", "workdir", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_path", ",", "\"tmp\"", ",", "\"captures\"", ")", "if", "not", "self", ".", "_deleted", ":", "try", ":", "os", ".", "makedirs"...
Returns a working directory where to temporary store packet capture files. :returns: path to the directory
[ "Returns", "a", "working", "directory", "where", "to", "temporary", "store", "packet", "capture", "files", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project.py#L233-L246
train
GNS3/gns3-server
gns3server/compute/project.py
Project.remove_node
def remove_node(self, node): """ Removes a node from the project. In theory this should be called by the node manager. :param node: Node instance """ if node in self._nodes: yield from node.delete() self._nodes.remove(node)
python
def remove_node(self, node): """ Removes a node from the project. In theory this should be called by the node manager. :param node: Node instance """ if node in self._nodes: yield from node.delete() self._nodes.remove(node)
[ "def", "remove_node", "(", "self", ",", "node", ")", ":", "if", "node", "in", "self", ".", "_nodes", ":", "yield", "from", "node", ".", "delete", "(", ")", "self", ".", "_nodes", ".", "remove", "(", "node", ")" ]
Removes a node from the project. In theory this should be called by the node manager. :param node: Node instance
[ "Removes", "a", "node", "from", "the", "project", ".", "In", "theory", "this", "should", "be", "called", "by", "the", "node", "manager", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project.py#L278-L288
train
GNS3/gns3-server
gns3server/compute/project.py
Project.close
def close(self): """ Closes the project, but keep information on disk """ project_nodes_id = set([n.id for n in self.nodes]) for module in self.compute(): module_nodes_id = set([n.id for n in module.instance().nodes]) # We close the project only for the ...
python
def close(self): """ Closes the project, but keep information on disk """ project_nodes_id = set([n.id for n in self.nodes]) for module in self.compute(): module_nodes_id = set([n.id for n in module.instance().nodes]) # We close the project only for the ...
[ "def", "close", "(", "self", ")", ":", "project_nodes_id", "=", "set", "(", "[", "n", ".", "id", "for", "n", "in", "self", ".", "nodes", "]", ")", "for", "module", "in", "self", ".", "compute", "(", ")", ":", "module_nodes_id", "=", "set", "(", "...
Closes the project, but keep information on disk
[ "Closes", "the", "project", "but", "keep", "information", "on", "disk" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project.py#L291-L316
train
GNS3/gns3-server
gns3server/compute/project.py
Project._close_and_clean
def _close_and_clean(self, cleanup): """ Closes the project, and cleanup the disk if cleanup is True :param cleanup: Whether to delete the project directory """ tasks = [] for node in self._nodes: tasks.append(asyncio.async(node.manager.close_node(node.id)))...
python
def _close_and_clean(self, cleanup): """ Closes the project, and cleanup the disk if cleanup is True :param cleanup: Whether to delete the project directory """ tasks = [] for node in self._nodes: tasks.append(asyncio.async(node.manager.close_node(node.id)))...
[ "def", "_close_and_clean", "(", "self", ",", "cleanup", ")", ":", "tasks", "=", "[", "]", "for", "node", "in", "self", ".", "_nodes", ":", "tasks", ".", "append", "(", "asyncio", ".", "async", "(", "node", ".", "manager", ".", "close_node", "(", "nod...
Closes the project, and cleanup the disk if cleanup is True :param cleanup: Whether to delete the project directory
[ "Closes", "the", "project", "and", "cleanup", "the", "disk", "if", "cleanup", "is", "True" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project.py#L319-L358
train
GNS3/gns3-server
gns3server/compute/project.py
Project.delete
def delete(self): """ Removes project from disk """ for module in self.compute(): yield from module.instance().project_closing(self) yield from self._close_and_clean(True) for module in self.compute(): yield from module.instance().project_closed(s...
python
def delete(self): """ Removes project from disk """ for module in self.compute(): yield from module.instance().project_closing(self) yield from self._close_and_clean(True) for module in self.compute(): yield from module.instance().project_closed(s...
[ "def", "delete", "(", "self", ")", ":", "for", "module", "in", "self", ".", "compute", "(", ")", ":", "yield", "from", "module", ".", "instance", "(", ")", ".", "project_closing", "(", "self", ")", "yield", "from", "self", ".", "_close_and_clean", "(",...
Removes project from disk
[ "Removes", "project", "from", "disk" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project.py#L361-L370
train
GNS3/gns3-server
gns3server/compute/project.py
Project._hash_file
def _hash_file(self, path): """ Compute and md5 hash for file :returns: hexadecimal md5 """ m = hashlib.md5() with open(path, "rb") as f: while True: buf = f.read(128) if not buf: break m.up...
python
def _hash_file(self, path): """ Compute and md5 hash for file :returns: hexadecimal md5 """ m = hashlib.md5() with open(path, "rb") as f: while True: buf = f.read(128) if not buf: break m.up...
[ "def", "_hash_file", "(", "self", ",", "path", ")", ":", "m", "=", "hashlib", ".", "md5", "(", ")", "with", "open", "(", "path", ",", "\"rb\"", ")", "as", "f", ":", "while", "True", ":", "buf", "=", "f", ".", "read", "(", "128", ")", "if", "n...
Compute and md5 hash for file :returns: hexadecimal md5
[ "Compute", "and", "md5", "hash", "for", "file" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/project.py#L413-L427
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/ethernet_switch.py
EthernetSwitchConsole.mac
def mac(self): """ Show MAC address table """ res = 'Port Mac VLAN\n' result = (yield from self._node._hypervisor.send('ethsw show_mac_addr_table {}'.format(self._node.name))) for line in result: mac, vlan, nio = line.replace(' ', ' ').sp...
python
def mac(self): """ Show MAC address table """ res = 'Port Mac VLAN\n' result = (yield from self._node._hypervisor.send('ethsw show_mac_addr_table {}'.format(self._node.name))) for line in result: mac, vlan, nio = line.replace(' ', ' ').sp...
[ "def", "mac", "(", "self", ")", ":", "res", "=", "'Port Mac VLAN\\n'", "result", "=", "(", "yield", "from", "self", ".", "_node", ".", "_hypervisor", ".", "send", "(", "'ethsw show_mac_addr_table {}'", ".", "format", "(", "self", ".", "_no...
Show MAC address table
[ "Show", "MAC", "address", "table" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_switch.py#L47-L67
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/ethernet_switch.py
EthernetSwitch.set_name
def set_name(self, new_name): """ Renames this Ethernet switch. :param new_name: New name for this switch """ yield from self._hypervisor.send('ethsw rename "{name}" "{new_name}"'.format(name=self._name, new_name=new_name)) log.info('Ethernet switch "{name}" [{id}]: ren...
python
def set_name(self, new_name): """ Renames this Ethernet switch. :param new_name: New name for this switch """ yield from self._hypervisor.send('ethsw rename "{name}" "{new_name}"'.format(name=self._name, new_name=new_name)) log.info('Ethernet switch "{name}" [{id}]: ren...
[ "def", "set_name", "(", "self", ",", "new_name", ")", ":", "yield", "from", "self", ".", "_hypervisor", ".", "send", "(", "'ethsw rename \"{name}\" \"{new_name}\"'", ".", "format", "(", "name", "=", "self", ".", "_name", ",", "new_name", "=", "new_name", ")"...
Renames this Ethernet switch. :param new_name: New name for this switch
[ "Renames", "this", "Ethernet", "switch", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_switch.py#L175-L186
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/ethernet_switch.py
EthernetSwitch.close
def close(self): """ Deletes this Ethernet switch. """ yield from self._telnet.close() self._telnet_server.close() for nio in self._nios.values(): if nio: yield from nio.close() self.manager.port_manager.release_tcp_port(self._...
python
def close(self): """ Deletes this Ethernet switch. """ yield from self._telnet.close() self._telnet_server.close() for nio in self._nios.values(): if nio: yield from nio.close() self.manager.port_manager.release_tcp_port(self._...
[ "def", "close", "(", "self", ")", ":", "yield", "from", "self", ".", "_telnet", ".", "close", "(", ")", "self", ".", "_telnet_server", ".", "close", "(", ")", "for", "nio", "in", "self", ".", "_nios", ".", "values", "(", ")", ":", "if", "nio", ":...
Deletes this Ethernet switch.
[ "Deletes", "this", "Ethernet", "switch", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_switch.py#L213-L235
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/ethernet_switch.py
EthernetSwitch.add_nio
def add_nio(self, nio, port_number): """ Adds a NIO as new port on Ethernet switch. :param nio: NIO instance to add :param port_number: port to allocate for the NIO """ if port_number in self._nios: raise DynamipsError("Port {} isn't free".format(port_number...
python
def add_nio(self, nio, port_number): """ Adds a NIO as new port on Ethernet switch. :param nio: NIO instance to add :param port_number: port to allocate for the NIO """ if port_number in self._nios: raise DynamipsError("Port {} isn't free".format(port_number...
[ "def", "add_nio", "(", "self", ",", "nio", ",", "port_number", ")", ":", "if", "port_number", "in", "self", ".", "_nios", ":", "raise", "DynamipsError", "(", "\"Port {} isn't free\"", ".", "format", "(", "port_number", ")", ")", "yield", "from", "self", "....
Adds a NIO as new port on Ethernet switch. :param nio: NIO instance to add :param port_number: port to allocate for the NIO
[ "Adds", "a", "NIO", "as", "new", "port", "on", "Ethernet", "switch", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_switch.py#L238-L259
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/ethernet_switch.py
EthernetSwitch.remove_nio
def remove_nio(self, port_number): """ Removes the specified NIO as member of this Ethernet switch. :param port_number: allocated port number :returns: the NIO that was bound to the port """ if port_number not in self._nios: raise DynamipsError("Port {} is ...
python
def remove_nio(self, port_number): """ Removes the specified NIO as member of this Ethernet switch. :param port_number: allocated port number :returns: the NIO that was bound to the port """ if port_number not in self._nios: raise DynamipsError("Port {} is ...
[ "def", "remove_nio", "(", "self", ",", "port_number", ")", ":", "if", "port_number", "not", "in", "self", ".", "_nios", ":", "raise", "DynamipsError", "(", "\"Port {} is not allocated\"", ".", "format", "(", "port_number", ")", ")", "nio", "=", "self", ".", ...
Removes the specified NIO as member of this Ethernet switch. :param port_number: allocated port number :returns: the NIO that was bound to the port
[ "Removes", "the", "specified", "NIO", "as", "member", "of", "this", "Ethernet", "switch", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_switch.py#L262-L289
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/ethernet_switch.py
EthernetSwitch.set_port_settings
def set_port_settings(self, port_number, settings): """ Applies port settings to a specific port. :param port_number: port number to set the settings :param settings: port settings """ if settings["type"] == "access": yield from self.set_access_port(port_num...
python
def set_port_settings(self, port_number, settings): """ Applies port settings to a specific port. :param port_number: port number to set the settings :param settings: port settings """ if settings["type"] == "access": yield from self.set_access_port(port_num...
[ "def", "set_port_settings", "(", "self", ",", "port_number", ",", "settings", ")", ":", "if", "settings", "[", "\"type\"", "]", "==", "\"access\"", ":", "yield", "from", "self", ".", "set_access_port", "(", "port_number", ",", "settings", "[", "\"vlan\"", "]...
Applies port settings to a specific port. :param port_number: port number to set the settings :param settings: port settings
[ "Applies", "port", "settings", "to", "a", "specific", "port", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_switch.py#L292-L305
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/ethernet_switch.py
EthernetSwitch.set_access_port
def set_access_port(self, port_number, vlan_id): """ Sets the specified port as an ACCESS port. :param port_number: allocated port number :param vlan_id: VLAN number membership """ if port_number not in self._nios: raise DynamipsError("Port {} is not allocat...
python
def set_access_port(self, port_number, vlan_id): """ Sets the specified port as an ACCESS port. :param port_number: allocated port number :param vlan_id: VLAN number membership """ if port_number not in self._nios: raise DynamipsError("Port {} is not allocat...
[ "def", "set_access_port", "(", "self", ",", "port_number", ",", "vlan_id", ")", ":", "if", "port_number", "not", "in", "self", ".", "_nios", ":", "raise", "DynamipsError", "(", "\"Port {} is not allocated\"", ".", "format", "(", "port_number", ")", ")", "nio",...
Sets the specified port as an ACCESS port. :param port_number: allocated port number :param vlan_id: VLAN number membership
[ "Sets", "the", "specified", "port", "as", "an", "ACCESS", "port", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_switch.py#L308-L328
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/ethernet_switch.py
EthernetSwitch.get_mac_addr_table
def get_mac_addr_table(self): """ Returns the MAC address table for this Ethernet switch. :returns: list of entries (Ethernet address, VLAN, NIO) """ mac_addr_table = yield from self._hypervisor.send('ethsw show_mac_addr_table "{}"'.format(self._name)) return mac_addr_t...
python
def get_mac_addr_table(self): """ Returns the MAC address table for this Ethernet switch. :returns: list of entries (Ethernet address, VLAN, NIO) """ mac_addr_table = yield from self._hypervisor.send('ethsw show_mac_addr_table "{}"'.format(self._name)) return mac_addr_t...
[ "def", "get_mac_addr_table", "(", "self", ")", ":", "mac_addr_table", "=", "yield", "from", "self", ".", "_hypervisor", ".", "send", "(", "'ethsw show_mac_addr_table \"{}\"'", ".", "format", "(", "self", ".", "_name", ")", ")", "return", "mac_addr_table" ]
Returns the MAC address table for this Ethernet switch. :returns: list of entries (Ethernet address, VLAN, NIO)
[ "Returns", "the", "MAC", "address", "table", "for", "this", "Ethernet", "switch", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_switch.py#L383-L391
train
GNS3/gns3-server
gns3server/web/web_server.py
WebServer.instance
def instance(host=None, port=None): """ Singleton to return only one instance of Server. :returns: instance of Server """ if not hasattr(WebServer, "_instance") or WebServer._instance is None: assert host is not None assert port is not None W...
python
def instance(host=None, port=None): """ Singleton to return only one instance of Server. :returns: instance of Server """ if not hasattr(WebServer, "_instance") or WebServer._instance is None: assert host is not None assert port is not None W...
[ "def", "instance", "(", "host", "=", "None", ",", "port", "=", "None", ")", ":", "if", "not", "hasattr", "(", "WebServer", ",", "\"_instance\"", ")", "or", "WebServer", ".", "_instance", "is", "None", ":", "assert", "host", "is", "not", "None", "assert...
Singleton to return only one instance of Server. :returns: instance of Server
[ "Singleton", "to", "return", "only", "one", "instance", "of", "Server", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/web/web_server.py#L64-L75
train
GNS3/gns3-server
gns3server/web/web_server.py
WebServer.shutdown_server
def shutdown_server(self): """ Cleanly shutdown the server. """ if not self._closing: self._closing = True else: log.warning("Close is already in progress") return if self._server: self._server.close() yield fr...
python
def shutdown_server(self): """ Cleanly shutdown the server. """ if not self._closing: self._closing = True else: log.warning("Close is already in progress") return if self._server: self._server.close() yield fr...
[ "def", "shutdown_server", "(", "self", ")", ":", "if", "not", "self", ".", "_closing", ":", "self", ".", "_closing", "=", "True", "else", ":", "log", ".", "warning", "(", "\"Close is already in progress\"", ")", "return", "if", "self", ".", "_server", ":",...
Cleanly shutdown the server.
[ "Cleanly", "shutdown", "the", "server", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/web/web_server.py#L87-L133
train
GNS3/gns3-server
gns3server/web/web_server.py
WebServer._exit_handling
def _exit_handling(self): """ Makes sure the asyncio loop is closed. """ def close_asyncio_loop(): loop = None try: loop = asyncio.get_event_loop() except AttributeError: pass if loop is not None: ...
python
def _exit_handling(self): """ Makes sure the asyncio loop is closed. """ def close_asyncio_loop(): loop = None try: loop = asyncio.get_event_loop() except AttributeError: pass if loop is not None: ...
[ "def", "_exit_handling", "(", "self", ")", ":", "def", "close_asyncio_loop", "(", ")", ":", "loop", "=", "None", "try", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "except", "AttributeError", ":", "pass", "if", "loop", "is", "not", "Non...
Makes sure the asyncio loop is closed.
[ "Makes", "sure", "the", "asyncio", "loop", "is", "closed", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/web/web_server.py#L181-L195
train
GNS3/gns3-server
gns3server/web/web_server.py
WebServer._on_startup
def _on_startup(self, *args): """ Called when the HTTP server start """ yield from Controller.instance().start() # Because with a large image collection # without md5sum already computed we start the # computing with server start asyncio.async(Qemu.instanc...
python
def _on_startup(self, *args): """ Called when the HTTP server start """ yield from Controller.instance().start() # Because with a large image collection # without md5sum already computed we start the # computing with server start asyncio.async(Qemu.instanc...
[ "def", "_on_startup", "(", "self", ",", "*", "args", ")", ":", "yield", "from", "Controller", ".", "instance", "(", ")", ".", "start", "(", ")", "# Because with a large image collection", "# without md5sum already computed we start the", "# computing with server start", ...
Called when the HTTP server start
[ "Called", "when", "the", "HTTP", "server", "start" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/web/web_server.py#L198-L206
train
GNS3/gns3-server
gns3server/compute/builtin/nodes/ethernet_hub.py
EthernetHub.create
def create(self): """ Creates this hub. """ super().create() log.info('Ethernet hub "{name}" [{id}] has been created'.format(name=self._name, id=self._id))
python
def create(self): """ Creates this hub. """ super().create() log.info('Ethernet hub "{name}" [{id}] has been created'.format(name=self._name, id=self._id))
[ "def", "create", "(", "self", ")", ":", "super", "(", ")", ".", "create", "(", ")", "log", ".", "info", "(", "'Ethernet hub \"{name}\" [{id}] has been created'", ".", "format", "(", "name", "=", "self", ".", "_name", ",", "id", "=", "self", ".", "_id", ...
Creates this hub.
[ "Creates", "this", "hub", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/builtin/nodes/ethernet_hub.py#L48-L54
train
GNS3/gns3-server
gns3server/compute/virtualbox/__init__.py
VirtualBox.list_vms
def list_vms(self, allow_clone=False): """ Gets VirtualBox VM list. """ vbox_vms = [] result = yield from self.execute("list", ["vms"]) for line in result: if len(line) == 0 or line[0] != '"' or line[-1:] != "}": continue # Broken output (per...
python
def list_vms(self, allow_clone=False): """ Gets VirtualBox VM list. """ vbox_vms = [] result = yield from self.execute("list", ["vms"]) for line in result: if len(line) == 0 or line[0] != '"' or line[-1:] != "}": continue # Broken output (per...
[ "def", "list_vms", "(", "self", ",", "allow_clone", "=", "False", ")", ":", "vbox_vms", "=", "[", "]", "result", "=", "yield", "from", "self", ".", "execute", "(", "\"list\"", ",", "[", "\"vms\"", "]", ")", "for", "line", "in", "result", ":", "if", ...
Gets VirtualBox VM list.
[ "Gets", "VirtualBox", "VM", "list", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/virtualbox/__init__.py#L174-L202
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/c7200.py
C7200.set_npe
def set_npe(self, npe): """ Sets the NPE model. :params npe: NPE model string (e.g. "npe-200") NPE models are npe-100, npe-150, npe-175, npe-200, npe-225, npe-300, npe-400 and npe-g2 (PowerPC c7200 only) """ if (yield from self.is_running()): raise D...
python
def set_npe(self, npe): """ Sets the NPE model. :params npe: NPE model string (e.g. "npe-200") NPE models are npe-100, npe-150, npe-175, npe-200, npe-225, npe-300, npe-400 and npe-g2 (PowerPC c7200 only) """ if (yield from self.is_running()): raise D...
[ "def", "set_npe", "(", "self", ",", "npe", ")", ":", "if", "(", "yield", "from", "self", ".", "is_running", "(", ")", ")", ":", "raise", "DynamipsError", "(", "\"Cannot change NPE on running router\"", ")", "yield", "from", "self", ".", "_hypervisor", ".", ...
Sets the NPE model. :params npe: NPE model string (e.g. "npe-200") NPE models are npe-100, npe-150, npe-175, npe-200, npe-225, npe-300, npe-400 and npe-g2 (PowerPC c7200 only)
[ "Sets", "the", "NPE", "model", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/c7200.py#L114-L132
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/c7200.py
C7200.set_midplane
def set_midplane(self, midplane): """ Sets the midplane model. :returns: midplane model string (e.g. "vxr" or "std") """ yield from self._hypervisor.send('c7200 set_midplane "{name}" {midplane}'.format(name=self._name, midplane=midplane)) log.info('Router "{name}" [{id...
python
def set_midplane(self, midplane): """ Sets the midplane model. :returns: midplane model string (e.g. "vxr" or "std") """ yield from self._hypervisor.send('c7200 set_midplane "{name}" {midplane}'.format(name=self._name, midplane=midplane)) log.info('Router "{name}" [{id...
[ "def", "set_midplane", "(", "self", ",", "midplane", ")", ":", "yield", "from", "self", ".", "_hypervisor", ".", "send", "(", "'c7200 set_midplane \"{name}\" {midplane}'", ".", "format", "(", "name", "=", "self", ".", "_name", ",", "midplane", "=", "midplane",...
Sets the midplane model. :returns: midplane model string (e.g. "vxr" or "std")
[ "Sets", "the", "midplane", "model", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/c7200.py#L145-L158
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/c7200.py
C7200.set_sensors
def set_sensors(self, sensors): """ Sets the 4 sensors with temperature in degree Celcius. :param sensors: list of 4 sensor temperatures corresponding to sensor 1 = I/0 controller inlet sensor 2 = I/0 controller outlet sensor 3 = NPE inlet sensor 4 = NPE outlet ...
python
def set_sensors(self, sensors): """ Sets the 4 sensors with temperature in degree Celcius. :param sensors: list of 4 sensor temperatures corresponding to sensor 1 = I/0 controller inlet sensor 2 = I/0 controller outlet sensor 3 = NPE inlet sensor 4 = NPE outlet ...
[ "def", "set_sensors", "(", "self", ",", "sensors", ")", ":", "sensor_id", "=", "0", "for", "sensor", "in", "sensors", ":", "yield", "from", "self", ".", "_hypervisor", ".", "send", "(", "'c7200 set_temp_sensor \"{name}\" {sensor_id} {temp}'", ".", "format", "(",...
Sets the 4 sensors with temperature in degree Celcius. :param sensors: list of 4 sensor temperatures corresponding to sensor 1 = I/0 controller inlet sensor 2 = I/0 controller outlet sensor 3 = NPE inlet sensor 4 = NPE outlet Example: [22, 22, 22, 22]
[ "Sets", "the", "4", "sensors", "with", "temperature", "in", "degree", "Celcius", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/c7200.py#L171-L196
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/c7200.py
C7200.set_power_supplies
def set_power_supplies(self, power_supplies): """ Sets the 2 power supplies with 0 = off, 1 = on. :param power_supplies: list of 2 power supplies. Example: [1, 0] = first power supply is on, second is off. """ power_supply_id = 0 for power_supply in power_suppli...
python
def set_power_supplies(self, power_supplies): """ Sets the 2 power supplies with 0 = off, 1 = on. :param power_supplies: list of 2 power supplies. Example: [1, 0] = first power supply is on, second is off. """ power_supply_id = 0 for power_supply in power_suppli...
[ "def", "set_power_supplies", "(", "self", ",", "power_supplies", ")", ":", "power_supply_id", "=", "0", "for", "power_supply", "in", "power_supplies", ":", "yield", "from", "self", ".", "_hypervisor", ".", "send", "(", "'c7200 set_power_supply \"{name}\" {power_supply...
Sets the 2 power supplies with 0 = off, 1 = on. :param power_supplies: list of 2 power supplies. Example: [1, 0] = first power supply is on, second is off.
[ "Sets", "the", "2", "power", "supplies", "with", "0", "=", "off", "1", "=", "on", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/c7200.py#L209-L229
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/c7200.py
C7200.start
def start(self): """ Starts this router. At least the IOS image must be set before starting it. """ # trick: we must send sensors and power supplies info after starting the router # otherwise they are not taken into account (Dynamips bug?) yield from Router.start...
python
def start(self): """ Starts this router. At least the IOS image must be set before starting it. """ # trick: we must send sensors and power supplies info after starting the router # otherwise they are not taken into account (Dynamips bug?) yield from Router.start...
[ "def", "start", "(", "self", ")", ":", "# trick: we must send sensors and power supplies info after starting the router", "# otherwise they are not taken into account (Dynamips bug?)", "yield", "from", "Router", ".", "start", "(", "self", ")", "if", "self", ".", "_sensors", "...
Starts this router. At least the IOS image must be set before starting it.
[ "Starts", "this", "router", ".", "At", "least", "the", "IOS", "image", "must", "be", "set", "before", "starting", "it", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/c7200.py#L232-L244
train
GNS3/gns3-server
gns3server/controller/export_project.py
export_project
def export_project(project, temporary_dir, include_images=False, keep_compute_id=False, allow_all_nodes=False, ignore_prefixes=None): """ Export the project as zip. It's a ZipStream object. The file will be read chunk by chunk when you iterate on the zip. It will ignore some file...
python
def export_project(project, temporary_dir, include_images=False, keep_compute_id=False, allow_all_nodes=False, ignore_prefixes=None): """ Export the project as zip. It's a ZipStream object. The file will be read chunk by chunk when you iterate on the zip. It will ignore some file...
[ "def", "export_project", "(", "project", ",", "temporary_dir", ",", "include_images", "=", "False", ",", "keep_compute_id", "=", "False", ",", "allow_all_nodes", "=", "False", ",", "ignore_prefixes", "=", "None", ")", ":", "# To avoid issue with data not saved we disa...
Export the project as zip. It's a ZipStream object. The file will be read chunk by chunk when you iterate on the zip. It will ignore some files like snapshots and :param temporary_dir: A temporary dir where to store intermediate data :param keep_compute_id: If false replace all compute id by local...
[ "Export", "the", "project", "as", "zip", ".", "It", "s", "a", "ZipStream", "object", ".", "The", "file", "will", "be", "read", "chunk", "by", "chunk", "when", "you", "iterate", "on", "the", "zip", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/export_project.py#L32-L102
train
GNS3/gns3-server
gns3server/controller/notification.py
Notification.dispatch
def dispatch(self, action, event, compute_id): """ Notification received from compute node. Send it directly to clients or process it :param action: Action name :param event: Event to send :param compute_id: Compute id of the sender """ if action == "node...
python
def dispatch(self, action, event, compute_id): """ Notification received from compute node. Send it directly to clients or process it :param action: Action name :param event: Event to send :param compute_id: Compute id of the sender """ if action == "node...
[ "def", "dispatch", "(", "self", ",", "action", ",", "event", ",", "compute_id", ")", ":", "if", "action", "==", "\"node.updated\"", ":", "try", ":", "# Update controller node data and send the event node.updated", "project", "=", "self", ".", "_controller", ".", "...
Notification received from compute node. Send it directly to clients or process it :param action: Action name :param event: Event to send :param compute_id: Compute id of the sender
[ "Notification", "received", "from", "compute", "node", ".", "Send", "it", "directly", "to", "clients", "or", "process", "it" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/notification.py#L56-L79
train
GNS3/gns3-server
gns3server/controller/notification.py
Notification.emit
def emit(self, action, event): """ Send a notification to clients scoped by projects :param action: Action name :param event: Event to send """ # If use in tests for documentation we save a sample if os.environ.get("PYTEST_BUILD_DOCUMENTATION") == "1": ...
python
def emit(self, action, event): """ Send a notification to clients scoped by projects :param action: Action name :param event: Event to send """ # If use in tests for documentation we save a sample if os.environ.get("PYTEST_BUILD_DOCUMENTATION") == "1": ...
[ "def", "emit", "(", "self", ",", "action", ",", "event", ")", ":", "# If use in tests for documentation we save a sample", "if", "os", ".", "environ", ".", "get", "(", "\"PYTEST_BUILD_DOCUMENTATION\"", ")", "==", "\"1\"", ":", "os", ".", "makedirs", "(", "\"docs...
Send a notification to clients scoped by projects :param action: Action name :param event: Event to send
[ "Send", "a", "notification", "to", "clients", "scoped", "by", "projects" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/notification.py#L81-L104
train
GNS3/gns3-server
gns3server/controller/notification.py
Notification._send_event_to_project
def _send_event_to_project(self, project_id, action, event): """ Send an event to all the client listening for notifications for this project :param project: Project where we need to send the event :param action: Action name :param event: Event to send """ ...
python
def _send_event_to_project(self, project_id, action, event): """ Send an event to all the client listening for notifications for this project :param project: Project where we need to send the event :param action: Action name :param event: Event to send """ ...
[ "def", "_send_event_to_project", "(", "self", ",", "project_id", ",", "action", ",", "event", ")", ":", "try", ":", "project_listeners", "=", "self", ".", "_listeners", "[", "project_id", "]", "except", "KeyError", ":", "return", "for", "listener", "in", "pr...
Send an event to all the client listening for notifications for this project :param project: Project where we need to send the event :param action: Action name :param event: Event to send
[ "Send", "an", "event", "to", "all", "the", "client", "listening", "for", "notifications", "for", "this", "project" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/notification.py#L106-L120
train
GNS3/gns3-server
gns3server/controller/notification.py
Notification._send_event_to_all
def _send_event_to_all(self, action, event): """ Send an event to all the client listening for notifications on all projects :param action: Action name :param event: Event to send """ for project_listeners in self._listeners.values(): for listener in ...
python
def _send_event_to_all(self, action, event): """ Send an event to all the client listening for notifications on all projects :param action: Action name :param event: Event to send """ for project_listeners in self._listeners.values(): for listener in ...
[ "def", "_send_event_to_all", "(", "self", ",", "action", ",", "event", ")", ":", "for", "project_listeners", "in", "self", ".", "_listeners", ".", "values", "(", ")", ":", "for", "listener", "in", "project_listeners", ":", "listener", ".", "put_nowait", "(",...
Send an event to all the client listening for notifications on all projects :param action: Action name :param event: Event to send
[ "Send", "an", "event", "to", "all", "the", "client", "listening", "for", "notifications", "on", "all", "projects" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/notification.py#L122-L132
train
GNS3/gns3-server
gns3server/controller/__init__.py
Controller._update_config
def _update_config(self): """ Call this when the server configuration file change """ if self._local_server: server_config = Config.instance().get_section_config("Server") self._local_server.user = server_config.get("user") self._local_server.p...
python
def _update_config(self): """ Call this when the server configuration file change """ if self._local_server: server_config = Config.instance().get_section_config("Server") self._local_server.user = server_config.get("user") self._local_server.p...
[ "def", "_update_config", "(", "self", ")", ":", "if", "self", ".", "_local_server", ":", "server_config", "=", "Config", ".", "instance", "(", ")", ".", "get_section_config", "(", "\"Server\"", ")", "self", ".", "_local_server", ".", "user", "=", "server_con...
Call this when the server configuration file change
[ "Call", "this", "when", "the", "server", "configuration", "file", "change" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/__init__.py#L205-L213
train
GNS3/gns3-server
gns3server/controller/__init__.py
Controller.save
def save(self): """ Save the controller configuration on disk """ # We don't save during the loading otherwise we could lost stuff if self._settings is None: return data = { "computes": [], "settings": self._settings, "gns3v...
python
def save(self): """ Save the controller configuration on disk """ # We don't save during the loading otherwise we could lost stuff if self._settings is None: return data = { "computes": [], "settings": self._settings, "gns3v...
[ "def", "save", "(", "self", ")", ":", "# We don't save during the loading otherwise we could lost stuff", "if", "self", ".", "_settings", "is", "None", ":", "return", "data", "=", "{", "\"computes\"", ":", "[", "]", ",", "\"settings\"", ":", "self", ".", "_setti...
Save the controller configuration on disk
[ "Save", "the", "controller", "configuration", "on", "disk" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/__init__.py#L230-L260
train
GNS3/gns3-server
gns3server/controller/__init__.py
Controller._load_controller_settings
def _load_controller_settings(self): """ Reload the controller configuration from disk """ try: if not os.path.exists(self._config_file): yield from self._import_gns3_gui_conf() self.save() with open(self._config_file) as f: ...
python
def _load_controller_settings(self): """ Reload the controller configuration from disk """ try: if not os.path.exists(self._config_file): yield from self._import_gns3_gui_conf() self.save() with open(self._config_file) as f: ...
[ "def", "_load_controller_settings", "(", "self", ")", ":", "try", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "_config_file", ")", ":", "yield", "from", "self", ".", "_import_gns3_gui_conf", "(", ")", "self", ".", "save", "(", ...
Reload the controller configuration from disk
[ "Reload", "the", "controller", "configuration", "from", "disk" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/__init__.py#L263-L286
train
GNS3/gns3-server
gns3server/controller/__init__.py
Controller.load_projects
def load_projects(self): """ Preload the list of projects from disk """ server_config = Config.instance().get_section_config("Server") projects_path = os.path.expanduser(server_config.get("projects_path", "~/GNS3/projects")) os.makedirs(projects_path, exist_ok=True) ...
python
def load_projects(self): """ Preload the list of projects from disk """ server_config = Config.instance().get_section_config("Server") projects_path = os.path.expanduser(server_config.get("projects_path", "~/GNS3/projects")) os.makedirs(projects_path, exist_ok=True) ...
[ "def", "load_projects", "(", "self", ")", ":", "server_config", "=", "Config", ".", "instance", "(", ")", ".", "get_section_config", "(", "\"Server\"", ")", "projects_path", "=", "os", ".", "path", ".", "expanduser", "(", "server_config", ".", "get", "(", ...
Preload the list of projects from disk
[ "Preload", "the", "list", "of", "projects", "from", "disk" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/__init__.py#L289-L307
train
GNS3/gns3-server
gns3server/controller/__init__.py
Controller.load_base_files
def load_base_files(self): """ At startup we copy base file to the user location to allow them to customize it """ dst_path = self.configs_path() src_path = get_resource('configs') try: for file in os.listdir(src_path): if not os.path.e...
python
def load_base_files(self): """ At startup we copy base file to the user location to allow them to customize it """ dst_path = self.configs_path() src_path = get_resource('configs') try: for file in os.listdir(src_path): if not os.path.e...
[ "def", "load_base_files", "(", "self", ")", ":", "dst_path", "=", "self", ".", "configs_path", "(", ")", "src_path", "=", "get_resource", "(", "'configs'", ")", "try", ":", "for", "file", "in", "os", ".", "listdir", "(", "src_path", ")", ":", "if", "no...
At startup we copy base file to the user location to allow them to customize it
[ "At", "startup", "we", "copy", "base", "file", "to", "the", "user", "location", "to", "allow", "them", "to", "customize", "it" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/__init__.py#L309-L321
train
GNS3/gns3-server
gns3server/controller/__init__.py
Controller._import_gns3_gui_conf
def _import_gns3_gui_conf(self): """ Import old config from GNS3 GUI """ config_file = os.path.join(os.path.dirname(self._config_file), "gns3_gui.conf") if os.path.exists(config_file): with open(config_file) as f: data = json.load(f) se...
python
def _import_gns3_gui_conf(self): """ Import old config from GNS3 GUI """ config_file = os.path.join(os.path.dirname(self._config_file), "gns3_gui.conf") if os.path.exists(config_file): with open(config_file) as f: data = json.load(f) se...
[ "def", "_import_gns3_gui_conf", "(", "self", ")", ":", "config_file", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "self", ".", "_config_file", ")", ",", "\"gns3_gui.conf\"", ")", "if", "os", ".", "path", ".", "exis...
Import old config from GNS3 GUI
[ "Import", "old", "config", "from", "GNS3", "GUI" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/__init__.py#L351-L400
train
GNS3/gns3-server
gns3server/controller/__init__.py
Controller.add_compute
def add_compute(self, compute_id=None, name=None, force=False, connect=True, **kwargs): """ Add a server to the dictionary of compute servers controlled by this controller :param compute_id: Compute server identifier :param name: Compute name :param force: True skip security che...
python
def add_compute(self, compute_id=None, name=None, force=False, connect=True, **kwargs): """ Add a server to the dictionary of compute servers controlled by this controller :param compute_id: Compute server identifier :param name: Compute name :param force: True skip security che...
[ "def", "add_compute", "(", "self", ",", "compute_id", "=", "None", ",", "name", "=", "None", ",", "force", "=", "False", ",", "connect", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "compute_id", "not", "in", "self", ".", "_computes", ":", ...
Add a server to the dictionary of compute servers controlled by this controller :param compute_id: Compute server identifier :param name: Compute name :param force: True skip security check :param connect: True connect to the compute immediately :param kwargs: See the documentat...
[ "Add", "a", "server", "to", "the", "dictionary", "of", "compute", "servers", "controlled", "by", "this", "controller" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/__init__.py#L418-L455
train
GNS3/gns3-server
gns3server/controller/__init__.py
Controller.close_compute_projects
def close_compute_projects(self, compute): """ Close projects running on a compute """ for project in self._projects.values(): if compute in project.computes: yield from project.close()
python
def close_compute_projects(self, compute): """ Close projects running on a compute """ for project in self._projects.values(): if compute in project.computes: yield from project.close()
[ "def", "close_compute_projects", "(", "self", ",", "compute", ")", ":", "for", "project", "in", "self", ".", "_projects", ".", "values", "(", ")", ":", "if", "compute", "in", "project", ".", "computes", ":", "yield", "from", "project", ".", "close", "(",...
Close projects running on a compute
[ "Close", "projects", "running", "on", "a", "compute" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/__init__.py#L458-L464
train
GNS3/gns3-server
gns3server/controller/__init__.py
Controller.delete_compute
def delete_compute(self, compute_id): """ Delete a compute node. Project using this compute will be close :param compute_id: Compute server identifier """ try: compute = self.get_compute(compute_id) except aiohttp.web.HTTPNotFound: return ...
python
def delete_compute(self, compute_id): """ Delete a compute node. Project using this compute will be close :param compute_id: Compute server identifier """ try: compute = self.get_compute(compute_id) except aiohttp.web.HTTPNotFound: return ...
[ "def", "delete_compute", "(", "self", ",", "compute_id", ")", ":", "try", ":", "compute", "=", "self", ".", "get_compute", "(", "compute_id", ")", "except", "aiohttp", ".", "web", ".", "HTTPNotFound", ":", "return", "yield", "from", "self", ".", "close_com...
Delete a compute node. Project using this compute will be close :param compute_id: Compute server identifier
[ "Delete", "a", "compute", "node", ".", "Project", "using", "this", "compute", "will", "be", "close" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/__init__.py#L467-L481
train
GNS3/gns3-server
gns3server/controller/__init__.py
Controller.get_compute
def get_compute(self, compute_id): """ Returns a compute server or raise a 404 error. """ try: return self._computes[compute_id] except KeyError: if compute_id == "vm": raise aiohttp.web.HTTPNotFound(text="You try to use a node on the GNS3 ...
python
def get_compute(self, compute_id): """ Returns a compute server or raise a 404 error. """ try: return self._computes[compute_id] except KeyError: if compute_id == "vm": raise aiohttp.web.HTTPNotFound(text="You try to use a node on the GNS3 ...
[ "def", "get_compute", "(", "self", ",", "compute_id", ")", ":", "try", ":", "return", "self", ".", "_computes", "[", "compute_id", "]", "except", "KeyError", ":", "if", "compute_id", "==", "\"vm\"", ":", "raise", "aiohttp", ".", "web", ".", "HTTPNotFound",...
Returns a compute server or raise a 404 error.
[ "Returns", "a", "compute", "server", "or", "raise", "a", "404", "error", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/__init__.py#L497-L506
train