Skip to content

Commit

Permalink
Merge pull request ansible-network#82 from gundalow/minor-fixes
Browse files Browse the repository at this point in the history
AnsibleFilterError, deprecations, and unused imports
  • Loading branch information
gundalow authored May 18, 2018
2 parents d61c18a + 11ecfda commit a3fbdc7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion action_plugins/text_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def run(self, tmp=None, task_vars=None):
version='2.6',
removed=False)

del tmp # tmp no longer has any effect
del tmp # tmp no longer has any effect

if task_vars is None:
task_vars = dict()
Expand Down
4 changes: 2 additions & 2 deletions filter_plugins/network_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def interface_split(interface, key=None):
match = re.match(r'([A-Za-z\-]*)(.+)', interface)
if not match:
raise FilterError('unable to parse interface %s' % interface)
raise AnsibleFilterError('unable to parse interface %s' % interface)
obj = {'name': match.group(1), 'index': match.group(2)}
if key:
return obj[key]
Expand All @@ -33,7 +33,7 @@ def interface_range(interface):
else:
match = re.match(r'([A-Za-z]*)(.+)', interface)
if not match:
raise FilterError('unable to parse interface %s' % interface)
raise AnsibleFilterError('unable to parse interface %s' % interface)
prefix = match.group(1)
index = match.group(2)

Expand Down
2 changes: 1 addition & 1 deletion library/_text_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'status': ['deprecated'],
'supported_by': 'network'}


Expand Down
2 changes: 1 addition & 1 deletion library/_textfsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'status': ['deprecated'],
'supported_by': 'network'}

DOCUMENTATION = '''
Expand Down
3 changes: 2 additions & 1 deletion lookup_plugins/json_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@

from ansible.errors import AnsibleError, AnsibleParserError
from ansible.plugins.lookup import LookupBase, display
from ansible.module_utils._text import to_bytes, to_text
from ansible.module_utils._text import to_bytes

sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.path.pardir, 'lib'))
from network_engine.plugins import template_loader


class LookupModule(LookupBase):

def run(self, terms, variables, **kwargs):
Expand Down
8 changes: 1 addition & 7 deletions lookup_plugins/network_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@
"""


import os
import re
import collections

from ansible import constants as C
from ansible.plugins.lookup import LookupBase, display
from ansible.module_utils.network.common.utils import to_list
from ansible.module_utils.network.common.config import NetworkConfig
from ansible.module_utils.six import iteritems, string_types
from ansible.module_utils._text import to_text, to_bytes
from ansible.errors import AnsibleError, AnsibleUndefinedVariable
Expand Down Expand Up @@ -76,7 +72,7 @@ def run(self, terms, variables, **kwargs):

when = task.pop('when', None)
if when is not None:
if not self._check_conditional(when, task_vars):
if not self._check_conditional(when, self.ds):
display.vvv('skipping task due to conditional check failure')
continue

Expand Down Expand Up @@ -248,7 +244,6 @@ def template(self, data, variables, convert_bare=False):
resp = self._coerce_to_native(resp)
except AnsibleUndefinedVariable:
resp = None
pass
finally:
self._templar.set_available_variables(tmp_avail_vars)
return resp
Expand All @@ -260,7 +255,6 @@ def _coerce_to_native(self, value):
except Exception as exc:
if value is None or len(value) == 0:
return None
pass
return value

def _check_conditional(self, when, variables):
Expand Down

0 comments on commit a3fbdc7

Please sign in to comment.