update ce_vrrp to fix a bug (#59185)

* update ce_vrrp to fix a bug

* update module ce_vrrp 20190718

* update ce_vrrp to fix bugs
This commit is contained in:
yanzhangi 2019-07-19 09:33:19 +08:00 committed by ansibot
parent 87601969a3
commit e7c9c9585e

View file

@ -44,12 +44,13 @@ options:
vrrp_type: vrrp_type:
description: description:
- Type of a VRRP backup group. - Type of a VRRP backup group.
type: str
choices: ['normal', 'member', 'admin'] choices: ['normal', 'member', 'admin']
admin_ignore_if_down: admin_ignore_if_down:
description: description:
- mVRRP ignores an interface Down event. - mVRRP ignores an interface Down event.
type: bool type: str
default: 'no' choices: ['true','false']
admin_vrid: admin_vrid:
description: description:
- Tracked mVRRP ID. The value is an integer ranging from 1 to 255. - Tracked mVRRP ID. The value is an integer ranging from 1 to 255.
@ -59,8 +60,8 @@ options:
admin_flowdown: admin_flowdown:
description: description:
- Disable the flowdown function for service VRRP. - Disable the flowdown function for service VRRP.
type: bool type: str
default: 'no' choices: ['true','false']
priority: priority:
description: description:
- Configured VRRP priority. - Configured VRRP priority.
@ -68,6 +69,7 @@ options:
version: version:
description: description:
- VRRP version. The default version is v2. - VRRP version. The default version is v2.
type: str
choices: ['v2','v3'] choices: ['v2','v3']
advertise_interval: advertise_interval:
description: description:
@ -95,13 +97,14 @@ options:
- Authentication type used for VRRP packet exchanges between virtual routers. - Authentication type used for VRRP packet exchanges between virtual routers.
The values are noAuthentication, simpleTextPassword, md5Authentication. The values are noAuthentication, simpleTextPassword, md5Authentication.
The default value is noAuthentication. The default value is noAuthentication.
type: str
choices: ['simple','md5','none'] choices: ['simple','md5','none']
is_plain: is_plain:
description: description:
- Select the display mode of an authentication key. - Select the display mode of an authentication key.
By default, an authentication key is displayed in ciphertext. By default, an authentication key is displayed in ciphertext.
type: bool type: str
default: 'no' choices: ['true','false']
auth_key: auth_key:
description: description:
- This object is set based on the authentication type. - This object is set based on the authentication type.
@ -111,10 +114,12 @@ options:
fast_resume: fast_resume:
description: description:
- mVRRP's fast resume mode. - mVRRP's fast resume mode.
type: str
choices: ['enable','disable'] choices: ['enable','disable']
state: state:
description: description:
- Specify desired state of the resource. - Specify desired state of the resource.
type: str
default: present default: present
choices: ['present','absent'] choices: ['present','absent']
@ -697,7 +702,7 @@ class Vrrp(object):
if self.vrrp_group_info["vrrpType"] != self.vrrp_type: if self.vrrp_group_info["vrrpType"] != self.vrrp_type:
return True return True
if self.admin_ignore_if_down: if self.admin_ignore_if_down:
if self.vrrp_group_info["adminIgnoreIfDown"] != str(self.admin_ignore_if_down).lower(): if self.vrrp_group_info["adminIgnoreIfDown"] != self.admin_ignore_if_down:
return True return True
if self.admin_vrid: if self.admin_vrid:
if self.vrrp_group_info["adminVrrpId"] != self.admin_vrid: if self.vrrp_group_info["adminVrrpId"] != self.admin_vrid:
@ -744,7 +749,7 @@ class Vrrp(object):
if self.vrrp_group_info["vrrpType"] != self.vrrp_type: if self.vrrp_group_info["vrrpType"] != self.vrrp_type:
return False return False
if self.admin_ignore_if_down: if self.admin_ignore_if_down:
if self.vrrp_group_info["adminIgnoreIfDown"] != str(self.admin_ignore_if_down).lower(): if self.vrrp_group_info["adminIgnoreIfDown"] != self.admin_ignore_if_down:
return False return False
if self.admin_vrid: if self.admin_vrid:
if self.vrrp_group_info["adminVrrpId"] != self.admin_vrid: if self.vrrp_group_info["adminVrrpId"] != self.admin_vrid:
@ -895,19 +900,13 @@ class Vrrp(object):
conf_str += "<adminVrrpId>%s</adminVrrpId>" % self.admin_vrid conf_str += "<adminVrrpId>%s</adminVrrpId>" % self.admin_vrid
if self.admin_interface: if self.admin_interface:
conf_str += "<adminIfName>%s</adminIfName>" % self.admin_interface conf_str += "<adminIfName>%s</adminIfName>" % self.admin_interface
if self.admin_flowdown is True or self.admin_flowdown is False: if self.admin_flowdown:
admin_flowdown = "false" conf_str += "<unflowdown>%s</unflowdown>" % self.admin_flowdown
if self.admin_flowdown is True:
admin_flowdown = "true"
conf_str += "<unflowdown>%s</unflowdown>" % admin_flowdown
if self.priority: if self.priority:
conf_str += "<priority>%s</priority>" % self.priority conf_str += "<priority>%s</priority>" % self.priority
if self.vrrp_type == "admin": if self.vrrp_type == "admin":
if self.admin_ignore_if_down is True or self.admin_ignore_if_down is False: if self.admin_ignore_if_down:
admin_ignore_if_down = "false" conf_str += "<adminIgnoreIfDown>%s</adminIgnoreIfDown>" % self.admin_ignore_if_down
if self.admin_ignore_if_down is True:
admin_ignore_if_down = "true"
conf_str += "<adminIgnoreIfDown>%s</adminIgnoreIfDown>" % admin_ignore_if_down
if self.fast_resume: if self.fast_resume:
fast_resume = "false" fast_resume = "false"
if self.fast_resume == "enable": if self.fast_resume == "enable":
@ -924,10 +923,7 @@ class Vrrp(object):
if self.auth_key: if self.auth_key:
conf_str += "<authenticationKey>%s</authenticationKey>" % self.auth_key conf_str += "<authenticationKey>%s</authenticationKey>" % self.auth_key
if self.auth_mode == "simple": if self.auth_mode == "simple":
is_plain = "false" conf_str += "<isPlain>%s</isPlain>" % self.is_plain
if self.is_plain is True:
is_plain = "true"
conf_str += "<isPlain>%s</isPlain>" % is_plain
conf_str += CE_NC_SET_VRRP_GROUP_INFO_TAIL conf_str += CE_NC_SET_VRRP_GROUP_INFO_TAIL
recv_xml = set_nc_config(self.module, conf_str) recv_xml = set_nc_config(self.module, conf_str)
@ -937,7 +933,7 @@ class Vrrp(object):
if self.interface and self.vrid: if self.interface and self.vrid:
if self.vrrp_type == "admin": if self.vrrp_type == "admin":
if self.admin_ignore_if_down is True: if self.admin_ignore_if_down == "true":
self.updates_cmd.append( self.updates_cmd.append(
"interface %s" % self.interface) "interface %s" % self.interface)
self.updates_cmd.append( self.updates_cmd.append(
@ -978,7 +974,7 @@ class Vrrp(object):
"vrrp vrid %s holding-multiplier %s" % (self.vrid, self.holding_multiplier)) "vrrp vrid %s holding-multiplier %s" % (self.vrid, self.holding_multiplier))
if self.admin_vrid and self.admin_interface: if self.admin_vrid and self.admin_interface:
if self.admin_flowdown is True: if self.admin_flowdown == "true":
self.updates_cmd.append( self.updates_cmd.append(
"interface %s" % self.interface) "interface %s" % self.interface)
self.updates_cmd.append("vrrp vrid %s track admin-vrrp interface %s vrid %s unflowdown" % self.updates_cmd.append("vrrp vrid %s track admin-vrrp interface %s vrid %s unflowdown" %
@ -991,7 +987,7 @@ class Vrrp(object):
if self.auth_mode and self.auth_key: if self.auth_mode and self.auth_key:
if self.auth_mode == "simple": if self.auth_mode == "simple":
if self.is_plain is True: if self.is_plain == "true":
self.updates_cmd.append( self.updates_cmd.append(
"interface %s" % self.interface) "interface %s" % self.interface)
self.updates_cmd.append("vrrp vrid %s authentication-mode simple plain %s" % self.updates_cmd.append("vrrp vrid %s authentication-mode simple plain %s" %
@ -1238,7 +1234,7 @@ class Vrrp(object):
self.end_state["admin_ignore_if_down"] = self.vrrp_group_info[ self.end_state["admin_ignore_if_down"] = self.vrrp_group_info[
"adminIgnoreIfDown"] "adminIgnoreIfDown"]
if self.admin_vrid and self.admin_interface: if self.admin_vrid and self.admin_interface:
self.existing["admin_vrid"] = self.vrrp_group_info[ self.end_state["admin_vrid"] = self.vrrp_group_info[
"adminVrrpId"] "adminVrrpId"]
self.end_state["admin_interface"] = self.vrrp_group_info[ self.end_state["admin_interface"] = self.vrrp_group_info[
"adminIfName"] "adminIfName"]
@ -1265,6 +1261,8 @@ class Vrrp(object):
self.end_state["auth_mode"] = self.vrrp_group_info[ self.end_state["auth_mode"] = self.vrrp_group_info[
"authenticationMode"] "authenticationMode"]
self.end_state["is_plain"] = self.vrrp_group_info["isPlain"] self.end_state["is_plain"] = self.vrrp_group_info["isPlain"]
if self.existing == self.end_state:
self.changed = False
def work(self): def work(self):
"""worker""" """worker"""
@ -1299,7 +1297,7 @@ class Vrrp(object):
if not self.vrrp_group_info: if not self.vrrp_group_info:
self.module.fail_json( self.module.fail_json(
msg='Error: The VRRP group does not exist.') msg='Error: The VRRP group does not exist.')
if self.admin_ignore_if_down is True: if self.admin_ignore_if_down == "true":
if self.vrrp_type != "admin": if self.vrrp_type != "admin":
self.module.fail_json( self.module.fail_json(
msg='Error: vrrpType must be admin when admin_ignore_if_down is true.') msg='Error: vrrpType must be admin when admin_ignore_if_down is true.')
@ -1341,10 +1339,10 @@ def main():
vrid=dict(type='str'), vrid=dict(type='str'),
virtual_ip=dict(type='str'), virtual_ip=dict(type='str'),
vrrp_type=dict(type='str', choices=['normal', 'member', 'admin']), vrrp_type=dict(type='str', choices=['normal', 'member', 'admin']),
admin_ignore_if_down=dict(type='bool', default=False), admin_ignore_if_down=dict(type='str', choices=['true', 'false']),
admin_vrid=dict(type='str'), admin_vrid=dict(type='str'),
admin_interface=dict(type='str'), admin_interface=dict(type='str'),
admin_flowdown=dict(type='bool', default=False), admin_flowdown=dict(type='str', choices=['true', 'false']),
priority=dict(type='str'), priority=dict(type='str'),
version=dict(type='str', choices=['v2', 'v3']), version=dict(type='str', choices=['v2', 'v3']),
advertise_interval=dict(type='str'), advertise_interval=dict(type='str'),
@ -1353,7 +1351,7 @@ def main():
recover_delay=dict(type='str'), recover_delay=dict(type='str'),
holding_multiplier=dict(type='str'), holding_multiplier=dict(type='str'),
auth_mode=dict(type='str', choices=['simple', 'md5', 'none']), auth_mode=dict(type='str', choices=['simple', 'md5', 'none']),
is_plain=dict(type='bool', default=False), is_plain=dict(type='str', choices=['true', 'false']),
auth_key=dict(type='str'), auth_key=dict(type='str'),
fast_resume=dict(type='str', choices=['enable', 'disable']), fast_resume=dict(type='str', choices=['enable', 'disable']),
state=dict(type='str', default='present', state=dict(type='str', default='present',