-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoll_based_downgrader.json
1 lines (1 loc) · 9.75 KB
/
poll_based_downgrader.json
1
[{"id":"13d7f886.b3ab07","type":"subflow","name":"Upgrade AP","info":"","category":"","in":[{"x":20,"y":80,"wires":[{"id":"5286d3a8.acca6c"}]}],"out":[{"x":1000,"y":220,"wires":[{"id":"6f951637.011e4","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"5286d3a8.acca6c","type":"switch","z":"13d7f886.b3ab07","name":"Check if Downgrade is needed","property":"downgrade","propertyType":"msg","rules":[{"t":"nnull"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":230,"y":80,"wires":[["65fe73cc.c8236c"],[]]},{"id":"65fe73cc.c8236c","type":"template","z":"13d7f886.b3ab07","name":"Build Upgrade Payload","field":"payload","fieldType":"msg","format":"json","syntax":"mustache","template":"{\n\"version\": \"{{downgrade}}\"\n}","output":"json","x":520,"y":80,"wires":[["a35650bf.64263"]]},{"id":"6f951637.011e4","type":"http request","z":"13d7f886.b3ab07","name":"Upgrade AP","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://api.mist.com/api/v1/sites/{{site_id}}/devices/00000000-0000-0000-1000-{{mac}}/upgrade","tls":"","persist":false,"proxy":"","authType":"","x":830,"y":260,"wires":[[]]},{"id":"a35650bf.64263","type":"template","z":"13d7f886.b3ab07","name":"Set API Headers","field":"headers","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"Authorization\": \"Token {{global.api_token}}\"\n}\n","output":"json","x":650,"y":180,"wires":[["6f951637.011e4"]]},{"id":"6d07264f.9010b8","type":"debug","z":"13d7f886.b3ab07","name":"Upgrade_Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":880,"y":80,"wires":[]},{"id":"39555052.7005a","type":"debug","z":"13d7f886.b3ab07","name":"Upgrade_Check_if_connected","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":350,"y":520,"wires":[]},{"id":"6b5d2dd7.eb6b64","type":"tab","label":"Poll Based Downgrade","disabled":false,"info":""},{"id":"f08ef3b4.ef272","type":"change","z":"6b5d2dd7.eb6b64","name":"REQUIRED: Set API Token HERE","rules":[{"t":"set","p":"api_token","pt":"global","to":"xxxxxxxxxxxxxxx","tot":"str"},{"t":"set","p":"org_id","pt":"msg","to":"xxxxxxxxxxxxxx","tot":"str"},{"t":"set","p":"downgrade","pt":"global","to":"0.8.20984","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":100,"wires":[["70927644.833a08"]]},{"id":"8e6dc89d.ce4ab8","type":"inject","z":"6b5d2dd7.eb6b64","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1800","crontab":"","once":true,"onceDelay":"2","topic":"","payload":"","payloadType":"date","x":190,"y":20,"wires":[["f08ef3b4.ef272"]]},{"id":"70927644.833a08","type":"template","z":"6b5d2dd7.eb6b64","name":"Set API Headers","field":"headers","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"Authorization\": \"Token {{global.api_token}}\"\n}\n","output":"json","x":150,"y":180,"wires":[["ad463693.50ac08","574d5929.23a9e8"]]},{"id":"ad463693.50ac08","type":"http request","z":"6b5d2dd7.eb6b64","name":"GET Device Versions","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.mist.com/api/v1/orgs/{{org_id}}/devices/count?distinct=version","tls":"","persist":false,"proxy":"","authType":"","x":180,"y":280,"wires":[["4ceb6b53.673214","574d5929.23a9e8"]]},{"id":"850f97bf.30ff78","type":"debug","z":"6b5d2dd7.eb6b64","name":"Upgrade_AP","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1310,"y":500,"wires":[]},{"id":"4ceb6b53.673214","type":"switch","z":"6b5d2dd7.eb6b64","name":"","property":"payload.total","propertyType":"msg","rules":[{"t":"gte","v":"2","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":380,"wires":[["73a49d52.91d684"],[]]},{"id":"d17ebbee.2ba0f8","type":"splitter","z":"6b5d2dd7.eb6b64","name":"Event Splitter","property":"payload.results","x":850,"y":40,"wires":[["6e85c3e9.c8360c"]]},{"id":"d0fc2ae2.b7d4d8","type":"switch","z":"6b5d2dd7.eb6b64","name":"","property":"payload.version","propertyType":"msg","rules":[{"t":"neq","v":"downgrade","vt":"global"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":970,"y":260,"wires":[["1148ea0a.8ff6b6","31d27177.a919ae"],["933650f2.6062a"]]},{"id":"edf6809d.e845d","type":"change","z":"6b5d2dd7.eb6b64","name":"Set Version","rules":[{"t":"set","p":"version","pt":"msg","to":"payload.version","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":250,"y":820,"wires":[[]]},{"id":"1df7acf.82acc53","type":"switch","z":"6b5d2dd7.eb6b64","name":"","property":"payload.version","propertyType":"msg","rules":[{"t":"neq","v":"0.8.21116","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":230,"y":720,"wires":[["edf6809d.e845d"],[]]},{"id":"4fea4aff.a09804","type":"splitter","z":"6b5d2dd7.eb6b64","name":"Event Splitter","property":"payload.results","x":210,"y":640,"wires":[["1df7acf.82acc53"]]},{"id":"73a49d52.91d684","type":"template","z":"6b5d2dd7.eb6b64","name":"Set API Headers","field":"headers","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"Authorization\": \"Token {{global.api_token}}\"\n}\n","output":"json","x":570,"y":40,"wires":[["a45dc273.eee08"]]},{"id":"a45dc273.eee08","type":"http request","z":"6b5d2dd7.eb6b64","name":"Get Org Devices","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.mist.com/api/v1/orgs/{{org_id}}/devices/search?model=AP32e,AP33,AP12&version=0.9.20739&limit=1000","tls":"","persist":false,"proxy":"","authType":"","x":660,"y":160,"wires":[["d17ebbee.2ba0f8","933650f2.6062a"]]},{"id":"c3c343ec.40aa9","type":"subflow:13d7f886.b3ab07","z":"6b5d2dd7.eb6b64","name":"","env":[],"x":1150,"y":720,"wires":[["850f97bf.30ff78","c7c79a17.cb5bc8"]]},{"id":"1148ea0a.8ff6b6","type":"change","z":"6b5d2dd7.eb6b64","name":"","rules":[{"t":"set","p":"mac","pt":"msg","to":"payload.mac","tot":"msg"},{"t":"set","p":"site_id","pt":"msg","to":"payload.site_id","tot":"msg"},{"t":"set","p":"ap_name","pt":"msg","to":"payload.hostname[0]","tot":"msg"},{"t":"set","p":"current_version","pt":"msg","to":"payload.version","tot":"msg"},{"t":"set","p":"downgrade","pt":"msg","to":"downgrade","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":970,"y":420,"wires":[["31d27177.a919ae","5b5484b4.56722c"]]},{"id":"31d27177.a919ae","type":"debug","z":"6b5d2dd7.eb6b64","name":"Version Mismatch","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1330,"y":360,"wires":[]},{"id":"574d5929.23a9e8","type":"debug","z":"6b5d2dd7.eb6b64","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":510,"y":280,"wires":[]},{"id":"6e85c3e9.c8360c","type":"change","z":"6b5d2dd7.eb6b64","name":"","rules":[{"t":"set","p":"site_id","pt":"msg","to":"payload.site_id","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":140,"wires":[["d0fc2ae2.b7d4d8"]]},{"id":"933650f2.6062a","type":"debug","z":"6b5d2dd7.eb6b64","name":"Ignored","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1270,"y":200,"wires":[]},{"id":"f341b81a.d51688","type":"debug","z":"6b5d2dd7.eb6b64","name":"Upgrade-Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1000,"y":960,"wires":[]},{"id":"c7c79a17.cb5bc8","type":"switch","z":"6b5d2dd7.eb6b64","name":"Output Checking","property":"org_id","propertyType":"msg","rules":[{"t":"eq","v":"e19cf7f6-af71-46b6-ac79-486e34e42296","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":1310,"y":1000,"wires":[[],["97166947.898c08"]]},{"id":"97166947.898c08","type":"template","z":"6b5d2dd7.eb6b64","name":"Slack Formatting","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"text\": \"AP Software Upgraded (POLLING)\\nAP: {{ap_name}} \\nSite: {{site_name}} \\nCurrent Version: {{current_version}} \\nNew Version: {{downgrade}}\"\n}","output":"json","x":1390,"y":740,"wires":[["bc2c51da.3ee93","c67b77da.bc3a68"]]},{"id":"bc2c51da.3ee93","type":"http request","z":"6b5d2dd7.eb6b64","name":"Slack Messaging","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://hooks.slack.com/services/XXXXXXXXX/xxxxxxxxxxx","tls":"","persist":false,"proxy":"","authType":"","x":1590,"y":700,"wires":[["c67b77da.bc3a68"]]},{"id":"c67b77da.bc3a68","type":"debug","z":"6b5d2dd7.eb6b64","name":"Slack Debugging","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1690,"y":800,"wires":[]},{"id":"613172e3.b4118c","type":"http request","z":"6b5d2dd7.eb6b64","name":"Check AP Connected","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.mist.com/api/v1/sites/{{site_id}}/stats/devices/00000000-0000-0000-1000-{{mac}}","tls":"","persist":false,"proxy":"","authType":"","x":860,"y":580,"wires":[["f341b81a.d51688","c9305a62.b54938"]]},{"id":"c9305a62.b54938","type":"switch","z":"6b5d2dd7.eb6b64","name":"Check if connected","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"connected","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":890,"y":680,"wires":[["c3c343ec.40aa9","f341b81a.d51688"],[]]},{"id":"5b5484b4.56722c","type":"template","z":"6b5d2dd7.eb6b64","name":"Set API Headers","field":"headers","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n \"Authorization\": \"Token {{global.api_token}}\"\n}\n","output":"json","x":850,"y":480,"wires":[["613172e3.b4118c"]]}]