Debian Codegraph @

ansible_collections/community/vmware/plugins/modules/vmware_host_tcpip_stacks.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2021, sky-joker
5 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
6 # SPDX-License-Identifier: GPL-3.0-or-later
7
8 from __future__ import absolute_import, division, print_function
9 __metaclass__ = type
10
11 DOCUMENTATION = r'''
12 ---
13 module: vmware_host_tcpip_stacks
14 short_description: Manage the TCP/IP Stacks configuration of ESXi host
15 author:
16 - sky-joker (@sky-joker)
17 description:
18 - This module can be used to modify the TCP/IP stacks configuration.
19 options:
20 esxi_hostname:
21 description:
22 - Name of the ESXi host.
23 type: str
24 required: true
25 default:
26 description:
27 - The TCP/IP stacks configuration of the I(default).
28 suboptions:
29 hostname:
30 description:
31 - The host name of the ESXi host.
32 type: str
33 required: true
34 domain:
35 description:
36 - The domain name portion of the DNS name.
37 type: str
38 required: true
39 preferred_dns:
40 description:
41 - The IP address of the preferred dns server.
42 type: str
43 alternate_dns:
44 description:
45 - The IP address of the alternate dns server.
46 type: str
47 search_domains:
48 description:
49 - The domain in which to search for hosts, placed in order of preference.
50 default: []
51 elements: str
52 type: list
53 gateway:
54 description:
55 - The ipv4 gateway address.
56 type: str
57 ipv6_gateway:
58 description:
59 - The ipv6 gateway address.
60 type: str
61 congestion_algorithm:
62 description:
63 - The TCP congest control algorithm.
64 choices:
65 - newreno
66 - cubic
67 default: newreno
68 type: str
69 max_num_connections:
70 description:
71 - The maximum number of socket connection that are requested.
72 default: 11000
73 type: int
74 type: dict
75 provisioning:
76 description:
77 - The TCP/IP stacks configuration of the I(provisioning).
78 suboptions:
79 gateway:
80 description:
81 - The ipv4 gateway address.
82 type: str
83 ipv6_gateway:
84 description:
85 - The ipv6 gateway address.
86 type: str
87 congestion_algorithm:
88 description:
89 - The TCP congest control algorithm.
90 choices:
91 - newreno
92 - cubic
93 default: newreno
94 type: str
95 max_num_connections:
96 description:
97 - The maximum number of socket connection that are requested.
98 default: 11000
99 type: int
100 type: dict
101 vmotion:
102 description:
103 - The TCP/IP stacks configuration of the I(vmotion).
104 suboptions:
105 gateway:
106 description:
107 - The ipv4 gateway address.
108 type: str
109 ipv6_gateway:
110 description:
111 - The ipv6 gateway address.
112 type: str
113 congestion_algorithm:
114 description:
115 - The TCP congest control algorithm.
116 choices:
117 - newreno
118 - cubic
119 default: newreno
120 type: str
121 max_num_connections:
122 description:
123 - The maximum number of socket connection that are requested.
124 default: 11000
125 type: int
126 type: dict
127 vxlan:
128 description:
129 - The TCP/IP stacks configuration of the I(vxlan).
130 suboptions:
131 gateway:
132 description:
133 - The ipv4 gateway address.
134 type: str
135 ipv6_gateway:
136 description:
137 - The ipv6 gateway address.
138 type: str
139 congestion_algorithm:
140 description:
141 - The TCP congest control algorithm.
142 choices:
143 - newreno
144 - cubic
145 default: newreno
146 type: str
147 max_num_connections:
148 description:
149 - The maximum number of socket connection that are requested.
150 default: 11000
151 type: int
152 type: dict
153 aliases:
154 - nsx_overlay
155 extends_documentation_fragment:
156 - vmware.vmware.base_options
157 '''
158
159 EXAMPLES = r'''
160 - name: Update the TCP/IP stack configuration of the default
161 community.vmware.vmware_host_tcpip_stacks:
162 hostname: "{{ vcenter_hostname }}"
163 username: "{{ vcenter_username }}"
164 password: "{{ vcenter_password }}"
165 validate_certs: false
166 esxi_hostname: "{{ esxi_hostname }}"
167 default:
168 hostname: "{{ esxi_hostname }}"
169 domain: example.com
170 preferred_dns: 192.168.10.1
171 alternate_dns: 192.168.20.1
172 search_domains:
173 - hoge.com
174 - fuga.com
175 gateway: 192.168.10.1
176 congestion_algorithm: cubic
177 max_num_connections: 12000
178
179 - name: Update the TCP/IP stack configuration of the provisioning
180 community.vmware.vmware_host_tcpip_stacks:
181 hostname: "{{ vcenter_hostname }}"
182 username: "{{ vcenter_username }}"
183 password: "{{ vcenter_password }}"
184 validate_certs: false
185 esxi_hostname: "{{ esxi_hostname }}"
186 provisioning:
187 congestion_algorithm: newreno
188 max_num_connections: 12000
189 gateway: 10.10.10.254
190
191 - name: Update the TCP/IP stack configuration of the default and provisioning
192 community.vmware.vmware_host_tcpip_stacks:
193 hostname: "{{ vcenter_hostname }}"
194 username: "{{ vcenter_username }}"
195 password: "{{ vcenter_password }}"
196 validate_certs: false
197 esxi_hostname: "{{ esxi_hostname }}"
198 default:
199 hostname: "{{ esxi_hostname }}"
200 domain: example.com
201 preferred_dns: 192.168.10.1
202 alternate_dns: 192.168.20.1
203 search_domains:
204 - hoge.com
205 - fuga.com
206 gateway: 192.168.10.1
207 congestion_algorithm: cubic
208 max_num_connections: 12000
209 provisioning:
210 congestion_algorithm: newreno
211 max_num_connections: 12000
212 gateway: 10.10.10.254
213
214 - name: Update the ipv6 gateway of the provisioning TCP/IP stack
215 community.vmware.vmware_host_tcpip_stacks:
216 hostname: "{{ vcenter_hostname }}"
217 username: "{{ vcenter_username }}"
218 password: "{{ vcenter_password }}"
219 validate_certs: false
220 esxi_hostname: "{{ esxi_hostname }}"
221 provisioning:
222 ipv6_gateway: ::ffff:6440:301
223 '''
224
225 RETURN = r'''
226 default:
227 description: dict of the TCP/IP stack configuration of the default.
228 returned: always
229 type: dict
230 sample: >-
231 {
232 "alternate_dns": "192.168.20.1",
233 "congestion_algorithm": "cubic",
234 "domain": "example.com",
235 "gateway": "192.168.10.1",
236 "ipv6_gateway", null,
237 "hostname": "esxi-test03",
238 "max_num_connections": 12000,
239 "preferred_dns": "192.168.10.1",
240 "search_domains": [
241 "hoge.com",
242 "fuga.com"
243 ]
244 }
245 provisioning:
246 description: dict of the TCP/IP stack configuration of the provisioning.
247 returned: always
248 type: dict
249 sample: >-
250 {
251 "congestion_algorithm": "newreno",
252 "gateway": "10.10.10.254",
253 "ipv6_gateway": null,
254 "max_num_connections": 12000
255 }
256 vmotion:
257 description: dict of the TCP/IP stack configuration of the vmotion.
258 returned: always
259 type: dict
260 sample: >-
261 {
262 "congestion_algorithm": "newreno",
263 "gateway": null,
264 "ipv6_gateway": null,
265 "max_num_connections": 11000
266 }
267 vxlan:
268 description: dict of the TCP/IP stack configuration of the vxlan.
269 returned: always
270 type: dict
271 sample: >-
272 {
273 "congestion_algorithm": "newreno",
274 "gateway": null,
275 "ipv6_gateway": null,
276 "max_num_connections": 11000
277 }
278 '''
279
280 try:
281 from pyVmomi import vim
282 except ImportError:
283 pass
284
285 try:
286 from collections import OrderedDict
287 except ImportError:
288 try:
289 from ordereddict import OrderedDict
290 except ImportError:
291 pass
292
293 from ansible.module_utils.basic import AnsibleModule
294 from ansible.module_utils.common.text.converters import to_text
295 from ansible_collections.community.vmware.plugins.module_utils.vmware import PyVmomi
296 from ansible_collections.vmware.vmware.plugins.module_utils.argument_spec import base_argument_spec
297
298
299 class VmwareHostTcpipStack(PyVmomi):
300 def __init__(self, module):
301 super(VmwareHostTcpipStack, self).__init__(module)
302 self.esxi_hostname = self.params['esxi_hostname']
303 self.default = self.params['default']
304 self.provisioning = self.params['provisioning']
305 self.vmotion = self.params['vmotion']
306 self.vxlan = self.params['vxlan']
307
308 self.net_stack_instance_keys = {
309 "default": "defaultTcpipStack",
310 "vmotion": "vmotion",
311 "provisioning": "vSphereProvisioning",
312 "vxlan": "vxlan"
313 }
314
315 def check_enabled_net_stack_instance(self):
316 """
317 Make sure if enabled each the tcpip stack item in ESXi host.
318 """
319 self.enabled_net_stack_instance = {
320 "default": False,
321 "vmotion": False,
322 "provisioning": False,
323 "vxlan": False
324 }
325 for net_stack_instance in self.host_obj.runtime.networkRuntimeInfo.netStackInstanceRuntimeInfo:
326 if net_stack_instance.netStackInstanceKey == self.net_stack_instance_keys['default']:
327 self.enabled_net_stack_instance['default'] = True
328
329 if net_stack_instance.netStackInstanceKey == self.net_stack_instance_keys['provisioning']:
330 self.enabled_net_stack_instance['provisioning'] = True
331
332 if net_stack_instance.netStackInstanceKey == self.net_stack_instance_keys['vmotion']:
333 self.enabled_net_stack_instance['vmotion'] = True
334
335 if net_stack_instance.netStackInstanceKey == self.net_stack_instance_keys['vxlan']:
336 self.enabled_net_stack_instance['vxlan'] = True
337
338 def get_net_stack_instance_config(self):
339 """
340 Get a configuration of tcpip stack item if it is enabled.
341 """
342 self.exist_net_stack_instance_config = {}
343 for key, value in self.enabled_net_stack_instance.items():
344 if value is True:
345 for net_stack_instance in self.host_obj.config.network.netStackInstance:
346 if net_stack_instance.key == self.net_stack_instance_keys[key]:
347 self.exist_net_stack_instance_config[key] = net_stack_instance
348
349 def diff_net_stack_instance_config(self):
350 """
351 Check the difference between a new and existing config.
352 """
353 self.change_flag = False
354
355 # Make the diff_config variable to check the difference between a new and existing config.
356 self.diff_config = dict(before={}, after={})
357 for key, value in self.enabled_net_stack_instance.items():
358 if value is True:
359 self.diff_config['before'][key] = {}
360 self.diff_config['after'][key] = {}
361
362 if self.enabled_net_stack_instance['default']:
363 exist_dns_servers = self.exist_net_stack_instance_config['default'].dnsConfig.address
364 for key in 'before', 'after':
365 self.diff_config[key]['default'] = dict(
366 hostname=self.exist_net_stack_instance_config['default'].dnsConfig.hostName,
367 domain=self.exist_net_stack_instance_config['default'].dnsConfig.domainName,
368 preferred_dns=exist_dns_servers[0] if [dns for dns in exist_dns_servers if exist_dns_servers.index(dns) == 0] else None,
369 alternate_dns=exist_dns_servers[1] if [dns for dns in exist_dns_servers if exist_dns_servers.index(dns) == 1] else None,
370 search_domains=self.exist_net_stack_instance_config['default'].dnsConfig.searchDomain,
371 gateway=self.exist_net_stack_instance_config['default'].ipRouteConfig.defaultGateway,
372 ipv6_gateway=self.exist_net_stack_instance_config['default'].ipRouteConfig.ipV6DefaultGateway,
373 congestion_algorithm=self.exist_net_stack_instance_config['default'].congestionControlAlgorithm,
374 max_num_connections=self.exist_net_stack_instance_config['default'].requestedMaxNumberOfConnections
375 )
376 if self.default:
377 if self.diff_config['before']['default']['hostname'] != self.default['hostname']:
378 self.change_flag = True
379 self.diff_config['after']['default']['hostname'] = self.default['hostname']
380 if self.diff_config['before']['default']['domain'] != self.default['domain']:
381 self.change_flag = True
382 self.diff_config['after']['default']['domain'] = self.default['domain']
383 if self.diff_config['before']['default']['preferred_dns'] != self.default['preferred_dns']:
384 self.change_flag = True
385 self.diff_config['after']['default']['preferred_dns'] = self.default['preferred_dns']
386 if self.diff_config['before']['default']['alternate_dns'] != self.default['alternate_dns']:
387 self.change_flag = True
388 self.diff_config['after']['default']['alternate_dns'] = self.default['alternate_dns']
389 if self.diff_config['before']['default']['search_domains'] != self.default['search_domains']:
390 self.change_flag = True
391 self.diff_config['after']['default']['search_domains'] = self.default['search_domains']
392 if self.diff_config['before']['default']['gateway'] != self.default['gateway']:
393 self.change_flag = True
394 self.diff_config['after']['default']['gateway'] = self.default['gateway']
395 if self.diff_config['before']['default']['ipv6_gateway'] != self.default['ipv6_gateway']:
396 self.change_flag = True
397 self.diff_config['after']['default']['ipv6_gateway'] = self.default['ipv6_gateway']
398 if self.diff_config['before']['default']['congestion_algorithm'] != self.default['congestion_algorithm']:
399 self.change_flag = True
400 self.diff_config['after']['default']['congestion_algorithm'] = self.default['congestion_algorithm']
401 if self.diff_config['before']['default']['max_num_connections'] != self.default['max_num_connections']:
402 self.change_flag = True
403 self.diff_config['after']['default']['max_num_connections'] = self.default['max_num_connections']
404
405 if self.enabled_net_stack_instance['provisioning']:
406 for key in 'before', 'after':
407 self.diff_config[key]['provisioning'] = dict(
408 gateway=self.exist_net_stack_instance_config['provisioning'].ipRouteConfig.defaultGateway,
409 ipv6_gateway=self.exist_net_stack_instance_config['provisioning'].ipRouteConfig.ipV6DefaultGateway,
410 congestion_algorithm=self.exist_net_stack_instance_config['provisioning'].congestionControlAlgorithm,
411 max_num_connections=self.exist_net_stack_instance_config['provisioning'].requestedMaxNumberOfConnections
412 )
413 if self.provisioning:
414 if self.diff_config['before']['provisioning']['gateway'] != self.provisioning['gateway']:
415 self.change_flag = True
416 self.diff_config['after']['provisioning']['gateway'] = self.provisioning['gateway']
417 if self.diff_config['before']['provisioning']['ipv6_gateway'] != self.provisioning['ipv6_gateway']:
418 self.change_flag = True
419 self.diff_config['after']['provisioning']['ipv6_gateway'] = self.provisioning['ipv6_gateway']
420 if self.diff_config['before']['provisioning']['max_num_connections'] != self.provisioning['max_num_connections']:
421 self.change_flag = True
422 self.diff_config['after']['provisioning']['max_num_connections'] = self.provisioning['max_num_connections']
423 if self.diff_config['before']['provisioning']['congestion_algorithm'] != self.provisioning['congestion_algorithm']:
424 self.change_flag = True
425 self.diff_config['after']['provisioning']['congestion_algorithm'] = self.provisioning['congestion_algorithm']
426
427 if self.enabled_net_stack_instance['vmotion']:
428 for key in 'before', 'after':
429 self.diff_config[key]['vmotion'] = dict(
430 gateway=self.exist_net_stack_instance_config['vmotion'].ipRouteConfig.defaultGateway,
431 ipv6_gateway=self.exist_net_stack_instance_config['vmotion'].ipRouteConfig.ipV6DefaultGateway,
432 congestion_algorithm=self.exist_net_stack_instance_config['vmotion'].congestionControlAlgorithm,
433 max_num_connections=self.exist_net_stack_instance_config['vmotion'].requestedMaxNumberOfConnections
434 )
435 if self.vmotion:
436 if self.diff_config['before']['vmotion']['gateway'] != self.vmotion['gateway']:
437 self.change_flag = True
438 self.diff_config['after']['vmotion']['gateway'] = self.vmotion['gateway']
439 if self.diff_config['before']['vmotion']['ipv6_gateway'] != self.vmotion['ipv6_gateway']:
440 self.change_flag = True
441 self.diff_config['after']['vmotion']['ipv6_gateway'] = self.vmotion['ipv6_gateway']
442 if self.diff_config['before']['vmotion']['max_num_connections'] != self.vmotion['max_num_connections']:
443 self.change_flag = True
444 self.diff_config['after']['vmotion']['max_num_connections'] = self.vmotion['max_num_connections']
445 if self.diff_config['before']['vmotion']['congestion_algorithm'] != self.vmotion['congestion_algorithm']:
446 self.change_flag = True
447 self.diff_config['after']['vmotion']['congestion_algorithm'] = self.vmotion['congestion_algorithm']
448
449 if self.enabled_net_stack_instance['vxlan']:
450 for key in 'before', 'after':
451 self.diff_config[key]['vxlan'] = dict(
452 gateway=self.exist_net_stack_instance_config['vxlan'].ipRouteConfig.defaultGateway,
453 ipv6_gateway=self.exist_net_stack_instance_config['vxlan'].ipRouteConfig.ipV6DefaultGateway,
454 congestion_algorithm=self.exist_net_stack_instance_config['vxlan'].congestionControlAlgorithm,
455 max_num_connections=self.exist_net_stack_instance_config['vxlan'].requestedMaxNumberOfConnections
456 )
457 if self.vxlan:
458 if self.diff_config['before']['vxlan']['gateway'] != self.vxlan['gateway']:
459 self.change_flag = True
460 self.diff_config['after']['vxlan']['gateway'] = self.vxlan['gateway']
461 if self.diff_config['before']['vxlan']['ipv6_gateway'] != self.vxlan['ipv6_gateway']:
462 self.change_flag = True
463 self.diff_config['after']['vxlan']['ipv6_gateway'] = self.vxlan['ipv6_gateway']
464 if self.diff_config['before']['vxlan']['max_num_connections'] != self.vxlan['max_num_connections']:
465 self.change_flag = True
466 self.diff_config['after']['vxlan']['max_num_connections'] = self.vxlan['max_num_connections']
467 if self.diff_config['before']['vxlan']['congestion_algorithm'] != self.vxlan['congestion_algorithm']:
468 self.change_flag = True
469 self.diff_config['after']['vxlan']['congestion_algorithm'] = self.vxlan['congestion_algorithm']
470
471 def generate_net_stack_instance_config(self):
472 """
473 Generate a new configuration for tcpip stack to modify the configuration.
474 """
475 self.new_net_stack_instance_configs = vim.host.NetworkConfig()
476 self.new_net_stack_instance_configs.netStackSpec = []
477
478 if self.default and self.enabled_net_stack_instance['default']:
479 default_config = vim.host.NetworkConfig.NetStackSpec()
480 default_config.operation = 'edit'
481 default_config.netStackInstance = vim.host.NetStackInstance()
482 default_config.netStackInstance.key = self.net_stack_instance_keys['default']
483 default_config.netStackInstance.ipRouteConfig = vim.host.IpRouteConfig()
484 default_config.netStackInstance.ipRouteConfig.defaultGateway = self.default['gateway']
485 default_config.netStackInstance.ipRouteConfig.ipV6DefaultGateway = self.default['ipv6_gateway']
486 default_config.netStackInstance.dnsConfig = vim.host.DnsConfig()
487 default_config.netStackInstance.dnsConfig.hostName = self.default['hostname']
488 default_config.netStackInstance.dnsConfig.domainName = self.default['domain']
489 dns_servers = []
490 if self.default['preferred_dns']:
491 dns_servers.append(self.default['preferred_dns'])
492 if self.default['alternate_dns']:
493 dns_servers.append(self.default['alternate_dns'])
494 default_config.netStackInstance.dnsConfig.address = dns_servers
495 default_config.netStackInstance.dnsConfig.searchDomain = self.default['search_domains']
496 default_config.netStackInstance.congestionControlAlgorithm = self.default['congestion_algorithm']
497 default_config.netStackInstance.requestedMaxNumberOfConnections = self.default['max_num_connections']
498 self.new_net_stack_instance_configs.netStackSpec.append(default_config)
499
500 if self.provisioning and self.enabled_net_stack_instance['provisioning']:
501 provisioning_config = vim.host.NetworkConfig.NetStackSpec()
502 provisioning_config.operation = 'edit'
503 provisioning_config.netStackInstance = vim.host.NetStackInstance()
504 provisioning_config.netStackInstance.key = self.net_stack_instance_keys['provisioning']
505 provisioning_config.netStackInstance.ipRouteConfig = vim.host.IpRouteConfig()
506 provisioning_config.netStackInstance.ipRouteConfig.defaultGateway = self.provisioning['gateway']
507 provisioning_config.netStackInstance.ipRouteConfig.ipV6DefaultGateway = self.provisioning['ipv6_gateway']
508 provisioning_config.netStackInstance.congestionControlAlgorithm = self.provisioning['congestion_algorithm']
509 provisioning_config.netStackInstance.requestedMaxNumberOfConnections = self.provisioning['max_num_connections']
510 self.new_net_stack_instance_configs.netStackSpec.append(provisioning_config)
511
512 if self.vmotion and self.enabled_net_stack_instance['vmotion']:
513 vmotion_config = vim.host.NetworkConfig.NetStackSpec()
514 vmotion_config.operation = 'edit'
515 vmotion_config.netStackInstance = vim.host.NetStackInstance()
516 vmotion_config.netStackInstance.key = self.net_stack_instance_keys['vmotion']
517 vmotion_config.netStackInstance.ipRouteConfig = vim.host.IpRouteConfig()
518 vmotion_config.netStackInstance.ipRouteConfig.defaultGateway = self.vmotion['gateway']
519 vmotion_config.netStackInstance.ipRouteConfig.ipV6DefaultGateway = self.vmotion['ipv6_gateway']
520 vmotion_config.netStackInstance.congestionControlAlgorithm = self.vmotion['congestion_algorithm']
521 vmotion_config.netStackInstance.requestedMaxNumberOfConnections = self.vmotion['max_num_connections']
522 self.new_net_stack_instance_configs.netStackSpec.append(vmotion_config)
523
524 if self.vxlan and self.enabled_net_stack_instance['vxlan']:
525 vxlan_config = vim.host.NetworkConfig.NetStackSpec()
526 vxlan_config.operation = 'edit'
527 vxlan_config.netStackInstance = vim.host.NetStackInstance()
528 vxlan_config.netStackInstance.key = self.net_stack_instance_keys['vxlan']
529 vxlan_config.netStackInstance.ipRouteConfig = vim.host.IpRouteConfig()
530 vxlan_config.netStackInstance.ipRouteConfig.defaultGateway = self.vxlan['gateway']
531 vxlan_config.netStackInstance.ipRouteConfig.ipV6DefaultGateway = self.vxlan['ipv6_gateway']
532 vxlan_config.netStackInstance.congestionControlAlgorithm = self.vxlan['congestion_algorithm']
533 vxlan_config.netStackInstance.requestedMaxNumberOfConnections = self.vxlan['max_num_connections']
534 self.new_net_stack_instance_configs.netStackSpec.append(vxlan_config)
535
536 def execute(self):
537 # The host name is unique in vCenter, so find the host from the whole.
538 self.host_obj = self.find_hostsystem_by_name(self.esxi_hostname)
539 if self.host_obj is None:
540 self.module.fail_json(msg="Cannot find the specified ESXi host: %s" % self.params['esxi_hostname'])
541
542 self.check_enabled_net_stack_instance()
543 self.get_net_stack_instance_config()
544 self.diff_net_stack_instance_config()
545 if self.change_flag:
546 if self.module.check_mode is False:
547 self.generate_net_stack_instance_config()
548 try:
549 self.host_obj.configManager.networkSystem.UpdateNetworkConfig(self.new_net_stack_instance_configs, 'modify')
550 except vim.fault.PlatformConfigFault as e:
551 self.module.fail_json(msg="cannot modify tcpip stack config: %s" % to_text(e.faultMessage[0].message))
552 except Exception as e:
553 self.module.fail_json(msg="cannot modify tcpip stack config: %s" % to_text(e.msg))
554
555 # Make a warning for the item if it isn't supported by ESXi when specified item.
556 for key, value in self.enabled_net_stack_instance.items():
557 if self.params[key] and value is False:
558 self.module.warn("%s isn't supported in %s" % (key, self.params['esxi_hostname']))
559
560 # Make the return value for the result.
561 result = dict(
562 changed=self.change_flag,
563 diff=dict(
564 before=OrderedDict(sorted(self.diff_config['before'].items())),
565 after=OrderedDict(sorted(self.diff_config['after'].items()))
566 )
567 )
568 for key, value in self.enabled_net_stack_instance.items():
569 if value:
570 result[key] = self.diff_config['after'][key]
571 else:
572 result[key] = {}
573 self.module.exit_json(**result)
574
575
576 def main():
577 argument_spec = base_argument_spec()
578 argument_spec.update(
579 esxi_hostname=dict(type='str', required=True),
580 default=dict(type='dict',
581 options=dict(
582 hostname=dict(type='str', required=True),
583 domain=dict(type='str', required=True),
584 preferred_dns=dict(type='str'),
585 alternate_dns=dict(type='str'),
586 search_domains=dict(type='list', elements='str', default=[]),
587 gateway=dict(type='str'),
588 ipv6_gateway=dict(type='str'),
589 congestion_algorithm=dict(type='str', choices=['newreno', 'cubic'], default='newreno'),
590 max_num_connections=dict(type='int', default=11000)
591
592 )),
593 provisioning=dict(type='dict',
594 options=dict(
595 gateway=dict(type='str'),
596 ipv6_gateway=dict(type='str'),
597 congestion_algorithm=dict(type='str', choices=['newreno', 'cubic'], default='newreno'),
598 max_num_connections=dict(type='int', default=11000)
599 )),
600 vmotion=dict(type='dict',
601 options=dict(
602 gateway=dict(type='str'),
603 ipv6_gateway=dict(type='str'),
604 congestion_algorithm=dict(type='str', choices=['newreno', 'cubic'], default='newreno'),
605 max_num_connections=dict(type='int', default=11000)
606 )),
607 vxlan=dict(type='dict',
608 aliases=['nsx_overlay'],
609 options=dict(
610 gateway=dict(type='str'),
611 ipv6_gateway=dict(type='str'),
612 congestion_algorithm=dict(type='str', choices=['newreno', 'cubic'], default='newreno'),
613 max_num_connections=dict(type='int', default=11000)
614 ))
615 )
616
617 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
618
619 vmware_host_tcpip_stack = VmwareHostTcpipStack(module)
620 vmware_host_tcpip_stack.execute()
621
622
623 if __name__ == "__main__":
624 main()