-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I7509a50707588b324e608e3ccd2b3e991b0ea746
- Loading branch information
Patrick Bozeman
committed
Jun 1, 2012
1 parent
0f22cc0
commit 69e6cce
Showing
40 changed files
with
2,121 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,318 @@ | ||
Hi. Lets take a tour of working with the cc locally and do a few basic | ||
operations. | ||
|
||
Heads up.. the CC doesn't match the API doc yet. This tour will guide you | ||
around the pitfalls. | ||
|
||
Run the CC | ||
|
||
First, let's get your cloud controller running. To do so, in another window | ||
run: | ||
|
||
bin/cloud_controller -d -m | ||
|
||
-d puts the cc into developer mode. -m will cause it to run migrations. | ||
|
||
You don't really have to go into dev mode, but you do need to run -m at | ||
least once. | ||
|
||
|
||
Test the CC | ||
|
||
Your cc should be up and running on port 8080 now, so test it out. | ||
with: | ||
|
||
curl -v http://localhost:8080/ | ||
|
||
You should get a 404 back and a custom error body. We should probably be | ||
nicer about returning something for /, but for now, meh. | ||
|
||
That error body is the standard sort of error that you will expect to see for | ||
other types of errors. | ||
|
||
Bootstrap an Admin | ||
|
||
Ok.. let's get your admin user created. We really need an external | ||
bootstrap tool to insert an initial admin into the db, but for now, you can | ||
do the following | ||
|
||
curl -v http://localhost:8080/bootstrap | ||
|
||
You should get back an HTTP 201 and a blob of json. Since the bootstrap call | ||
is not a real CC api call, it is not in the standard format with a metadata | ||
and entity section. | ||
|
||
Let's see a server error: | ||
|
||
If you run the same command again: | ||
|
||
curl -v http://localhost:8080/bootstrap | ||
|
||
You will get back a 500 and a custom server error response body. This is | ||
because the bootstrap route bypasses the API. Had you gone through the API | ||
you would have gotten a real error message. Still, you didn't get a blob of | ||
html on an unhandled error like in the original cc. | ||
|
||
Note the window you are running the cc in. You should see a big stack trace. | ||
If you get any weird server errors, go check for those sort of backtraces and | ||
send them to me. | ||
|
||
Let's create an org: | ||
|
||
Ok, this will be a load of fun! | ||
|
||
curl -X POST -H "Content-Type: application/json" \ | ||
-d '{"name":"my cool org"}' \ | ||
http://localhost:8080/v2/organizations | ||
|
||
Oh, you got an auth error. Silly you. | ||
|
||
|
||
Let's create an org with "correct" auth/authz | ||
|
||
Ok, this will be even more fun. Fun like a horror movie. (UAA integration | ||
is coming. We used to have our own signed token, but didn't bother checking | ||
it in because the UAA is the true new hotness.) | ||
|
||
curl -X POST -H "Content-Type: application/json" \ | ||
-H "Authorization: iliag@vmware.com" \ | ||
-d '{"name":"my cool org"}' \ | ||
http://localhost:8080/v2/organizations | ||
|
||
Now this time you should get something back like: | ||
|
||
{ | ||
"metadata": { | ||
"id": 1, | ||
"url": "/v2/organizations/1", | ||
"created_at": "2012-05-14 12:49:31 -0700", | ||
"updated_at": null | ||
}, | ||
"entity": { | ||
"name": "my cool org", | ||
"users_url": | ||
"/v2/users?q=organization_id:1", | ||
"app_spaces_url": | ||
"/v2/app_spaces?q=organization_id:1" | ||
} | ||
} | ||
|
||
Yay. | ||
|
||
Note the Location header in the response. You should be able to do | ||
a GET on that. | ||
|
||
|
||
Let's double check our org: | ||
|
||
curl -H "Authorization: iliag@vmware.com" \ | ||
http://localhost:8080/v2/organizations/1 | ||
|
||
{ | ||
"metadata": { | ||
"id": 1, | ||
"url": "/v2/organizations/1", | ||
"created_at": "2012-05-14 12:49:31 -0700", | ||
"updated_at": null | ||
}, | ||
"entity": { | ||
"name": "my cool org", | ||
"users_url": | ||
"/v2/users?q=organization_id:1", | ||
"app_spaces_url": | ||
"/v2/app_spaces?q=organization_id:1" | ||
} | ||
} | ||
|
||
Double yay. | ||
|
||
|
||
Let's rename the org: | ||
|
||
curl -v -X PUT -H "Content-Type: application/json" \ | ||
-H "Authorization: iliag@vmware.com" \ | ||
-d '{"name":"ilia likes orgs"}' \ | ||
http://localhost:8080/v2/organizations/1 | ||
|
||
{ | ||
"metadata": { | ||
"id": 1, | ||
"url": "/v2/organizations/1", | ||
"created_at": "2012-05-14 12:49:31 -0700", | ||
"updated_at": "2012-05-14 12:55:01 -0700" | ||
}, | ||
"entity": { | ||
"name": "ilia likes orgs", | ||
"users_url": | ||
"/v2/users?q=organization_id:1", | ||
"app_spaces_url": | ||
"/v2/app_spaces?q=organization_id:1" | ||
} | ||
} | ||
|
||
|
||
Let's go create a user: | ||
|
||
curl -v -X POST -H "Content-Type: application/json" \ | ||
-H "Authorization: iliag@vmware.com" \ | ||
-d '{"id":"1234-4567-89AB-CDEF"}' \ | ||
http://localhost:8080/v2/users | ||
|
||
{ | ||
"metadata": { | ||
"id": "1234-4567-89AB-CDEF", | ||
"url": "/v2/users/1234-4567-89AB-CDEF", | ||
"created_at": "2012-05-14 12:57:08 -0700", | ||
"updated_at": null | ||
}, | ||
"entity": { | ||
"id": "1234-4567-89AB-CDEF", | ||
"admin": false, | ||
"active": false, | ||
"organizations_url": | ||
"/v2/organizations?q=user_id:1234-4567-89AB-CDEF", | ||
"app_spaces_url": | ||
"/v2/app_spaces?q=user_id:1234-4567-89AB-CDEF" | ||
} | ||
} | ||
|
||
So now we should have 2 users, (the boot strap user, plus the one above) | ||
let's see: (NOTE: The bootstrap user is currently using an email address | ||
since that is what was provided in the last drop, but for now, | ||
all uaa_ids are basically arbitrary text strings as far as the CC is concerned) | ||
|
||
curl -v -H "Authorization: iliag@vmware.com" http://localhost:8080/v2/users | ||
|
||
{ | ||
"total_results": 2, | ||
"prev_url": null, | ||
"next_url": null, | ||
"resources": [ | ||
{ | ||
"metadata": { | ||
"id": "iliag@vmware.com", | ||
"url": "/v2/users/iliag@vmware.com", | ||
"created_at": "2012-05-14 12:47:03 -0700", | ||
"updated_at": null | ||
}, | ||
"entity": { | ||
"id": "iliag@vmware.com", | ||
"admin": true, | ||
"active": true, | ||
"organizations_url": "/v2/organizations?q=user_id:iliag@vmware.com", | ||
"app_spaces_url": "/v2/app_spaces?q=user_id:iliag@vmware.com" | ||
} | ||
}, | ||
{ | ||
"metadata": { | ||
"id": "1234-4567-89AB-CDEF", | ||
"url": "/v2/users/1234-4567-89AB-CDEF", | ||
"created_at": "2012-05-14 12:57:08 -0700", | ||
"updated_at": null | ||
}, | ||
"entity": { | ||
"id": "1234-4567-89AB-CDEF", | ||
"admin": false, | ||
"active": false, | ||
"organizations_url": "/v2/organizations?q=user_id:1234-4567-89AB-CDEF", | ||
"app_spaces_url": "/v2/app_spaces?q=user_id:1234-4567-89AB-CDEF" | ||
} | ||
} | ||
] | ||
} | ||
|
||
Yep | ||
|
||
Check the orgs the same way: | ||
|
||
curl -v -H "Authorization: iliag@vmware.com" \ | ||
http://localhost:8080/v2/organizations | ||
|
||
{ | ||
"total_results": 1, | ||
"prev_url": null, | ||
"next_url": null, | ||
"resources": [ | ||
{ | ||
"metadata": { | ||
"id": 1, | ||
"url": "/v2/organizations/1", | ||
"created_at": "2012-05-14 12:49:31 -0700", | ||
"updated_at": "2012-05-14 12:55:01 -0700" | ||
}, | ||
"entity": { | ||
"name": "ilia likes orgs", | ||
"users_url": "/v2/users?q=organization_id:1", | ||
"app_spaces_url": "/v2/app_spaces?q=organization_id:1" | ||
} | ||
} | ||
] | ||
} | ||
|
||
|
||
Those url associations work. Let's check the one for | ||
the 1234-... user. | ||
|
||
curl -v -H "Authorization: iliag@vmware.com" \ | ||
http://localhost:8080/v2/organizations?q=user_id:1234-4567-89AB-CDEF | ||
|
||
{ | ||
"total_results": 0, | ||
"prev_url": null, | ||
"next_url": null, | ||
"resources": [ | ||
|
||
] | ||
} | ||
|
||
Which is correct because we haven't added the user to an org yet. | ||
|
||
|
||
Now let's add that 1234-... user to an org: | ||
|
||
curl -v -X PUT -H "Content-Type: application/json" \ | ||
-H "Authorization: iliag@vmware.com" \ | ||
-d '{"user_ids":["1234-4567-89AB-CDEF"]}' \ | ||
http://localhost:8080/v2/organizations/1 | ||
|
||
{ | ||
"metadata": { | ||
"id": 1, | ||
"url": "/v2/organizations/1", | ||
"created_at": "2012-05-14 12:49:31 -0700", | ||
"updated_at": "2012-05-14 13:09:59 -0700" | ||
}, | ||
"entity": { | ||
"name": "ilia likes orgs", | ||
"users_url": "/v2/users?q=organization_id:1", | ||
"app_spaces_url": "/v2/app_spaces?q=organization_id:1" | ||
} | ||
} | ||
|
||
Now if we fetch the url association for that user again: | ||
|
||
curl -v -H "Authorization: iliag@vmware.com" \ | ||
http://localhost:8080/v2/organizations?q=user_id:1234-4567-89AB-CDEF | ||
|
||
{ | ||
"total_results": 1, | ||
"prev_url": null, | ||
"next_url": null, | ||
"resources": [ | ||
{ | ||
"metadata": { | ||
"id": 1, | ||
"url": "/v2/organizations/1", | ||
"created_at": "2012-05-14 12:49:31 -0700", | ||
"updated_at": "2012-05-14 13:09:59 -0700" | ||
}, | ||
"entity": { | ||
"name": "ilia likes orgs", | ||
"users_url": "/v2/users?q=organization_id:1", | ||
"app_spaces_url": "/v2/app_spaces?q=organization_id:1" | ||
} | ||
} | ||
] | ||
} | ||
|
||
Yep.. he shows up in org 1 as expected. |
Oops, something went wrong.