Commit da004af5 authored by Stavros Sachtouris's avatar Stavros Sachtouris

Implement "server create" simple/minimal case

The request we have tested so far is a server creation with as few
parameters as possible.
parent a05d29bc
......@@ -115,6 +115,21 @@ def snf_get_server_net_attachments(cls, req, compute_id):
return r
def snf_create_server(cls, req, name, image, flavor, **kwargs):
"""Synnefo: create a new VM"""
req.environ['service_type'] = 'compute'
req.environ['method_name'] = 'servers_post'
body = dict(name=name, imageRef=image, flavorRef=flavor)
body.update(kwargs)
req.environ['kwargs'] = dict(json_data=dict(server=body))
response = req.get_response(cls.app)
r = cls.get_from_response(response, 'server', {})
_openstackify_addresses(r['addresses'], r['attachments'])
return r
def snf_delete_server(cls, req, server_id):
print 'Deleting VM with id:' + str(server_id)
req.environ['service_type'] = 'compute'
......@@ -122,6 +137,7 @@ def snf_delete_server(cls, req, server_id):
req.environ['kwargs'] = {'server_id': server_id}
req.get_response(cls.app)
function_map = {
'index': snf_index,
'get_server': snf_get_server,
......@@ -132,5 +148,6 @@ function_map = {
'get_floating_ip_pools': empty_list_200,
'get_server_volumes_link': snf_get_server_volumes_link,
'_get_ports': snf_get_server_net_attachments,
'delete': snf_delete_server
'delete': snf_delete_server,
'create_server': snf_create_server,
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment