Permalink
Browse files

Merge pull request #35 from jordan-developer/milestone

Feb version
  • Loading branch information...
2 parents 39f3db9 + 640ad78 commit 78abc3e2ef4e14cfcd87dede58a42d8feda13915 @jordan-developer committed Feb 26, 2013
View
@@ -61,16 +61,10 @@ This software needs this packages to run:
* python-all-dev (for eventlet/greenlet install/make)
* python-setuptools (to execute the setup.py file)
* couchdb >= 1.2.0:
-Example of installing couchdb using build-couchdb on Ubuntu (more details on: https://github.com/iriscouch/build-couchdb)
+To install couchdb on Ubuntu
::
- sudo apt-get install help2man make gcc zlib1g-dev libssl-dev rake help2man
- git clone git://github.com/iriscouch/build-couchdb
- cd build-couchdb
- git submodule init
- git submodule update
- rake
- build/bin/couchdb
+ sudo apt-get install couchdb
To test CouchDB: http://127.0.0.1:5984
@@ -105,6 +99,7 @@ In order to use pyOCNI, you must respect certain rules :
#. Scheme + Term = OCCI_ID : unique identifier of the OCCI (Kind/Mixin/Action) description
#. PyOCNI_Server_Address + location = OCCI_Location of (Kind/Mixin/Action) description
#. location word refers to a kind or mixin location.
+#. Links will be treated the same way as resources and internal links are not taking into account for clarity reasons.
PyOCNI offers two OCCI rendering formats : **HTTP and JSON**. The following commands are JSON specific. If you want to see HTTP command please check `here <https://github.com/mseknibilel/PyOCNI/blob/milestone/HTTP_HowTo.rst>`_.
@@ -50,7 +50,7 @@ def setUp(self):
self.p = Process(target=start_server)
self.p.start()
time.sleep(0.5)
- init_fakeDB()
+ #init_fakeDB()
time.sleep(0.5)
def tearDown(self):
@@ -63,10 +63,10 @@ def test_register_entities(self):
"""
storage = StringIO.StringIO()
c = pycurl.Curl()
- c.setopt(c.URL, 'http://127.0.0.1:8090/compute/?action=start')
+ c.setopt(c.URL, 'http://127.0.0.1:8090/compute/')
c.setopt(c.HTTPHEADER, ['Accept:text/plain', 'Content-Type: application/occi+json'])
c.setopt(c.VERBOSE, True)
- c.setopt(pycurl.POSTFIELDS, f_entities.action_plus_attributes)
+ c.setopt(pycurl.POSTFIELDS, f_entities.link)
c.setopt(c.CUSTOMREQUEST, 'POST')
c.setopt(c.WRITEFUNCTION, storage.write)
c.perform()
@@ -33,6 +33,7 @@
import pyocni.pyocni_tools.config as config
def start_server():
+
ocni_server_instance = ocni_server()
ocni_server_instance.run_server()
@@ -79,7 +79,7 @@ def post(self):
jBody = self.req_adapter.convert_request_entity_content(self.req)
if jBody is None:
- self.res.status_code = return_code['Not Acceptable']
+ self.res.status_int = return_code['Not Acceptable']
self.res.body = self.req.content_type + " is an unknown request content type"
else:
@@ -92,11 +92,11 @@ def post(self):
if self.triggered_action is None:
- var, self.res.status_code = self.jungler.channel_post_multi_resources(jBody, self.path_url)
+ var, self.res.status_int = self.jungler.channel_post_multi_resources(jBody, self.path_url)
#Step[4a]: Adapt response to the required Accept-Type
- if self.res.status_code == return_code['OK, and location returned']:
+ if self.res.status_int == return_code['OK, and location returned']:
self.res_adapter.convert_response_entity_multi_location_content(var, self.res)
else:
@@ -105,7 +105,7 @@ def post(self):
#Step[3b]: Trigger an action on all resources belonging to a kind
else:
- self.res.body, self.res.status_code = self.jungler.channel_trigger_actions(jBody, self.path_url,
+ self.res.body, self.res.status_int = self.jungler.channel_trigger_actions(jBody, self.path_url,
self.triggered_action)
return self.res
@@ -124,20 +124,20 @@ def get(self):
jBody = self.req_adapter.convert_request_entity_content_v2(self.req)
if jBody is None:
- self.res.status_code = return_code['Not Acceptable']
+ self.res.status_int = return_code['Not Acceptable']
self.res.body = self.req.content_type + " is an unknown request content type"
else:
#Step[2a]: Retrieve entities matching the filter provided
- var, self.res.status_code = self.jungler.channel_get_filtered_entities(self.path_url, jBody)
+ var, self.res.status_int = self.jungler.channel_get_filtered_entities(self.path_url, jBody)
else:
#Step[2b]: Retrieve all the entities
- var, self.res.status_code = self.jungler.channel_get_all_entities(self.path_url, "")
+ var, self.res.status_int = self.jungler.channel_get_all_entities(self.path_url, "")
#Step[3]: Adapt the response to the format defined in the Accept-Type header
- if self.res.status_code == return_code['OK']:
+ if self.res.status_int == return_code['OK']:
self.res_adapter.convert_response_entity_multi_x_occi_location_content(var, self.res)
@@ -158,13 +158,13 @@ def put(self):
jBody = self.req_adapter.convert_request_category_content(self.req)
if jBody is None:
- self.res.status_code = return_code['Not Acceptable']
+ self.res.status_int = return_code['Not Acceptable']
self.res.body = self.req.content_type + " is an unknown request content type"
else:
#Step[2]: Fully update the mixin collection of entities
- self.res.body, self.res.status_code = self.jungler.channel_put_multi(jBody, self.path_url)
+ self.res.body, self.res.status_int = self.jungler.channel_put_multi(jBody, self.path_url)
return self.res
@@ -181,11 +181,11 @@ def delete(self):
jBody = self.req_adapter.convert_request_category_content(self.req)
if jBody is None:
- self.res.status_code = return_code['Not Acceptable']
+ self.res.status_int = return_code['Not Acceptable']
self.res.body = self.req.content_type + " is an unknown request content type"
#Step[2a]: This is a dissociate mixin request
- self.res.body, self.res.status_code = self.jungler.channel_delete_multi(jBody, self.path_url)
+ self.res.body, self.res.status_int = self.jungler.channel_delete_multi(jBody, self.path_url)
else:
#Step[2b]: This is a delete on path request:
self.jungler_p.channel_delete_on_path(self.path_url)
@@ -62,25 +62,25 @@ def get(self):
jreq = self.req_adapter.convert_request_category_content(self.req)
if jreq is None:
- self.res.status_code = return_code['Not Acceptable']
+ self.res.status_int = return_code['Not Acceptable']
self.res.body = self.req.content_type + " is an unknown request content type"
else:
#Step[2a]: Retrieve the categories matching with the filter provided in the request:
- var, self.res.status_code = self.jungler.channel_get_filtered_categories(jreq)
+ var, self.res.status_int = self.jungler.channel_get_filtered_categories(jreq)
else:
#Step[2b]: Retrieve all the categories:
- var, self.res.status_code = self.jungler.channel_get_all_categories()
+ var, self.res.status_int = self.jungler.channel_get_all_categories()
#Step[3]: Adapt the response to the required accept-type
- if self.res.status_code == return_code['OK']:
+ if self.res.status_int == return_code['OK']:
self.res = self.res_adapter.convert_response_category_content(self.res, var)
else:
self.res.content_type = "text/html"
- self.res.body = var
+ self.res.body = str(var)
return self.res
@@ -96,12 +96,12 @@ def post(self):
if jBody is None:
- self.res.status_code = return_code['Not Acceptable']
+ self.res.status_int = return_code['Not Acceptable']
self.res.body = self.req.content_type + " is an unknown request content type"
else:
#Step[2]: Create the categories
- self.res.body, self.res.status_code = self.jungler.channel_register_categories(jBody)
+ self.res.body, self.res.status_int = self.jungler.channel_register_categories(jBody)
return self.res
@@ -116,13 +116,13 @@ def put(self):
jBody = self.req_adapter.convert_request_category_content(self.req)
if jBody is None:
- self.res.status_code = return_code['Not Acceptable']
+ self.res.status_int = return_code['Not Acceptable']
self.res.body = self.req.content_type + " is an unknown request content type"
else:
#Step[2]: Update the new data:
- self.res.body, self.res.status_code = self.jungler.channel_update_categories(jBody)
+ self.res.body, self.res.status_int = self.jungler.channel_update_categories(jBody)
return self.res
@@ -136,12 +136,12 @@ def delete(self):
jBody = self.req_adapter.convert_request_category_content(self.req)
if jBody is None:
- self.res.status_code = return_code['Not Acceptable']
+ self.res.status_int = return_code['Not Acceptable']
self.res.body = self.req.content_type + " is an unknown request content type"
else:
#Step[2]: Delete the category
- self.res.body, self.res.status_code = self.jungler.channel_delete_categories(jBody)
+ self.res.body, self.res.status_int = self.jungler.channel_delete_categories(jBody)
return self.res
@@ -74,16 +74,16 @@ def put(self):
jBody = self.req_adapter.convert_request_entity_content(self.req)
if jBody is None:
- self.res.status_code = return_code['Not Acceptable']
+ self.res.status_int = return_code['Not Acceptable']
self.res.body = self.req.content_type + " is an unknown request content type"
else:
#Step[2]: create the resource with custom URL
- var, self.res.status_code = self.jungler.channel_put_single_resource(jBody, self.path_url)
+ var, self.res.status_int = self.jungler.channel_put_single_resource(jBody, self.path_url)
#Step[3]: Adapt the response to the required accept-type
- if self.res.status_code == return_code['OK, and location returned']:
+ if self.res.status_int == return_code['OK, and location returned']:
self.res = self.res_adapter.convert_response_entity_location_content(var, self.res)
else:
self.res.content_type = "text/html"
@@ -101,11 +101,11 @@ def get(self):
#Step[1]: get the resource description
- var, self.res.status_code = self.jungler.channel_get_single_resource(self.path_url)
+ var, self.res.status_int = self.jungler.channel_get_single_resource(self.path_url)
#Step[2]: Adapt the response to the required accept-type
- if self.res.status_code == return_code['OK']:
+ if self.res.status_int == return_code['OK']:
self.res = self.res_adapter.convert_response_entity_content(self.res, var)
else:
@@ -132,17 +132,17 @@ def post(self):
jBody = self.req_adapter.convert_request_entity_content_v2(self.req)
if jBody is None:
- self.res.status_code = return_code['Not Acceptable']
+ self.res.status_int = return_code['Not Acceptable']
self.res.body = self.req.content_type + " is an unknown request content type"
else:
#Step[3a]: Partially update the resource if there was no action defined.
if self.triggered_action is None:
- var, self.res.status_code = self.jungler.channel_post_single_resource(jBody, self.path_url)
+ var, self.res.status_int = self.jungler.channel_post_single_resource(jBody, self.path_url)
- if self.res.status_code == return_code['OK, and location returned']:
+ if self.res.status_int == return_code['OK, and location returned']:
#Step[4a]: Adapt the response to the required accept-type
self.res = self.res_adapter.convert_response_entity_location_content(var, self.res)
@@ -153,7 +153,7 @@ def post(self):
else:
# Step[3b]: Trigger an action on a resource
- self.res.body, self.res.status_code = self.jungler.channel_triggered_action_single(jBody, self.path_url,
+ self.res.body, self.res.status_int = self.jungler.channel_triggered_action_single(jBody, self.path_url,
self.triggered_action)
return self.res
@@ -167,7 +167,7 @@ def delete(self):
#Step[1]: Delete a single resource
- self.res.body, self.res.status_code = self.jungler.channel_delete_single_resource(self.path_url)
+ self.res.body, self.res.status_int = self.jungler.channel_delete_single_resource(self.path_url)
#Step[2]: return the response back to the caller
@@ -47,6 +47,7 @@ class CategoryJungler:
"""
def __init__(self):
+
self.manager_k = KindManager()
self.manager_m = MixinManager()
self.manager_a = ActionManager()
Oops, something went wrong. Retry.

0 comments on commit 78abc3e

Please sign in to comment.