The bootstrap script will pass in as argument to the main method of each action a special object called ‘attributes’. The only API the action needs to be aware for this object is the ‘get’ method, which will return the value of an attribute, as configured on the server:
- the value can be local to a particular action or global
- if an attribute is defined at both the local and global scopes, the local value takes priority
- if an attribute is not defined at either the local or global level, then the ‘get’ method will return None
e.g. (action code)
def main(attributes): print attributes.get(‘software_image’)
Besides the values coming from the server, a couple of special entries* (always upper case) are also contained in the attributes object:
- ‘NODE’: a node object for making eAPI calls to localhost. See the Bootstrap Client documentation.
def main(attributes): print attributes.get(‘NODE’).api_enable_cmds([‘show version’])
DHCP response contains the URL pointing to the bootstrap script on the server
The location of the server is hardcoded in the bootstrap script, using the SERVER global variable. The bootstrap script uses this base address in order to generate the URL to use in order to GET the logging details: BASE_URL/config e.g.
SERVER = ‘http://my-bootstrap-server:80’ # Note that the port and the transport mechanism # is included in the URL
The bootstrap script uses the SERVER base address in order to compute the URL to use in order to POST the node’s information: BASE_URL/config
The bootstrap script uses the ‘location’ header in the POST reply as the URL to use in order to request the definition
Actions and resources URLs& are computed by using the base address in the bootstrap script: BASE_URL/actions/, BASE_URL/files/