Fixing nxos_feature
This commit is contained in:
parent
f916dae700
commit
e375b4c61c
1 changed files with 21 additions and 16 deletions
|
@ -835,34 +835,39 @@ def apply_key_map(key_map, table):
|
||||||
|
|
||||||
def get_available_features(feature, module):
|
def get_available_features(feature, module):
|
||||||
available_features = {}
|
available_features = {}
|
||||||
|
feature_regex = '(?P<feature>\S+)\s+\d+\s+(?P<state>.*)'
|
||||||
command = 'show feature'
|
command = 'show feature'
|
||||||
body = execute_show_command(command, module)
|
|
||||||
|
|
||||||
try:
|
body = execute_show_command(command, module, command_type='cli_show_ascii')
|
||||||
body = body[0]['TABLE_cfcFeatureCtrlTable']['ROW_cfcFeatureCtrlTable']
|
split_body = body[0].splitlines()
|
||||||
except (TypeError, IndexError):
|
|
||||||
return available_features
|
|
||||||
|
|
||||||
for each_feature in body:
|
for line in split_body:
|
||||||
feature = each_feature['cfcFeatureCtrlName2']
|
try:
|
||||||
state = each_feature['cfcFeatureCtrlOpStatus2']
|
match_feature = re.match(feature_regex, line, re.DOTALL)
|
||||||
|
feature_group = match_feature.groupdict()
|
||||||
|
feature = feature_group['feature']
|
||||||
|
state = feature_group['state']
|
||||||
|
except AttributeError:
|
||||||
|
feature = ''
|
||||||
|
state = ''
|
||||||
|
|
||||||
if 'enabled' in state:
|
if feature and state:
|
||||||
state = 'enabled'
|
if 'enabled' in state:
|
||||||
|
state = 'enabled'
|
||||||
|
|
||||||
if feature not in available_features.keys():
|
if feature not in available_features.keys():
|
||||||
available_features[feature] = state
|
|
||||||
else:
|
|
||||||
if (available_features[feature] == 'disabled' and
|
|
||||||
state == 'enabled'):
|
|
||||||
available_features[feature] = state
|
available_features[feature] = state
|
||||||
|
else:
|
||||||
|
if (available_features[feature] == 'disabled' and
|
||||||
|
state == 'enabled'):
|
||||||
|
available_features[feature] = state
|
||||||
|
|
||||||
return available_features
|
return available_features
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_commands(proposed, existing, state, module):
|
def get_commands(proposed, existing, state, module):
|
||||||
feature = validate_feature(module, mode='config')
|
feature = validate_feature(module, mode='config')
|
||||||
|
|
||||||
commands = []
|
commands = []
|
||||||
feature_check = proposed == existing
|
feature_check = proposed == existing
|
||||||
if not feature_check:
|
if not feature_check:
|
||||||
|
|
Loading…
Reference in a new issue