Backport/2.9/62471 ce_link_status:update to fix a bug. (#62417) (#63423)

* update to fix a bug. (#62417)


(cherry picked from commit 7541dab1ef)

* add a changelog fragment.
pull/64281/head
Xu Yuandong 6 years ago committed by Toshio Kuratomi
parent 6446b70728
commit c68507bcb0

@ -0,0 +1,2 @@
bugfixes:
- ce_link_status - fix some bugs, result of interface <get> operation involves a large amount of data,interact with the device through the <get-next>.(https://github.com/ansible/ansible/pull/62417).

@ -55,7 +55,7 @@ notes:
options: options:
interface: interface:
description: description:
- For the interface parameter, you can enter C(all) to display information about all interface, - For the interface parameter, you can enter C(all) to display information about all interfaces,
an interface type such as C(40GE) to display information about interfaces of the specified type, an interface type such as C(40GE) to display information about interfaces of the specified type,
or full name of an interface such as C(40GE1/0/22) or C(vlanif10) or full name of an interface such as C(40GE1/0/22) or C(vlanif10)
to display information about the specific interface. to display information about the specific interface.
@ -88,7 +88,7 @@ EXAMPLES = '''
interface: 40GE interface: 40GE
provider: "{{ cli }}" provider: "{{ cli }}"
- name: Get all interface link status information - name: Get all interfaces link status information
ce_link_status: ce_link_status:
interface: all interface: all
provider: "{{ cli }}" provider: "{{ cli }}"
@ -128,7 +128,7 @@ result:
from xml.etree import ElementTree from xml.etree import ElementTree
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.network.cloudengine.ce import ce_argument_spec, get_nc_config from ansible.module_utils.network.cloudengine.ce import ce_argument_spec, get_nc_config, get_nc_next
CE_NC_GET_PORT_SPEED = """ CE_NC_GET_PORT_SPEED = """
<filter type="subtree"> <filter type="subtree">
@ -393,10 +393,10 @@ class LinkStatus(object):
'Outbound rate(pkts/sec)'] = eles.text 'Outbound rate(pkts/sec)'] = eles.text
def get_all_interface_info(self, intf_type=None): def get_all_interface_info(self, intf_type=None):
"""Get interface information all or by interface type""" """Get interface information by all or by interface type"""
xml_str = CE_NC_GET_INT_STATISTICS % '' xml_str = CE_NC_GET_INT_STATISTICS % ''
con_obj = get_nc_config(self.module, xml_str) con_obj = get_nc_next(self.module, xml_str)
if "<data/>" in con_obj: if "<data/>" in con_obj:
return return
@ -406,7 +406,7 @@ class LinkStatus(object):
# get link status information # get link status information
root = ElementTree.fromstring(xml_str) root = ElementTree.fromstring(xml_str)
intfs_info = root.find("ifm/interfaces") intfs_info = root.findall("ifm/interfaces/interface")
if not intfs_info: if not intfs_info:
return return

Loading…
Cancel
Save