You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
« Previous
Version 4
Next »
DHCPv2 Module
The DHCPv2 system is built upon the Resource API, so actions relating to DHCP tasks are largely expressed in terms of Resource actions.
This section describes common DHCP tasks and how they are accomplished via the DHCPv2 system.
get all DHCP-enabled resources |
---|
Description | Finds all resources from section 'dhcp_module,' which indicates that their parents are DHCP-enabled. Adding in other Resource-Get API parameters can filter this list further. |
URL | /api/v1/api.php?target=resource&action=get&type=dhcp_module |
Returns | Examples: SUCCESSFUL: | {"success":1,"message":"Search successful","data":[{"id":"1432", "name":"1392 DHCP Module" ,"slug":"1392-dhcp-module", "type":"dhcp_module", "parent_id":"1392", "category_id":null, "attr":{"_dhcp_attributes":"{\"type\":\"ISC\", \"notes\":\"\", \"username\":\"\", \"port\":\"\", \"config_test\":\"\/etc\/init.d\/dhcpd configtest\", \"server_stop\":\"\/etc\/init.d\/dhcpd stop\", \"server_start\":\"\/etc\/init.d\/dhcpd start\", \"config_path\":\"\", \"option_routers\":\"\", \"option_domain_name_servers\":\"\", \"option_domain_name\":\"\", \"authoritative\":\"1\", \"default_lease_time\":\"600\", \"max_lease_time\":\"7200\", \"local_port\":\"67\", \"log_facility\":\"local7\", \"password\":\"\", \"server_ip\":\"10.0.0.0\", \"freeLines\":0}", "_dhcp_config_id":"33"}}], "result_count":1, "found_count":1} | ERROR: | {"success":0, "message":"error message"} |
Return Detail: Name | Type | Description |
---|
id | INTEGER | ID of the dhcp_module resource | name | STRING | The name of the dhcp_module | slug | STRING | The unique reference string for this resource | type | STRING | Always 'dhcp_module | parent_id | INTEGER | The resource to which the dhcp_module is attached | category_id | INTEGER | The category to which this dhcp_module is associated | result_count | INTEGER | How many dhcp_modules are returned in this search. | found_count | INTEGER | How many dhcp_modules were found in this query, without pagination. |
Attributes: Key | Type | Description |
---|
_dhcp_attributes | JSON | A JSON-encoded string containing all the specific configuration parameters which govern this DHCP server. An expansion of the JSON object is given below in the Data Attributes section. |
|
create a new DHCP-enabled resource |
---|
Description | A resource becomes a DHCP-enabled by adding a special "dhcp_module" resource as a child. This action is identical to a normal Resource Create command. |
URL | /api/v1/api.php?target=resource&action=add&meta[type]=dhcp_module&meta[name]=2163 DHCP Module&meta[parent_id]=2163 |
Returns | Examples: SUCCESSFUL: | {"success":1,"message":"Resource added","data":{"id": 2165,"name" :"2163 DHCP Module","slug": "2163-dhcp-module-2","type" :"dhcp_module","parent_id": 2163,"category_id": null,"attr":[]}} | ERROR: | {"success":0, "message":"error message"} |
Return Detail: Name | Type | Description |
---|
id | INTEGER | ID of the newly created dhcp_module | name | STRING | The name of the dhcp_module | slug | STRING | The unique reference string for this resource | type | STRING | Always 'dhcp_module' | parent_id | INTEGER | The resource to which the dhcp_module is attached | category_id | INTEGER | The category to which this dhcp_module is associated |
|
update a DHCP-enabled resource with new configuration info |
---|
Description | Modifying an existing dhcp_module uses the identical commands as all other Resource-Update actions. An example of configuring a DHCP server is given below. |
URL | /api/v1/api.php?target=resource&action=update&meta[id]=2178 &meta[type]=dhcp_module&fields[_dhcp_attributes][]={"type":"ISC","notes":"notes go here","username":"username","port":"port","config_test":"/etc/init.d/dhcpd configtest","server_stop":"/etc/init.d/dhcpd stop","server_start":"/etc/init.d/dhcpd start","config_path":"/tmp/dhcpd.conf","option_routers":"192.168.0.0","option_domain_name_servers":"ns1.6connect.com","option_domain_name":"6connect.com","authoritative":"1","default_lease_time":"600","max_lease_time":"7200","local_port":"67","log_facility":"local7","password":"password","server_ip":"192.168.0.1","freeLines":3,"freeLine1":"free line 1","freeLine2":"free line 2","freeLine3":"free line 3"} |
Returns | Examples: SUCCESSFUL: | {"success": 1,"message": "Resource Updated","data": {"id":"2166" ,"name":"2163 DHCP Module", "slug":"2163-dhcp-module-3" ,"type":"dhcp_module", "parent_id":"2163", "category_id":null ,"attr":{"_dhcp_attributes": "{\"type\":\"ISC\", \"notes\":\"notes go here\", \"username\":\"username\", \"port\":\"port\", \"config_test\":\"\\\/etc\\\/init.d\\\/dhcpd configtest\" ,\"server_stop\":\"\\\/etc\\\/init.d\\\/dhcpd stop\" ,\"server_start\":\"\\\/etc\\\/init.d\\\/dhcpd start\",\"config_path\":\"\\\/tmp\\\/dhcpd.conf\", \"option_routers\":\"192.168.0.0\", \"option_domain_name_servers\":\"ns1.6connect.com\", \"option_domain_name\":\"6connect.com\", \"authoritative\":\"1\", \"default_lease_time\":\"600\", \"max_lease_time\":\"7200\", \"local_port\":\"67\", \"log_facility\":\"local7\" ,\"password\":\"**********\", \"server_ip\":\"192.168.0.1\", \"freeLines\":3, \"freeLine1\":\"free line 1\", \"freeLine2\":\"free line 2\", \"freeLine3\":\"free line 3\"}"}}} | ERROR: | {"success":0, "message":"error message"} |
Return Detail: Name | Type | Description |
---|
id | INTEGER | ID of the newly created dhcp_module | name | STRING | The name of the dhcp_module | slug | STRING | The unique reference string for this resource | type | STRING | Always 'dhcp_module' | parent_id | INTEGER | The resource to which the dhcp_module is attached | category_id | INTEGER | The category to which this dhcp_module is associated |
Attributes: Key | Type | Description |
---|
_dhcp_attributes | JSON | A JSON-encoded string containing all the specific configuration parameters which govern this DHCP server. An expansion of the JSON object is given below in the Data Attributes section. |
|
Data Attributes
_dhcp_attributes |
---|
Description | The _dhcp_attributes data attribute holds the specific settings used to generate a DHCP configuration file, place it on a server via SCP, and restart that server via a SSH session. |
Example: | {"type":"ISC", "notes":"notes here", "username":"username", "port":"22", "config_test":"/etc/init.d/dhcpd configtest", "server_stop":"/etc/init.d/dhcpd stop", "server_start":"/etc/init.d/dhcpd start", "config_path":"/tmp/dhcpd.conf", "option_routers":"", "option_domain_name_servers":"", "option_domain_name":"", "authoritative":"1", "default_lease_time":"600", "max_lease_time":"7200", "local_port":"67", "log_facility":"local7", "password":"", "server_ip":"10.0.0.0", "freeLines":0} |
| Data Description Name | Type | Description |
---|
type | STRING | The type of DHCP server being administered. Currently only 'ISC' is supported. | notes | STRING | Notes associated with this DHCP server | server_ip | STRING | The IP address of the DHCP server | username | STRING | The SSH username employed when transferring the DHCP configuration file to the server. | password | STRING | The SSH password employed when transferring the DHCP configuration file to the server. | port | INTEGER | The SSH port employed when transferring the DHCP configuration file to the server. | config_test | STRING | The command to test if a configuration file parses correctly. ex: /etc/init.d/dhcpd configtest | server_stop | STRING | The command to stop the DHCP server. ex: /etc/init.d/dhcpd stop | server_start | STRING | The command to start the DHCP server. ex: /etc/init.d/dhcpd start | config_path | STRING | Where to place the configuration file on the server. | authoritative | BOOL | Whether or not this DHCP server is authoritative. | default_lease_time | INTEGER | The default lease time for IPs distributed by this DHCP server. | max_lease_time | INTEGER | The max lease time for IPs distributed by this DHCP server. | local_port | INTEGER | The port on which this DHCP server listens | option_routers | STRING | The information which populates the "routers" option in the DHCP configuration | option_domain_name_servers | STRING | The information which populates the "domain_name_servers" option in the DHCP configuration | option_domain_name | STRING | The information which populates the "domain_name" option in the DHCP configuration | log_facility | STRING | The log facility to which this DHCP Server sends its logging information | freeLines | INTEGER | As this system cannot hope to support all the thousands of different DHCP configurations, ProVision's DHCPv2 system includes a mechanism for adding "free lines" to the end of certain DHCP config sections so that administrators can customize their DHCP config file to their needs. The "freeLines" field indicates how many of these lines exist to be inserted after the general server definition section but before the subnets and hosts are enumerated. | freeLine# | STRING | Free line data to be inserted after the general server definition section but before the subnets and hosts are enumerated. There can be multiple instances of this attribute, numbered appropriately. ex: "freeLine1", "freeLine2", "freeLine3", etc. The number of freeLine# entries must match the number in the "freeLines" attribute. | _dhcp_config_id | INTEGER | A reference to the DHCP Config file written within the system. This field is maintained by the DHCPv2 system itself and should not be set externally. |
|