1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-01 04:38:12 +00:00
gns3-server/gns3server/controller/gns3vm/remote_gns3_vm.py

74 lines
2.0 KiB
Python
Raw Normal View History

2016-08-30 08:19:01 +00:00
#!/usr/bin/env python
#
# Copyright (C) 2016 GNS3 Technologies Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from .base_gns3_vm import BaseGNS3VM
from .gns3_vm_error import GNS3VMError
import logging
2021-04-13 09:16:50 +00:00
2016-08-30 08:19:01 +00:00
log = logging.getLogger(__name__)
class RemoteGNS3VM(BaseGNS3VM):
def __init__(self, controller):
self._engine = "remote"
super().__init__(controller)
async def list(self):
2016-08-30 08:19:01 +00:00
"""
List all VMs
"""
res = []
for compute in self._controller.computes.values():
if compute.id not in ["local", "vm"]:
res.append({"vmname": compute.name})
return res
async def start(self):
2016-08-30 08:19:01 +00:00
"""
Starts the GNS3 VM.
"""
if not self.vmname:
return
2016-08-30 08:19:01 +00:00
for compute in self._controller.computes.values():
if compute.name == self.vmname:
self.running = True
self.protocol = compute.protocol
self.ip_address = compute.host
self.port = compute.port
self.user = compute.user
self.password = compute.password
return
2021-04-13 09:07:58 +00:00
raise GNS3VMError(f"Can't start the GNS3 VM remote VM {self.vmname} not found")
2016-08-30 08:19:01 +00:00
async def suspend(self):
2016-09-08 13:32:35 +00:00
"""
Suspend do nothing for remote server
"""
self.running = False
async def stop(self):
2016-08-30 08:19:01 +00:00
"""
Stops the GNS3 VM.
"""
self.running = False