Commit 0d212350 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou Committed by Christos Stavrakakis

Rename nodeapi to vmapi

parent 565ec075
......@@ -334,9 +334,6 @@ def create_server(request):
'password': password
})
# TODO: if nodeapi app is enabled vm gets an extra attribute `params_url`
# we should provide that url to the create_instance method. How ????
try:
if settings.PUBLIC_USE_POOL:
(network, address) = util.allocate_public_address(backend)
......@@ -365,6 +362,8 @@ def create_server(request):
flavor=flavor,
action="CREATE")
vmapi_url = vm.get_vmapi_params_urls()
try:
jobID = create_instance(vm, nic, flavor, image, password, personality)
except GanetiApiError:
......
......@@ -5,6 +5,7 @@ synnefo_web_apps = [
'synnefo.db',
'synnefo.logic',
'synnefo.plankton',
'synnefo.vmapi',
'synnefo.helpdesk',
'synnefo.nodeapi',
'synnefo.ui.userdata',
......
......@@ -39,7 +39,7 @@ urlpatterns = patterns('',
name='ui_machines_console'),
url(r'^machines/connect$', 'synnefo.ui.views.machines_connect',
name='ui_machines_connect'),
(r'^nodeapi/', include('synnefo.nodeapi.urls')),
(r'^vmapi/', include('synnefo.vmapi.urls')),
(r'^api/', include('synnefo.api.urls')),
(r'^plankton/', include('synnefo.plankton.urls')),
(r'^helpdesk/', include('synnefo.helpdesk.urls')),
......
......@@ -36,7 +36,7 @@ from uuid import uuid4
from django.core.cache import get_cache
from django.core import signals
from synnefo.nodeapi.settings import CACHE_KEY_PREFIX, CACHE_BACKEND
from synnefo.vmapi.settings import CACHE_KEY_PREFIX, CACHE_BACKEND
def get_uuid():
return str(uuid4())
......
......@@ -36,7 +36,7 @@ from django.utils import simplejson as json
from django.core.urlresolvers import reverse
from synnefo.api.servers import server_created
from synnefo.nodeapi import backend, get_key, get_uuid
from synnefo.vmapi import backend, get_key, get_uuid
def create_server_params(sender, created_vm_params, **kwargs):
......@@ -46,7 +46,7 @@ def create_server_params(sender, created_vm_params, **kwargs):
backend.set(key, json_value)
# inject sender (vm) with its parameters url
setattr(sender, 'params_url', reverse('nodeapi_server_params', args=[uuid]))
setattr(sender, 'params_url', reverse('vmapi_server_params', args=[uuid]))
return uuid
server_created.connect(create_server_params)
......
......@@ -33,9 +33,9 @@
from django.conf import settings
CACHE_BACKEND = getattr(settings, 'NODEAPI_CACHE_BACKEND',
CACHE_BACKEND = getattr(settings, 'VMAPI_CACHE_BACKEND',
settings.CACHE_BACKEND)
CACHE_KEY_PREFIX = getattr(settings, 'NODEAPI_CACHE_KEY_PREFIX',
'nodeapi')
RESET_PARAMS = getattr(settings, 'NODEAPI_RESET_PARAMS', True)
CACHE_KEY_PREFIX = getattr(settings, 'VMAPI_CACHE_KEY_PREFIX',
'vmapi')
RESET_PARAMS = getattr(settings, 'VMAPI_RESET_PARAMS', True)
......@@ -38,20 +38,20 @@ from django.utils import simplejson as json
class TestServerParams(TestCase):
def test_cache_backend(self):
from synnefo.nodeapi import backend
from synnefo.vmapi import backend
backend.set("test", 1)
self.assertEqual(backend.get("test"), 1)
backend.set("test", None)
self.assertEqual(backend.get("test"), None)
def test_get_key(self):
from synnefo.nodeapi import get_key
self.assertEqual(get_key("snf-1", "12345"), "nodeapi_snf-1_12345")
self.assertEqual(get_key("snf-1", None, "12345"), "nodeapi_snf-1_12345")
from synnefo.vmapi import get_key
self.assertEqual(get_key("snf-1", "12345"), "vmapi_snf-1_12345")
self.assertEqual(get_key("snf-1", None, "12345"), "vmapi_snf-1_12345")
def test_params_create(self):
from synnefo.nodeapi.models import create_server_params
from synnefo.nodeapi import backend
from synnefo.vmapi.models import create_server_params
from synnefo.vmapi import backend
try:
from synnefo.api.servers import server_created
from synnefo.db.models import VirtualMachine
......@@ -64,8 +64,8 @@ class TestServerParams(TestCase):
params = {'password': 'X^942Jjfdsa', 'personality': {}}
uuid = create_server_params(sender=vm, created_vm_params=params)
self.assertEqual(vm.params_url, '/nodeapi/server-params/%s' % uuid)
key = "nodeapi_%s" % uuid
self.assertEqual(vm.params_url, '/vmapi/server-params/%s' % uuid)
key = "vmapi_%s" % uuid
self.assertEqual(type(backend.get(key)), str)
data = json.loads(backend.get(key))
self.assertEqual('password' in data, True)
......
......@@ -33,6 +33,6 @@
from django.conf.urls.defaults import include, patterns, url
urlpatterns = patterns('synnefo.nodeapi.views',
url(r'^server-params/(?P<uuid>.*)$', 'server_params', name="nodeapi_server_params"),
urlpatterns = patterns('synnefo.vmapi.views',
url(r'^server-params/(?P<uuid>.*)$', 'server_params', name="vmapi_server_params"),
)
......@@ -33,8 +33,8 @@
from django.http import Http404, HttpResponse
from synnefo.nodeapi import backend, get_key
from synnefo.nodeapi.settings import RESET_PARAMS
from synnefo.vmapi import backend, get_key
from synnefo.vmapi.settings import RESET_PARAMS
def server_params(request, uuid):
uuid = request.GET.get('uuid', None)
......
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