Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ce_vrrp to fix a bug #59185

Merged
merged 3 commits into from
Jul 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 28 additions & 30 deletions lib/ansible/modules/network/cloudengine/ce_vrrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@
vrrp_type:
description:
- Type of a VRRP backup group.
type: str
choices: ['normal', 'member', 'admin']
admin_ignore_if_down:
description:
- mVRRP ignores an interface Down event.
type: bool
default: 'no'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

miss type defined.
The blow is same as this.

type: str
choices: ['true','false']
admin_vrid:
description:
- Tracked mVRRP ID. The value is an integer ranging from 1 to 255.
Expand All @@ -59,15 +60,16 @@
admin_flowdown:
description:
- Disable the flowdown function for service VRRP.
type: bool
default: 'no'
type: str
choices: ['true','false']
priority:
description:
- Configured VRRP priority.
The value ranges from 1 to 254. The default value is 100. A larger value indicates a higher priority.
version:
description:
- VRRP version. The default version is v2.
type: str
choices: ['v2','v3']
advertise_interval:
description:
Expand Down Expand Up @@ -95,13 +97,14 @@
- Authentication type used for VRRP packet exchanges between virtual routers.
The values are noAuthentication, simpleTextPassword, md5Authentication.
The default value is noAuthentication.
type: str
choices: ['simple','md5','none']
is_plain:
description:
- Select the display mode of an authentication key.
By default, an authentication key is displayed in ciphertext.
type: bool
default: 'no'
type: str
choices: ['true','false']
auth_key:
description:
- This object is set based on the authentication type.
Expand All @@ -111,10 +114,12 @@
fast_resume:
description:
- mVRRP's fast resume mode.
type: str
choices: ['enable','disable']
state:
description:
- Specify desired state of the resource.
type: str
default: present
choices: ['present','absent']

Expand Down Expand Up @@ -697,7 +702,7 @@ def is_vrrp_group_info_change(self):
if self.vrrp_group_info["vrrpType"] != self.vrrp_type:
return True
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
if self.admin_vrid:
if self.vrrp_group_info["adminVrrpId"] != self.admin_vrid:
Expand Down Expand Up @@ -744,7 +749,7 @@ def is_vrrp_group_info_exist(self):
if self.vrrp_group_info["vrrpType"] != self.vrrp_type:
return False
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
if self.admin_vrid:
if self.vrrp_group_info["adminVrrpId"] != self.admin_vrid:
Expand Down Expand Up @@ -895,19 +900,13 @@ def set_vrrp_group(self):
conf_str += "<adminVrrpId>%s</adminVrrpId>" % self.admin_vrid
if self.admin_interface:
conf_str += "<adminIfName>%s</adminIfName>" % self.admin_interface
if self.admin_flowdown is True or self.admin_flowdown is False:
admin_flowdown = "false"
if self.admin_flowdown is True:
admin_flowdown = "true"
conf_str += "<unflowdown>%s</unflowdown>" % admin_flowdown
if self.admin_flowdown:
conf_str += "<unflowdown>%s</unflowdown>" % self.admin_flowdown
if self.priority:
conf_str += "<priority>%s</priority>" % self.priority
if self.vrrp_type == "admin":
if self.admin_ignore_if_down is True or self.admin_ignore_if_down is False:
admin_ignore_if_down = "false"
if self.admin_ignore_if_down is True:
admin_ignore_if_down = "true"
conf_str += "<adminIgnoreIfDown>%s</adminIgnoreIfDown>" % admin_ignore_if_down
if self.admin_ignore_if_down:
conf_str += "<adminIgnoreIfDown>%s</adminIgnoreIfDown>" % self.admin_ignore_if_down
if self.fast_resume:
fast_resume = "false"
if self.fast_resume == "enable":
Expand All @@ -924,10 +923,7 @@ def set_vrrp_group(self):
if self.auth_key:
conf_str += "<authenticationKey>%s</authenticationKey>" % self.auth_key
if self.auth_mode == "simple":
is_plain = "false"
if self.is_plain is True:
is_plain = "true"
conf_str += "<isPlain>%s</isPlain>" % is_plain
conf_str += "<isPlain>%s</isPlain>" % self.is_plain

conf_str += CE_NC_SET_VRRP_GROUP_INFO_TAIL
recv_xml = set_nc_config(self.module, conf_str)
Expand All @@ -937,7 +933,7 @@ def set_vrrp_group(self):

if self.interface and self.vrid:
if self.vrrp_type == "admin":
if self.admin_ignore_if_down is True:
if self.admin_ignore_if_down == "true":
self.updates_cmd.append(
"interface %s" % self.interface)
self.updates_cmd.append(
Expand Down Expand Up @@ -978,7 +974,7 @@ def set_vrrp_group(self):
"vrrp vrid %s holding-multiplier %s" % (self.vrid, self.holding_multiplier))

if self.admin_vrid and self.admin_interface:
if self.admin_flowdown is True:
if self.admin_flowdown == "true":
self.updates_cmd.append(
"interface %s" % self.interface)
self.updates_cmd.append("vrrp vrid %s track admin-vrrp interface %s vrid %s unflowdown" %
Expand All @@ -991,7 +987,7 @@ def set_vrrp_group(self):

if self.auth_mode and self.auth_key:
if self.auth_mode == "simple":
if self.is_plain is True:
if self.is_plain == "true":
self.updates_cmd.append(
"interface %s" % self.interface)
self.updates_cmd.append("vrrp vrid %s authentication-mode simple plain %s" %
Expand Down Expand Up @@ -1238,7 +1234,7 @@ def get_end_state(self):
self.end_state["admin_ignore_if_down"] = self.vrrp_group_info[
"adminIgnoreIfDown"]
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"]
self.end_state["admin_interface"] = self.vrrp_group_info[
"adminIfName"]
Expand All @@ -1265,6 +1261,8 @@ def get_end_state(self):
self.end_state["auth_mode"] = self.vrrp_group_info[
"authenticationMode"]
self.end_state["is_plain"] = self.vrrp_group_info["isPlain"]
if self.existing == self.end_state:
self.changed = False

def work(self):
"""worker"""
Expand Down Expand Up @@ -1299,7 +1297,7 @@ def work(self):
if not self.vrrp_group_info:
self.module.fail_json(
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":
self.module.fail_json(
msg='Error: vrrpType must be admin when admin_ignore_if_down is true.')
Expand Down Expand Up @@ -1341,10 +1339,10 @@ def main():
vrid=dict(type='str'),
virtual_ip=dict(type='str'),
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_interface=dict(type='str'),
admin_flowdown=dict(type='bool', default=False),
admin_flowdown=dict(type='str', choices=['true', 'false']),
priority=dict(type='str'),
version=dict(type='str', choices=['v2', 'v3']),
advertise_interval=dict(type='str'),
Expand All @@ -1353,7 +1351,7 @@ def main():
recover_delay=dict(type='str'),
holding_multiplier=dict(type='str'),
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'),
fast_resume=dict(type='str', choices=['enable', 'disable']),
state=dict(type='str', default='present',
Expand Down