Commit d7dfc401 authored by John Giannelos's avatar John Giannelos
Browse files

Added config.py / disabled OCCI's update,replace

parent 6fa30928
from snfOCCI.config import SERVER_CONFIG
from kamaki.clients.compute import ComputeClient
from kamaki.clients.cyclades import CycladesClient
from kamaki.config import Config
......@@ -15,20 +17,10 @@ class MyBackend(KindBackend, ActionBackend):
'''
def update(self, old, new, extras):
# here you can check what information from new_entity you wanna bring
# into old_entity
# trigger your hypervisor and push most recent information
print('Updating a resource with id: ' + old.identifier)
for item in new.attributes.keys():
old.attributes[item] = new.attributes[item]
raise AttributeError("This action is currently no applicable.")
def replace(self, old, new, extras):
print('Replacing a resource with id: ' + old.identifier)
old.attributes = {}
for item in new.attributes.keys():
old.attributes[item] = new.attributes[item]
old.attributes['occi.compute.state'] = 'inactive'
raise AttributeError("This action is currently no applicable.")
class ComputeBackend(MyBackend):
......@@ -46,8 +38,8 @@ class ComputeBackend(MyBackend):
flavor = mixin
flavor_id = mixin.attributes['occi.core.id']
entity.attributes['occi.compute.state'] = 'active'
entity.actions = [STOP, SUSPEND, RESTART]
entity.attributes['occi.compute.state'] = 'inactive'
entity.actions = [START]
#Registry identifier is the uuid key occi.handler assigns
#attribute 'occi.core.id' will be the snf-server id
......@@ -59,8 +51,10 @@ class ComputeBackend(MyBackend):
vm_name = entity.attributes['occi.compute.hostname']
info = snf.create_server(vm_name, flavor_id, image_id)
entity.attributes['occi.core.id'] = str(info['id'])
entity.attributes['occi.compute.architecture'] = SERVER_CONFIG['compute_arch']
entity.attributes['occi.compute.cores'] = flavor.attributes['occi.compute.cores']
entity.attributes['occi.compute.memory'] = flavor.attributes['occi.compute.memory']
entity.attributes['occi.compute.hostname'] = SERVER_CONFIG['hostname'] % {'id':info['id']}
def retrieve(self, entity, extras):
......@@ -127,5 +121,4 @@ class ComputeBackend(MyBackend):
elif action == SUSPEND:
#TODO VM suspending
print "Suspending VM"
raise AttributeError("This actions is currently no applicable")
SERVER_CONFIG = {
'port': 8888,
'hostname': 'snf-%(id)d.vm.okeanos.grnet.gr',
'compute_arch': 'x86'
}
......@@ -2,6 +2,7 @@
from snfOCCI.registry import snfRegistry
from snfOCCI.compute import ComputeBackend
from snfOCCI.config import SERVER_CONFIG
from kamaki.clients.compute import ComputeClient
from kamaki.clients.cyclades import CycladesClient
......@@ -36,7 +37,6 @@ class MyAPP(Application):
if __name__ == '__main__':
APP = MyAPP(registry = snfRegistry())
COMPUTE_BACKEND = ComputeBackend()
APP.register_backend(COMPUTE, COMPUTE_BACKEND)
......@@ -67,6 +67,6 @@ if __name__ == '__main__':
VALIDATOR_APP = validator(APP)
HTTPD = make_server('', 8888, VALIDATOR_APP)
HTTPD = make_server('', SERVER_CONFIG['port'], VALIDATOR_APP)
HTTPD.serve_forever()
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