<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: API, Python or other way to check command syntax and ability to execute in ExtremeSwitching (EXOS/Switch Engine)</title>
    <link>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60705#M17678</link>
    <description>Hi Adrian,&lt;BR /&gt;
&lt;BR /&gt;
If you have your current config as rollback.xsf, it might not necessarily roll things back. If your config.xsf had "create vlan Data tag 20" and your rollback.xsf doesn't, it will not remove the vlan Data. With that in mind you could do:&lt;BR /&gt;
&lt;DIV class="threadCode"&gt;&lt;B&gt;code:&lt;/B&gt;&lt;PRE spellcheck="false"&gt;1. If 'commit confirmed' (or let's say 'commit ack' &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; )&lt;BR /&gt;1.a. save config as rollback.cfg&lt;BR /&gt;1.b. load script config.xsf&lt;BR /&gt;1.c. sleep(timeout)&lt;BR /&gt;1.d. use configuration rollback.cfg&lt;BR /&gt;1.e. reboot&lt;BR /&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BR /&gt;
It could also be default.xsf created from current pre-commit config, so once the switch went unconfigured it would load the older config. But both approaches require a reboot, so I thought of something different.&lt;BR /&gt;
&lt;BR /&gt;
I wanted to create a script that is a 'shell' which collects the commands.&lt;BR /&gt;
&lt;DIV class="threadCode"&gt;&lt;B&gt;code:&lt;/B&gt;&lt;PRE spellcheck="false"&gt;1. If 'show*' -&amp;gt; pass the command to the CLI immediately&lt;BR /&gt;2. If another user input -&amp;gt; add to a list of commands to execute&lt;BR /&gt;3. If 'commit' -&amp;gt; execute all commands (flush the buffer)&lt;BR /&gt;4. If 'commit ack [min]':&lt;BR /&gt;4.a. Build contrary config for each user input command&lt;BR /&gt;4.b. Execute all commands (flush the buffer)&lt;BR /&gt;4.c. Timer set to [min]&lt;BR /&gt;4.d. If commit then stop the timer, save config and clear the rollback commands buffer&lt;BR /&gt;4.e. If timer expires issue contrary commands (flush the rollback buffer)&lt;BR /&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Things to overcome with some effort:&lt;BR /&gt;
&lt;OL&gt; 
&lt;LI&gt;Check command syntax (e.g. 'cerate veelan Data'), most likely right at the time of being provided by user - here is where I wanted to rely on EXOS Python library, otherwise would have to build some kind of command library and some smart checks (never done that before  ). 
&lt;/LI&gt;&lt;LI&gt;Check command validity (e.g. 'configure vlan Nonexistent add port 1 tagged) - gotta check not only the existing config but also the ones that are already in the pre-commit buffer as the VLAN might not be in the config but the user just ordered to create it and will commit alongside. In the example it would have to parse the config and the buffer to see if there is 'create vlan Nonexistent tag *'. Hmm... this would also be nice to check right at the time of user input. 
&lt;/LI&gt;&lt;LI&gt;Engine that will create contrary commands for a rollback, seems to be massive pain in the bottom but least complicated. 
&lt;/LI&gt;&lt;/OL&gt;
Kind regards,&lt;BR /&gt;
Tomasz</description>
    <pubDate>Fri, 24 May 2019 16:18:29 GMT</pubDate>
    <dc:creator>Tomasz</dc:creator>
    <dc:date>2019-05-24T16:18:29Z</dc:date>
    <item>
      <title>API, Python or other way to check command syntax and ability to execute</title>
      <link>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60701#M17674</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I'm about to do some initial steps with Python for EXOS. I want to write kind of an intermediate shell that would work on user input (CLI commands) before ultimate execution.&lt;BR /&gt;
Walked through Python Getting Started Guide (some old PDF) and the API reference (https://api.extremenetworks.com/EXOS/ProgramInterfaces/PYTHONAPI/) but I've no idea if I can achieve some ready-to-go syntax check (e.g. 'crete veelan Data tag 20') and validity check (e.g. 'conf vlan Data add port 20 tagged' when Data doesn't exist), or should I attempt to create these checks from the scratch. Would CM Backend be useful here?&lt;BR /&gt;
&lt;BR /&gt;
Kind regards,&lt;BR /&gt;
Tomasz</description>
      <pubDate>Wed, 22 May 2019 18:42:52 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60701#M17674</guid>
      <dc:creator>Tomasz</dc:creator>
      <dc:date>2019-05-22T18:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: API, Python or other way to check command syntax and ability to execute</title>
      <link>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60702#M17675</link>
      <description>Hi Tomasz,&lt;BR /&gt;
&lt;BR /&gt;
Just curious--what is the ultimate end goal here?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Brad</description>
      <pubDate>Wed, 22 May 2019 22:38:47 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60702#M17675</guid>
      <dc:creator>BradP</dc:creator>
      <dc:date>2019-05-22T22:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: API, Python or other way to check command syntax and ability to execute</title>
      <link>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60703#M17676</link>
      <description>Hi B-rad,&lt;BR /&gt;
&lt;BR /&gt;
I don't want to recall any similar feature from the market here, but the idea is about buffering the commands before doing actual commit (like in WiNG), but with option of a timeout, so if the commit is not confirmed within that time window, it will revert the commands (configuration comes back to pre-commit shape).&lt;BR /&gt;
The easy path is to buffer all the commands and after issuing 'commit' current config could be backed up, and in case of no confirmation the switch could do 'use configuration commitbackup.cfg' and reboot, the hard path is to build some dictionary of opposite commands (no reboot needed - no prolonged outage in case of doing something wrong by commiting the changes).&lt;BR /&gt;
But for such commit to be successful without any gaps, syntax and relevance checks should be possible I believe.&lt;BR /&gt;
&lt;BR /&gt;
Not a business-related feature request, but I was thinking on it for last few years, recently I've spoken to several people and got some morale boost to spend my free time on that. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
And it seems to be a nice starting point to play with Python for EXOS, as this is a feature I'd like to have (motivation kicks in).&lt;BR /&gt;
&lt;BR /&gt;
Kind regards,&lt;BR /&gt;
Tomasz</description>
      <pubDate>Thu, 23 May 2019 01:37:34 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60703#M17676</guid>
      <dc:creator>Tomasz</dc:creator>
      <dc:date>2019-05-23T01:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: API, Python or other way to check command syntax and ability to execute</title>
      <link>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60704#M17677</link>
      <description>Hi guys,&lt;BR /&gt;
&lt;BR /&gt;
I´ve thinking about something like this too, the same behavior as in JunOS. Roughly I think we need:&lt;BR /&gt;
&lt;BR /&gt;
 	1. A script "commit_confirmed" that takes two arguments: timeout to automatic rollback and the 	 configuration file (config.xsf) to apply . This script would do:&lt;BR /&gt;
&lt;DIV class="threadCode"&gt;&lt;B&gt;code:&lt;/B&gt;&lt;PRE spellcheck="false"&gt; save config as rollback.xsf&lt;BR /&gt;&lt;BR /&gt; load script config.xsf&lt;BR /&gt;&lt;BR /&gt; sleep(timeout)&lt;BR /&gt;&lt;BR /&gt; load script rollback.xsf&lt;BR /&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;
 &lt;BR /&gt;
 	2. A script "commit" witch would find the process started by the "commit_confirmed" script and stop it while it is sleeping, effectively canceling the rollback.&lt;BR /&gt;
&lt;BR /&gt;
The are nuances and enhancements to this but I think this could work, its something to start. What do you think?&lt;BR /&gt;
&lt;BR /&gt;
We can do more: a "commit_check" for syntax, a "commit_at" for scheduled, log messages for each step (even with commit messages)...</description>
      <pubDate>Fri, 24 May 2019 14:04:50 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60704#M17677</guid>
      <dc:creator>AdrianO</dc:creator>
      <dc:date>2019-05-24T14:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: API, Python or other way to check command syntax and ability to execute</title>
      <link>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60705#M17678</link>
      <description>Hi Adrian,&lt;BR /&gt;
&lt;BR /&gt;
If you have your current config as rollback.xsf, it might not necessarily roll things back. If your config.xsf had "create vlan Data tag 20" and your rollback.xsf doesn't, it will not remove the vlan Data. With that in mind you could do:&lt;BR /&gt;
&lt;DIV class="threadCode"&gt;&lt;B&gt;code:&lt;/B&gt;&lt;PRE spellcheck="false"&gt;1. If 'commit confirmed' (or let's say 'commit ack' &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; )&lt;BR /&gt;1.a. save config as rollback.cfg&lt;BR /&gt;1.b. load script config.xsf&lt;BR /&gt;1.c. sleep(timeout)&lt;BR /&gt;1.d. use configuration rollback.cfg&lt;BR /&gt;1.e. reboot&lt;BR /&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BR /&gt;
It could also be default.xsf created from current pre-commit config, so once the switch went unconfigured it would load the older config. But both approaches require a reboot, so I thought of something different.&lt;BR /&gt;
&lt;BR /&gt;
I wanted to create a script that is a 'shell' which collects the commands.&lt;BR /&gt;
&lt;DIV class="threadCode"&gt;&lt;B&gt;code:&lt;/B&gt;&lt;PRE spellcheck="false"&gt;1. If 'show*' -&amp;gt; pass the command to the CLI immediately&lt;BR /&gt;2. If another user input -&amp;gt; add to a list of commands to execute&lt;BR /&gt;3. If 'commit' -&amp;gt; execute all commands (flush the buffer)&lt;BR /&gt;4. If 'commit ack [min]':&lt;BR /&gt;4.a. Build contrary config for each user input command&lt;BR /&gt;4.b. Execute all commands (flush the buffer)&lt;BR /&gt;4.c. Timer set to [min]&lt;BR /&gt;4.d. If commit then stop the timer, save config and clear the rollback commands buffer&lt;BR /&gt;4.e. If timer expires issue contrary commands (flush the rollback buffer)&lt;BR /&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Things to overcome with some effort:&lt;BR /&gt;
&lt;OL&gt; 
&lt;LI&gt;Check command syntax (e.g. 'cerate veelan Data'), most likely right at the time of being provided by user - here is where I wanted to rely on EXOS Python library, otherwise would have to build some kind of command library and some smart checks (never done that before  ). 
&lt;/LI&gt;&lt;LI&gt;Check command validity (e.g. 'configure vlan Nonexistent add port 1 tagged) - gotta check not only the existing config but also the ones that are already in the pre-commit buffer as the VLAN might not be in the config but the user just ordered to create it and will commit alongside. In the example it would have to parse the config and the buffer to see if there is 'create vlan Nonexistent tag *'. Hmm... this would also be nice to check right at the time of user input. 
&lt;/LI&gt;&lt;LI&gt;Engine that will create contrary commands for a rollback, seems to be massive pain in the bottom but least complicated. 
&lt;/LI&gt;&lt;/OL&gt;
Kind regards,&lt;BR /&gt;
Tomasz</description>
      <pubDate>Fri, 24 May 2019 16:18:29 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60705#M17678</guid>
      <dc:creator>Tomasz</dc:creator>
      <dc:date>2019-05-24T16:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: API, Python or other way to check command syntax and ability to execute</title>
      <link>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60706#M17679</link>
      <description>&lt;I&gt;If you have your current config as rollback.xsf, it might not necessarily roll things back. If your config.xsf had "create vlan Data tag 20" and your rollback.xsf doesn't, it will not remove the vlan Data. With that in mind you could do.&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
You're right. It would reapply the rollback config but wouldn't unconfigure anything.&lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;Check command syntax (e.g. 'cerate veelan Data'), most likely right at the time of being provided by user&lt;/I&gt;&lt;BR /&gt;
&lt;I&gt;Check command validity&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
 To do this right for the full command catalog it would require a lexical, syntactic and semantic analyzers. Additionally we would have to update them with changes in commands. I dont want to be the party popper but its a huge undertaking. Maybe we can leverage the capacity in the OS of the switch to do this somehow.&lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;Engine that will create contrary commands for a rollback, seems to be massive pain in the bottom but least complicated.&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
Maybe this is more approachable thanks to the configure/unconfigure, add/delete, etc structure, although I think that not always you can substitute one for the other for rollback, like in:&lt;BR /&gt;
&lt;BR /&gt;
		enable sharing 1:1 grouping 1:1 lacp&lt;BR /&gt;
 		disable sharing 1:1 grouping 1:1 lacp -&amp;gt; its not correct&lt;BR /&gt;
&lt;BR /&gt;
I don´t think I have so much free time, but I could collaborate on some parts maybe. If someone from extreme sees this and can push for it with the engineers it can be a feature request. I really think that it should be a integrated feature in exos, but I dont know if it is feasible with scripts or the best way is integration in exos.&lt;BR /&gt;
&lt;BR /&gt;
Great thread by the way.</description>
      <pubDate>Fri, 24 May 2019 18:27:35 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60706#M17679</guid>
      <dc:creator>AdrianO</dc:creator>
      <dc:date>2019-05-24T18:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: API, Python or other way to check command syntax and ability to execute</title>
      <link>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60707#M17680</link>
      <description>Oops, I wanted to like your post but when one posts a thread there is 'Answer' in place... But it's a good answer indeed! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
With rollback dictionary I thought we would have to rely on enable/disable add/delete, but with some exceptions manually treated with higher precedence than generic inversion rules, e.g.:&lt;BR /&gt;
&lt;DIV class="threadCode"&gt;&lt;B&gt;code:&lt;/B&gt;&lt;PRE spellcheck="false"&gt;if: enable sharing X grouping (whatever)&lt;BR /&gt;then: disable sharing X&lt;BR /&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BR /&gt;
It will get even more funny with some examples but once you see this working... &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Kind regards,&lt;BR /&gt;
Tomasz&lt;BR /&gt;
&lt;BR /&gt;
P.S. &lt;USER-MENTION data-id="6470422"&gt;@Drew C.&lt;/USER-MENTION&gt;, can we revert the topic from 'answered' state, please? </description>
      <pubDate>Fri, 24 May 2019 18:56:39 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremeswitching-exos-switch/api-python-or-other-way-to-check-command-syntax-and-ability-to/m-p/60707#M17680</guid>
      <dc:creator>Tomasz</dc:creator>
      <dc:date>2019-05-24T18:56:39Z</dc:date>
    </item>
  </channel>
</rss>

