projects
/
snf-occi
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
bbf0c7f
)
Fixed token passing to extras
author
John Giannelos
<johngiannelos@gmail.com>
Tue, 24 Apr 2012 10:06:59 +0000
(13:06 +0300)
committer
John Giannelos
<johngiannelos@gmail.com>
Tue, 24 Apr 2012 10:06:59 +0000
(13:06 +0300)
snf-occi-server.py
patch
|
blob
|
history
diff --git
a/snf-occi-server.py
b/snf-occi-server.py
index
c9854e5
..
b0ab125
100755
(executable)
--- a/
snf-occi-server.py
+++ b/
snf-occi-server.py
@@
-58,7
+58,10
@@
class ComputeBackend(MyBackend):
#Registry identifier is the uuid key occi.handler assigns
#attribute 'occi.core.id' will be the snf-server id
#Registry identifier is the uuid key occi.handler assigns
#attribute 'occi.core.id' will be the snf-server id
- snf = ComputeClient(Config())
+ conf = Config()
+ conf.set('token',extras['token'])
+ snf = ComputeClient(conf)
+
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'])
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'])
@@
-68,7
+71,9
@@
class ComputeBackend(MyBackend):
def retrieve(self, entity, extras):
# triggering cyclades to retrieve up to date information
def retrieve(self, entity, extras):
# triggering cyclades to retrieve up to date information
- snf = ComputeClient(Config())
+ conf = Config()
+ conf.set('token',extras['token'])
+ snf = ComputeClient(conf)
vm_id = int(entity.attributes['occi.core.id'])
vm_info = snf.get_server_details(vm_id)
vm_id = int(entity.attributes['occi.core.id'])
vm_info = snf.get_server_details(vm_id)
@@
-94,14
+99,20
@@
class ComputeBackend(MyBackend):
def delete(self, entity, extras):
# delete vm with vm_id = entity.attributes['occi.core.id']
def delete(self, entity, extras):
# delete vm with vm_id = entity.attributes['occi.core.id']
- snf = ComputeClient(Config())
+ conf = Config()
+ conf.set('token',extras['token'])
+ snf = ComputeClient(conf)
+
vm_id = int(entity.attributes['occi.core.id'])
snf.delete_server(vm_id)
def action(self, entity, action, extras):
vm_id = int(entity.attributes['occi.core.id'])
snf.delete_server(vm_id)
def action(self, entity, action, extras):
-
- client = CycladesClient(Config())
+
+ conf = Config()
+ conf.set('token',extras['token'])
+ client = CycladesClient(conf)
+
vm_id = int(entity.attributes['occi.core.id'])
if action not in entity.actions:
vm_id = int(entity.attributes['occi.core.id'])
if action not in entity.actions:
@@
-132,12
+143,12
@@
class MyAPP(Application):
'''
def __call__(self, environ, response):
'''
def __call__(self, environ, response):
-
- token = environ['HTTP_AUTH_TOKEN']
+
+ print 'Using authentication token:'
+ print environ['HTTP_AUTH_TOKEN']
# token will be represented in self.extras
# token will be represented in self.extras
-
- return self._call_occi(environ, response, token)
+ return self._call_occi(environ, response, security = None, token = environ['HTTP_AUTH_TOKEN'])
if __name__ == '__main__':
if __name__ == '__main__':
@@
-153,6
+164,7
@@
if __name__ == '__main__':
APP.register_backend(OS_TEMPLATE, MixinBackend())
snf = ComputeClient(Config())
APP.register_backend(OS_TEMPLATE, MixinBackend())
snf = ComputeClient(Config())
+
images = snf.list_images()
for image in images:
IMAGE_ATTRIBUTES = {'occi.core.id': str(image['id'])}
images = snf.list_images()
for image in images:
IMAGE_ATTRIBUTES = {'occi.core.id': str(image['id'])}