Monday, October 31, 2016

停止生氣與憤怒

幾十個年頭下來,至少體悟到,
在憤怒時說的話,後悔的都是自己。
不管你多有理由,不管你多冠冕堂皇,後悔的都是自己。

生氣其實是脆弱引發的,接著失控,因此導致自己的後悔。
如果把憤怒,轉變成思路與策略,我想一切都會很不同。

從另一個角度看:
這也暴露了人類的弱點,憤怒是最脆弱的時刻,
打倒你,很簡單,惹怒你就好,永比射向阿基里斯腱容易。

或許,你不會藉機惹怒別人,但別人會。
別上當了,因此,請學會控制自己,

如果這樣寫的都無法打動自己,
那麼,請相信猶太人相信的,和氣生財。

Tuesday, October 4, 2016

OpenStack: How to bind a Tenant/Project to a Specific Region

keystonetenantbindRegion

How to bind a Tenant to a specific Region

Long time ago, I am trying to solve the problem that can a tenant bind to a region ?
Now we got the answer, we can use Mitaka keystone and with v3 API to solve this problem.

http://developer.openstack.org/api-ref/identity/v3-ext/?expanded=create-endpoint-group-detail

V3 API changes the Tenant to Project, so sometimes we use these two words mix.

We can use the keystone v3 extension API: v3/OS-EP-FILTER/projects/{project_id}/endpoints/{endpoint_id}.

Started Binding Tenant and Region

先找出来,我们现有的Region ID。 First of all, we find out the region that we want to bind to.

root@mitakakeystone:~/v3keystone# curl  -si -H"X-Auth-Token:admintoken" -H "Content-type: application/json" "http://localhost:35357/v3/endpoints"
HTTP/1.1 200 OK
Vary: X-Auth-Token
Content-Type: application/json
Content-Length: 3327
X-Openstack-Request-Id: req-99c406c8-2f1e-41b8-8bb4-bfad7beb2c99
Date: Tue, 04 Oct 2016 06:20:45 GMT

.
 {"region_id": "RR", "links": {"self": "http://localhost:35357/v3/endpoints/909a15358430456cab93020fab101b9f"},   
 "url": "http://localhost:35357/v3/services/c6f427a715a54d0190ec8364d46f307b", "region": "RR", "enabled": true,   
 "interface": "public", "service_id": "c6f427a715a54d0190ec8364d46f307b", "id": "909a15358430456cab93020fab101b9f"}   
.

Remember the Region_ID 909a15358430456cab93020fab101b9f, we will bind a project to this region.

That's see Is there any endpoint binding to the project(tenant) id via /v3/OS-EP-FILTE API.

root@mitakakeystone:~/v3keystone# curl -si -H "X-Auth-Token:admintoken" -H "Content-type: application/json" "http://localhost:35357/v3/OS-EP-FILTER/projects/404838490fab42e7ad560b66725e4f64/endpoints"
HTTP/1.1 200 OK
Vary: X-Auth-Token
Content-Type: application/json
Content-Length: 162
X-Openstack-Request-Id: req-560e8715-e992-42e6-b761-9c3487040a93
Date: Tue, 04 Oct 2016 06:16:38 GMT

{"endpoints": [], "links": {"self": "http://localhost:35357/v3/OS-EP-FILTER/projects/404838490fab42e7ad560b66725e4f64/endpoints", "previous": null, "next": null}}

No binding at all.

Now we can start to bind project id 404838490fab42e7ad560b66725e4f64 to Region ID 909a15358430456cab93020fab101b9f

curl -X PUT -si -H "X-Auth-Token:admintoken" -H "Content-type: application/json" "http://localhost:35357/v3/OS-EP-FILTER/projects/404838490fab42e7ad560b66725e4f64/endpoints/909a15358430456cab93020fab101b9f"

To check it out.

root@mitakakeystone:~/v3keystone# curl -si -H "X-Auth-Token:admintoken" -H "Content-type: application/json" "http://localhost:35357/v3/OS-EP-FILTER/projects/404838490fab42e7ad560b66725e4f64/endpoints"
HTTP/1.1 200 OK
Vary: X-Auth-Token
Content-Type: application/json
Content-Length: 498
X-Openstack-Request-Id: req-404dd3f3-df71-4665-bd8e-acae1f33b2a9
Date: Tue, 04 Oct 2016 06:18:02 GMT

{"endpoints": [{"region_id": "RR", "links": {"self": "http://localhost:35357/v3/endpoints/909a15358430456cab93020fab101b9f"}, "url": "http://localhost:35357/v3/services/c6f427a715a54d0190ec8364d46f307b", "region": "RR", "enabled": true, "interface": "public", "service_id": "c6f427a715a54d0190ec8364d46f307b", "id": "909a15358430456cab93020fab101b9f"}], "links": {"self": "http://localhost:35357/v3/OS-EP-FILTER/projects/404838490fab42e7ad560b66725e4f64/endpoints", "previous": null, "next": null}}

We can see we can bind the project to a spcific region.

To see the original API, no changes any more

root@mitakakeystone:~/v3keystone# curl  -si -H"X-Auth-Token:admintoken" -H "Content-type: application/json" "http://localhost:35357/v3/projects/404838490fab42e7ad560b66725e4f64"
HTTP/1.1 200 OK
Vary: X-Auth-Token
Content-Type: application/json
Content-Length: 283
X-Openstack-Request-Id: req-26d3a544-83ac-4b9b-a10b-ba7f5bbfbf19
Date: Tue, 04 Oct 2016 06:29:47 GMT

{"project": {"is_domain": false, "description": "Service Tenant", "links": {"self": "http://localhost:35357/v3/projects/404838490fab42e7ad560b66725e4f64"}, "enabled": true, "id": "404838490fab42e7ad560b66725e4f64", "parent_id": "default", "domain_id": "default", "name": "service1"}}

So to solve the problem, we must use v3/OS-EP-FILTER/ API.