vmshepherd.http package

Submodules

vmshepherd.http.rpc_api module

class vmshepherd.http.rpc_api.RpcApi(allowed_methods=None)[source]

Bases: aiohttp_jsonrpc.handler.JSONRPCView

RPC Api to manage virtual machines

enabled_checker()[source]

Access decorator which checks if a RPC method is enabled by our configuration

get_vm_metadata(preset, vm_id)[source]

Get vm metadata

Parameters:
  • preset (string) – preset name
  • vm_id (int) – Virtual Machine id
Returns:

Metadata for Virtual Machine

Return type:

dict

Sample response:
{ 'time_shutdown' : "12312312321' }
handler(request)[source]
list_vms(preset)[source]

Listing virtual machines in a given preset

Parameters:preset (string) – preset name
Returns:(Size of a preset, list of virtual machines)
  • first element of a tuple is a size of virtual machines in a preset
  • second element is a dict which contains all Virtual Machines, where every element of this dict looks like that:

    { "VIRTUAL_MACHINE_ID": { "ip": "IP_ADDR", "state": "VM_STATE" }

Return type:tuple
Sample response:
( 1, {'180aa486-ee46-4628-ab1c-f4554b63231': {'ip': '172.1.1.2', 'state': 'running'}} )
terminate_vm(preset, vm_id)[source]

Discard vm in specified preset

Parameters:
  • preset (string) – preset name
  • vm_id (int) – Virtual Machine id
Returns:

‘OK’

Sample response:
OK

Module contents

class vmshepherd.http.Panel(request)[source]

Bases: aiohttp.web_urldispatcher.View

get()[source]

Inject all preset data to Panel and Render a Home Page

class vmshepherd.http.WebServer(vmshepherd, config=None)[source]

Bases: aiohttp.web_app.Application

configure_api(allowed_methods=None)[source]

Configure route for api :arg list allowed_methods: List of a methods which are turned on in our api

configure_panel()[source]

Configure templates and routing

start()[source]

Initialize and start WebServer