Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

Commit 93d57d8

Browse files
committed
linters fix
Signed-off-by: Sumit Jaiswal <[email protected]>
1 parent 84b3b21 commit 93d57d8

File tree

13 files changed

+106
-95
lines changed

13 files changed

+106
-95
lines changed

library/ios_facts.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,3 @@ def main():
110110

111111
if __name__ == '__main__':
112112
main()
113-

library/ios_l3_interface.py

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33
# Copyright 2019 Red Hat Inc.
4-
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4+
# GNU General Public License v3.0+
5+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
56

67
##############################################
7-
################# WARNING ####################
8-
##############################################
9-
###
10-
### This file is auto generated by the resource
11-
### module builder playbook.
12-
###
13-
### Do not edit this file manually.
14-
###
15-
### Changes to this file will be over written
16-
### by the resource module builder.
17-
###
18-
### Changes should be made in the model used to
19-
### generate this file or in the resource module
20-
### builder template.
21-
###
22-
##############################################
23-
##############################################
8+
# WARNING
9+
#
10+
# This file is auto generated by the resource
11+
# module builder playbook.
12+
#
13+
# Do not edit this file manually.
14+
#
15+
# Changes to this file will be over written
16+
# by the resource module builder.
17+
#
18+
# Changes should be made in the model used to
19+
# generate this file or in the resource module
20+
# builder template.
21+
#
22+
#
2423
##############################################
2524

