<div id="google_translate_element"></div> <script type="text/javascript"> function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element'); } </script> <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> |
If you want to get a jumpstart on common API use cases, you came to the right place! Expand the text areas below for walkthroughs and code samples of API calls...
Context: How do I update the notes field of an IP block using the API in PHP?
1) Start with providing instance information, API key, Secret Key, and DNS Server IP; set up the connection
2) Split the metadata you want to have showing in the notes, and find the block with which it should associate
3) Update the block with the notes
|
Context: I unassigned an IP address and now it's in the Holding Tank. Now I want to assign an IP from the Holding Tank. I don't want to unassign an IP randomly, in case it is allocated to a Resource. What are my options?
There are 3 options:
|
Context: I need to create a Resource Holder, assign them an IP block, then subassign some IPs out of that block to two new Resource Holders. What does this look like in Python?
We broke this up in a few steps so it's easier to link together. 1) Let's create a Resource Holder called "Ned"
2) Now let's add the 213.29.27.0/24 IP block
3) With the block in the system, we can assign 213.29.27.0/24 to "Ned" the Resource Holder
4) Since we plan on assigning IPs out of this block, we should enable subassignments for 213.29.27.0/24
5) Now let's create a Resource Holder "Tara"
6) To keep it interesting, let's create another Resource Holder "Una"
7) Assign a /28 block from Ned's 213.29.27.0/24 to Tara
8) Then assign another /28 block from Ned's 213.29.27.0/24 to Una
|
Context: I need to set up a DNS server using ProVision's API in PHP, create a zone with a few simple records, and push it to the server.
1) Start with providing instance information, API key, Secret Key, and DNS Server IP
2) Add a DNS server
3) Create a zone
4) Add Zone records
4) Link the Zone to the new DNS server and push
|
Context: I need to attach the DHCP module as a child
DHCPv2 functionality is enabled on a particular resource by attaching a DHCP Module as a child. A command to do this is as follows:
The special resource type “dhcp_module” indicates to ProVision that the DHCP system is enabled for the parent object. The attributes associated with the “dhcp_module” resource govern the DHCP system's behavior.
Updating the attributes of a DHCP Server uses a Resource Update command:
This command appears rather complicated, but can be broken apart into reasonable pieces. The first section:
is familiar from other parts of ProVision. We are updating a resource of type “dhcp_module” whose resource id is 2178. The second section of the command details the update values, starting with
which contains a JSON-encoded string of all the fields specific to a DHCP server's function. When expanded into its full object form it is substantially easier to digest:
This object describes all the most common DHCP server configuration options. For a full explanation of each of the fields, see the Detailed API Specification later in this document.
Please note that the object above must be passed to the DHCP system as a JSON-encoded string. It must be passed into the special “_dhcp_attributes” attribute for it to be functional, as in the example URL. |
Context: I need to add a DHCP aggregate
An example command to add a DHCP Aggregate is:
The important part to note is that the IP block is being assigned to resourceId 1282, which corresponds to the DHCP Available resource. The DHCP Available resource is a system-level resource which is used to hold all unassigned DHCP IP addresses. Every instance has its own DHCP Available resource, whose id can be found with the following command:
New DHCP subnets and hosts draw their IPs from this pool. If there are no IPs in the DHCP Available pool new subnets and hosts will not be able to be created.
DHCP IP aggregates are fetched, updated, split, and deleted using the standard IPAM management API endpoints. Please see the IPAM API Documentation. for details. |
Context: I need to add a DHCP Pool
Similar to how the “dhcp_module” resource was created above, the command to create a DHCP Pool is as follows:
The first half of this command is relatively straightforward:
This section informs the API that we wish to create a new, empty “dhcp_pool” resource whose name is “New Subnet.”
The second half of the command behaves in a similar manner to the “dhcp_module.” The “_dhcp_pool_attributes” field holds a JSON-encoded string which describes the dhcp_pool resource. When expanded, the JSON string becomes the following object:
For a full explanation of each of the fields, see the Detailed API Specification.
Once a dhcp_pool resource is in the system it can be updated with IP data obtained from the IP Management system. Under DHCPv2, the DHCP system uses all the standard IPAM API endpoints and can make use of both the smartAssign and the directAssign methods. Please see the IPAM API documentation for details. |
Context: I need to link a DHCP pool to a DHCP server
An example of building a link between a dhcp_pool and a DHCP Server is:
The Resource Linkage system controls which DHCP Pools are associated with a given DHCP Server. In the case of linking a DHCP Pool to a DHCP Server, the relation used is “dhcpPoolLink”. This is a directional link, so it is important that resource_id1 and resource_id2 do not get confused.
To undo the above and break a DHCP Pool link, use the same command but substitute “deleteLink” for the action “addLink”.
|
Context: I need to push a DHCP config file
Once the server has been configured according to the previous sections, hitting the following API endpoint will trigger a DHCP push:
The “id” in the above string is the id of the dhcp_module resource attached to the server you whose configuration is to be pushed. The API return payload will contain success or failure codes, as well as a description of any errors which might have occurred. When a DHCP configuration file is pushed an SSH connection is opened to the configured server using the user, password, and port supplied to the '_dhcp_attributes' attribute on the dhcp_module resource. If the system successfully connects, it will assemble a DHCP configuration from the information given to the dhcp_module's '_dhcp_attribute' attribute and then parse and add in all linked dhcp_pool resources. After the assembled file has been transferred to the DHCP server it will be placed in the location given by 'config_path' on the dhcp_module, and then the command described in 'config_test' will be run to determine whether or not this new file parses correctly. If 'config_test' is blank or omitted, this step is skipped. If the file parses correctly the DHCP will be stopped and restarted according to the 'server_stop' and 'server_start' commands on the DHCP module. If there are errors at any point the system backs out, replaces old config files, and reports the errors via the 'message' return field of the API call. |
Context: How do I create aggregates, get block information, and delete aggregates using the API / python SDK?
|