Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reviewing Reform

  • Loading branch information...
commit a91802908913f6cc32a8eee1bb0085ee15b5d05a 1 parent 8a88288
Msekni Bilel authored
View
6 HTTP_HowTo.rst
@@ -220,7 +220,7 @@ It's up to the user to define what format he wants in the request Content-Type h
* Response::
- N/A
+ Location: http://localhost:8090/{location}/{my_custom_resource_id}
2.Get a Resource::
@@ -248,7 +248,7 @@ It's up to the user to define what format he wants in the request Content-Type h
* Response::
- X-OCCI-Location: http://localhost:8090/{location}/{resource-id}
+ Location: http://localhost:8090/{location}/{resource-id}
4.Partial Update of a Resource::
@@ -256,7 +256,7 @@ It's up to the user to define what format he wants in the request Content-Type h
* Response::
- X-OCCI-Location: http://localhost:8090/{location}/{resource-id}
+ Location: http://localhost:8090/{location}/{resource-id}
5.Trigger an action on a resource::
View
8 README.rst
@@ -369,7 +369,7 @@ PyOCNI offers two OCCI rendering formats : **HTTP and JSON**. The following comm
* Response::
- N/A
+ {"Location": ["http://localhost:8090/{location}/{my_custom_resource_id}"]}
2.Get a Resource::
@@ -439,7 +439,7 @@ PyOCNI offers two OCCI rendering formats : **HTTP and JSON**. The following comm
* Response::
{
- "X-OCCI-Location": [
+ Location": [
"http://localhost:8090/{location}/{resource-id}"
]
}
@@ -451,8 +451,8 @@ PyOCNI offers two OCCI rendering formats : **HTTP and JSON**. The following comm
* Response::
{
- "X-OCCI-Location": [
- "http://localhost:8090/{location}/resource-id"
+ "Location": [
+ "http://localhost:8090/{location}/{resource-id}"
]
}
View
20 pyocni/TDD/Tests/singleentityInterface_Tests.py
@@ -66,11 +66,11 @@ def test_post_entities(self):
"""
storage = StringIO.StringIO()
c = pycurl.Curl()
- c.setopt(c.URL,'http://127.0.0.1:8090/compute/258af9df-dcba-4ff5-89f6-2c5f17c46e6f')
- c.setopt(c.HTTPHEADER, ['Accept: application/occi+json','Content-Type: application/occi+json'])
+ c.setopt(c.URL,'http://127.0.0.1:8090/compute/this_is_bilel?action=start')
+ c.setopt(c.HTTPHEADER, ['Accept: application/occi+json','Content-Type: text/plain'])
c.setopt(c.CUSTOMREQUEST, 'POST')
c.setopt(c.VERBOSE, True)
- c.setopt(c.POSTFIELDS,entities.j_occi_att)
+ c.setopt(c.POSTFIELDS,entities.action_att_http)
c.setopt(c.WRITEFUNCTION, storage.write)
c.perform()
content = storage.getvalue()
@@ -104,7 +104,7 @@ def test_get_entity(self):
storage = StringIO.StringIO()
c = pycurl.Curl()
c.setopt(c.URL,"http://127.0.0.1:8090/compute/9930")
- c.setopt(c.HTTPHEADER, ['Accept:text/occi'])
+ c.setopt(c.HTTPHEADER, ['Accept:application/occi+json'])
c.setopt(c.VERBOSE, True)
c.setopt(c.CUSTOMREQUEST, 'GET')
c.setopt(c.WRITEFUNCTION, storage.write)
@@ -135,10 +135,9 @@ def test_delete_entity(self):
storage = StringIO.StringIO()
c = pycurl.Curl()
- c.setopt(c.URL,"http://127.0.0.1:8090/bilel/vms/v01")
+ c.setopt(c.URL,"http://127.0.0.1:8090/compute/this_is_bilel")
c.setopt(c.HTTPHEADER, ['Content-Type: application/occi+json', 'Accept: application/occi+json'])
c.setopt(c.CUSTOMREQUEST, 'DELETE')
- c.setopt(c.USERPWD, 'user_1:password')
c.setopt(c.WRITEFUNCTION, storage.write)
c.perform()
content = storage.getvalue()
@@ -156,6 +155,8 @@ def setUp(self):
self.p = Process(target = start_server)
self.p.start()
time.sleep(0.5)
+ #init_fakeDB()
+ time.sleep(0.5)
def tearDown(self):
self.p.terminate()
@@ -165,10 +166,11 @@ def test_create_custom_resource(self):
"""
storage = StringIO.StringIO()
c = pycurl.Curl()
- c.setopt(c.URL,'http://127.0.0.1:8090/compute/d4e49287-e8bd-4cd8-953a-b90f327084e5')
+ c.setopt(c.URL,'http://127.0.0.1:8090/compute/this_is_bilel')
- c.setopt(c.HTTPHEADER, ['Accept: text/plain','Content-Type: text/occi',entities.part_entity_http])
+ c.setopt(c.HTTPHEADER, ['Accept: application/occi+json','Content-Type: text/plain'])
c.setopt(c.CUSTOMREQUEST, 'PUT')
+ c.setopt(c.POSTFIELDS,entities.entity_http)
c.setopt(c.VERBOSE, True)
c.setopt(c.WRITEFUNCTION, storage.write)
@@ -189,4 +191,4 @@ def test_create_custom_resource(self):
post_suite = loader.loadTestsFromTestCase(test_post)
#Run tests
- runner.run(post_suite)
+ runner.run(delete_suite)
View
45 pyocni/TDD/fake_Data/entities.py
@@ -97,7 +97,7 @@
"attributes": {
"occi": {
"compute": {
- "speed": 2,
+ "speed": 12,
"memory": 4,
"cores": 12
}
@@ -108,7 +108,40 @@
}
"""
-
+action_plus_attributes =\
+"""
+ {
+ "actions": [
+ {
+ "term": "start",
+ "scheme": "http://schemas.ogf.org/occi/infrastructure/compute/action#",
+ "title": "Start Compute instance now",
+ "attributes": {
+ "method": {
+ "mutable": true,
+ "required": false,
+ "type": "string",
+ "pattern": "graceful|acpion|poweron",
+ "default": "poweron"
+ }
+ }
+ }
+ ],
+ "attributes": {
+ "occi": {
+ "infrastructure": {
+ "networkinterface": {
+ "interface": "eth0",
+ "mac": "00:80:41:ae:fd:7e",
+ "address": "192.168.0.100",
+ "gateway": "192.168.0.1",
+ "allocation": "dynamic"
+ }
+ }
+ }
+ }
+}
+"""
#=======================================================================================================================
# HTTP format
#=======================================================================================================================
@@ -124,4 +157,10 @@
#=======================================================================================================================
-x_occi_att = "X-OCCI-Attribute: occi.compute.cores=20:2"
+x_occi_att = "X-OCCI-Attribute: occi.compute.cores=20:2"
+
+action_att_http = """Category: start;
+ scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";
+ class=action;
+ X-OCCI-Attribute: occi.compute.cores=20:2
+"""
View
6 pyocni/adapters/i_ResponseAdapter.py
@@ -86,8 +86,9 @@ def convert_response_entity_multi_location_content(self, var, res):
return res
def convert_response_entity_location_content(self, var, res):
+
if str(res.content_type) == "application/occi+json":
- res.body = var
+ res.body = json.dumps({"Location":[var]})
elif str(res.content_type) == "text/occi":
#reformat the response to text/occi
@@ -97,11 +98,12 @@ def convert_response_entity_location_content(self, var, res):
else:
#reformat the response to text/plain (default OCCI response format)
res.content_type = "text/plain"
- res.location = var
+ res.body = "Location: "+ var
return res
def convert_response_entity_content(self, res, var):
+
if str(res.content_type) == "application/occi+json":
res.body = json.dumps(var)
View
2  pyocni/junglers/single_entityJungler.py
@@ -129,7 +129,7 @@ def channel_put_single_resource(self, jBody, path_url):
self.PostMan.save_updated_doc_in_db(entity)
- logger.debug("===== Channel_post_single_resource ==== : Finished (2b) with success")
+ logger.debug("===== Channel_put_single_resource ==== : Finished (2b) with success")
#return the locations of the resources
backend_m.update_entity(olddoc['OCCI_Description'],entity['OCCI_Description'])
Please sign in to comment.
Something went wrong with that request. Please try again.