2625
"""
@@ -46,7 +45,9 @@
4645
module: ios_l3_interfaces
4746
version_added: 2.9
4847
short_description: Manage Layer-3 interface on Cisco IOS devices.
49-
description: This module provides declarative management of Layer-3 interface on Cisco IOS devices.
48+
description:
49+
- This module provides declarative management of Layer-3 interface
50+
on Cisco IOS devices.
5051
author: Sumit Jaiswal (@justjais)
5152
options:
5253
config:
@@ -56,14 +57,15 @@
5657
suboptions:
5758
name:
5859
description:
59-
- Full name of the interface excluding any logical unit number, i.e. GigabitEthernet0/1.
60+
- Full name of the interface excluding any logical unit number,
61+
i.e. GigabitEthernet0/1.
6062
type: str
6163
required: True
6264
ipv4:
6365
description:
64-
- IPv4 address to be set for the Layer-3 interface mentioned in I(name) option.
65-
The address format is <ipv4 address>/<mask>, the mask is number in range 0-32
66-
eg. 192.168.0.1/24
66+
- IPv4 address to be set for the Layer-3 interface mentioned in
67+
I(name) option. The address format is <ipv4 address>/<mask>,
68+
the mask is number in range 0-32 eg. 192.168.0.1/24.
6769
suboptions:
6870
address:
6971
description:
@@ -75,19 +77,21 @@
7577
type: bool
7678
dhcp_client:
7779
description:
78-
- Configures and specifies client-id to use over DHCP ip. Note, This option shall
79-
work only when dhcp is configured as IP.
80+
- Configures and specifies client-id to use over DHCP ip.
81+
Note, This option shall work only when dhcp is configured
82+
as IP.
8083
type: str
8184
dhcp_hostname:
8285
description:
83-
- Configures and specifies value for hostname option over DHCP ip. Note, This option shall
84-
work only when dhcp is configured as IP.
86+
- Configures and specifies value for hostname option over
87+
DHCP ip. Note, This option shall work only when dhcp is
88+
configured as IP.
8589
type: str
8690
ipv6:
8791
description:
88-
- IPv6 address to be set for the Layer-3 interface mentioned in I(name) option.
89-
The address format is <ipv6 address>/<mask>, the mask is number in range 0-128
90-
eg. fd5d:12c9:2201:1::1/64
92+
- IPv6 address to be set for the Layer-3 interface mentioned in
93+
I(name) option. The address format is <ipv6 address>/<mask>,
94+
the mask is number in range 0-128 eg. fd5d:12c9:2201:1::1/64
9195
suboptions:
9296
address:
9397
description:
@@ -133,11 +137,11 @@
133137
ios_l3_interfaces:
134138
config:
135139
- name: GigabitEthernet0/1
136-
ipv4:
140+
ipv4:
137141
- address: 192.168.0.1/24
138142
secondary: True
139143
- name: GigabitEthernet0/2
140-
ipv4:
144+
ipv4:
141145
- address: 192.168.0.2/24
142146
- name: GigabitEthernet0/3
143147
ipv6:
@@ -199,7 +203,7 @@
199203
ipv4:
200204
- address: 192.168.2.0/24
201205
- name: GigabitEthernet0/3
202-
ipv4:
206+
ipv4:
203207
- address: dhcp
204208
dhcp_client: 2
205209
dhcp_hostname: test.com

module_utils/ios/argspec/facts/facts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88

99

10-
class FactsArgs(object): #pylint: disable=R0903
10+
class FactsArgs(object):
1111
""" The arg spec for the ios facts module
1212
"""
1313

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33
# Copyright 2019 Red Hat Inc.
4-
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5-
4+
# GNU General Public License v3.0+
5+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6+
#
67
#############################################
7-
################# WARNING ####################
8-
##############################################
9-
###
10-
### This file is auto generated by the resource
11-
### module builder playbook.
12-
###
13-
### Do not edit this file manually.
14-
###
15-
### Changes to this file will be over written
16-
### by the resource module builder.
17-
###
18-
### Changes should be made in the model used to
19-
### generate this file or in the resource module
20-
### builder template.
21-
###
22-
##############################################
23-
##############################################
8+
# WARNING
9+
#
10+
# This file is auto generated by the resource
11+
# module builder playbook.
12+
#
13+
# Do not edit this file manually.
14+
#
15+
# Changes to this file will be over written
16+
# by the resource module builder.
17+
#
18+
# Changes should be made in the model used to
19+
# generate this file or in the resource module
20+
# builder template.
21+
#
2422
##############################################
2523
"""
2624
The arg spec for the ios_l3_interfaces module
2725
"""
2826

27+
2928
class L3_InterfacesArgs(object):
3029

3130
def __init__(self, **kwargs):
3231
pass
3332

3433
ipv4addr_spec = dict(address=dict(type=str),
35-
secondary=dict(type=bool),
34+
secondary=dict(type=bool, default=True),
3635
dhcp_client=dict(type=str),
3736
dhcp_hostname=dict(type=str))
3837

@@ -42,11 +41,11 @@ def __init__(self, **kwargs):
4241

4342
config_spec = {
4443
'name': dict(type='str', required=True),
45-
'ipv4':dict(type='list', elements='dict', options=ipv4addr_spec),
46-
'ipv6':dict(type='list', elements='dict', options=ipv6addr_spec)
44+
'ipv4': dict(type='list', elements='dict', options=ipv4addr_spec),
45+
'ipv6': dict(type='list', elements='dict', options=ipv6addr_spec)
4746
}
4847

4948
argument_spec = {
5049
'state': dict(default='merged', choices=['merged', 'replaced', 'overridden', 'deleted']),
5150
'config': dict(type='list', elements='dict', options=config_spec)
52-
}
51+
}

module_utils/ios/argspec/resource/resource.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,20 @@
44
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
55

66
#############################################
7-
################# WARNING ####################
8-
##############################################
9-
###
10-
### This file is auto generated by the resource
11-
### module builder playbook.
12-
###
13-
### Do not edit this file manually.
14-
###
15-
### Changes to this file will be over written
16-
### by the resource module builder.
17-
###
18-
### Changes should be made in the model used to
19-
### generate this file or in the resource module
20-
### builder template.
21-
###
22-
##############################################
23-
##############################################
7+
# WARNING
8+
#
9+
# This file is auto generated by the resource
10+
# module builder playbook.
11+
#
12+
# Do not edit this file manually.
13+
#
14+
# Changes to this file will be over written
15+
# by the resource module builder.
16+
#
17+
# Changes should be made in the model used to
18+
# generate this file or in the resource module
19+
# builder template.
20+
#
2421
##############################################
2522
"""
2623
The arg spec for the ios_l3_interfaces module

module_utils/ios/config/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
from ansible.module_utils.connection import Connection
1010

11-
class ConfigBase(object): #pylint: disable=R0205,R0903
11+
12+
class ConfigBase(object):
1213
""" The base class for all ios resource modules
1314
"""
1415
_connection = None
@@ -20,5 +21,5 @@ def __init__(self, module):
2021
def _get_connection(self):
2122
if self._connection:
2223
return self._connection
23-
self._connection = Connection(self._module._socket_path) #pylint: disable=W0212
24-
return self._connection
24+
self._connection = Connection(self._module._socket_path)
25+
return self._connection

