PR changes resolved

pull/58969/head
shashik 7 years ago
parent 931a175abb
commit 6dd37e3c05

@ -1,30 +1,6 @@
# This code is part of Ansible, but is an independent component.
# This particular file snippet, and this file snippet only, is BSD licensed.
# Modules you write using this snippet, which is embedded dynamically by Ansible
# still belong to the author of the module, and may assign their own license
# to the complete work.
#
# (c) 2016 Red Hat Inc.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# -*- coding: utf-8 -*-
# Copyright: (c) 2019, Ansible Project
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
from __future__ import absolute_import, division, print_function
__metaclass__ = type

@ -1,21 +1,5 @@
#
# (c) 2016 Red Hat Inc.
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
@ -23,7 +7,7 @@ __metaclass__ = type
DOCUMENTATION = """
---
author: Ansible Networking Team
cliconf: ios
cliconf: icx
short_description: Use icx cliconf to run command on Cisco ICX platform
description:
- This icx plugin provides low level abstraction apis for
@ -187,59 +171,6 @@ class Cliconf(CliconfBase):
resp['response'] = results
return resp
# @enable_mode
# def edit_config(self, candidate=None, commit=True, replace=None, comment=None):
# resp = {}
# # operations = self.get_device_operations()
# # self.check_edit_config_capability(operations, candidate, commit, replace, comment)
# results = []
# requests = []
# if commit:
# self.send_command('configure terminal')
# for line in to_list(candidate):
# if not isinstance(line, Mapping):
# line = {'command': line}
# cmd = line['command']
# if cmd != 'end' and cmd[0] != '!':
# results.append(self.send_command(**line))
# requests.append(cmd)
# self.send_command('end')
# else:
# raise ValueError('check mode is not supported')
# resp['request'] = requests
# resp['response'] = results
# return resp
# def edit_macro(self, candidate=None, commit=True, replace=None, comment=None):
# resp = {}
# operations = self.get_device_operations()
# self.check_edit_config_capabiltiy(operations, candidate, commit, replace, comment)
# results = []
# requests = []
# if commit:
# commands = ''
# for line in candidate:
# if line != 'None':
# commands += (' ' + line + '\n')
# self.send_command('config terminal', sendonly=True)
# obj = {'command': commands, 'sendonly': True}
# results.append(self.send_command(**obj))
# requests.append(commands)
# self.send_command('end', sendonly=True)
# time.sleep(0.1)
# results.append(self.send_command('\n'))
# requests.append('\n')
# resp['request'] = requests
# resp['response'] = results
# return resp
def get(self, command=None, prompt=None, answer=None, sendonly=False, output=None, check_all=False):
if not command:
raise ValueError('must provide value of command to execute')
@ -370,25 +301,6 @@ class Cliconf(CliconfBase):
return responses
# def get_defaults_flag(self):
# """
# The method identifies the filter that should be used to fetch running-configuration
# with defaults.
# :return: valid default filter
# """
# out = self.get('show running-config ?')
# out = to_text(out, errors='surrogate_then_replace')
# commands = set()
# for line in out.splitlines():
# if line.strip():
# commands.add(line.strip().split()[0])
# if 'all' in commands:
# return 'all'
# else:
# return 'full'
def _extract_banners(self, config):
banners = {}
banner_cmds = re.findall(r'^banner (\w+)', config, re.M)

@ -1,21 +1,5 @@
#
# (c) 2016 Red Hat Inc.
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
@ -61,11 +45,6 @@ class TerminalModule(TerminalBase):
def on_open_shell(self):
pass
# try:
# for c in (b''):
# self._exec_cli_command(c)
# except AnsibleConnectionFailure:
# raise AnsibleConnectionFailure('unable to set terminal parameters')
def __del__(self):
try:
@ -78,10 +57,6 @@ class TerminalModule(TerminalBase):
return
cmd = {u'command': u'enable'}
# if passwd:
# Note: python-3.5 cannot combine u"" and r"" together. Thus make
# an r string and use to_text to ensure it's text on both py2 and py3.
#
cmd[u'prompt'] = to_text(r"[\r\n](?:Local_)?[Pp]assword: ?$", errors='surrogate_or_strict')
cmd[u'answer'] = passwd
cmd[u'prompt_retry_check'] = True
@ -97,7 +72,6 @@ class TerminalModule(TerminalBase):
def on_unbecome(self):
prompt = self._get_prompt()
if prompt is None:
# if prompt is None most likely the terminal is hung up at a prompt
return
if b'(config' in prompt:
@ -106,20 +80,3 @@ class TerminalModule(TerminalBase):
elif prompt.endswith(b'#'):
self._exec_cli_command(b'exit')
# def get_mode(self):
# prompt = self._get_prompt()
# if prompt is None:
# # if prompt is None most likely the terminal is hung up at a prompt
# return
# if b'(config-if' in prompt:
# return 3
# if b'(config' in prompt:
# return 2
# elif prompt.endswith(b'#'):
# return 1
# return 0

@ -1,21 +1,5 @@
# (c) 2016 Red Hat Inc.
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

@ -1,19 +1,5 @@
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from units.compat.mock import patch

Loading…
Cancel
Save