API » History » Version 8
Ohad Levy, 05/09/2011 02:47 AM
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 | h2. List of API's |
||
8 | |||
9 | |_.Path|_.REST Type|_.Description|_.Example Input JSON| |
||
10 | |_.FEATURES | |
||
11 | |/features|GET|List of features supported by the proxy|| |
||
12 | |_.DHCP | |
||
13 | |/dhcp|GET|Retrieve a list of subnets|| |
||
14 | |/dhcp/10.1.2.0|GET|Retrieve 10.1.2.0 subnets records|| |
||
15 | |/dhcp/10.1.2.0/10.1.2.5|GET|Retrieve 10.1.2.5 reservation information || |
||
16 | |/dhcp/10.1.2.0/unused_ip|GET|Provides an unused ip address in 10.1.2.0 subnet || |
||
17 | 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}@| |
18 | 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|| |
19 | |_.DNS | |
||
20 | 5 | Frank Sweetser | |/dns|POST|Create a new DNS record|@{"fqdn":string(name/ip), "value":string(ip/reverse), "type":string(A/PTR)}@| |
21 | 1 | Ohad Levy | |/dns/value|DELETE|remove value(ip or reverse) DNS record|| |
22 | |_.TFTP | |
||
23 | 5 | Frank Sweetser | |/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}@| |
24 | |/tftp/00:11:22:33:44:55|DELETE|remove pxelinux configuration file for host with MAC address 00:11:22:33:44:55|| |
||
25 | |/tftp/create_default|POST|creates a default pxelinux configuration file|@{"syslinux_config":string}@| |
||
26 | |/tftp/fetch_boot_file|POST|creates a default pxelinux configuration file|@{"prefix":string, "path":string}@| |
||
27 | 8 | Ohad Levy | |/tftp/serverName|GET|fetches the TFTP server name to be used within a dhcp record|| |
28 | 1 | Ohad Levy | |_.PUPPET CA | |
29 | |/puppet/ca|GET| list of all puppet certificates || |
||
30 | 7 | Ohad Levy | |/puppet/ca/certname|POST| Sign pending certificate request || |
31 | |/puppet/ca/certname|DELETE| Remove (clean) and revoke a certificate || |
||
32 | 1 | Ohad Levy | |/puppet/ca/autosign|GET| list of all puppet autosign entires || |
33 | |/puppet/ca/autosign/certname|POST| Add certname to Puppet autosign || |
||
34 | |/puppet/ca/autosign/certname|DELETE| Remove certname from Puppet autosign || |
||
35 | |_.PUPPET | |
||
36 | 5 | Frank Sweetser | |/puppet/run|POST| Trigger puppet run / kick|@["hostA", "hostB"]@| |
37 | 1 | Ohad Levy | |
38 | Please raise a new issue if you need additional API's |
||
39 | 4 | Frank Sweetser | |
40 | h2. Manually Calling the API |
||
41 | |||
42 | 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. |
||
43 | |||
44 | 1 | Ohad Levy | <pre> |
45 | curl http://localhost:8443/features |
||
46 | </pre> |
||
47 | |||
48 | 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. |
||
49 | <pre> |
||
50 | curl -d 'nodes=server.example.com' http://localhost:8443/puppet/run |
||
51 | 5 | Frank Sweetser | </pre> |
52 | |||
53 | Multiple post options may be specified by repeating the -d argument. |
||
54 | <pre> |
||
55 | 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 |
||
56 | </pre> |
||
57 | |||
58 | 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.) |
||
59 | |||
60 | <pre> |
||
61 | curl -d 'syslinux_config=Hello World' http://localhost:8443/tftp/00:11:22:33:44:55 |
||
62 | </pre> |
||
63 | |||
64 | 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. |
||
65 | |||
66 | <pre> |
||
67 | curl -X DELETE http://localhost:8443/tftp/00:11:22:33:44:55 |
||
68 | 4 | Frank Sweetser | </pre> |
69 | 6 | Brian Gupta | |
70 | [[Draft 2.0 version of DNS API]] |