module_utils/ios/config/l3_interfaces/l3_interfaces.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
"""
1212

1313
from ansible.module_utils.network.common.utils import to_list
14-
from ansible.module_utils.network.common.utils import is_netmask, is_masklen, to_netmask, to_masklen
14+
from ansible.module_utils.network.common.utils import is_masklen, to_netmask
1515
from ansible.module_utils.six import iteritems
1616

1717
from ansible.module_utils.ios.argspec.l3_interfaces.l3_interfaces import L3_InterfacesArgs
1818
from ansible.module_utils.ios.config.base import ConfigBase
1919
from ansible.module_utils.ios.facts.facts import Facts
20-
import q
20+
2121

2222
class L3_Interfaces(ConfigBase, L3_InterfacesArgs):
2323
"""
@@ -296,7 +296,8 @@ def set_interface(**kwargs):
296296
ip_addr_want = L3_Interfaces.validate_n_expand_ipv4(module, each)
297297
each['address'] = ip_addr_want
298298

299-
want_ipv4 = set(tuple({k:v for k,v in iteritems(address) if v is not None}.items()) for address in want.get("ipv4") or [])
299+
want_ipv4 = set(tuple({k: v for k, v in iteritems(address) if v is not None}.items())
300+
for address in want.get("ipv4") or [])
300301
have_ipv4 = set(tuple(address.items()) for address in have.get("ipv4") or [])
301302
diff = want_ipv4 - have_ipv4
302303
for address in diff:
@@ -307,17 +308,19 @@ def set_interface(**kwargs):
307308
cmd += " secondary"
308309
elif address.get('address') == 'dhcp':
309310
if address.get('dhcp_client') and address.get('dhcp_hostname'):
310-
cmd = "ip address dhcp client-id GigabitEthernet 0/{} hostname {}".format\
311-
(address.get('dhcp_client'),address.get('dhcp_hostname'))
311+
cmd = "ip address dhcp client-id GigabitEthernet 0/{} hostname {}".\
312+
format(address.get('dhcp_client'), address.get('dhcp_hostname'))
312313
elif address.get('dhcp_client') and not address.get('dhcp_hostname'):
313-
cmd = "ip address dhcp client-id GigabitEthernet 0/{}".format(address.get('dhcp_client'))
314+
cmd = "ip address dhcp client-id GigabitEthernet 0/{}".\
315+
format(address.get('dhcp_client'))
314316
elif not address.get('dhcp_client') and address.get('dhcp_hostname'):
315317
cmd = "ip address dhcp hostname {}".format(address.get('dhcp_client'))
316318

317319
L3_Interfaces._add_command_to_interface(interface, cmd, commands)
318320

319321
# To handle L3 IPV6 configuration
320-
want_ipv6 = set(tuple({k:v for k,v in iteritems(address) if v is not None}.items()) for address in want.get("ipv6") or [])
322+
want_ipv6 = set(tuple({k: v for k, v in iteritems(address) if v is not None}.items())
323+
for address in want.get("ipv6") or [])
321324
have_ipv6 = set(tuple(address.items()) for address in have.get("ipv6") or [])
322325
diff = want_ipv6 - have_ipv6
323326
for address in diff:

module_utils/ios/facts/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from ansible.module_utils.six import iteritems
1313

1414

15-
class FactsBase(object): #pylint: disable=R0205
15+
class FactsBase(object):
1616
"""
1717
The ios facts base class
1818
"""
@@ -102,5 +102,5 @@ def generate_final_config(cfg_dict):
102102

103103
for key, val in iteritems(cfg_dict):
104104
if val:
105-
final_cfg.update({key:val})
105+
final_cfg.update({key: val})
106106
return final_cfg

module_utils/ios/facts/facts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
FACT_SUBSETS = {}
2121

2222

23-
class Facts(FactsArgs, FactsBase): #pylint: disable=R0903
23+
class Facts(FactsArgs, FactsBase):
2424
""" The fact class for ios l3 interface
2525
"""
2626

module_utils/ios/facts/l3_interfaces/l3_interfaces.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from ansible.module_utils.ios.facts.base import FactsBase
1616
from ansible.module_utils.ios.utils.utils import get_interface_type, normalize_interface
17-
import q
17+
1818

1919
class L3_interfacesFacts(FactsBase):
2020
""" The ios l3 interfaces fact class
@@ -54,7 +54,6 @@ def render_config(self, spec, conf):
5454
:rtype: dictionary
5555
:returns: The generated config
5656
"""
57-
import q
5857
config = deepcopy(spec)
5958
match = re.search(r'^(\S+)', conf)
6059
intf = match.group(1)
@@ -70,6 +69,7 @@ def render_config(self, spec, conf):
7069
each_ipv4 = dict()
7170
if 'secondary' not in each and 'dhcp' not in each:
7271
each_ipv4['address'] = each
72+
each_ipv4['secondary'] = False
7373
elif 'secondary' in each:
7474
each_ipv4['secondary'] = True
7575
each_ipv4['address'] = each.split(' secondary')[0]

0 commit comments

Comments
 (0)