Changing Data With cURL For Object is Quite Easy in OpenStack Swift. Here Are Examples With HP Cloud CDN To Make it Clear. Official Examples Are Bad, They Are Written By Rackspace’s Employees. Rackspace uses API Key based access while normally we use Key Stone based Access – HP Cloud uses Key Stone based access too. That is why Racksace’s stuffs will not work with HP Cloud Products including HP Cloud CDN. Skip the first sub header in this article, if you do not want to read criticism and other things. Rackspace Cloud is an OpenStack deployment that uses a custom authentication back end not the Native OpenStack installation. Otherwise, people would port them easily.
Changing Data With cURL for OpenStack Swift (HP Cloud CDN) : Why It Feels Hell Like Tough?
Releasing Softwares with non cross-vendor usability renders it vendor locked. That is Richard M. Stallman said “Cloud Computing is a Hype.” Basically, his contribution is huge only in Linux! He will know what a Software has inside it. You are reading this article means, you are either advanced user or going to be advanced user. You have understood the fact – HP Cloud’s whole team can not easily make their services very user friendly to a new, novice computer user. We described how to upload the static contents from WordPress to OpenStack Swift (HP Cloud CDN) for the first time on this Planet. We have not discovered anything new. They were written but not in usable form to a new user. Python Swift Client is the best development for OpenStack Swift. Code contribution for OpenStack is highest by HP. HP is hardware company. Their Software License is like Free Software. That is why you’ll see that, HP sponsors Free Software Foundation. Articles like this are useless :
1 | http://arstechnica.com/information–technology/2008/09/why–stallman–is–wrong–when–he–calls–cloud–computing–stupid/ |
The person wrote has not much contribution to Free Software :
1 | https://github.com/segphault?tab=repositories |
Now you know very well about PRISM, NSA Spyware activities etc. There is another Ryan Paul, who has no beard – it is a US Political Person. But this Ryan Paul’s Google Plus account is verified :
1 | https://plus.google.com/+RyanPaul/about |
All are arranged. Back to the topic – we will demonstrate you using cURL for OpenStack Swift which you can test with HP Cloud CDN. The examples are badly written, one reason is written above and another reason is that – they are employees, not Bloggers or Technical Blog Writers. If Darren Rowse wrote it, he would write more readable way.
Why I do not write Health Blogs? Because I know; I can not make easy to understand. Our brain processes stuffs of different domains in different ways. If you pay me $8000
per month and force to write “How to replace elbow joint”, it will be quite unreadable. Technically sound but practically useless. Also, cURL is not installed on MS Windows – you can install cURL on Windows by reading this guide.
Changing Data With cURL for OpenStack Swift (HP Cloud CDN)
Take native OpenStack Swift installation and HP Cloud CDN as Equivalent. We do not need to create a container, publish it as CDN etc, via CLI, we have the features on Graphical User Interface. We need to change the Metadata like things – like Expires Header of some objects.
We have four secrets :
- All data in the OpenStack RC file (written in Python Swift Client tuts)
- Account username and password
- The API URLs from where you downloaded the OpenStack RC file
- URL of the Container or Object
Run this command after modification :
1 | curl –v –X GET –H “X-Auth-User: username” –H “X-Auth-Key: password” “https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/” |
The username
and password
both are in that OpenStack RC file and is the thing which you use to login to HP Cloud except – the username is in LOWER CASE. This command will definitely work and you’ll get this response :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | âžœ ~ curl –v –X GET –H “X-Auth-User: myusername” –H “X-Auth-Key: myPasSword” “https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0/” * Hostname was NOT found in DNS cache * Trying 206.164.176.15… * Connected to region–b.geo–1.identity.hpcloudsvc.com (206.164.176.15) port 35357 (#0) * TLS 1.2 connection using TLS_RSA_WITH_RC4_128_MD5 * Server certificate: region–b.geo–1.identity.hpcloudsvc.com * Server certificate: VeriSign Class 3 Secure Server CA – G3 * Server certificate: VeriSign Class 3 Public Primary Certification Authority – G5 > GET /v2.0/ HTTP/1.1 > User–Agent: curl/7.37.1 > Host: region–b.geo–1.identity.hpcloudsvc.com:35357 > Accept: */* > X–Auth–User: myusername > X–Auth–Key: myPasSword > < HTTP/1.1 200 OK < Date: Sun, 08 Feb 2015 11:06:51 GMT * Server Apache is not blacklisted < Server: Apache < Vary: X–Auth–Token < Content–Length: 277 < Content–Type: application/json < Connection: keep–alive < * Connection #0 to host region–b.geo–1.identity.hpcloudsvc.com left intact {“version”: {“status”: “stable”, “updated”: “2012-06-20T16:55:53.340Z”, “id”: “v2.0”, “links”: [{“href”: “https://docs.hpcloud.com/api/identity”, “type”: “text/html”, “rel”: “describedby”}, {...} |
Have you received the X-Auth-Key
? See the output above ! The official guides are described in this way :
1 2 3 4 | curl –i –X POST –H “Origin: example.com” –H “X-Auth-Token: 48e17715dfce47bb90dc2a336f63493a“ https://storage.example.com/v1/MossoCloudFS_c31366f1–9f1c–40dc–a b92–6b3f0b5a8c45/ephotos |
Rackspace wrote the guides – MossoCloud is Rackspace Cloud Sites. Now, you have a CDN API URL which looks like this :
1 | https://region–a.geo–1.objects.hpcloudsvc.com/v1/1234567890123 |
If your container’s name is tcw-all-january
and inside its root, there is a file named apple-touch-icon-144x144-precomposed.png
, then the relative URI becomes :
1 | ./tcw–all–january/apple–touch–icon–144×144–precomposed.png |
That dot is what we said above :
1 | https://region–a.geo–1.objects.hpcloudsvc.com/v1/1234567890123 |
Join these two :
1 | https://region–a.geo–1.objects.hpcloudsvc.com/v1/1234567890123/tcw–all–january/apple–touch–icon–144×144–precomposed.png |
We normally use the CDN URLs which has read only function. First test that URI return header which has read and write permission for you :
1 | curl –i https://region–a.geo–1.objects.hpcloudsvc.com/v1/1234567890123/tcw–all–january/apple–touch–icon–144×144–precomposed.png |
You’ll get :
1 2 3 4 5 6 7 8 9 10 | HTTP/1.1 200 OK Content–Length: 19752 Content–Type: image/png Accept–Ranges: bytes Last–Modified: Fri, 23 Jan 2015 18:44:58 GMT Etag: 003372f86df8eb31286cdb7036635139 X–Timestamp: 1422038698.69038 X–Object–Meta–Mtime: 1371802422.000000 X–Trans–Id: txcbfafd0a53604a8aa8f57–0054d74b70 Date: Sun, 08 Feb 2015 11:41:36 GMT |
Morons write the documentations in this way :
1 2 3 4 5 6 7 8 9 10 11 | curl –i https://region–a.geo–1.objects.hpcloudsvc.com/v1/1234567890123/tcw–all–january/apple–touch–icon–144×144–precomposed.png HTTP/1.1 200 OK Content–Length: 19752 Content–Type: image/png Accept–Ranges: bytes Last–Modified: Fri, 23 Jan 2015 18:44:58 GMT Etag: 003372f86df8eb31286cdb7036635139 X–Timestamp: 1422038698.69038 X–Object–Meta–Mtime: 1371802422.000000 X–Trans–Id: txcbfafd0a53604a8aa8f57–0054d74b70 Date: Sun, 08 Feb 2015 11:41:36 GMT |
It is really difficult to understand. Sajal Kayan also suffered, he is quite known person; he initially could not change the meta data (expire headers). Time to time, with complex commands; which is command and which is response becomes difficult to understand.
Text Books has not written to write in that way. It is like, some doctors do not talk properly with the patients! That is a wrong in accordance to the Text books. Patient Should be Explained and Counseled. In the same way, in the Engineering Text books (related to these topics) exactly the same is written – User Might Be Explained.
Human frankly does not talk properly after taking money when a human is dying, how you can expect that his brother will explain which is command and which is output or why -k flag is used? That is why software engineers, doctors all faces a bit “control” by the owner groups. Otherwise, both will not work properly. Basic thing is that, they assume, degree or traditional education will do the things. Owners usually do not have MBA but has better engine to control the MBA. Practical thing.
If you run this for HP Cloud :
1 | curl –X –i –k https://region–a.geo–1.objects.hpcloudsvc.com/v1/1234567890123/tcw–all–january/apple–touch–icon–144×144–precomposed.png |
You will get a response :
1 | This method may not be used.% |
This means – everything is right, you need to put that Authentication stuff. Firewall is blocking. For a given provider, HP Cloud, if you run :
1 | curl –k https://region–b.geo–1.identity.hpcloudsvc.com:35357 |
You’ll Get :
1 | “versions”: {“values”: [{“status”: “stable”, “updated”: “2012-06-20T16:55:53.340Z”, “id”: “v1.0”}, {“status”: “stable”, “updated”: “2012-06-20T16:55:53.340Z”, “id”: “v1.1”, “links”: [{“href”: “https://docs.hpcloud.com/api/identity”, “type”: “text/html”, “rel”: “described by”}]}, {“status”: “stable”, “updated”: “2012-06-20T16:55:53.340Z”, “id”: “v2.0”, “links”: [{“href”: “https://docs.hpcloud.com/api/identity”, “type”: “text/html”, “rel”: “described by”}, {“href”: “https://region-b.geo-1.identity.hpcloudsvc.com:35357/v2.0”, “rel”: “self”}]}, {“status”: “stable”, “updated”: “2013-04-25T16:55:53.340Z”, “id”: “v3.0”, “links”: [{“href”: “https://docs.hpcloud.com/api/v13/identity”, “type”: “text/html”, “rel”: “describedby”}, {“href”: “https://region-b.geo-1.identity.hpcloudsvc.com:35357/v3”, “rel”: “self”}]}]}}% |
Collapsed JSON response. Officially, according to HP Cloud CDN docs, you should use this format to update the metadata TTL :
1 | curl –i –k –X POST “X-Auth-Token: PassWord” https://region–a.geo–1.objects.hpcloudsvc.com/v1/1234567890123/tcw–all–january/apple–touch–icon–144×144–precomposed.png “x_ttl: 1024” |
You can use :
"X-Auth-User: username" -H "X-Auth-Key: Password"
in place of
"X-Auth-Token: PassWord"
If you are getting :
1 2 3 4 5 6 7 | HTTP/1.1 401 Unauthorized Content–Length: 131 Content–Type: text/html; charset=UTF–8 X–Trans–Id: txbf160d2639c244afa20ef–0054d7599d Date: Sun, 08 Feb 2015 12:42:05 GMT <html><h1>Unauthorized</h1><p>This server could not verify that you are authorized to access the document you requested.</p></html>% |
Then ask HP Cloud’s Support. It is Firewall which is blocking. You have done 90% right.
Python Middleware is a better way, that is fully different topic. We at least passed you to a point which possibly you were fighting too much.