This app demonstrates automated build of a full stack site in Mist. All APIs used by the automation is clearly printed when run, and examples are provided for several different environments:
- clone repo and
cd
to the directory:
git clone https://github.com/reidstidolph-JNPR/mist-auto-fullstack.git && cd mist-auto-fullstack
- Create a file called
env.json
with properties for:
orgId
- your org IDtoken
- API token for your orgenvBaseUrl
- base URL for API calls (varies depending on cloud)gatewaytemplate_id
- SSR WAN template IDwlantemplate_id
- Wireless template IDnetworktemplate_id
- Switch template IDsiteSettings
->timezone
- site timezonesiteSettings
->country_code
- site country codesiteSettings
->address
- site addresssiteSettings
->latlng
- site coordinatessiteSettings
->vars
(optional) - site variables
Example:
{
"token": "ru5...E5f",
"orgId": "1ec....f2e",
"baseUrl": "https://api.mist.com/api/v1",
"gatewaytemplate_id": "82d7...bc7a",
"wlantemplate_id": "2277...9cfe",
"networktemplate_id": "56a4...ea19",
"siteSettings": {
"timezone": "America/Denver",
"country_code": "US",
"address": "Denver, CO, USA",
"latlng": {
"lat": 39.739236,
"lng": -104.990251
},
"vars": {
"foo": "bar"
}
}
}
Next, run the automation using Docker, Python, Go, NodeJS, PHP, or Ruby.
- Have Docker (and optionally
docker-compose
) installed. - Have one or more devices you want to deploy using the automation, claimed and unnassigned in your Mist org inventory.
Use 1 of the following 2 options run the script:
Use this if you only have Docker.
- Build a docker image:
docker build -t build-site .
- Run it:
docker run -it --rm -v ./env.json:/home/node/app/env.json build-site
This creates a one-time container based on the image, and destroys it when finished.
Alternatively, to create as a persistent container:
docker create --name build-site -v ./env.json:/home/node/app/env.json build-site
Then to run subsequently:
docker start -i build-site
- Use this is you have Docker + docker-compose.
docker-compose run --rm build-site
Install module dependencies:
pip3 install aiofiles
pip3 install aiohttp
pip3 install asyncio
Run the python version of the script:
python3 build.py
Install module dependencies:
npm install
Run the javascript version of the script:
node build.js
Run the golang version of the script:
go run build.go
Run the PHP version of the script:
php build.php
Run the Ruby version of the script:
ruby build.rb
A list of devices can be fed into the automation script in one of two ways:
- CLI prompted user input of comma-separated list (default)
- A file in the script directory called
devices.txt
If a devices.txt
file is found, the script will not prompt for user input, and attempt to read from file. It expects the file to contain a list of device MACs, one per line. Example:
50c709979b5f
c878670c4bce
5433c601082e
This script uses the following Mist API endpoints:
A GET
to this endpoint is used to retrieve unassigned device inventory.
/api/v1/orgs/${orgId}/inventory?unassigned=true
A POST
to this endpoint with devices is used to assign devices to a site.
/api/v1/orgs/${orgId}/inventory
A GET
to this endpoint is used to retrieve the list of sites. Used by script to ensure a site with the same name does not already exist.
A POST
to this endpoint with site settings is used to create a new site.
/api/v1/orgs/${orgId}/sites
A GET
and a PUT
is made to this endpoint to modify existing sites associated with the WLAN template, adding the newly created site.
/api/v1/orgs/${orgId}/templates/${wlantemplate_id}