|
|
@ -23,90 +23,98 @@ from ..modules.vpcs import VPCS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VPCSHandler(object):
|
|
|
|
class VPCSHandler(object):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
API entry points for VPCS.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
@classmethod
|
|
|
|
@Route.post(
|
|
|
|
@Route.post(
|
|
|
|
r"/vpcs",
|
|
|
|
r"/vpcs",
|
|
|
|
status_codes={
|
|
|
|
status_codes={
|
|
|
|
201: "Success of creation of VPCS",
|
|
|
|
201: "VPCS instance created",
|
|
|
|
409: "Conflict"
|
|
|
|
409: "Conflict"
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description="Create a new VPCS and return it",
|
|
|
|
description="Create a new VPCS instance",
|
|
|
|
input=VPCS_CREATE_SCHEMA,
|
|
|
|
input=VPCS_CREATE_SCHEMA,
|
|
|
|
output=VPCS_OBJECT_SCHEMA)
|
|
|
|
output=VPCS_OBJECT_SCHEMA)
|
|
|
|
def create(request, response):
|
|
|
|
def create(request, response):
|
|
|
|
|
|
|
|
|
|
|
|
vpcs = VPCS.instance()
|
|
|
|
vpcs = VPCS.instance()
|
|
|
|
vm = yield from vpcs.create_vm(request.json['name'])
|
|
|
|
vm = yield from vpcs.create_vm(request.json["name"])
|
|
|
|
response.json({'name': vm.name,
|
|
|
|
response.json({"name": vm.name,
|
|
|
|
"vpcs_id": vm.id,
|
|
|
|
"id": vm.id,
|
|
|
|
"console": vm.console})
|
|
|
|
"console": vm.console})
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
@classmethod
|
|
|
|
@Route.post(
|
|
|
|
@Route.post(
|
|
|
|
r"/vpcs/{vpcs_id}/start",
|
|
|
|
r"/vpcs/{id:\d+}/start",
|
|
|
|
parameters={
|
|
|
|
parameters={
|
|
|
|
"vpcs_id": "Id of VPCS instance"
|
|
|
|
"id": "VPCS instance ID"
|
|
|
|
},
|
|
|
|
},
|
|
|
|
status_codes={
|
|
|
|
status_codes={
|
|
|
|
201: "Success of creation of VPCS",
|
|
|
|
204: "VPCS instance started",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description="Start VPCS",
|
|
|
|
description="Start a VPCS instance")
|
|
|
|
)
|
|
|
|
|
|
|
|
def create(request, response):
|
|
|
|
def create(request, response):
|
|
|
|
|
|
|
|
|
|
|
|
vpcs_manager = VPCS.instance()
|
|
|
|
vpcs_manager = VPCS.instance()
|
|
|
|
vm = yield from vpcs_manager.start_vm(int(request.match_info['vpcs_id']))
|
|
|
|
yield from vpcs_manager.start_vm(int(request.match_info["id"]))
|
|
|
|
response.json({})
|
|
|
|
response.json({})
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
@classmethod
|
|
|
|
@Route.post(
|
|
|
|
@Route.post(
|
|
|
|
r"/vpcs/{vpcs_id}/stop",
|
|
|
|
r"/vpcs/{id:\d+}/stop",
|
|
|
|
parameters={
|
|
|
|
parameters={
|
|
|
|
"vpcs_id": "Id of VPCS instance"
|
|
|
|
"id": "VPCS instance ID"
|
|
|
|
},
|
|
|
|
},
|
|
|
|
status_codes={
|
|
|
|
status_codes={
|
|
|
|
201: "Success of stopping VPCS",
|
|
|
|
201: "Success of stopping VPCS",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description="Stop VPCS",
|
|
|
|
description="Stop a VPCS instance")
|
|
|
|
)
|
|
|
|
|
|
|
|
def create(request, response):
|
|
|
|
def create(request, response):
|
|
|
|
|
|
|
|
|
|
|
|
vpcs_manager = VPCS.instance()
|
|
|
|
vpcs_manager = VPCS.instance()
|
|
|
|
vm = yield from vpcs_manager.stop_vm(int(request.match_info['vpcs_id']))
|
|
|
|
yield from vpcs_manager.stop_vm(int(request.match_info["id"]))
|
|
|
|
response.json({})
|
|
|
|
response.json({})
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
@classmethod
|
|
|
|
@Route.get(
|
|
|
|
@Route.get(
|
|
|
|
r"/vpcs/{vpcs_id}",
|
|
|
|
r"/vpcs/{id:\d+}",
|
|
|
|
parameters={
|
|
|
|
parameters={
|
|
|
|
"vpcs_id": "Id of VPCS instance"
|
|
|
|
"id": "VPCS instance ID"
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description="Get information about a VPCS",
|
|
|
|
description="Get information about a VPCS",
|
|
|
|
output=VPCS_OBJECT_SCHEMA)
|
|
|
|
output=VPCS_OBJECT_SCHEMA)
|
|
|
|
def show(request, response):
|
|
|
|
def show(request, response):
|
|
|
|
response.json({'name': "PC 1", "vpcs_id": 42, "console": 4242})
|
|
|
|
|
|
|
|
|
|
|
|
response.json({'name': "PC 1", "id": 42, "console": 4242})
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
@classmethod
|
|
|
|
@Route.put(
|
|
|
|
@Route.put(
|
|
|
|
r"/vpcs/{vpcs_id}",
|
|
|
|
r"/vpcs/{id:\d+}",
|
|
|
|
parameters={
|
|
|
|
parameters={
|
|
|
|
"vpcs_id": "Id of VPCS instance"
|
|
|
|
"id": "VPCS instance ID"
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description="Update VPCS information",
|
|
|
|
description="Update VPCS information",
|
|
|
|
input=VPCS_OBJECT_SCHEMA,
|
|
|
|
input=VPCS_OBJECT_SCHEMA,
|
|
|
|
output=VPCS_OBJECT_SCHEMA)
|
|
|
|
output=VPCS_OBJECT_SCHEMA)
|
|
|
|
def update(request, response):
|
|
|
|
def update(request, response):
|
|
|
|
response.json({'name': "PC 1", "vpcs_id": 42, "console": 4242})
|
|
|
|
|
|
|
|
|
|
|
|
response.json({'name': "PC 1", "id": 42, "console": 4242})
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
@classmethod
|
|
|
|
@Route.post(
|
|
|
|
@Route.post(
|
|
|
|
r"/vpcs/{vpcs_id}/nio",
|
|
|
|
r"/vpcs/{id:\d+}/nio",
|
|
|
|
parameters={
|
|
|
|
parameters={
|
|
|
|
"vpcs_id": "Id of VPCS instance"
|
|
|
|
"id": "VPCS instance ID"
|
|
|
|
},
|
|
|
|
},
|
|
|
|
status_codes={
|
|
|
|
status_codes={
|
|
|
|
201: "Success of creation of NIO",
|
|
|
|
201: "NIO created",
|
|
|
|
409: "Conflict"
|
|
|
|
409: "Conflict"
|
|
|
|
},
|
|
|
|
},
|
|
|
|
description="ADD NIO to a VPCS",
|
|
|
|
description="ADD NIO to a VPCS",
|
|
|
|
input=VPCS_ADD_NIO_SCHEMA)
|
|
|
|
input=VPCS_ADD_NIO_SCHEMA)
|
|
|
|
def create_nio(request, response):
|
|
|
|
def create_nio(request, response):
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: raise 404 if VPCS not found
|
|
|
|
# TODO: raise 404 if VPCS not found
|
|
|
|
response.json({'name': "PC 2", "vpcs_id": 42, "console": 4242})
|
|
|
|
response.json({'name': "PC 2", "id": 42, "console": 4242})
|
|
|
|