Example #1
0
def create_server_params(sender, created_vm_params, **kwargs):
    json_value = json.dumps(created_vm_params)
    uuid = get_uuid()
    key = get_key(uuid)
    log.info("Setting vmapi params with key %s for %s", key, sender)
    backend.set(key, json_value)

    path = reverse("vmapi_server_params", args=[uuid]).lstrip('/')
    config_url = join_urls(settings.BASE_HOST, path)
    # inject sender (vm) with its configuration url
    setattr(sender, 'config_url', config_url)
    return uuid
Example #2
0
def create_server_params(sender, created_vm_params, **kwargs):
    json_value = json.dumps(created_vm_params)
    uuid = get_uuid()
    key = get_key(uuid)
    log.info("Setting vmapi params with key %s for %s", key, sender)
    backend.set(key, json_value)

    path = reverse("vmapi_server_params", args=[uuid]).lstrip('/')
    config_url = join_urls(settings.BASE_HOST, path)
    # inject sender (vm) with its configuration url
    setattr(sender, 'config_url', config_url)
    return uuid
Example #3
0
def server_params(request, uuid):
    if not uuid:
        raise Http404

    cache_key = get_key(uuid)
    params = backend.get(cache_key)
    if not params:
        log.error('Request vmapi params key not found: %s', cache_key)
        raise Http404

    if settings.RESET_PARAMS:
        backend.set(cache_key, None)

    return HttpResponse(params, content_type="application/json")
Example #4
0
 def test_get_key(self):
     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")