commit
9c5bcda4fe
2 changed files with 53 additions and 11 deletions
|
@ -29,11 +29,10 @@
|
|||
|
||||
import re
|
||||
|
||||
from ansible.module_utils.network import NetworkModule, NetworkError
|
||||
from ansible.module_utils.network import add_argument, register_transport, to_list
|
||||
from ansible.module_utils.shell import CliBase
|
||||
|
||||
# temporary fix until modules are update. to be removed before 2.2 final
|
||||
from ansible.module_utils.network import get_module
|
||||
from ansible.module_utils.netcli import Command
|
||||
|
||||
add_argument('show_command', dict(default='show running-config', choices=['show running-config', 'more system:running-config']))
|
||||
add_argument('context', dict(required=False))
|
||||
|
@ -64,11 +63,20 @@ class Cli(CliBase):
|
|||
|
||||
def connect(self, params, **kwargs):
|
||||
super(Cli, self).connect(params, kickstart=False, **kwargs)
|
||||
self.execute('no terminal pager')
|
||||
|
||||
if params['context']:
|
||||
self.change_context(params, **kwargs)
|
||||
|
||||
def authorize(self, params, **kwargs):
|
||||
passwd = params['auth_pass']
|
||||
cmd = Command('enable', prompt=self.NET_PASSWD_RE, response=passwd)
|
||||
self.execute([cmd, 'no terminal pager'])
|
||||
|
||||
### Cli methods ###
|
||||
|
||||
def run_commands(self, commands):
|
||||
return self.execute(to_list(commands))
|
||||
|
||||
def change_context(self, params, **kwargs):
|
||||
context = params['context']
|
||||
if context == 'system':
|
||||
|
@ -83,15 +91,21 @@ class Cli(CliBase):
|
|||
def configure(self, commands):
|
||||
cmds = ['configure terminal']
|
||||
cmds.extend(to_list(commands))
|
||||
if cmds[-1] != 'end':
|
||||
cmds.append('end')
|
||||
responses = self.execute(cmds)
|
||||
return responses[1:]
|
||||
|
||||
def get_config(self, params, **kwargs):
|
||||
if self.filter:
|
||||
cmd = 'show running-config %s ' % self.filter
|
||||
else:
|
||||
cmd = params['show_command']
|
||||
if params.get('include_defaults'):
|
||||
def get_config(self, include_defaults=False, **kwargs):
|
||||
cmd = 'show running-config'
|
||||
if include_defaults:
|
||||
cmd += ' all'
|
||||
return self.execute(cmd)
|
||||
return self.run_commands(cmd)[0]
|
||||
|
||||
def load_config(self, commands, **kwargs):
|
||||
return self.configure(commands)
|
||||
|
||||
def save_config(self):
|
||||
self.execute(['write memory'])
|
||||
|
||||
Cli = register_transport('cli', default=True)(Cli)
|
||||
|
|
28
lib/ansible/plugins/action/asa_config.py
Normal file
28
lib/ansible/plugins/action/asa_config.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
#
|
||||
# Copyright 2015 Peter Sprygada <psprygada@ansible.com>
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.plugins.action.net_config import ActionModule as NetActionModule
|
||||
|
||||
class ActionModule(NetActionModule, ActionBase):
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in a new issue