Project

General

Profile

API » History » Version 15

Corey Osman, 09/04/2012 05:02 PM

1 1 Ohad Levy
h1. API
2
3
Foreman Smart Proxy provides a "REST":http://en.wikipedia.org/wiki/Representational_State_Transfer API, communicating via JSON.
4
5
Please refer to this document for latest information about Foreman Smart Proxy API.
6
7 10 Paul Kelly
_The API entries containing *variant* are only available in smart-proxy v2.0 and later._
8
9 1 Ohad Levy
h2. List of API's
10
11
|_.Path|_.REST Type|_.Description|_.Example Input JSON|  
12
|_.FEATURES |
13
|/features|GET|List of features supported by the proxy||
14 9 Ohad Levy
|/version|GET|Proxy version||
15 1 Ohad Levy
|_.DHCP |
16
|/dhcp|GET|Retrieve a list of subnets||
17
|/dhcp/10.1.2.0|GET|Retrieve 10.1.2.0 subnets records||
18
|/dhcp/10.1.2.0/10.1.2.5|GET|Retrieve 10.1.2.5 reservation information ||
19
|/dhcp/10.1.2.0/unused_ip|GET|Provides an unused ip address in 10.1.2.0 subnet ||
20 5 Frank Sweetser
|/dhcp/10.1.2.0|POST|creates new reservation in 10.1.2.0 subnet |@{"hostname":string, "name":string, "filename":string, "ip":string, "nextserver":string, "mac":string}@|
21 1 Ohad Levy
|/dhcp/10.1.2.0/10.1.2.5|DELETE|Deletes 10.1.2.5 reservation from 10.1.2.0 subnet||
22
|_.DNS |
23 11 Michael Coulter
|/dns/|POST|Create a new DNS record|@{"fqdn":string(name/ip), "value":string(ip/reverse), "type":string(A/PTR)}@|
24 1 Ohad Levy
|/dns/value|DELETE|remove value(ip or reverse) DNS record||
25
|_.TFTP |
26 10 Paul Kelly
|/tftp/00:11:22:33:44:55|POST|creates pxelinux configuration file for host with MAC address 00:11:22:33:44:55|@{"syslinux_config":string}@. Implicit variant of "syslinux"|
27
|/tftp/<variant>/00:11:22:33:44:55|POST|creates pxeconfig configuration file for host with MAC address 00:11:22:33:44:55|@{"pxeconfig":string}@. Variant can be "syslinux" or "pxegrub"|
28
|/tftp/00:11:22:33:44:55|DELETE|remove pxelinux configuration file for host with MAC address 00:11:22:33:44:55|Implicit variant of "syslinux"|
29
|/tftp/<variant>/00:11:22:33:44:55|DELETE|remove pxeconfig configuration file for host with MAC address 00:11:22:33:44:55|. Variant can be "syslinux" or "pxegrub"|
30
|/tftp/create_default|POST|creates a default pxelinux configuration file|@{"syslinux_config":string}@. Implicit variant of "syslinux" |
31
|/tftp/<variant>/create_default|POST|creates a default pxeconfig configuration file|@{"pxeconfig":string}@. Variant can be "syslinux" or "pxegrub"|
32 5 Frank Sweetser
|/tftp/fetch_boot_file|POST|creates a default pxelinux configuration file|@{"prefix":string, "path":string}@|
33 8 Ohad Levy
|/tftp/serverName|GET|fetches the TFTP server name to be used within a dhcp record||
34 1 Ohad Levy
|_.PUPPET CA |
35
|/puppet/ca|GET| list of all puppet certificates ||
36 7 Ohad Levy
|/puppet/ca/certname|POST| Sign pending certificate request ||
37
|/puppet/ca/certname|DELETE| Remove (clean) and revoke a certificate ||
38 1 Ohad Levy
|/puppet/ca/autosign|GET| list of all puppet autosign entires ||
39
|/puppet/ca/autosign/certname|POST| Add certname to Puppet autosign ||
40
|/puppet/ca/autosign/certname|DELETE| Remove certname from Puppet autosign ||
41
|_.PUPPET |
42 5 Frank Sweetser
|/puppet/run|POST| Trigger puppet run / kick|@["hostA", "hostB"]@|
43 12 Ohad Levy
|/puppet/environments |GET| list of all puppet environment names||
44
|/puppet/environments/production> |GET| show puppet production environment name and module paths||
45 13 Ohad Levy
|/puppet/environments/production/classes |GET| return a hash of puppet classes in the production environment|Puppet class parameters is supported from 1.1|
46 15 Corey Osman
|_.BMC |
47
|/bmc/providers|GET|Get a list of supported BMC providers|
48
|/bmc/providers/installed|GET|Get a list of installed BMC providers|
49
50 1 Ohad Levy
51
Please raise a new issue if you need additional API's
52 4 Frank Sweetser
53
h2. Manually Calling the API
54
55
The API can be manually tested out using curl.  GET types can be retrieved like any other URL.  This one, for example, will return the HTML formatted page with the list of features enabled on the proxy.
56
57 1 Ohad Levy
<pre>
58
curl http://localhost:8443/features
59
</pre>
60
61 14 Michael Coulter
The results can also be returned as JSON if you set an appropriate Accept header.
62
63
<pre>
64
curl -H "Accept: application/json" http://localhost:8443/features
65
</pre>
66
67 1 Ohad Levy
POST URLs, used to create objects or trigger actions, need to have the parameters passed in via the -d argument.  This curl command line will trigger a puppetrun on server.example.com.
68
<pre>
69
curl -d 'nodes=server.example.com' http://localhost:8443/puppet/run
70 11 Michael Coulter
</pre>
71
72
This curl command line will add an A record for server.example.com with ip address of 10.1.2.5.
73
<pre>
74
curl -d 'fqdn=servers.example.com&value=10.1.2.5&type=A' http://localhost:8443/dns/
75 5 Frank Sweetser
</pre>
76
77
Multiple post options may be specified by repeating the -d argument.
78
<pre>
79
curl -d 'prefix=boot/CentOS-5-x86_64' -d 'path=http://yourlocalmirrorhere/pub/centos/5/os/x86_64/images/pxeboot/vmlinuz'  http://localhost:8443/tftp/fetch_boot_file
80
</pre>
81
82
When you are creating an object, the identifier for the object is typically passed in as part of the URL, rather than as a POST value.  For example, this will create a PXE boot configuration file for a host with MAC address 00:11:22:33:44:55, and will just put "Hello World" as the contents of the file.  (A real world example would, of course, substitute a valid PXE boot configuration in the string.)
83
84
<pre>
85
curl -d 'syslinux_config=Hello World' http://localhost:8443/tftp/00:11:22:33:44:55
86
</pre>
87
88
In order to delete objects, you use the same URL as in the original creation, but pass it not POST values, and use the DELETE HTTP method instead of POST.  This will delete the PXE boot configuration file created above.
89
90
<pre>
91
curl -X DELETE http://localhost:8443/tftp/00:11:22:33:44:55
92 4 Frank Sweetser
</pre>
93 6 Brian Gupta
94
[[Draft 2.0 version of DNS API]]