Loading

×Sorry to interrupt
Uncaught ReferenceError: addCTracking is not defined
throws at https://kb.vmware.com/resource/KM_TealiumTrackingJS?v=0.5:100:1

Refresh

Cookie Preference Center

General Information on cookies

When you visit our website, we use cookies to ensure that we give you the best experience. This information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies by clicking on the different category headings to find out more and change your settings. However, blocking some types of cookies may impact your experience on the site and the services we are able to offer. Further information can be found in our

Cookie Policy.

Strictly Necessary

Strictly Necessary

Always Active

Strictly Necessary

Strictly necessary cookies are always enabled since they are essential for our website to function. They enable core functionality such as security, network management, and website accessibility. You can set your browser to block or alert you about these cookies, but this may affect how the website functions. For more information please visit www.aboutcookies.org or www.allaboutcookies.org.

Cookie Details‎

Performance

Performance

Performance

Performance cookies are used to analyze the user experience to improve our website by collecting and reporting information on how you use it. They allow us to know which pages are the most and least popular, see how visitors move around the site, optimize our website and make it easier to navigate.

Cookie Details‎

Please confirm your settings by refreshing the page.

Functional

Functional

Functional

Functional cookies help us keep track of your past browsing choices so we can improve usability and customize your experience. These cookies enable the website to remember your preferred settings, language preferences, location and other customizable elements such as font or text size. If you do not allow these cookies, then some or all of these services may not function properly.

Cookie Details‎

Advertising

Advertising

Advertising

Advertising cookies are used to send you relevant advertising and promotional information. They may be set through our site by third parties to build a profile of your interests and show you relevant advertisements on other sites. These cookies do not directly store personal information, but their function is based on uniquely identifying your browser and internet device.

Cookie Details‎

Advertising Cookies

Consent Leg.Interest

Select All Vendors

Select All Vendors

Select All Hosts

Select All

Clear Filters

Information storage and access

Apply

Confirm My Choices Reject All Allow All

My Subscriptions

Loading

Knowledge Base

VoyenceControl: How do I capture sections of config with preconditions when there are no obvious boundaries between sections? (324738)

Last Updated: 3/22/2024Categories: TroubleshootingTotal Views: 1874Language:
English

Subscribe to get an email
newsletter with new updates

Please provide article feedback:

Symptoms

How do I capture sections of config with preconditions when there are no obvious boundaries between sections?

Building regex tests against Nortel VLANs
Building regex tests against Cisco access lists

Resolution

An example of a configuration section with no "obvious" boundaries can be seen in Nortel VLAN or Cisco CatOS access list configurations.   There are no decisive or obvious boundaries to build your begin-with and end-with patterns against to properly split the groupings.  For example, Nortel VLAN configurations will begin after a comment line, will have groupings of one or more lines prefixed with the same VLAN number, will only roll the VLAN number between groupings, and then end with another comment line:

#
vlan 1 option one
vlan 10 option one
vlan 10 option two
vlan 10 option three
vlan 20 option one
vlan 20 option two
#

In comparison, Cisco IOS interfaces are simple to split because they always start and end with "interface" and "!" respectively.  These boundaries are obvious:

!
interface ethernet 1/10
desc my interface
!
interface ethernet 2/10
desc my interface
!

In order to separate and process each vlan grouping from the vlan example, you can use the following syntax in your precondition:

Begin-with: ^vlan (\d+)

End-with: ^((?!vlan \1 )"#)

This makes use of a capture group, a negative lookahead and a back reference .  The VLAN number is captured in the begin-with precondition via "(\d+)".  The end-with precondition uses a negative lookahead "(?!)" to match anything that is not "vlan \1".   The back reference "\1" recalls the characters matched by the first capture group. By using the back reference inside the negative lookahead, the end-with pattern will only stop grouping at a VLAN line that is not the same VLAN number matched from the begin-with pattern, or a trailing comment line.  It has the affect of splitting the example configuration into three pieces:

vlan 1 option one

vlan 10 option one
vlan 10 option two
vlan 10 option three

vlan 20 option one
vlan 20 option two

From here you can begin crafting check patterns and remedies to process against the VLAN groupings, but there are a few other things that allow this to work that should be pointed out:

The beginning-of-line anchor "^" is used to make the pattern only match from the beginning of the line.  This practice is done to overcome situations where the pattern you want to match also appears in an unrelated section of the config further down.

In the negative lookahead "(?!vlan \1 )" note that there is a space after the back reference "\1". Without this, there is the potential pitfall that the VLAN number from the capture group would match a subset of a following VLAN number that is in fact different.  The example exhibits this scenario; without the space added the precondition would group VLAN 10 with VLAN 1 because both begin with "vlan 1".

The ""#" piece of the pattern means to alternatively match a comment "#".  It is isolated from the negative lookahead to allow the lookahead to only concern itself with not matching the same VLAN number.  If the alternation was inside the lookahead, the precondition would group the entire VLAN section together because it could continue matching lines that did not begin with "#".

Related Information

Regex or RegEx stands for Regular Expression.
More information on Regex syntax is available in the VoyenceControl Online User's Guide under the topic "Using RegEx".  Please see Solution ID 11362  for details on how to access and search the VoyenceControl Online User's Guide.

Detectable by VMware SkylineTM

Actions

Copy

link to clipboard
copied!

Print

Language:
English

Attachments

Additional Resources

No results for undefined

Ask The Community

Get answers quickly from VMware experts in the community

Post Subject

CONTINUE IN COMMUNITIES

Related Products:

Related Versions:

VMware Smart Assurance - NCM

Take Our Survey

Support Assistant