08-06-2009 05:48 PM
I'm looking at trying to write a compliance check with a couple dependencies. I seem to be going around in circles with this.
I want to write it so there is a prerequisite at the global level which then determines if it should walk the interfaces. Then if it finds a matching interface look for a second command.
So basically, if the global matches:
+ spanning-tree portfast default
Then verify if the interface is a trunk
Submode [#inteface .#]
+ switchport mode trunk
And if it is a trunk, consider it a compliance failure if the portfast isn't disabled.
+spanning-tree portfast diabled
The problem I run in to is. I can't make a commandlet that is already a prerequisite to be a prerequisite for another commandlet. I don't know if this is by design or not. So I tried creating a parent that includes the [#inteface .*#] but I keep getting back devices that I know are not compliant as compliant.
Here's what it looks like:
---------------------------------
Name: isSpanningTreePortfastGlobalDefault SubMode: No isPrerequisite: Yes
Ordered : No Prerequisite-Commandset : none Parent: none
+ spanning-tree portfast default
Name: interfaceParent SubMode: Yes isPrerequisite: No
Ordered : No Prerequisite-Commandset : isSpanningTreePortfastGlobalDefault Parent: isSpanningTreePortfastGlobalDefault
[#interface .*#]
#To check for existence of command enter
Name: isTrunk SubMode: No isPrerequisite: Yes
Ordered : No Prerequisite-Commandset : none Parent: interfaceParent
+ switchport mode trunk
Name: isPortfastDisabled SubMode: No isPrerequisite: No
Ordered : No Prerequisite-Commandset : isTrunk Parent: isTrunk
+ spanning-tree portfast disabled
08-06-2009 09:43 PM
What version of RME are you using?
08-06-2009 10:06 PM
Resource Manager Essentials 4.2.0 13 Feb 2009, 02:30:55 GMT
08-06-2009 11:08 PM
This should work:
Name: Global SubMode: No isPrerequisite: No
Ordered : No Prerequisite-Commandset : none Parent: none
Name: isPortfastEnabled SubMode: No isPrerequisite: Yes
Ordered : No Prerequisite-Commandset : none Parent: none
+ spanning-tree portfast default
Name: trunkPortSubmode SubMode: Yes isPrerequisite: No
Ordered : No Prerequisite-Commandset : isPortfastEnabled Parent: none
interface [#.*Ethernet#]
#Left empty on purpose
Name: isTrunk SubMode: No isPrerequisite: Yes
Ordered : No Prerequisite-Commandset : none Parent: trunkPortSubmode
+ switchport mode trunk
Name: portFastDisabled SubMode: No isPrerequisite: No
Ordered : No Prerequisite-Commandset : isTrunk Parent: isTrunk
+ spanning-tree portfast disabled
08-13-2009 08:03 PM
No such luck. I tried a couple variations in this and still can't seem to get it to work. Odd. I can get each of the independent checks to work. I just can't seem to get them to work when they are made prerequisites.
Did you try this and get it to work? I'm working on 3750s. I have a test device that I have set with the global default and I have the two gigabit trunks one with it enabled and one with it disabled.
With what you have and some variations I tried, it walks all interfaces and ignores if it's a trunk or not. All interfaces that do not have "spanning-tree portfast disable" come back non-compliant.
There are some variances I've seen that come back compliant but they don't give enough detail on the check results or how it steps through to let me why it passes when it should fail.
08-13-2009 09:56 PM
I had thought I had it working, but my test was inaccurate. Someone had configured additional trunks on my 3560, and those did not have spanning-tree portfast disable. So, I looked at the code, and found that RME wasn't recursing through the children of commandlets when the child was a prereq. I thought what you wanted to do was pretty useful, so I added some code to do the recursion, and it appears to be working. If you contact TAC, and have your engineer contact me directly, I can provide you an experimental patch to try.
08-16-2009 07:39 PM
Thanks Joe. I've opened a case.
08-16-2009 10:42 PM
Hmmm... I tried the patch and didn't have any luck. I still see it recurse the interfaces that do not have 'mode trunk' configured.
btw... a couple things I had to fix in the syntax
interface [#.*Ethernet.*#]
or it wouldn't try any interfaces. And...
+ spanning-tree portfast disable
There's no (d) at the end.
08-16-2009 10:45 PM
Right, my fault. This is the template I used with the patch, and it did work:
Name: Global SubMode: No isPrerequisite: No
Ordered : No Prerequisite-Commandset : none Parent: none
Name: isPortfastEnabled SubMode: No isPrerequisite: Yes
Ordered : No Prerequisite-Commandset : none Parent: none
+ spanning-tree portfast default
Name: PortFastDefault SubMode: No isPrerequisite: No
Ordered : No Prerequisite-Commandset : isPortfastEnabled Parent: none
+ spanning-tree portfast default
Name: isTrunk SubMode: Yes isPrerequisite: Yes
Ordered : No Prerequisite-Commandset : none Parent: PortFastDefault
interface [#.*Ethernet.*#]
+ switchport mode trunk
Name: portFastDisabled SubMode: No isPrerequisite: No
Ordered : No Prerequisite-Commandset : isTrunk Parent: isTrunk
+ spanning-tree portfast disable
Be sure not to edit an existing template as that may cause problems. Instead, create a new template using the above model.
08-16-2009 10:47 PM
08-16-2009 11:05 PM
Thanks.
That did work. What is the issue with using existing templates?
08-16-2009 11:16 PM
Due to the nature of the code, this particular flow is required. Ideally, it should be possible to make prereqs which have prereqs of their own. But in lieu of that, the patch plus this template effectively allows for this flow:
if (condition) :
if (submode.condition) :
assert(submode.contains(PATTERN);
endif
endif
09-02-2009 03:57 AM
Will this patch be made available to the public, or included in the next release (3.3) ?
09-02-2009 08:42 AM
It is slated for the next release of LMS.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide