mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Create VPCS VM on controller
This commit is contained in:
13 files changed
+76
-34
No files matched your search
@@ -90,9 +90,9 @@ class Hypervisor:
|
||||
data = data.__json__()
|
||||
data = json.dumps(data)
|
||||
response = yield from session.request(method, url, headers=headers, data=data)
|
||||
print(response.status)
|
||||
assert response.status < 300
|
||||
body = yield from response.read()
|
||||
if response.status >= 300:
|
||||
raise aiohttp.errors.HttpProcessingError(code=response.status, message=body)
|
||||
yield from response.release()
|
||||
return body
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ import uuid
|
||||
|
||||
|
||||
class VM:
|
||||
def __init__(self, project, hypervisor, vm_id=None, vm_type=None, name=None, console=None, console_type="telnet", **kwargs):
|
||||
|
||||
def __init__(self, project, hypervisor, vm_id=None, vm_type=None, name=None, console=None, console_type="telnet", properties={}):
|
||||
"""
|
||||
:param project: Project of the VM
|
||||
:param hypervisor: Hypervisor server where the server will run
|
||||
@@ -30,7 +31,7 @@ class VM:
|
||||
:param name: Name of the vm
|
||||
:param console: TCP port of the console
|
||||
:param console_type: Type of the console (telnet, vnc, serial..)
|
||||
:param kwargs: Emulator specific properties of the VM
|
||||
:param properties: Emulator specific properties of the VM
|
||||
"""
|
||||
|
||||
if vm_id is None:
|
||||
@@ -44,7 +45,7 @@ class VM:
|
||||
self._vm_type = vm_type
|
||||
self._console = console
|
||||
self._console_type = console_type
|
||||
self._properties = kwargs
|
||||
self._properties = properties
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
@@ -74,6 +75,7 @@ class VM:
|
||||
def create(self):
|
||||
data = self._properties
|
||||
data["vm_id"] = self._id
|
||||
data["name"] = self._name
|
||||
data["console"] = self._console
|
||||
data["console_type"] = self._console_type
|
||||
yield from self._hypervisor.post("/projects/{}/{}/vms".format(self._project.id, self._vm_type), data=data)
|
||||
@@ -81,6 +83,7 @@ class VM:
|
||||
def __json__(self):
|
||||
return {
|
||||
"hypervisor_id": self._hypervisor.id,
|
||||
"project_id": self._project.id,
|
||||
"vm_id": self._id,
|
||||
"vm_type": self._vm_type,
|
||||
"name": self._name,
|
||||
@@ -88,4 +91,3 @@ class VM:
|
||||
"console_type": self._console_type,
|
||||
"properties": self._properties
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user