mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
Assorted pylint fixes
This commit is contained in:
parent
8e0f95951d
commit
f9ab9b4d68
65 changed files with 343 additions and 473 deletions
|
@ -1,9 +1,8 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2014, Mischa Peters <mpeters@a10networks.com>
|
||||
# (c) 2016, Eric Chou <ericc@a10networks.com>
|
||||
#
|
||||
# Copyright: (c) 2014, Mischa Peters <mpeters@a10networks.com>
|
||||
# Copyright: (c) 2016, Eric Chou <ericc@a10networks.com>
|
||||
# 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
|
||||
|
@ -162,7 +161,7 @@ def main():
|
|||
slb_server_status = module.params['server_status']
|
||||
slb_server_ports = module.params['server_ports']
|
||||
|
||||
axapi_base_url = 'https://{}/axapi/v3/'.format(host)
|
||||
axapi_base_url = 'https://{0}/axapi/v3/'.format(host)
|
||||
axapi_auth_url = axapi_base_url + 'auth/'
|
||||
signature = axapi_authenticate_v3(module, axapi_auth_url, username, password)
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
# Created on July 24, 2017
|
||||
#
|
||||
|
@ -6,8 +7,8 @@
|
|||
#
|
||||
# module_check: not supported
|
||||
#
|
||||
# Copyright: (c) 2017 Gaurav Rastogi, <grastogi@avinetworks.com>
|
||||
# Vilian Atmadzhov, <vilian.atmadzhov@paddypowerbetfair.com>
|
||||
# Copyright: (c) 2017, Gaurav Rastogi <grastogi@avinetworks.com>
|
||||
# Copyright: (c) 2017, Vilian Atmadzhov <vilian.atmadzhov@paddypowerbetfair.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
#
|
||||
"""
|
||||
|
@ -83,7 +84,7 @@ def main():
|
|||
api.close()
|
||||
module.exit_json(changed=False, obj=remote)
|
||||
except Exception as e:
|
||||
module.fail_json(msg="Unable to get an AVI session. {}".format(e))
|
||||
module.fail_json(msg="Unable to get an AVI session. {0}".format(e))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Ted Elhourani <ted@bigswitch.com>
|
||||
# Copyright: (c) 2017, Ted Elhourani <ted@bigswitch.com>
|
||||
# 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
|
||||
|
@ -101,7 +101,7 @@ def switch(module, check_mode):
|
|||
|
||||
response = rest.get('switch-config', data={})
|
||||
if response.status_code != 200:
|
||||
module.fail_json(msg="failed to obtain existing switch config: {}".format(response.json['description']))
|
||||
module.fail_json(msg="failed to obtain existing switch config: {0}".format(response.json['description']))
|
||||
|
||||
config_present = False
|
||||
for switch in response.json:
|
||||
|
@ -127,14 +127,14 @@ def switch(module, check_mode):
|
|||
if response.status_code == 204:
|
||||
module.exit_json(changed=True)
|
||||
else:
|
||||
module.fail_json(msg="error configuring switch '{}': {}".format(name, response.json['description']))
|
||||
module.fail_json(msg="error configuring switch '{0}': {1}".format(name, response.json['description']))
|
||||
|
||||
if state in ('absent'):
|
||||
response = rest.delete('switch-config[name="%s"]' % name, data={})
|
||||
if response.status_code == 204:
|
||||
module.exit_json(changed=True)
|
||||
else:
|
||||
module.fail_json(msg="error deleting switch '{}': {}".format(name, response.json['description']))
|
||||
module.fail_json(msg="error deleting switch '{0}': {1}".format(name, response.json['description']))
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Ansible module to manage Big Monitoring Fabric service chains
|
||||
# (c) 2016, Ted Elhourani <ted@bigswitch.com>
|
||||
# Copyright: (c) 2016, Ted Elhourani <ted@bigswitch.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Ansible module to manage Big Monitoring Fabric service chains
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
@ -88,7 +89,7 @@ def chain(module):
|
|||
|
||||
response = rest.get('chain?config=true', data={})
|
||||
if response.status_code != 200:
|
||||
module.fail_json(msg="failed to obtain existing chain config: {}".format(response.json['description']))
|
||||
module.fail_json(msg="failed to obtain existing chain config: {0}".format(response.json['description']))
|
||||
|
||||
config_present = False
|
||||
matching = [chain for chain in response.json if chain['name'] == name]
|
||||
|
@ -106,14 +107,14 @@ def chain(module):
|
|||
if response.status_code == 204:
|
||||
module.exit_json(changed=True)
|
||||
else:
|
||||
module.fail_json(msg="error creating chain '{}': {}".format(name, response.json['description']))
|
||||
module.fail_json(msg="error creating chain '{0}': {1}".format(name, response.json['description']))
|
||||
|
||||
if state in ('absent'):
|
||||
response = rest.delete('chain[name="%s"]' % name, data={})
|
||||
if response.status_code == 204:
|
||||
module.exit_json(changed=True)
|
||||
else:
|
||||
module.fail_json(msg="error deleting chain '{}': {}".format(name, response.json['description']))
|
||||
module.fail_json(msg="error deleting chain '{0}': {1}".format(name, response.json['description']))
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Ansible module to manage Big Monitoring Fabric service chains
|
||||
# (c) 2016, Ted Elhourani <ted@bigswitch.com>
|
||||
# Copyright: (c) 2016, Ted Elhourani <ted@bigswitch.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Ansible module to manage Big Monitoring Fabric service chains
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
@ -121,7 +122,7 @@ def policy(module):
|
|||
|
||||
response = rest.get('policy?config=true', data={})
|
||||
if response.status_code != 200:
|
||||
module.fail_json(msg="failed to obtain existing policy config: {}".format(response.json['description']))
|
||||
module.fail_json(msg="failed to obtain existing policy config: {0}".format(response.json['description']))
|
||||
|
||||
config_present = False
|
||||
|
||||
|
@ -151,14 +152,14 @@ def policy(module):
|
|||
if response.status_code == 204:
|
||||
module.exit_json(changed=True)
|
||||
else:
|
||||
module.fail_json(msg="error creating policy '{}': {}".format(name, response.json['description']))
|
||||
module.fail_json(msg="error creating policy '{0}': {1}".format(name, response.json['description']))
|
||||
|
||||
if state in ('absent'):
|
||||
response = rest.delete('policy[name="%s"]' % name, data={})
|
||||
if response.status_code == 204:
|
||||
module.exit_json(changed=True)
|
||||
else:
|
||||
module.fail_json(msg="error deleting policy '{}': {}".format(name, response.json['description']))
|
||||
module.fail_json(msg="error deleting policy '{0}': {1}".format(name, response.json['description']))
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
|
@ -281,7 +268,7 @@ class FileCopy(object):
|
|||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect(hostname=hostname, username=username, password=password, port=port)
|
||||
full_remote_path = '{}{}'.format(self.file_system, dest)
|
||||
full_remote_path = '{0}{1}'.format(self.file_system, dest)
|
||||
scp = SCPClient(ssh.get_transport())
|
||||
try:
|
||||
scp.put(self.local_file, full_remote_path)
|
||||
|
@ -351,7 +338,7 @@ class FileCopy(object):
|
|||
|
||||
if not os.path.isfile(self.local_file):
|
||||
self.module.fail_json(
|
||||
msg="Local file {} not found".format(self.local_file))
|
||||
msg="Local file {0} not found".format(self.local_file))
|
||||
|
||||
dest = self.remote_file or ('/' + os.path.basename(self.local_file))
|
||||
remote_exists, file_size = self.remote_file_exists(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Ansible by Red Hat, inc
|
||||
# Copyright: (c) 2017, Ansible by Red Hat, inc
|
||||
# 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
|
||||
|
@ -187,7 +187,7 @@ def parse_shutdown(configobj, name):
|
|||
cfg = configobj['interface %s' % name]
|
||||
cfg = '\n'.join(cfg.children)
|
||||
match = re.search(r'shutdown', cfg, re.M)
|
||||
return True if match else False
|
||||
return bool(match)
|
||||
|
||||
|
||||
def parse_config_argument(configobj, name, arg=None):
|
||||
|
@ -368,7 +368,7 @@ def check_declarative_intent_params(module, want, result):
|
|||
have_host = []
|
||||
have_port = []
|
||||
if have_neighbors is None:
|
||||
command = {'command': 'show lldp neighbors {}'.format(w['name']), 'output': 'text'}
|
||||
command = {'command': 'show lldp neighbors {0}'.format(w['name']), 'output': 'text'}
|
||||
have_neighbors = run_commands(module, [command])
|
||||
|
||||
if have_neighbors[0]:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Ansible by Red Hat, inc
|
||||
# Copyright: (c) 2017, Ansible by Red Hat, inc
|
||||
# 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
|
||||
|
@ -170,23 +170,23 @@ def map_obj_to_commands(updates, module):
|
|||
if state == 'absent' and obj_in_have:
|
||||
if obj_in_have['ipv4']:
|
||||
if ipv4:
|
||||
commands.append('no ip address {}'.format(ipv4))
|
||||
commands.append('no ip address {0}'.format(ipv4))
|
||||
else:
|
||||
commands.append('no ip address')
|
||||
if obj_in_have['ipv6']:
|
||||
if ipv6:
|
||||
commands.append('no ipv6 address {}'.format(ipv6))
|
||||
commands.append('no ipv6 address {0}'.format(ipv6))
|
||||
else:
|
||||
commands.append('no ipv6 address')
|
||||
|
||||
elif state == 'present':
|
||||
if ipv4:
|
||||
if obj_in_have is None or obj_in_have['ipv4'] is None or ipv4 != obj_in_have['ipv4']:
|
||||
commands.append('ip address {}'.format(ipv4))
|
||||
commands.append('ip address {0}'.format(ipv4))
|
||||
|
||||
if ipv6:
|
||||
if obj_in_have is None or obj_in_have['ipv6'] is None or ipv6.lower() != obj_in_have['ipv6'].lower():
|
||||
commands.append('ipv6 address {}'.format(ipv6))
|
||||
commands.append('ipv6 address {0}'.format(ipv6))
|
||||
|
||||
if commands[-1] == interface:
|
||||
commands.pop(-1)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Ansible by Red Hat, inc
|
||||
# Copyright: (c) 2017, Ansible by Red Hat, inc
|
||||
# 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
|
||||
|
@ -141,10 +141,10 @@ def map_obj_to_commands(updates, module):
|
|||
|
||||
if state == 'absent':
|
||||
if obj_in_have:
|
||||
commands.append('no interface port-channel {}'.format(group))
|
||||
commands.append('no interface port-channel {0}'.format(group))
|
||||
|
||||
elif state == 'present':
|
||||
cmd = ['interface port-channel {}'.format(group),
|
||||
cmd = ['interface port-channel {0}'.format(group),
|
||||
'end']
|
||||
if not obj_in_have:
|
||||
if not group:
|
||||
|
@ -152,11 +152,11 @@ def map_obj_to_commands(updates, module):
|
|||
commands.extend(cmd)
|
||||
|
||||
if min_links != 'None':
|
||||
commands.append('port-channel min-links {}'.format(min_links))
|
||||
commands.append('port-channel min-links {0}'.format(min_links))
|
||||
|
||||
if members:
|
||||
for m in members:
|
||||
commands.append('interface {}'.format(m))
|
||||
commands.append('interface {0}'.format(m))
|
||||
commands.append('channel-group {0} mode {1}'.format(group, mode))
|
||||
|
||||
else:
|
||||
|
@ -164,27 +164,27 @@ def map_obj_to_commands(updates, module):
|
|||
if 'members' not in obj_in_have.keys():
|
||||
for m in members:
|
||||
commands.extend(cmd)
|
||||
commands.append('interface {}'.format(m))
|
||||
commands.append('interface {0}'.format(m))
|
||||
commands.append('channel-group {0} mode {1}'.format(group, mode))
|
||||
|
||||
elif set(members) != set(obj_in_have['members']):
|
||||
missing_members = list(set(members) - set(obj_in_have['members']))
|
||||
for m in missing_members:
|
||||
commands.extend(cmd)
|
||||
commands.append('interface {}'.format(m))
|
||||
commands.append('interface {0}'.format(m))
|
||||
commands.append('channel-group {0} mode {1}'.format(group, mode))
|
||||
|
||||
superfluous_members = list(set(obj_in_have['members']) - set(members))
|
||||
for m in superfluous_members:
|
||||
commands.extend(cmd)
|
||||
commands.append('interface {}'.format(m))
|
||||
commands.append('no channel-group {}'.format(group))
|
||||
commands.append('interface {0}'.format(m))
|
||||
commands.append('no channel-group {0}'.format(group))
|
||||
|
||||
if purge:
|
||||
for h in have:
|
||||
obj_in_want = search_obj_in_list(h['group'], want)
|
||||
if not obj_in_want:
|
||||
commands.append('no interface port-channel {}'.format(h['group']))
|
||||
commands.append('no interface port-channel {0}'.format(h['group']))
|
||||
|
||||
return commands
|
||||
|
||||
|
@ -221,9 +221,9 @@ def parse_mode(group, member, config):
|
|||
mode = None
|
||||
|
||||
for line in config.strip().split('!'):
|
||||
match_int = re.findall(r'interface {}\\b'.format(member), line, re.M)
|
||||
match_int = re.findall(r'interface {0}\\b'.format(member), line, re.M)
|
||||
if match_int:
|
||||
match = re.search(r'channel-group {} mode (\S+)'.format(group), line, re.M)
|
||||
match = re.search(r'channel-group {0} mode (\S+)'.format(group), line, re.M)
|
||||
if match:
|
||||
mode = match.group(1)
|
||||
|
||||
|
@ -234,7 +234,7 @@ def parse_members(group, config):
|
|||
members = []
|
||||
|
||||
for line in config.strip().split('!'):
|
||||
match_group = re.findall(r'channel-group {} mode'.format(group), line, re.M)
|
||||
match_group = re.findall(r'channel-group {0} mode'.format(group), line, re.M)
|
||||
if match_group:
|
||||
match = re.search(r'interface (\S+)', line, re.M)
|
||||
if match:
|
||||
|
@ -263,7 +263,7 @@ def parse_min_links(group, config):
|
|||
min_links = ''
|
||||
|
||||
for line in config.strip().split('!'):
|
||||
match_pc = re.findall(r'interface Port-Channel{}\\b'.format(group), line, re.M)
|
||||
match_pc = re.findall(r'interface Port-Channel{0}\\b'.format(group), line, re.M)
|
||||
if match_pc:
|
||||
match = re.search(r'port-channel min-links (\S+)', line, re.M)
|
||||
if match:
|
||||
|
|
|
@ -1,23 +1,9 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Ansible by Red Hat, inc
|
||||
#
|
||||
# This file is part of Ansible by Red Hat
|
||||
#
|
||||
# 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) 2017, Ansible by Red Hat, inc
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
|
@ -152,16 +138,16 @@ def map_obj_to_commands(updates, module):
|
|||
if state == 'absent' and w in have:
|
||||
if dest:
|
||||
if dest == 'host':
|
||||
commands.append('no logging host {}'.format(name))
|
||||
commands.append('no logging host {0}'.format(name))
|
||||
|
||||
elif dest in DEST_GROUP:
|
||||
commands.append('no logging {}'.format(dest))
|
||||
commands.append('no logging {0}'.format(dest))
|
||||
|
||||
else:
|
||||
module.fail_json(msg='dest must be among console, monitor, buffered, host, on')
|
||||
|
||||
if facility:
|
||||
commands.append('no logging facility {}'.format(facility))
|
||||
commands.append('no logging facility {0}'.format(facility))
|
||||
|
||||
if state == 'present' and w not in have:
|
||||
if facility:
|
||||
|
@ -175,10 +161,10 @@ def map_obj_to_commands(updates, module):
|
|||
present = True
|
||||
|
||||
if not present:
|
||||
commands.append('logging facility {}'.format(facility))
|
||||
commands.append('logging facility {0}'.format(facility))
|
||||
|
||||
if dest == 'host':
|
||||
commands.append('logging host {}'.format(name))
|
||||
commands.append('logging host {0}'.format(name))
|
||||
|
||||
elif dest == 'on':
|
||||
commands.append('logging on')
|
||||
|
@ -203,14 +189,14 @@ def map_obj_to_commands(updates, module):
|
|||
|
||||
if not present:
|
||||
if size and level:
|
||||
commands.append('logging buffered {} {}'.format(size, level))
|
||||
commands.append('logging buffered {0} {1}'.format(size, level))
|
||||
else:
|
||||
commands.append('logging buffered {}'.format(size))
|
||||
commands.append('logging buffered {0}'.format(size))
|
||||
|
||||
else:
|
||||
dest_cmd = 'logging {}'.format(dest)
|
||||
dest_cmd = 'logging {0}'.format(dest)
|
||||
if level:
|
||||
dest_cmd += ' {}'.format(level)
|
||||
dest_cmd += ' {0}'.format(level)
|
||||
|
||||
commands.append(dest_cmd)
|
||||
|
||||
|
@ -268,7 +254,7 @@ def parse_level(line, dest):
|
|||
match = re.search(r'logging buffered (?:\d+) (\S+)', line, re.M)
|
||||
|
||||
else:
|
||||
match = re.search(r'logging {} (\S+)'.format(dest), line, re.M)
|
||||
match = re.search(r'logging {0} (\S+)'.format(dest), line, re.M)
|
||||
|
||||
if match:
|
||||
if match.group(1) in LEVEL_GROUP:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Ansible by Red Hat, inc
|
||||
# Copyright: (c) 2017, Ansible by Red Hat, inc
|
||||
# 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
|
||||
|
@ -224,7 +224,7 @@ def main():
|
|||
|
||||
if address and prefix:
|
||||
if '/' not in address or not validate_ip_address(address.split('/')[0]):
|
||||
module.fail_json(msg='{} is not a valid IP address'.format(address))
|
||||
module.fail_json(msg='{0} is not a valid IP address'.format(address))
|
||||
|
||||
if not validate_prefix(prefix):
|
||||
module.fail_json(msg='Length of prefix should be between 0 and 32 bits')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Ansible by Red Hat, inc
|
||||
# Copyright: (c) 2017, Ansible by Red Hat, inc
|
||||
# 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
|
||||
|
@ -188,12 +188,12 @@ def map_obj_to_commands(updates, module):
|
|||
address = ipv4.split('/')
|
||||
if len(address) == 2:
|
||||
ipv4 = '{0} {1}'.format(address[0], to_netmask(address[1]))
|
||||
commands.append('no ip address {}'.format(ipv4))
|
||||
commands.append('no ip address {0}'.format(ipv4))
|
||||
else:
|
||||
commands.append('no ip address')
|
||||
if obj_in_have['ipv6']:
|
||||
if ipv6:
|
||||
commands.append('no ipv6 address {}'.format(ipv6))
|
||||
commands.append('no ipv6 address {0}'.format(ipv6))
|
||||
else:
|
||||
commands.append('no ipv6 address')
|
||||
if 'dhcp' in obj_in_have['ipv6']:
|
||||
|
@ -205,11 +205,11 @@ def map_obj_to_commands(updates, module):
|
|||
address = ipv4.split('/')
|
||||
if len(address) == 2:
|
||||
ipv4 = '{0} {1}'.format(address[0], to_netmask(address[1]))
|
||||
commands.append('ip address {}'.format(ipv4))
|
||||
commands.append('ip address {0}'.format(ipv4))
|
||||
|
||||
if ipv6:
|
||||
if obj_in_have is None or obj_in_have.get('ipv6') is None or ipv6.lower() not in [addr.lower() for addr in obj_in_have['ipv6']]:
|
||||
commands.append('ipv6 address {}'.format(ipv6))
|
||||
commands.append('ipv6 address {0}'.format(ipv6))
|
||||
|
||||
if commands[-1] == interface:
|
||||
commands.pop(-1)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Ansible by Red Hat, inc
|
||||
# Copyright: (c) 2017, Ansible by Red Hat, inc
|
||||
# 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
|
||||
|
@ -111,7 +111,7 @@ class ConfigBase(object):
|
|||
def map_params_to_obj(self):
|
||||
text = self._module.params['text']
|
||||
if text:
|
||||
text = "{!r}".format(str(text).strip())
|
||||
text = "{0!r}".format(str(text).strip())
|
||||
self._want.update({
|
||||
'banner': self._module.params['banner'],
|
||||
'text': text,
|
||||
|
@ -128,11 +128,11 @@ class CliConfiguration(ConfigBase):
|
|||
state = self._module.params['state']
|
||||
if state == 'absent':
|
||||
if self._have.get('state') != 'absent' and ('text' in self._have.keys() and self._have['text']):
|
||||
commands.append('no banner {!s}'.format(self._module.params['banner']))
|
||||
commands.append('no banner {0!s}'.format(self._module.params['banner']))
|
||||
elif state == 'present':
|
||||
if (self._want['text'] and
|
||||
self._want['text'].encode().decode('unicode_escape').strip("'") != self._have.get('text')):
|
||||
banner_cmd = 'banner {!s} '.format(self._module.params['banner'])
|
||||
banner_cmd = 'banner {0!s} '.format(self._module.params['banner'])
|
||||
banner_cmd += self._want['text'].strip()
|
||||
commands.append(banner_cmd)
|
||||
self._result['commands'] = commands
|
||||
|
@ -144,7 +144,7 @@ class CliConfiguration(ConfigBase):
|
|||
self._result['changed'] = True
|
||||
|
||||
def map_config_to_obj(self):
|
||||
cli_filter = 'banner {!s}'.format(self._module.params['banner'])
|
||||
cli_filter = 'banner {0!s}'.format(self._module.params['banner'])
|
||||
output = get_config(self._module, config_filter=cli_filter)
|
||||
match = re.search(r'banner (\S+) (.*)', output, re.DOTALL)
|
||||
if match:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Ansible by Red Hat, inc
|
||||
# Copyright: (c) 2017, Ansible by Red Hat, inc
|
||||
# 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
|
||||
|
@ -322,7 +322,7 @@ class CliConfiguration(ConfigBase):
|
|||
'speed': self.parse_config_argument(intf_config, 'speed'),
|
||||
'duplex': self.parse_config_argument(intf_config, 'duplex'),
|
||||
'mtu': self.parse_config_argument(intf_config, 'mtu'),
|
||||
'enabled': True if not self.parse_shutdown(intf_config) else False,
|
||||
'enabled': not bool(self.parse_shutdown(intf_config)),
|
||||
'active': active,
|
||||
'state': 'present'
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ class CliConfiguration(ConfigBase):
|
|||
if self._result['changed']:
|
||||
sleep(want_item['delay'])
|
||||
|
||||
command = 'show interfaces {!s}'.format(want_item['name'])
|
||||
command = 'show interfaces {0!s}'.format(want_item['name'])
|
||||
out = run_commands(self._module, command)[0]
|
||||
|
||||
if want_state in ('up', 'down'):
|
||||
|
@ -399,7 +399,7 @@ class CliConfiguration(ConfigBase):
|
|||
have_state = match.group(1)
|
||||
|
||||
if have_state is None or not conditional(want_state, have_state.strip()):
|
||||
failed_conditions.append('state ' + 'eq({!s})'.format(want_state))
|
||||
failed_conditions.append('state ' + 'eq({0!s})'.format(want_state))
|
||||
|
||||
if want_tx_rate:
|
||||
match = re.search(r'%s (\d+)' % 'output rate', out, re.M)
|
||||
|
@ -575,7 +575,7 @@ class NCConfiguration(ConfigBase):
|
|||
|
||||
if want_state in ('up', 'down'):
|
||||
if want_state not in line_state_map[want_item['name']]:
|
||||
failed_conditions.append('state ' + 'eq({!s})'.format(want_state))
|
||||
failed_conditions.append('state ' + 'eq({0!s})'.format(want_state))
|
||||
|
||||
if want_tx_rate:
|
||||
if want_tx_rate != data_rate_map[want_item['name']]['output-data-rate']:
|
||||
|
|
|
@ -1,23 +1,9 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Ansible by Red Hat, inc
|
||||
#
|
||||
# This file is part of Ansible by Red Hat
|
||||
#
|
||||
# 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) 2017, Ansible by Red Hat, inc
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
|
@ -232,19 +218,19 @@ def map_obj_to_commands(updates):
|
|||
if state == 'absent' and w in have:
|
||||
if w['facility'] is not None:
|
||||
if not w['dest'] and not w['facility_link_status'] and w['facility'] not in DEFAULT_LOGGING_LEVEL[int(w['facility_level'])]:
|
||||
commands.append('no logging level {} {}'.format(w['facility'], w['facility_level']))
|
||||
commands.append('no logging level {0} {1}'.format(w['facility'], w['facility_level']))
|
||||
|
||||
if w['facility_link_status'] and w['facility'] in ('ethpm'):
|
||||
commands.append('no logging level {} {}'.format(w['facility'], STATIC_CLI[w['facility_link_status']]))
|
||||
commands.append('no logging level {0} {1}'.format(w['facility'], STATIC_CLI[w['facility_link_status']]))
|
||||
|
||||
if w['name'] is not None:
|
||||
commands.append('no logging logfile')
|
||||
|
||||
if w['dest'] in ('console', 'module', 'monitor'):
|
||||
commands.append('no logging {}'.format(w['dest']))
|
||||
commands.append('no logging {0}'.format(w['dest']))
|
||||
|
||||
if w['dest'] == 'server':
|
||||
commands.append('no logging server {}'.format(w['remote_server']))
|
||||
commands.append('no logging server {0}'.format(w['remote_server']))
|
||||
|
||||
if w['interface']:
|
||||
commands.append('no logging source-interface')
|
||||
|
@ -262,14 +248,14 @@ def map_obj_to_commands(updates):
|
|||
if w['facility'] is None:
|
||||
if w['dest']:
|
||||
if w['dest'] not in ('logfile', 'server'):
|
||||
commands.append('logging {} {}'.format(w['dest'], w['dest_level']))
|
||||
commands.append('logging {0} {1}'.format(w['dest'], w['dest_level']))
|
||||
|
||||
elif w['dest'] == 'logfile':
|
||||
if w['file_size']:
|
||||
commands.append('logging logfile {} {} size {}'.format(
|
||||
commands.append('logging logfile {0} {1} size {2}'.format(
|
||||
w['name'], w['dest_level'], w['file_size']))
|
||||
else:
|
||||
commands.append('logging logfile {} {}'.format(
|
||||
commands.append('logging logfile {0} {1}'.format(
|
||||
w['name'], w['dest_level']))
|
||||
|
||||
elif w['dest'] == 'server':
|
||||
|
@ -306,11 +292,11 @@ def map_obj_to_commands(updates):
|
|||
w['facility']))
|
||||
else:
|
||||
if w['facility_link_status']:
|
||||
commands.append('logging level {} {}'.format(
|
||||
commands.append('logging level {0} {1}'.format(
|
||||
w['facility'], STATIC_CLI[w['facility_link_status']]))
|
||||
else:
|
||||
commands.append('logging level {} {}'.format(w['facility'],
|
||||
w['facility_level']))
|
||||
commands.append('logging level {0} {1}'.format(w['facility'],
|
||||
w['facility_level']))
|
||||
|
||||
if w['interface']:
|
||||
commands.append('logging source-interface {0} {1}'.format(*split_interface(w['interface'])))
|
||||
|
@ -337,7 +323,7 @@ def parse_facility_link_status(line, facility, status):
|
|||
facility_link_status = None
|
||||
|
||||
if facility is not None:
|
||||
match = re.search(r'logging level {} {} (\S+)'.format(facility, status), line, re.M)
|
||||
match = re.search(r'logging level {0} {1} (\S+)'.format(facility, status), line, re.M)
|
||||
if match:
|
||||
facility_link_status = status + "-" + match.group(1)
|
||||
|
||||
|
@ -347,7 +333,7 @@ def parse_facility_link_status(line, facility, status):
|
|||
def parse_event_status(line, event):
|
||||
status = None
|
||||
|
||||
match = re.search(r'logging event {} (\S+)'.format(event + '-status'), line, re.M)
|
||||
match = re.search(r'logging event {0} (\S+)'.format(event + '-status'), line, re.M)
|
||||
if match:
|
||||
state = match.group(1)
|
||||
if state:
|
||||
|
@ -383,7 +369,7 @@ def parse_message(line):
|
|||
def parse_file_size(line, name, level):
|
||||
file_size = None
|
||||
|
||||
match = re.search(r'logging logfile {} {} size (\S+)'.format(name, level), line, re.M)
|
||||
match = re.search(r'logging logfile {0} {1} size (\S+)'.format(name, level), line, re.M)
|
||||
if match:
|
||||
file_size = match.group(1)
|
||||
if file_size == '8192':
|
||||
|
@ -441,7 +427,7 @@ def parse_dest_level(line, dest, name):
|
|||
|
||||
if dest and dest != 'server':
|
||||
if dest == 'logfile':
|
||||
match = re.search(r'logging logfile {} (\S+)'.format(name), line, re.M)
|
||||
match = re.search(r'logging logfile {0} (\S+)'.format(name), line, re.M)
|
||||
if match:
|
||||
dest_level = parse_match(match)
|
||||
|
||||
|
@ -450,7 +436,7 @@ def parse_dest_level(line, dest, name):
|
|||
if match:
|
||||
dest_level = parse_match(match)
|
||||
else:
|
||||
match = re.search(r'logging {} (\S+)'.format(dest), line, re.M)
|
||||
match = re.search(r'logging {0} (\S+)'.format(dest), line, re.M)
|
||||
if match:
|
||||
dest_level = parse_match(match)
|
||||
|
||||
|
@ -466,7 +452,7 @@ def parse_facility_level(line, facility, dest):
|
|||
facility_level = match.group(1)
|
||||
|
||||
elif facility is not None:
|
||||
match = re.search(r'logging level {} (\S+)'.format(facility), line, re.M)
|
||||
match = re.search(r'logging level {0} (\S+)'.format(facility), line, re.M)
|
||||
if match:
|
||||
facility_level = match.group(1)
|
||||
|
||||
|
|
|
@ -1,20 +1,8 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
|
@ -369,7 +357,7 @@ def main():
|
|||
result['changed'] = True
|
||||
|
||||
if action == 'create' and module.params['path'] and module.params['save_snapshot_locally']:
|
||||
command = 'show snapshot dump {} | json'.format(module.params['snapshot_name'])
|
||||
command = 'show snapshot dump {0} | json'.format(module.params['snapshot_name'])
|
||||
content = execute_show_command(command, module)[0]
|
||||
if content:
|
||||
write_on_file(str(content), module.params['snapshot_name'], module)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2017, Ansible by Red Hat, inc
|
||||
# Copyright: (c) 2017, Ansible by Red Hat, inc
|
||||
# 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
|
||||
|
@ -160,9 +160,9 @@ def map_obj_to_commands(updates, module):
|
|||
for i in w['interfaces']:
|
||||
cmd = 'set interfaces ethernet {0} vif {1}'.format(i, vlan_id)
|
||||
if w['name']:
|
||||
commands.append(cmd + ' description {}'.format(name))
|
||||
commands.append(cmd + ' description {0}'.format(name))
|
||||
elif w['address']:
|
||||
commands.append(cmd + ' address {}'.format(address))
|
||||
commands.append(cmd + ' address {0}'.format(address))
|
||||
else:
|
||||
commands.append(cmd)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue