forked from cloudfoundry/docs-bosh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
director-api-v1.html.md.erb
612 lines (471 loc) · 17.9 KB
/
director-api-v1.html.md.erb
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
---
title: Director API v1
---
<p class="note">Note: Before using the Director API directly, we strongly encourage to consider using the CLI for automation such as performing a scheduled deploy from a CI. We hope that you will open a <a href="https://github.com/cloudfoundry/bosh/issues">GitHub issue</a> to share your use cases so that we can suggest or possibly make additions to the CLI.</a>
This document lists common API endpoints provided by the Director.
---
## <a id="overview"></a> Overview
### <a id="auth"></a> Security
All API access should be done over verified HTTPS.
The Director can be configured in two authentication modes: [basic auth](director-users.html#preconfigured) and [UAA](director-users-uaa.html). [Info endpoint](#info) does not require any authentication and can be used to determine which authentication mechanism to use. All other endpoints require authentication.
`401 Unauthorized` will be returned for requests that contain an invalid basic auth credentials or an invalid/expired UAA access token.
### <a id="http-verbs"></a> HTTP verbs
Standard HTTP verb semantics are followed:
| Verb | Description |
-------|-------------|
| GET | Used for retrieving resources. |
| POST/PUT | Used for creating/updating resources. |
| DELETE | Used for deleting resources. |
### <a id="http-verbs"></a> HTTP redirects
Any request may result in a redirection. Receiving an HTTP redirection is not an error and clients should follow that redirect. Redirect responses will have a Location header field. Clients should use same authentication method when following a redirect.
### <a id="rate-limiting"></a> Rate limiting
Currently no rate limiting is performed.
### <a id="pagination"></a> Pagination
Currently none of the resources are paginated.
### <a id="long-running-ops"></a> Long running operations (aka Director tasks)
Certain requests result in complex and potentially long running operations against the IaaS, blobstore, or other resources. [`POST /deployments`](#post-deployment) is a good example. Such requests start a [Director task](director-tasks.html) and continue running on the Director after response is returned. Response to such request will be a `302 Moved Temporarily` redirect to a created task resource.
Once a Director task is created, clients can follow its progress by polling [`GET /tasks/{id}`](#get-task) to find out its state. While waiting for the task to finish, different types of logs ([event](#get-task-event), [result](#get-task-result), [debug](#get-task-debug) information, etc.) can be followed to gain insight into what the task is doing.
---
## <a id="general"></a> General
### <a id="info"></a> `GET /info`: Info
#### Response body schema
**[root]** [Hash]: Director details.
- **name** [String]: Name of the Director.
- **uuid** [String]: Unique ID of the Director.
- **version** [String]: Version of the Director software.
- **user** [String or null]: Logged in user's user name if authentication is provided, otherwise null.
- **cpi** [String]: Name of the CPI the Director will use.
- **user_authentication** [Hash]:
- **type** [String]: Type of the authentication the Director is configured to expect.
- **options** [Hash]: Additional information provided to how authentication should be performed.
#### Notes
- This is the only endpoint that does not require authentication.
- In future `version` will contain version of the deployed BOSH release.
#### Example
<pre class="terminal">
$ curl -s -k https://192.168.50.4:25555/info | jq .
</pre>
```yaml
{
"name": "Bosh Lite Director",
"uuid": "2daf673a-9755-4b4f-aa6d-3632fbed8012",
"version": "1.3126.0 (00000000)",
"user": null,
"cpi": "warden_cpi",
"user_authentication": {
"type": "basic",
"options": {}
}
}
```
---
## <a id="tasks"></a> Tasks
### <a id="list-tasks"></a> `GET /tasks`: List all tasks
#### Response body schema
**[root]** [Array]: List of tasks.
- **id** [Integer]: Numeric ID of the task.
- **state** [String]: Current state of the task. Possible values are: `queued`, `processing`, `cancelled`, `cancelling`, `done`, `errored`.
- **description** [String]: Description of the task's purpose.
- **timestamp** [Integer]: todo.
- **result** [String or null]: Description of the task's result. Will not be populated (string) unless tasks finishes.
- **user** [String]: User which started the task.
#### Example
<pre class="terminal">
$ curl -v -s -k 'https://admin:[email protected]:25555/tasks?verbose=2&limit=3' | jq .
</pre>
```yaml
[
{
"id": 1180,
"state": "processing",
"description": "run errand acceptance_tests from deployment cf-warden",
"timestamp": 1447033291,
"result": null,
"user": "admin"
},
{
"id": 1179,
"state": "done",
"description": "scan and fix",
"timestamp": 1447031334,
"result": "scan and fix complete",
"user": "admin"
},
{
"id": 1178,
"state": "done",
"description": "scan and fix",
"timestamp": 1447031334,
"result": "scan and fix complete",
"user": "admin"
}
]
```
---
### <a id="list-current-tasks"></a> `GET /tasks?state=...`: List currently running tasks
#### Response body schema
See schema [above](#list-tasks).
#### Example
<pre class="terminal">
$ curl -v -s -k 'https://admin:[email protected]:25555/tasks?state=queued,processing,cancelling&verbose=2' | jq .
</pre>
```yaml
[
{
"id": 1180,
"state": "processing",
"description": "run errand acceptance_tests from deployment cf-warden",
"timestamp": 1447033291,
"result": null,
"user": "admin"
}
]
```
---
### <a id="get-task"></a> `GET /tasks/{id}`: Retrieve single task
#### Response body schema
**[root]** [Hash]: Task details.
See additional schema details [above](#list-tasks).
#### Example
<pre class="terminal">
$ curl -v -s -k 'https://admin:[email protected]:25555/tasks/1180' | jq .
</pre>
```yaml
{
"id": 1180,
"state": "processing",
"description": "run errand acceptance_tests from deployment cf-warden",
"timestamp": 1447033291,
"result": null,
"user": "admin"
}
```
---
### <a id="get-task-debug"></a> `GET /tasks/{id}/output?type=debug`: Retrieve task's debug log
#### Response body schema
**[root]** [String]: Debug output for the chosen task.
#### Example
<pre class="terminal">
$ curl -v -s -k 'https://admin:[email protected]:25555/tasks/1180/output?type=debug'
</pre>
```
...
D, [2015-11-09 02:19:36 #32545] [] DEBUG -- DirectorJobRunner: RECEIVED: director.37d8c089-853e-458c-8535-195085b4b7ed.459b05ae-8b69-4679-b2d5-b34e5fef2dcc {"value":{"agent_task_id":"c9f5b328-0656-41f1-631c-e17151be1e18","state":"running"}}
D, [2015-11-09 02:19:36 #32545] [task:1180] DEBUG -- DirectorJobRunner: (0.000441s) SELECT NULL
D, [2015-11-09 02:19:36 #32545] [task:1180] DEBUG -- DirectorJobRunner: (0.000317s) SELECT * FROM "tasks" WHERE "id" = 1180
```
---
### <a id="get-task-event"></a> `GET /tasks/{id}/output?type=event`: Retrieve task's event log
#### Response body schema
**[root]** [String]: Result output for the chosen task. Newlines separate valid event JSON records.
#### Example
<pre class="terminal">
$ curl -v -s -k 'https://admin:[email protected]:25555/tasks/1181/output?type=event'
</pre>
```
...
{
"time": 1446959491,
"stage": "Deleting errand instances",
"tags": [ "smoke_tests" ],
"total": 1,
"task": "59d5b228-a732-4c68-6017-31fe5bc9d8c5",
"index": 1,
"state": "started",
"progress": 0
}
{
"time": 1446959496,
"stage": "Deleting errand instances",
"tags": [ "smoke_tests" ],
"total": 1,
"task": "59d5b228-a732-4c68-6017-31fe5bc9d8c5",
"index": 1,
"state": "finished",
"progress": 100
}
```
---
### <a id="get-task-result"></a> `GET /tasks/{id}/output?type=result`: Retrieve task's result
#### Response body schema
**[root]** [String]: Result output for the chosen task. Contents depend on a type of task.
#### Example of VM details task
<pre class="terminal">
$ curl -v -s -k 'https://admin:[email protected]:25555/tasks/1181/output?type=result'
</pre>
```
...
{"vm_cid":"ec974048-3352-4ba4-669d-beab87b16bcb","disk_cid":null,"ips":["10.244.0.142"],"dns":[],"agent_id":"c5e7c705-459e-41c0-b640-db32d8dc6e71","job_name":"doppler_z1","index":0,"job_state":"running","resource_pool":"medium_z1","vitals":{"cpu":{"sys":"9.1","user":"2.1","wait":"1.7"},"disk":{"ephemeral":{"inode_percent":"11","percent":"36"},"system":{"inode_percent":"11","percent":"36"}},"load":["0.61","0.74","1.10"],"mem":{"kb":"2520960","percent":"41"},"swap":{"kb":"102200","percent":"10"}},"processes":[{"name":"doppler","state":"running"},{"name":"syslog_drain_binder","state":"running"},{"name":"metron_agent","state":"running"}],"resurrection_paused":false}
```
---
## <a id="stemcells"></a> Stemcells
### <a id="list-stemcells"></a> `GET /stemcells`: List all uploaded stemcells
#### Response body schema
**[root]** [Array]: List of stemcells.
- **name** [String]: Name of the stemcell.
- **version** [String]: Version of the stemcell.
- **operating_system** [String]: Operating system identifier. Example: `ubuntu-trusty` and `centos-7`.
- **cid** [String]: Cloud ID of the stemcell.
- **deployments** [Array]: List of deployments currently using this stemcell version.
- **name** [String]: Deployment name.
#### Example
<pre class="terminal">
$ curl -v -s -k https://admin:[email protected]:25555/stemcells | jq .
</pre>
```yaml
[
{
"name": "bosh-warden-boshlite-ubuntu-trusty-go_agent",
"operating_system": "ubuntu-trusty",
"version": "3126",
"cid": "c3705a0d-0dd3-4b67-52b5-50533a432244",
"deployments": [
{ "name": "cf-warden" }
]
}
]
```
---
## <a id="releases"></a> Releases
### <a id="list-releases"></a> `GET /releases`: List all uploaded releases
#### Response body schema
**[root]** [Array]: List of releases.
- **name** [String]: Name of the release.
- **release_versions** [Array]: List of versions available.
- **version** [String]: Version of the release version.
- **commit_hash** [String]: Identifier in the SCM repository for the release version source code.
- **uncommitted_changes** [Boolean]: Whether or not the release version was created from a SCM repository with unsaved changes.
- **currently_deployed** [Boolean]: Whether or not the release version is used by any deployments.
- **job_names** [Array of strings]: List of job names associated with the release version.
#### Example
<pre class="terminal">
$ curl -v -s -k https://admin:[email protected]:25555/releases | jq .
</pre>
```yaml
[
{
"name": "bosh-warden-cpi",
"release_versions": [
{
"version": "28",
"commit_hash": "4c36884a",
"uncommitted_changes": false,
"currently_deployed": false,
"job_names": [ "warden_cpi" ]
}
]
},
{
"name": "test",
"release_versions": [
{
"version": "0+dev.16",
"commit_hash": "31ef3167",
"uncommitted_changes": true,
"currently_deployed": false,
"job_names": [ "http_server", "service" ]
},
{
"version": "0+dev.17",
"commit_hash": "e5416248",
"uncommitted_changes": true,
"currently_deployed": true,
"job_names": [ "drain", "errand", "http_server", "pre_start", "service" ]
},
]
}
]
```
---
## <a id="deployments"></a> Deployments
### <a id="list-deployments"></a> `GET /deployments`: List all deployments
#### Response body schema
**[root]** [Array]: List of deployments.
- **name** [String]: Name of the deployment.
- **cloud_config** [String]: Indicator whether latest cloud config is used for this deployment. Possible values: `none`, `outdated`, `latest`.
- **releases** [Array]: List of releases used by the deployment.
- **name** [String]: Name of the release.
- **version** [String]: Version of the release.
- **stemcells** [Array]: List of stemcells used by the deploymemt.
- **name** [String]: Name of the stemcell.
- **version** [String]: Version of the stemcell.
#### Example
<pre class="terminal">
$ curl -v -s -k https://admin:[email protected]:25555/deployments | jq .
</pre>
```yaml
[
{
"name": "cf-warden",
"cloud_config": "none",
"releases": [
{
"name": "cf",
"version": "222"
},
{
"name": "cf",
"version": "223"
}
],
"stemcells": [
{
"name": "bosh-warden-boshlite-ubuntu-trusty-go_agent",
"version": "2776"
},
{
"name": "bosh-warden-boshlite-ubuntu-trusty-go_agent",
"version": "3126"
}
]
}
]
```
---
### <a id="post-deployment"></a> `POST /deployments`: Create/update single deployment
#### Request query
- **recreate** [Boolean]: Whether or not to ignore deletion errors. Possible values: `true` or not present. Default is not present.
- **skip_drain** [String]: Comma separated list of job names that should not run drain scripts during the update. Possible values: `*` to represent all jobs, `<job1>,<job2>` to list job names, or not present. Default is not present.
#### Request headers
- **Content-Type** must be `text/yaml`.
#### Request body scheme
**[root]** [String]: Manifest string. Note that non-exact version values (`latest` value) for releases and stemcells must be resolved before making a request.
#### Response
Creating/updating a deployment is performed in a Director task. Response will be a redirect to a task resource.
---
### <a id="get-deployment"></a> `GET /deployments/{name}`: Retrieve single deployment
#### Response body schema
**[root]** [Hash]: Single deployment.
- **manifest** [String]: Last successfully deployed manifest string.
#### Example
<pre class="terminal">
$ curl -v -s -k https://admin:[email protected]:25555/deployments/cf-warden | jq .
</pre>
```yaml
{
"manifest": "---\nname: cf-warden\n...",
}
```
---
### <a id="delete-deployment"></a> `DELETE /deployments/{name}`: Delete single deployment
#### Request query
- **force** [Boolean]: Whether or not to ignore deletion errors. Dangerous! Possible values: `true` or not present. Default is not present.
#### Request body
Empty.
#### Response
Deleting a deployment is performed in a Director task. Response will be a redirect to a task resource.
---
## <a id="vms"></a> VMs in a deployment
### <a id="list-vms"></a> `GET /deployments/{name}/vms`: List all VMs
#### Response body schema
**[root]** [Array]: List of VMs.
- **agent_id** [String]: Unique ID of the Agent associated with the VM.
- **cid** [String]: Cloud ID of the VM.
- **job** [String]: Name of the job.
- **index** [Integer]: Numeric job index.
#### Notes
- This endpoint does not query Agents on the VMs, hence is returned immediately.
#### Example
<pre class="terminal">
$ curl -v -s -k 'https://admin:[email protected]:25555/deployments/cf-warden/vms' | jq .
</pre>
```yaml
[
{
"agent_id": "c5e7c705-459e-41c0-b640-db32d8dc6e71",
"cid": "ec974048-3352-4ba4-669d-beab87b16bcb",
"job": "doppler_z1",
"index": 0
},
{
"agent_id": "81f7b585-f3d3-4dbc-8d7c-f76dbe861bdc",
"cid": "427c1995-2d06-42b2-4218-418150bc31c9",
"job": "api_z1",
"index": 0
}
]
```
---
### <a id="list-vms-detailed"></a> `GET /deployments/{name}/vms?format=full`: List VM details
#### Response body schema
**[root]** [String]: Each VM's details are separated by a newline.
- **agent_id** [String]: Unique ID of the Agent associated with the VM.
- **vm_cid** [String]: Cloud ID of the VM.
- **resource_pool** [String]: Name of the resource pool used for the VM.
- **disk_cid** [String or null]: Cloud ID of the associated persistent disk if one is attached.
- **job_name** [String]: Name of the job.
- **index** [Integer]: Numeric job index.
- **resurrection_paused** [Boolean]: Whether or not ressurector will try to bring back the VM is it goes missing.
- **job_state** [String]: Aggregate state of job. Possible values: `running` and other values that represent unhealthy state.
- **ips** [Array of strings]: List of IPs.
- **dns** [Array of strings]: List of DNS records.
- **vitals** [Hash]: VM vitals.
- **processes** [Array of hashes]: List of processes running as part of the job.
#### Example
<pre class="terminal">
$ curl -v -s -k 'https://admin:[email protected]:25555/deployments/cf-warden/vms?format=full'
< HTTP/1.1 302 Moved Temporarily
< Location: https://192.168.50.4:25555/tasks/1181
...
$ curl -v -s -k 'https://admin:[email protected]:25555/tasks/1181' | jq .
$ curl -v -s -k 'https://admin:[email protected]:25555/tasks/1181/output?type=result'
</pre>
```
...
{"vm_cid":"ec974048-3352-4ba4-669d-beab87b16bcb","disk_cid":null,"ips":["10.244.0.142"],"dns":[],"agent_id":"c5e7c705-459e-41c0-b640-db32d8dc6e71","job_name":"doppler_z1","index":0,"job_state":"running","resource_pool":"medium_z1","vitals":{"cpu":{"sys":"9.1","user":"2.1","wait":"1.7"},"disk":{"ephemeral":{"inode_percent":"11","percent":"36"},"system":{"inode_percent":"11","percent":"36"}},"load":["0.61","0.74","1.10"],"mem":{"kb":"2520960","percent":"41"},"swap":{"kb":"102200","percent":"10"}},"processes":[{"name":"doppler","state":"running"},{"name":"syslog_drain_binder","state":"running"},{"name":"metron_agent","state":"running"}],"resurrection_paused":false}
```
#### Example of a single VM details formatted
```yaml
{
"agent_id": "c5e7c705-459e-41c0-b640-db32d8dc6e71",
"vm_cid": "ec974048-3352-4ba4-669d-beab87b16bcb",
"resource_pool": "medium_z1",
"disk_cid": null,
"job_name": "doppler_z1",
"index": 0,
"resurrection_paused": false,
"job_state": "running",
"ips": [ "10.244.0.142" ],
"dns": [],
"vitals": {
"cpu": {
"sys": "9.1",
"user": "2.1",
"wait": "1.7"
},
"disk": {
"ephemeral": {
"inode_percent": "11",
"percent": "36"
},
"system": {
"inode_percent": "11",
"percent": "36"
}
},
"load": [ "0.61", "0.74", "1.10" ],
"mem": {
"kb": "2520960",
"percent": "41"
},
"swap": {
"kb": "102200",
"percent": "10"
}
},
"processes": [
{
"name": "doppler",
"state": "running"
},
{
"name": "syslog_drain_binder",
"state": "running"
},
{
"name": "metron_agent",
"state": "running"
}
]
}
```