From afe7cd3fda72cabbec23f9bded598d2cbc5b1b0e Mon Sep 17 00:00:00 2001 From: YuandongXu <786018072@qq.com> Date: Fri, 28 Jun 2019 06:53:56 +0800 Subject: [PATCH] ce_snmp_location: fix for out of array index. (#57903) --- .../57903-ce_snmp_location_fix_for_out_of_array_index.yml | 3 +++ .../modules/network/cloudengine/ce_snmp_location.py | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/57903-ce_snmp_location_fix_for_out_of_array_index.yml diff --git a/changelogs/fragments/57903-ce_snmp_location_fix_for_out_of_array_index.yml b/changelogs/fragments/57903-ce_snmp_location_fix_for_out_of_array_index.yml new file mode 100644 index 00000000000..9accccb10e6 --- /dev/null +++ b/changelogs/fragments/57903-ce_snmp_location_fix_for_out_of_array_index.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - fix bug - out of array index.There should be a judgement about array length before the value of the array is taken out. \ No newline at end of file diff --git a/lib/ansible/modules/network/cloudengine/ce_snmp_location.py b/lib/ansible/modules/network/cloudengine/ce_snmp_location.py index b27a4a9489f..662a43bb00f 100644 --- a/lib/ansible/modules/network/cloudengine/ce_snmp_location.py +++ b/lib/ansible/modules/network/cloudengine/ce_snmp_location.py @@ -171,8 +171,9 @@ class SnmpLocation(object): tmp_cfg = self.cli_get_config() if tmp_cfg: temp_data = tmp_cfg.split(r"location ") - self.cur_cfg["location"] = temp_data[1] - self.existing["location"] = temp_data[1] + if len(temp_data) > 1: + self.cur_cfg["location"] = temp_data[1] + self.existing["location"] = temp_data[1] def get_end_state(self): """ Get end state """ @@ -180,7 +181,8 @@ class SnmpLocation(object): tmp_cfg = self.cli_get_config() if tmp_cfg: temp_data = tmp_cfg.split(r"location ") - self.end_state["location"] = temp_data[1] + if len(temp_data) > 1: + self.end_state["location"] = temp_data[1] def cli_load_config(self, commands): """ Load config by cli """