Get / Set Blueprint ParametersΒΆ

Once you have created a Blueprint, you will need to assign values that are specific to this service. These values include, for example, the IP addresses, VLANs, ASNs, specific device-models to use, and ultimately specific devices. You will need to provide all blueprint values before you can actually deploy the blueprint to the devices. This section describes the generalized process to get and set blueprint parameters. If you are specifically looking to manage the blueprint links, see Cabling.

You can assign blueprint values using the designated slots defined by the design Template. You can get a list of the known slots using the params.names list. For example:

>>> print json.dumps(blueprint.params.names, indent=2)
[
  "external_router_interfaces",
  "leaf_loopback_ips",
  "spine_leaf_link_ips",
  "to_external_router_link_ips",
  "leaf_asns",
  "node_leaf_1_interfaces",
  "hcls",
  "devices",
  "node_spine_1_interfaces",
  "spine_loopback_ips",
  "deploy",
  "spine_asns",
  "dhcp_server_ip",
  "logical_device_maps",
  "resource_pools",
  "node_leaf_3_interfaces",
  "node_leaf_2_interfaces",
  "hostnames",
  "external_links",
  "node_spine_2_interfaces",
  "port_maps"
]

You can inspect the purpose and current value of a blueprint parameter by accessing it as a collection item. For example, let’s look at a commonly used slot called resource_pools. This parameter is where you would assign the specific IP-Pools and ASN-Pools for this blueprint.

>>> param = blueprint.params['resource_pools']
>>> param
{
   "Blueprint Name": "My-POD-A",
   "Blueprint ID": "a58e8c3f-84c5-472c-aaf8-a2292f4aa2c6",
   "Parameter Name": "resource_pools",
   "Parameter Value": {},
   "Parameter Info": {
      "slot_type": "POOL_LIST",
      "name": "resource_pools",
      "ids": [
         "leaf_loopback_ips",
         "spine_leaf_link_ips",
         "to_external_router_link_ips",
         "leaf_asns",
         "spine_loopback_ips",
         "spine_asns",
         "virtual_network_svi_subnets"
      ]
   }
}

The resource_pool is one of the more complicated, but most often used, values. So it’s worthwhile to explore this one in detail here. You can see from the “Parameter Info” description that the resource_pools slot has a number of sub-parameters, leaf_asns for example. This means that if you want to assign the ASN-Pool for the leaf switches, you would store that value there. Looking at the “Parameter Value” area, you can see that no values are actually assigned to the resource_pools slot. So let’s assign the ASN pool called “Private-ASN-pool”:

>>> aos.AsnPools['Private-ASN-pool'].id
u'b4fdb577-531b-40ba-96a8-9a015794b30c'

From the “slot_type” information we can see the value must actually be a list. So in order to update one specific slot in the resource_pools you would need to do something like this:

>>> param.update({'leaf_asns': [aos.AsnPools['Private-ASN-pool'].id]})

You can see update() takes a value to merge into the slot, and that value is a dictionary keyed by the slot ids . In this case we are only updating a single key, leaf_asns. The value for this key must be a list of ASN-Pool IDs. In this case, we are only assigning a single pool, so a list of one element. Once this action is completed, you can verify this by examining the param value property:

>>> param.value
{u'leaf_asns': [u'b4fdb577-531b-40ba-96a8-9a015794b30c']}

You can also see this update on the AOS-Server UI, for example:

../_images/aos-assigned-asn-pool.png

Let’s look at one more example, this one much less complex. This blueprint has a DHCP relay service component, and one of the blueprint parameters is to provide the DHCP server IP address. The slot name here is:

>>> blueprint.params['dhcp_server_ip']
{
   "Blueprint Name": "My-POD-A",
   "Blueprint ID": "a58e8c3f-84c5-472c-aaf8-a2292f4aa2c6",
   "Parameter Name": "dhcp_server_ip",
   "Parameter Value": {},
   "Parameter Info": {
      "slot_type": "IP",
      "name": "dhcp_server_ip",
      "ids": [
         "value"
      ]
   }
}

So in order to assign this value, we would need to perform a parameter update, the key is value and we need to provide the IP address. We could do this update in a simple line, for example:

>>> blueprint.params['dhcp_server_ip'].update({'value': "192.168.59.254"})

And reading this back, we can see the update is completed as reflected in the “Parameter Value”:

>>> blueprint.params['dhcp_server_ip']
{
   "Blueprint Name": "My-POD-A",
   "Blueprint ID": "a58e8c3f-84c5-472c-aaf8-a2292f4aa2c6",
   "Parameter Name": "dhcp_server_ip",
   "Parameter Value": {
      "value": "192.168.59.254"
   },
   "Parameter Info": {
      "slot_type": "IP",
      "name": "dhcp_server_ip",
      "ids": [
         "value"
      ]
   }
}

or more simply by examining just the value property:

>>> blueprint.params['dhcp_server_ip'].value
{u'value': u'192.168.59.254'}

For more details on using the aos-pyez API with Blueprints, see Blueprints.