|
|
|
|
@ -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)
|
|
|
|
|
|