-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathbrocade_fibrechannel_logical_switch_fibrechannel_logical_switch.py
168 lines (133 loc) · 4.95 KB
/
brocade_fibrechannel_logical_switch_fibrechannel_logical_switch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/usr/bin/python
# Copyright 2019-2025 Broadcom. All rights reserved.
# The term 'Broadcom' refers to Broadcom Inc. and/or its subsidiaries.
# 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
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'certified'}
DOCUMENTATION = '''
module: brocade_fibrechannel_logical_switch_fibrechannel_logical_switch
short_description: Brocade Logical Switch Configuration
version_added: '2.7'
author: Broadcom BSN Ansible Team <[email protected]>
description:
- Update logging audit configuration.
options:
credential:
description:
- login information including
fos_ip_addr - ip address of the FOS switch
fos_user_name - login name of FOS switch REST API
fos_password - password of FOS switch REST API
https - True for HTTPS, self for self-signed HTTPS, or False for HTTP
type: dict
required: true
vfid:
description:
- vfid of the switch to target. The value can be -1 for
FOS without VF enabled. For VF enabled FOS, a valid vfid
should be given
required: false
throttle:
description:
- rest throttling delay in seconds to retry once more if
server is busy.
required: false
timeout:
description:
- rest timeout in seconds for operations taking longer than
default timeout.
required: false
all_entries:
description:
- Boolean to indicate if the entries specified are full
list of objects or not. By default, all_entries are
thought to be true if not specified. If all_entries
is set to true, the entries is used to calculate the change
of existing entryies, addition, and deletion. If
all_entries is set to false, the entries is used to
calculate the change of existing entries and addition
of entries only. i.e. the module will not attempt to
delete objects that do not show up in the entries.
required: false
logical_switches:
description:
- list of logical switch data structure
All writable attributes supported
by BSN REST API with - replaced with _.
All of non-default switches are required. No default switch data should
be present.
required: true
'''
EXAMPLES = """
gather_facts: False
vars:
credential:
fos_ip_addr: "{{fos_ip_addr}}"
fos_user_name: admin
fos_password: xxxx
https: False
tasks:
- name: initial logical switch configuration
brocade_fibrechannel_logical_switch_fibrechannel_logical_switch:
credential: "{{credential}}"
vfid: -1
logical_switches:
- fabric_id: 1
base_switch_enabled: 0
ficon_mode_enabled: 0
logical_isl_enabled: 1
port_member_list:
port_member:
- "0/1"
- "0/2"
"""
RETURN = """
msg:
description: Success message
returned: success
type: str
"""
"""
Brocade Fibre Channel Logical Switch Configuration
"""
from ansible.module_utils.brocade_objects import list_helper
from ansible.module_utils.basic import AnsibleModule
def main():
"""
Main function
"""
argument_spec = dict(
credential=dict(required=True, type='dict', options=dict(
fos_ip_addr=dict(required=True, type='str'),
fos_user_name=dict(required=True, type='str'),
fos_password=dict(required=True, type='str', no_log=True),
https=dict(required=True, type='str'),
ssh_hostkeymust=dict(required=False, type='bool'))),
vfid=dict(required=False, type='int'),
throttle=dict(required=False, type='int'),
timeout=dict(required=False, type='int'),
all_entries=dict(required=False, type='bool'),
logical_switches=dict(required=True, type='list'))
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True
)
input_params = module.params
# Set up state variables
fos_ip_addr = input_params['credential']['fos_ip_addr']
fos_user_name = input_params['credential']['fos_user_name']
fos_password = input_params['credential']['fos_password']
https = input_params['credential']['https']
throttle = input_params['throttle']
timeout = input_params['timeout']
all_entries = input_params['all_entries']
vfid = input_params['vfid']
logical_switches = input_params['logical_switches']
result = {"changed": False}
list_helper(module, fos_ip_addr, fos_user_name, fos_password, https, True, throttle, vfid, "brocade_fibrechannel_logical_switch", "fibrechannel_logical_switch", logical_switches, all_entries, result, timeout)
if __name__ == '__main__':
main()