コード例 #1
0
ファイル: ce_bfd_global.py プロジェクト: ernstp/ansible
    def netconf_load_config(self, xml_str):
        """load bfd config by netconf"""

        if not xml_str:
            return

        xml_cfg = """
            <config>
            <bfd xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
            %s
            </bfd>
            </config>""" % xml_str
        set_nc_config(self.module, xml_cfg)
        self.changed = True
コード例 #2
0
    def netconf_load_config(self, xml_str):
        """load bfd config by netconf"""

        if not xml_str:
            return

        xml_cfg = """
            <config>
            <bfd xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
            %s
            </bfd>
            </config>""" % xml_str
        set_nc_config(self.module, xml_cfg)
        self.changed = True
コード例 #3
0
ファイル: ce_vrf_interface.py プロジェクト: ernstp/ansible
    def config_interface_vrf(self):
        """ configure VPN instance of the interface"""

        if not self.conf_exist and self.state == 'present':

            xml_str = CE_NC_MERGE_VRF_INTERFACE % (
                self.vrf, self.vpn_interface)
            ret_xml = set_nc_config(self.module, xml_str)
            self.check_response(ret_xml, "VRF_INTERFACE_CONFIG")
            self.changed = True
        elif self.state == 'absent':
            xml_str = CE_NC_DEL_INTF_VPN % (self.vrf, self.vpn_interface)
            ret_xml = set_nc_config(self.module, xml_str)
            self.check_response(ret_xml, "DEL_VRF_INTERFACE_CONFIG")
            self.changed = True
コード例 #4
0
    def config_interface_vrf(self):
        """ configure VPN instance of the interface"""

        if not self.conf_exist and self.state == 'present':

            xml_str = CE_NC_MERGE_VRF_INTERFACE % (self.vrf,
                                                   self.vpn_interface)
            ret_xml = set_nc_config(self.module, xml_str)
            self.check_response(ret_xml, "VRF_INTERFACE_CONFIG")
            self.changed = True
        elif self.state == 'absent':
            xml_str = CE_NC_DEL_INTF_VPN % (self.vrf, self.vpn_interface)
            ret_xml = set_nc_config(self.module, xml_str)
            self.check_response(ret_xml, "DEL_VRF_INTERFACE_CONFIG")
            self.changed = True
コード例 #5
0
ファイル: ce_interface.py プロジェクト: ernstp/ansible
    def default_interface(self, ifname):
        """default_interface"""

        change = False
        xmlstr = ""
        self.updates_cmd.append("interface %s" % ifname)
        # set description default
        if self.intf_info["ifDescr"]:
            xmlstr += CE_NC_XML_MERGE_INTF_DES % (ifname, '')
            self.updates_cmd.append("undo description")
            change = True

        # set admin_status default
        if is_admin_state_enable(self.intf_type) \
                and self.intf_info["ifAdminStatus"] != 'up':
            xmlstr += CE_NC_XML_MERGE_INTF_STATUS % (ifname, 'up')
            self.updates_cmd.append("undo shutdown")
            change = True

        # set portswitch default
        if is_portswitch_enalbe(self.intf_type) \
                and self.intf_info["isL2SwitchPort"] != "true":
            xmlstr += CE_NC_XML_MERGE_INTF_L2ENABLE % (ifname, 'enable')
            self.updates_cmd.append("portswitch")
            change = True

        if not change:
            return

        conf_str = '<config> ' + xmlstr + ' </config>'
        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "SET_INTF_DEFAULT")
        self.changed = True
コード例 #6
0
ファイル: ce_dldp.py プロジェクト: ernstp/ansible
    def config_global_dldp(self):
        """Config global dldp"""

        if self.same_conf:
            return

        enable = self.enable
        if not self.enable:
            enable = self.dldp_conf['dldpEnable']
        if enable == 'enable':
            enable = 'true'
        else:
            enable = 'false'

        internal = self.internal
        if not self.internal:
            internal = self.dldp_conf['dldpInterval']

        work_mode = self.work_mode
        if not self.work_mode:
            work_mode = self.dldp_conf['dldpWorkMode']

        if work_mode == 'enhance' or work_mode == 'dldpEnhance':
            work_mode = 'dldpEnhance'
        else:
            work_mode = 'dldpNormal'

        auth_mode = self.auth_mode
        if not self.auth_mode:
            auth_mode = self.dldp_conf['dldpAuthMode']
        if auth_mode == 'md5':
            auth_mode = 'dldpAuthMD5'
        elif auth_mode == 'simple':
            auth_mode = 'dldpAuthSimple'
        elif auth_mode == 'sha':
            auth_mode = 'dldpAuthSHA'
        elif auth_mode == 'hmac-sha256':
            auth_mode = 'dldpAuthHMAC-SHA256'
        elif auth_mode == 'none':
            auth_mode = 'dldpAuthNone'

        xml_str = CE_NC_MERGE_DLDP_GLOBAL_CONFIG_HEAD % (
            enable, internal, work_mode)
        if self.auth_mode:
            if self.auth_mode == 'none':
                xml_str += "<dldpAuthMode>dldpAuthNone</dldpAuthMode>"
            else:
                xml_str += "<dldpAuthMode>%s</dldpAuthMode>" % auth_mode
                xml_str += "<dldpPasswords>%s</dldpPasswords>" % self.auth_pwd

        xml_str += CE_NC_MERGE_DLDP_GLOBAL_CONFIG_TAIL
        ret_xml = set_nc_config(self.module, xml_str)
        self.check_response(ret_xml, "MERGE_DLDP_GLOBAL_CONFIG")

        if self.reset == 'enable':
            xml_str = CE_NC_ACTION_RESET_DLDP
            ret_xml = execute_nc_action(self.module, xml_str)
            self.check_response(ret_xml, "ACTION_RESET_DLDP")

        self.changed = True
コード例 #7
0
    def default_interface(self, ifname):
        """default_interface"""

        change = False
        xmlstr = ""
        self.updates_cmd.append("interface %s" % ifname)
        # set description default
        if self.intf_info["ifDescr"]:
            xmlstr += CE_NC_XML_MERGE_INTF_DES % (ifname, '')
            self.updates_cmd.append("undo description")
            change = True

        # set admin_status default
        if is_admin_state_enable(self.intf_type) \
                and self.intf_info["ifAdminStatus"] != 'up':
            xmlstr += CE_NC_XML_MERGE_INTF_STATUS % (ifname, 'up')
            self.updates_cmd.append("undo shutdown")
            change = True

        # set portswitch default
        if is_portswitch_enalbe(self.intf_type) \
                and self.intf_info["isL2SwitchPort"] != "true":
            xmlstr += CE_NC_XML_MERGE_INTF_L2ENABLE % (ifname, 'enable')
            self.updates_cmd.append("portswitch")
            change = True

        if not change:
            return

        conf_str = '<config> ' + xmlstr + ' </config>'
        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "SET_INTF_DEFAULT")
        self.changed = True
コード例 #8
0
    def create_interface(self, ifname, description, admin_state, mode, l2sub):
        """Create interface."""

        if l2sub:
            self.updates_cmd.append("interface %s mode l2" % ifname)
        else:
            self.updates_cmd.append("interface %s" % ifname)

        if not description:
            description = ''
        else:
            self.updates_cmd.append("description %s" % description)

        if l2sub:
            xmlstr = CE_NC_XML_CREATE_INTF_L2SUB % (ifname, description)
        else:
            xmlstr = CE_NC_XML_CREATE_INTF % (ifname, description)
        if admin_state and is_admin_state_enable(self.intf_type):
            xmlstr += CE_NC_XML_MERGE_INTF_STATUS % (ifname, admin_state)
            if admin_state == 'up':
                self.updates_cmd.append("undo shutdown")
            else:
                self.updates_cmd.append("shutdown")
        if mode and is_portswitch_enalbe(self.intf_type):
            if mode == "layer2":
                xmlstr += CE_NC_XML_MERGE_INTF_L2ENABLE % (ifname, 'enable')
                self.updates_cmd.append('portswitch')
            elif mode == "layer3":
                xmlstr += CE_NC_XML_MERGE_INTF_L2ENABLE % (ifname, 'disable')
                self.updates_cmd.append('undo portswitch')

        conf_str = '<config> ' + xmlstr + ' </config>'
        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "CREATE_INTF")
        self.changed = True
コード例 #9
0
    def merge_debug_source(self):
        """ Merge debug source """

        conf_str = CE_MERGE_DEBUG_SOURCE_HEADER

        if self.module_name:
            conf_str += "<moduleName>%s</moduleName>" % self.module_name
        if self.channel_id:
            conf_str += "<icChannelId>%s</icChannelId>" % self.channel_id
        if self.debug_enable != 'no_use':
            conf_str += "<dbgEnFlg>%s</dbgEnFlg>" % self.debug_enable
        if self.debug_level:
            conf_str += "<dbgEnLevel>%s</dbgEnLevel>" % self.debug_level

        conf_str += CE_MERGE_DEBUG_SOURCE_TAIL

        recv_xml = set_nc_config(self.module, conf_str)
        if "<ok/>" not in recv_xml:
            self.module.fail_json(msg='Error: Merge debug source failed.')

        cmd = "info-center source"
        if self.module_name:
            cmd += " %s" % self.module_name
        if self.channel_id:
            cmd += " channel %s" % self.channel_id
        if self.debug_enable != 'no_use':
            if self.debug_enable == "true":
                cmd += " debug state on"
            else:
                cmd += " debug state off"
        if self.debug_level:
            cmd += " level %s" % self.debug_level

        self.updates_cmd.append(cmd)
        self.changed = True
コード例 #10
0
ファイル: ce_mlag_interface.py プロジェクト: ernstp/ansible
    def set_mlag_interface(self):
        """set mlag interface atrribute info"""

        if self.is_mlag_interface_info_change():
            mlag_port = "Eth-Trunk"
            mlag_port += self.eth_trunk_id
            conf_str = CE_NC_SET_LACP_MLAG_INFO_HEAD % mlag_port
            if self.mlag_priority_id:
                conf_str += "<lacpMlagPriority>%s</lacpMlagPriority>" % self.mlag_priority_id
            if self.mlag_system_id:
                conf_str += "<lacpMlagSysId>%s</lacpMlagSysId>" % self.mlag_system_id
            conf_str += CE_NC_SET_LACP_MLAG_INFO_TAIL
            recv_xml = set_nc_config(self.module, conf_str)
            if "<ok/>" not in recv_xml:
                self.module.fail_json(
                    msg='Error: set mlag interface atrribute info failed.')

            self.updates_cmd.append("interface %s" % mlag_port)
            if self.mlag_priority_id:
                self.updates_cmd.append(
                    "lacp m-lag priority %s" % self.mlag_priority_id)

            if self.mlag_system_id:
                self.updates_cmd.append(
                    "lacp m-lag system-id %s" % self.mlag_system_id)
            self.changed = True
コード例 #11
0
    def config_vap_sub_intf(self):
        """configure a Layer 2 sub-interface as a service access point"""

        if not self.vap_info:
            self.module.fail_json(
                msg="Error: Bridge domain %s does not exist." %
                self.bridge_domain_id)

        xml_str = ""
        if self.state == "present":
            if self.l2_sub_interface not in self.vap_info["intfList"]:
                self.updates_cmd.append("interface %s" % self.l2_sub_interface)
                self.updates_cmd.append("bridge-domain %s" %
                                        self.bridge_domain_id)
                xml_str = CE_NC_MERGE_BD_INTF % (self.bridge_domain_id,
                                                 self.l2_sub_interface)
        else:
            if self.l2_sub_interface in self.vap_info["intfList"]:
                self.updates_cmd.append("interface %s" % self.l2_sub_interface)
                self.updates_cmd.append("undo bridge-domain %s" %
                                        self.bridge_domain_id)
                xml_str = CE_NC_DELETE_BD_INTF % (self.bridge_domain_id,
                                                  self.l2_sub_interface)

        if not xml_str:
            return
        recv_xml = set_nc_config(self.module, xml_str)
        self.check_response(recv_xml, "CONFIG_VAP_SUB_INTERFACE")
        self.changed = True
コード例 #12
0
ファイル: ce_vxlan_vap.py プロジェクト: ernstp/ansible
    def config_vap_sub_intf(self):
        """configure a Layer 2 sub-interface as a service access point"""

        if not self.vap_info:
            self.module.fail_json(msg="Error: Bridge domain %s does not exist." % self.bridge_domain_id)

        xml_str = ""
        if self.state == "present":
            if self.l2_sub_interface not in self.vap_info["intfList"]:
                self.updates_cmd.append("interface %s" % self.l2_sub_interface)
                self.updates_cmd.append("bridge-domain %s" %
                                        self.bridge_domain_id)
                xml_str = CE_NC_MERGE_BD_INTF % (
                    self.bridge_domain_id, self.l2_sub_interface)
        else:
            if self.l2_sub_interface in self.vap_info["intfList"]:
                self.updates_cmd.append("interface %s" % self.l2_sub_interface)
                self.updates_cmd.append(
                    "undo bridge-domain %s" % self.bridge_domain_id)
                xml_str = CE_NC_DELETE_BD_INTF % (
                    self.bridge_domain_id, self.l2_sub_interface)

        if not xml_str:
            return
        recv_xml = set_nc_config(self.module, xml_str)
        self.check_response(recv_xml, "CONFIG_VAP_SUB_INTERFACE")
        self.changed = True
コード例 #13
0
ファイル: ce_interface.py プロジェクト: ernstp/ansible
    def create_interface(self, ifname, description, admin_state, mode, l2sub):
        """Create interface."""

        if l2sub:
            self.updates_cmd.append("interface %s mode l2" % ifname)
        else:
            self.updates_cmd.append("interface %s" % ifname)

        if not description:
            description = ''
        else:
            self.updates_cmd.append("description %s" % description)

        if l2sub:
            xmlstr = CE_NC_XML_CREATE_INTF_L2SUB % (ifname, description)
        else:
            xmlstr = CE_NC_XML_CREATE_INTF % (ifname, description)
        if admin_state and is_admin_state_enable(self.intf_type):
            xmlstr += CE_NC_XML_MERGE_INTF_STATUS % (ifname, admin_state)
            if admin_state == 'up':
                self.updates_cmd.append("undo shutdown")
            else:
                self.updates_cmd.append("shutdown")
        if mode and is_portswitch_enalbe(self.intf_type):
            if mode == "layer2":
                xmlstr += CE_NC_XML_MERGE_INTF_L2ENABLE % (ifname, 'enable')
                self.updates_cmd.append('portswitch')
            elif mode == "layer3":
                xmlstr += CE_NC_XML_MERGE_INTF_L2ENABLE % (ifname, 'disable')
                self.updates_cmd.append('undo portswitch')

        conf_str = '<config> ' + xmlstr + ' </config>'
        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "CREATE_INTF")
        self.changed = True
コード例 #14
0
    def config_vap_vlan(self):
        """configure a VLAN as a service access point"""

        if not self.vap_info:
            self.module.fail_json(
                msg="Error: Bridge domain %s does not exist." %
                self.bridge_domain_id)

        xml_str = ""
        if self.state == "present":
            if not is_vlan_in_bitmap(self.bind_vlan_id,
                                     self.vap_info["vlanList"]):
                self.updates_cmd.append("bridge-domain %s" %
                                        self.bridge_domain_id)
                self.updates_cmd.append("l2 binding vlan %s" %
                                        self.bind_vlan_id)
                vlan_bitmap = vlan_vid_to_bitmap(self.bind_vlan_id)
                xml_str = CE_NC_MERGE_BD_VLAN % (self.bridge_domain_id,
                                                 vlan_bitmap, vlan_bitmap)
        else:
            if is_vlan_in_bitmap(self.bind_vlan_id, self.vap_info["vlanList"]):
                self.updates_cmd.append("bridge-domain %s" %
                                        self.bridge_domain_id)
                self.updates_cmd.append("undo l2 binding vlan %s" %
                                        self.bind_vlan_id)
                vlan_bitmap = vlan_vid_to_bitmap(self.bind_vlan_id)
                xml_str = CE_NC_MERGE_BD_VLAN % (self.bridge_domain_id,
                                                 "0" * 1024, vlan_bitmap)

        if not xml_str:
            return
        recv_xml = set_nc_config(self.module, xml_str)
        self.check_response(recv_xml, "CONFIG_VAP_VLAN")
        self.changed = True
コード例 #15
0
    def config_global_dldp(self):
        """Config global dldp"""

        if self.same_conf:
            return

        enable = self.enable
        if not self.enable:
            enable = self.dldp_conf['dldpEnable']
        if enable == 'enable':
            enable = 'true'
        else:
            enable = 'false'

        internal = self.internal
        if not self.internal:
            internal = self.dldp_conf['dldpInterval']

        work_mode = self.work_mode
        if not self.work_mode:
            work_mode = self.dldp_conf['dldpWorkMode']

        if work_mode == 'enhance' or work_mode == 'dldpEnhance':
            work_mode = 'dldpEnhance'
        else:
            work_mode = 'dldpNormal'

        auth_mode = self.auth_mode
        if not self.auth_mode:
            auth_mode = self.dldp_conf['dldpAuthMode']
        if auth_mode == 'md5':
            auth_mode = 'dldpAuthMD5'
        elif auth_mode == 'simple':
            auth_mode = 'dldpAuthSimple'
        elif auth_mode == 'sha':
            auth_mode = 'dldpAuthSHA'
        elif auth_mode == 'hmac-sha256':
            auth_mode = 'dldpAuthHMAC-SHA256'
        elif auth_mode == 'none':
            auth_mode = 'dldpAuthNone'

        xml_str = CE_NC_MERGE_DLDP_GLOBAL_CONFIG_HEAD % (enable, internal,
                                                         work_mode)
        if self.auth_mode:
            if self.auth_mode == 'none':
                xml_str += "<dldpAuthMode>dldpAuthNone</dldpAuthMode>"
            else:
                xml_str += "<dldpAuthMode>%s</dldpAuthMode>" % auth_mode
                xml_str += "<dldpPasswords>%s</dldpPasswords>" % self.auth_pwd

        xml_str += CE_NC_MERGE_DLDP_GLOBAL_CONFIG_TAIL
        ret_xml = set_nc_config(self.module, xml_str)
        self.check_response(ret_xml, "MERGE_DLDP_GLOBAL_CONFIG")

        if self.reset == 'enable':
            xml_str = CE_NC_ACTION_RESET_DLDP
            ret_xml = execute_nc_action(self.module, xml_str)
            self.check_response(ret_xml, "ACTION_RESET_DLDP")

        self.changed = True
コード例 #16
0
ファイル: ce_eth_trunk.py プロジェクト: ernstp/ansible
    def netconf_set_config(self, xml_str, xml_name):
        """ netconf set config """

        recv_xml = set_nc_config(self.module, xml_str)

        if "<ok/>" not in recv_xml:
            self.module.fail_json(msg='Error: %s failed.' % xml_name)
コード例 #17
0
    def set_mlag_interface(self):
        """set mlag interface atrribute info"""

        if self.is_mlag_interface_info_change():
            mlag_port = "Eth-Trunk"
            mlag_port += self.eth_trunk_id
            conf_str = CE_NC_SET_LACP_MLAG_INFO_HEAD % mlag_port
            if self.mlag_priority_id:
                conf_str += "<lacpMlagPriority>%s</lacpMlagPriority>" % self.mlag_priority_id
            if self.mlag_system_id:
                conf_str += "<lacpMlagSysId>%s</lacpMlagSysId>" % self.mlag_system_id
            conf_str += CE_NC_SET_LACP_MLAG_INFO_TAIL
            recv_xml = set_nc_config(self.module, conf_str)
            if "<ok/>" not in recv_xml:
                self.module.fail_json(
                    msg='Error: set mlag interface atrribute info failed.')

            self.updates_cmd.append("interface %s" % mlag_port)
            if self.mlag_priority_id:
                self.updates_cmd.append("lacp m-lag priority %s" %
                                        self.mlag_priority_id)

            if self.mlag_system_id:
                self.updates_cmd.append("lacp m-lag system-id %s" %
                                        self.mlag_system_id)
            self.changed = True
コード例 #18
0
    def config_delete_vni_peer_ip(self, nve_name, vni_id, peer_ip_list):
        """remove vni peer ip"""

        for peer_ip in peer_ip_list:
            if not self.is_vni_peer_list_exist(nve_name, vni_id, peer_ip):
                self.module.fail_json(msg='Error: The %s does not exist' % peer_ip)
        config = self.get_current_config(vni_id, peer_ip_list)
        if not config:
            cfg_xml = CE_NC_DELETE_VNI_PEER_ADDRESS_IP_HEAD % (
                nve_name, vni_id)
            for peer_ip in peer_ip_list:
                cfg_xml += CE_NC_DELETE_VNI_PEER_ADDRESS_IP_DELETE % peer_ip
            cfg_xml += CE_NC_DELETE_VNI_PEER_ADDRESS_IP_END
        else:
            cfg_xml = CE_NC_DELETE_PEER_ADDRESS_IP_HEAD % (
                nve_name, vni_id)
            for peer_ip in peer_ip_list:
                cfg_xml += CE_NC_DELETE_VNI_PEER_ADDRESS_IP_DELETE % peer_ip
            cfg_xml += CE_NC_DELETE_PEER_ADDRESS_IP_END

        recv_xml = set_nc_config(self.module, cfg_xml)
        self.check_response(recv_xml, "DELETE_VNI_PEER_IP")
        self.updates_cmd.append("interface %s" % nve_name)

        for peer_ip in peer_ip_list:
            cmd_output = "undo vni %s head-end peer-list %s" % (vni_id, peer_ip)
            self.updates_cmd.append(cmd_output)

        self.changed = True
コード例 #19
0
    def merge_debug_source(self):
        """ Merge debug source """

        conf_str = CE_MERGE_DEBUG_SOURCE_HEADER

        if self.module_name:
            conf_str += "<moduleName>%s</moduleName>" % self.module_name
        if self.channel_id:
            conf_str += "<icChannelId>%s</icChannelId>" % self.channel_id
        if self.debug_enable != 'no_use':
            conf_str += "<dbgEnFlg>%s</dbgEnFlg>" % self.debug_enable
        if self.debug_level:
            conf_str += "<dbgEnLevel>%s</dbgEnLevel>" % self.debug_level

        conf_str += CE_MERGE_DEBUG_SOURCE_TAIL

        recv_xml = set_nc_config(self.module, conf_str)
        if "<ok/>" not in recv_xml:
            self.module.fail_json(msg='Error: Merge debug source failed.')

        cmd = "info-center source"
        if self.module_name:
            cmd += " %s" % self.module_name
        if self.channel_id:
            cmd += " channel %s" % self.channel_id
        if self.debug_enable != 'no_use':
            if self.debug_enable == "true":
                cmd += " debug state on"
            else:
                cmd += " debug state off"
        if self.debug_level:
            cmd += " level %s" % self.debug_level

        self.updates_cmd.append(cmd)
        self.changed = True
コード例 #20
0
ファイル: ce_vxlan_vap.py プロジェクト: ernstp/ansible
    def config_vap_vlan(self):
        """configure a VLAN as a service access point"""

        if not self.vap_info:
            self.module.fail_json(msg="Error: Bridge domain %s does not exist." % self.bridge_domain_id)

        xml_str = ""
        if self.state == "present":
            if not is_vlan_in_bitmap(self.bind_vlan_id, self.vap_info["vlanList"]):
                self.updates_cmd.append("bridge-domain %s" %
                                        self.bridge_domain_id)
                self.updates_cmd.append(
                    "l2 binding vlan %s" % self.bind_vlan_id)
                vlan_bitmap = vlan_vid_to_bitmap(self.bind_vlan_id)
                xml_str = CE_NC_MERGE_BD_VLAN % (
                    self.bridge_domain_id, vlan_bitmap, vlan_bitmap)
        else:
            if is_vlan_in_bitmap(self.bind_vlan_id, self.vap_info["vlanList"]):
                self.updates_cmd.append("bridge-domain %s" %
                                        self.bridge_domain_id)
                self.updates_cmd.append(
                    "undo l2 binding vlan %s" % self.bind_vlan_id)
                vlan_bitmap = vlan_vid_to_bitmap(self.bind_vlan_id)
                xml_str = CE_NC_MERGE_BD_VLAN % (
                    self.bridge_domain_id, "0" * 1024, vlan_bitmap)

        if not xml_str:
            return
        recv_xml = set_nc_config(self.module, xml_str)
        self.check_response(recv_xml, "CONFIG_VAP_VLAN")
        self.changed = True
コード例 #21
0
ファイル: ce_eth_trunk.py プロジェクト: vharishgup/ansible-1
    def netconf_set_config(self, xml_str, xml_name):
        """ netconf set config """

        recv_xml = set_nc_config(self.module, xml_str)

        if "<ok/>" not in recv_xml:
            self.module.fail_json(msg='Error: %s failed.' % xml_name)
コード例 #22
0
ファイル: ce_ospf.py プロジェクト: ernstp/ansible
    def delete_process(self):
        """Delete ospf process"""

        xml_str = CE_NC_DELETE_PROCESS % self.process_id
        recv_xml = set_nc_config(self.module, xml_str)
        self.check_response(recv_xml, "DELETE_PROCESS")
        self.updates_cmd.append("undo ospf %s" % self.process_id)
        self.changed = True
コード例 #23
0
ファイル: ce_vlan.py プロジェクト: ernstp/ansible
    def undo_config_vlan(self, vlanid):
        """Delete vlan."""

        conf_str = CE_NC_DELETE_VLAN % vlanid
        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "DELETE_VLAN")
        self.changed = True
        self.updates_cmd.append('undo vlan %s' % self.vlan_id)
コード例 #24
0
ファイル: ce_ospf.py プロジェクト: vharishgup/ansible-1
    def delete_process(self):
        """Delete ospf process"""

        xml_str = CE_NC_DELETE_PROCESS % self.process_id
        recv_xml = set_nc_config(self.module, xml_str)
        self.check_response(recv_xml, "DELETE_PROCESS")
        self.updates_cmd.append("undo ospf %s" % self.process_id)
        self.changed = True
コード例 #25
0
    def undo_config_vlan(self, vlanid):
        """Delete vlan."""

        conf_str = CE_NC_DELETE_VLAN % vlanid
        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "DELETE_VLAN")
        self.changed = True
        self.updates_cmd.append('undo vlan %s' % self.vlan_id)
コード例 #26
0
    def create_dfs_group(self):
        """create dfs group info"""

        conf_str = CE_NC_CREATE_DFS_GROUP_INFO_HEADER % self.dfs_group_id
        if self.priority_id and self.priority_id != 100:
            conf_str += "<priority>%s</priority>" % self.priority_id
        if self.ip_address:
            conf_str += "<ipAddress>%s</ipAddress>" % self.ip_address
        if self.vpn_instance_name:
            if not self.ip_address:
                self.module.fail_json(
                    msg=
                    'Error: ip_address can not be null if vpn_instance_name is exist.'
                )
            conf_str += "<srcVpnName>%s</srcVpnName>" % self.vpn_instance_name

        if self.nickname or self.pseudo_nickname or self.pseudo_priority:
            conf_str += "<trillType>"
            if self.nickname:
                conf_str += "<localNickname>%s</localNickname>" % self.nickname
            if self.pseudo_nickname:
                conf_str += "<pseudoNickname>%s</pseudoNickname>" % self.pseudo_nickname
            if self.pseudo_priority:
                if not self.pseudo_nickname:
                    self.module.fail_json(
                        msg=
                        'Error: pseudo_nickname can not be null if pseudo_priority is exist.'
                    )
                conf_str += "<pseudoPriority>%s</pseudoPriority>" % self.pseudo_priority
            conf_str += "</trillType>"

        conf_str += CE_NC_CREATE_DFS_GROUP_INFO_TAIL
        recv_xml = set_nc_config(self.module, conf_str)
        if "<ok/>" not in recv_xml:
            self.module.fail_json(msg='Error: Merge DFS group info failed.')

        self.updates_cmd.append("dfs-group 1")
        if self.priority_id:
            self.updates_cmd.append("priority %s" % self.priority_id)
        if self.ip_address:
            if self.vpn_instance_name:
                self.updates_cmd.append(
                    "source ip %s vpn-instance %s" %
                    (self.ip_address, self.vpn_instance_name))
            else:
                self.updates_cmd.append("source ip %s" % self.ip_address)
        if self.nickname:
            self.updates_cmd.append("source nickname %s" % self.nickname)
        if self.pseudo_nickname:
            if self.pseudo_priority:
                self.updates_cmd.append(
                    "pseudo-nickname %s priority %s" %
                    (self.pseudo_nickname, self.pseudo_priority))
            else:
                self.updates_cmd.append("pseudo-nickname %s" %
                                        self.pseudo_nickname)

        self.changed = True
コード例 #27
0
    def netconf_set_config(self, **kwargs):
        """ Set configure through netconf """

        module = kwargs["module"]
        conf_str = kwargs["conf_str"]

        xml_str = set_nc_config(module, conf_str)

        return xml_str
コード例 #28
0
    def delete_interface(self, ifname):
        """ Delete interface."""

        xmlstr = CE_NC_XML_DELETE_INTF % ifname
        conf_str = '<config> ' + xmlstr + ' </config>'
        self.updates_cmd.append('undo interface %s' % ifname)
        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "DELETE_INTF")
        self.changed = True
コード例 #29
0
ファイル: ce_snmp_community.py プロジェクト: ernstp/ansible
    def netconf_set_config(self, **kwargs):
        """ Set configure through netconf """

        module = kwargs["module"]
        conf_str = kwargs["conf_str"]

        xml_str = set_nc_config(module, conf_str)

        return xml_str
コード例 #30
0
ファイル: ce_interface.py プロジェクト: ernstp/ansible
    def delete_interface(self, ifname):
        """ Delete interface."""

        xmlstr = CE_NC_XML_DELETE_INTF % ifname
        conf_str = '<config> ' + xmlstr + ' </config>'
        self.updates_cmd.append('undo interface %s' % ifname)
        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "DELETE_INTF")
        self.changed = True
コード例 #31
0
ファイル: ce_mlag_config.py プロジェクト: ernstp/ansible
    def modify_dfs_group(self):
        """modify dfs group info"""

        if self.is_dfs_group_info_change():

            conf_str = CE_NC_MERGE_DFS_GROUP_INFO_HEADER % self.dfs_group_id
            if self.priority_id and self.dfs_group_info["priority"] != self.priority_id:
                conf_str += "<priority>%s</priority>" % self.priority_id
            if self.ip_address and self.dfs_group_info["ipAddress"] != self.ip_address:
                conf_str += "<ipAddress>%s</ipAddress>" % self.ip_address
            if self.vpn_instance_name and self.dfs_group_info["srcVpnName"] != self.vpn_instance_name:
                if not self.ip_address:
                    self.module.fail_json(
                        msg='Error: ip_address can not be null if vpn_instance_name is exist.')
                conf_str += "<srcVpnName>%s</srcVpnName>" % self.vpn_instance_name

            if self.nickname or self.pseudo_nickname or self.pseudo_priority:
                conf_str += "<trillType>"
                if self.nickname and self.dfs_group_info["localNickname"] != self.nickname:
                    conf_str += "<localNickname>%s</localNickname>" % self.nickname
                if self.pseudo_nickname and self.dfs_group_info["pseudoNickname"] != self.pseudo_nickname:
                    conf_str += "<pseudoNickname>%s</pseudoNickname>" % self.pseudo_nickname

                if self.pseudo_priority and self.dfs_group_info["pseudoPriority"] != self.pseudo_priority:
                    if not self.pseudo_nickname:
                        self.module.fail_json(
                            msg='Error: pseudo_nickname can not be null if pseudo_priority is exist.')
                    conf_str += "<pseudoPriority>%s</pseudoPriority>" % self.pseudo_priority
                conf_str += "</trillType>"

            conf_str += CE_NC_MERGE_DFS_GROUP_INFO_TAIL
            recv_xml = set_nc_config(self.module, conf_str)
            if "<ok/>" not in recv_xml:
                self.module.fail_json(
                    msg='Error: Merge DFS group info failed.')

            self.updates_cmd.append("dfs-group 1")
            if self.priority_id:
                self.updates_cmd.append("priority %s" % self.priority_id)
            if self.ip_address:
                if self.vpn_instance_name:
                    self.updates_cmd.append(
                        "source ip %s vpn-instance %s" % (self.ip_address, self.vpn_instance_name))
                else:
                    self.updates_cmd.append("source ip %s" % self.ip_address)
            if self.nickname:
                self.updates_cmd.append("source nickname %s" % self.nickname)
            if self.pseudo_nickname:
                if self.pseudo_priority:
                    self.updates_cmd.append(
                        "pseudo-nickname %s priority %s" % (self.pseudo_nickname, self.pseudo_priority))
                else:
                    self.updates_cmd.append(
                        "pseudo-nickname %s" % self.pseudo_nickname)

            self.changed = True
コード例 #32
0
ファイル: ce_vxlan_vap.py プロジェクト: ernstp/ansible
    def config_traffic_encap_qinq(self):
        """configure traffic encapsulation type qinq"""

        xml_str = ""
        self.updates_cmd.append("interface %s" % self.l2_sub_interface)
        if self.state == "present":
            if self.encapsulation != self.l2sub_info.get("flowType"):
                if self.ce_vid:
                    vlan_bitmap = vlan_vid_to_bitmap(self.ce_vid)
                    xml_str = CE_NC_SET_ENCAP_QINQ % (self.l2_sub_interface,
                                                      self.pe_vid,
                                                      vlan_bitmap,
                                                      vlan_bitmap)
                    self.updates_cmd.append(
                        "encapsulation %s vid %s ce-vid %s" % (self.encapsulation,
                                                               self.pe_vid,
                                                               self.ce_vid))
                else:
                    xml_str = CE_NC_SET_ENCAP % (
                        self.l2_sub_interface, self.encapsulation)
                    self.updates_cmd.append(
                        "encapsulation %s" % self.encapsulation)
            else:
                if self.ce_vid:
                    if not is_vlan_in_bitmap(self.ce_vid, self.l2sub_info.get("ceVids")) \
                            or self.pe_vid != self.l2sub_info.get("peVlanId"):
                        vlan_bitmap = vlan_vid_to_bitmap(self.ce_vid)
                        xml_str = CE_NC_SET_ENCAP_QINQ % (self.l2_sub_interface,
                                                          self.pe_vid,
                                                          vlan_bitmap,
                                                          vlan_bitmap)
                        self.updates_cmd.append(
                            "encapsulation %s vid %s ce-vid %s" % (self.encapsulation,
                                                                   self.pe_vid,
                                                                   self.ce_vid))
        else:
            if self.encapsulation == self.l2sub_info.get("flowType"):
                if self.ce_vid:
                    if is_vlan_in_bitmap(self.ce_vid, self.l2sub_info.get("ceVids")) \
                            and self.pe_vid == self.l2sub_info.get("peVlanId"):
                        xml_str = CE_NC_UNSET_ENCAP % self.l2_sub_interface
                        self.updates_cmd.append(
                            "undo encapsulation %s vid %s ce-vid %s" % (self.encapsulation,
                                                                        self.pe_vid,
                                                                        self.ce_vid))
                else:
                    xml_str = CE_NC_UNSET_ENCAP % self.l2_sub_interface
                    self.updates_cmd.append(
                        "undo encapsulation %s" % self.encapsulation)

        if not xml_str:
            self.updates_cmd.pop()
            return
        recv_xml = set_nc_config(self.module, xml_str)
        self.check_response(recv_xml, "CONFIG_INTF_ENCAP_QINQ")
        self.changed = True
コード例 #33
0
    def config_merge_vni2bd(self, bd_id, vni_id):
        """config vni to bd id"""

        if self.is_vni_bd_change(vni_id, bd_id):
            cfg_xml = CE_NC_MERGE_VNI_BD_ID % (vni_id, bd_id)
            recv_xml = set_nc_config(self.module, cfg_xml)
            self.check_response(recv_xml, "MERGE_VNI_BD")
            self.updates_cmd.append("bridge-domain %s" % bd_id)
            self.updates_cmd.append("vxlan vni %s" % vni_id)
            self.changed = True
コード例 #34
0
    def config_merge_mode(self, nve_name, mode):
        """config nve mode"""

        if self.is_nve_mode_change(nve_name, mode):
            cfg_xml = CE_NC_MERGE_NVE_MODE % (nve_name, mode)
            recv_xml = set_nc_config(self.module, cfg_xml)
            self.check_response(recv_xml, "MERGE_MODE")
            self.updates_cmd.append("interface %s" % nve_name)
            self.updates_cmd.append("mode l3")
            self.changed = True
コード例 #35
0
ファイル: ce_ntp_auth.py プロジェクト: ernstp/ansible
    def config_ntp_auth_keyid(self):
        """Config ntp authentication keyid"""

        if self.trusted_key == 'enable':
            trusted_key = 'true'
        else:
            trusted_key = 'false'
        xml_str = CE_NC_MERGE_NTP_AUTH_CONFIG % (
            self.key_id, self.auth_mode.upper(), self.password, trusted_key)
        ret_xml = set_nc_config(self.module, xml_str)
        self.check_response(ret_xml, "NTP_AUTH_KEYID_CONFIG")
コード例 #36
0
    def config_ntp_auth_keyid(self):
        """Config ntp authentication keyid"""

        if self.trusted_key == 'enable':
            trusted_key = 'true'
        else:
            trusted_key = 'false'
        xml_str = CE_NC_MERGE_NTP_AUTH_CONFIG % (
            self.key_id, self.auth_mode.upper(), self.password, trusted_key)
        ret_xml = set_nc_config(self.module, xml_str)
        self.check_response(ret_xml, "NTP_AUTH_KEYID_CONFIG")
コード例 #37
0
    def delete_dfs_group(self):
        """delete dfg group"""

        conf_str = CE_NC_DELETE_DFS_GROUP_INFO_HEADER % self.dfs_group_id
        conf_str += CE_NC_DELETE_DFS_GROUP_INFO_TAIL

        recv_xml = set_nc_config(self.module, conf_str)
        if "<ok/>" not in recv_xml:
            self.module.fail_json(msg='Error: Delete DFS group id failed.')
        self.updates_cmd.append("undo dfs-group 1")
        self.changed = True
コード例 #38
0
    def config_merge_source_ip(self, nve_name, source_ip):
        """config nve source ip"""

        if self.is_nve_source_ip_change(nve_name, source_ip):
            cfg_xml = CE_NC_MERGE_NVE_SOURCE_IP_PROTOCOL % (
                nve_name, source_ip)
            recv_xml = set_nc_config(self.module, cfg_xml)
            self.check_response(recv_xml, "MERGE_SOURCE_IP")
            self.updates_cmd.append("interface %s" % nve_name)
            self.updates_cmd.append("source %s" % source_ip)
            self.changed = True
コード例 #39
0
ファイル: ce_ntp_auth.py プロジェクト: ernstp/ansible
    def config_ntp_auth_enable(self):
        """Config ntp authentication enable"""

        if self.ntp_auth_conf['authentication'] != self.authentication:
            if self.authentication == 'enable':
                state = 'true'
            else:
                state = 'false'
            xml_str = CE_NC_MERGE_NTP_AUTH_ENABLE % state
            ret_xml = set_nc_config(self.module, xml_str)
            self.check_response(ret_xml, "NTP_AUTH_ENABLE")
コード例 #40
0
    def config_ntp_auth_enable(self):
        """Config ntp authentication enable"""

        if self.ntp_auth_conf['authentication'] != self.authentication:
            if self.authentication == 'enable':
                state = 'true'
            else:
                state = 'false'
            xml_str = CE_NC_MERGE_NTP_AUTH_ENABLE % state
            ret_xml = set_nc_config(self.module, xml_str)
            self.check_response(ret_xml, "NTP_AUTH_ENABLE")
コード例 #41
0
    def config_vlan(self, vlan_id, name='', description=''):
        """Create vlan."""

        if name is None:
            name = ''
        if description is None:
            description = ''

        conf_str = CE_NC_CREATE_VLAN % (vlan_id, name, description)
        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "CREATE_VLAN")
        self.changed = True
コード例 #42
0
ファイル: ce_mlag_config.py プロジェクト: ernstp/ansible
    def delete_dfs_group(self):
        """delete dfg group"""

        conf_str = CE_NC_DELETE_DFS_GROUP_INFO_HEADER % self.dfs_group_id
        conf_str += CE_NC_DELETE_DFS_GROUP_INFO_TAIL

        recv_xml = set_nc_config(self.module, conf_str)
        if "<ok/>" not in recv_xml:
            self.module.fail_json(
                msg='Error: Delete DFS group id failed.')
        self.updates_cmd.append("undo dfs-group 1")
        self.changed = True
コード例 #43
0
ファイル: ce_interface.py プロジェクト: ernstp/ansible
    def merge_interfaces(self, iftype, description, admin_state, mode):
        """ Merge interface attributes by type."""

        xmlstr = ''
        change = False
        intfs_list = self.intfs_info.get(iftype.lower())
        if not intfs_list:
            return

        for intf in intfs_list:
            if_change = False
            self.updates_cmd.append("interface %s" % intf['ifName'])
            if description and intf["ifDescr"] != description:
                xmlstr += CE_NC_XML_MERGE_INTF_DES % (
                    intf['ifName'], description)
                self.updates_cmd.append("description %s" % description)
                if_change = True
            if admin_state and is_admin_state_enable(self.intf_type)\
                    and intf["ifAdminStatus"] != admin_state:
                xmlstr += CE_NC_XML_MERGE_INTF_STATUS % (
                    intf['ifName'], admin_state)
                if_change = True
                if admin_state == "up":
                    self.updates_cmd.append("undo shutdown")
                else:
                    self.updates_cmd.append("shutdown")

            if is_portswitch_enalbe(self.intf_type):
                if mode == "layer2" \
                        and intf["isL2SwitchPort"] != "true":
                    xmlstr += CE_NC_XML_MERGE_INTF_L2ENABLE % (
                        intf['ifName'], 'enable')
                    self.updates_cmd.append("portswitch")
                    if_change = True
                elif mode == "layer3" \
                        and intf["isL2SwitchPort"] != "false":
                    xmlstr += CE_NC_XML_MERGE_INTF_L2ENABLE % (
                        intf['ifName'], 'disable')
                    self.updates_cmd.append("undo portswitch")
                    if_change = True

            if if_change:
                change = True
            else:
                self.updates_cmd.pop()

        if not change:
            return

        conf_str = '<config> ' + xmlstr + ' </config>'
        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "MERGE_INTFS_ATTR")
        self.changed = True
コード例 #44
0
    def merge_interfaces(self, iftype, description, admin_state, mode):
        """ Merge interface attributes by type."""

        xmlstr = ''
        change = False
        intfs_list = self.intfs_info.get(iftype.lower())
        if not intfs_list:
            return

        for intf in intfs_list:
            if_change = False
            self.updates_cmd.append("interface %s" % intf['ifName'])
            if description and intf["ifDescr"] != description:
                xmlstr += CE_NC_XML_MERGE_INTF_DES % (intf['ifName'],
                                                      description)
                self.updates_cmd.append("description %s" % description)
                if_change = True
            if admin_state and is_admin_state_enable(self.intf_type)\
                    and intf["ifAdminStatus"] != admin_state:
                xmlstr += CE_NC_XML_MERGE_INTF_STATUS % (intf['ifName'],
                                                         admin_state)
                if_change = True
                if admin_state == "up":
                    self.updates_cmd.append("undo shutdown")
                else:
                    self.updates_cmd.append("shutdown")

            if is_portswitch_enalbe(self.intf_type):
                if mode == "layer2" \
                        and intf["isL2SwitchPort"] != "true":
                    xmlstr += CE_NC_XML_MERGE_INTF_L2ENABLE % (intf['ifName'],
                                                               'enable')
                    self.updates_cmd.append("portswitch")
                    if_change = True
                elif mode == "layer3" \
                        and intf["isL2SwitchPort"] != "false":
                    xmlstr += CE_NC_XML_MERGE_INTF_L2ENABLE % (intf['ifName'],
                                                               'disable')
                    self.updates_cmd.append("undo portswitch")
                    if_change = True

            if if_change:
                change = True
            else:
                self.updates_cmd.pop()

        if not change:
            return

        conf_str = '<config> ' + xmlstr + ' </config>'
        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "MERGE_INTFS_ATTR")
        self.changed = True
コード例 #45
0
ファイル: ce_vlan.py プロジェクト: ernstp/ansible
    def config_vlan(self, vlan_id, name='', description=''):
        """Create vlan."""

        if name is None:
            name = ''
        if description is None:
            description = ''

        conf_str = CE_NC_CREATE_VLAN % (vlan_id, name, description)
        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "CREATE_VLAN")
        self.changed = True
コード例 #46
0
ファイル: ce_ntp.py プロジェクト: vharishgup/ansible-1
    def set_ntp(self, *args):
        """Configure ntp parameters"""

        if self.state == 'present':
            if self.ip_ver == 'IPv4':
                xml_str = CE_NC_MERGE_NTP_CONFIG % (
                    args[0], args[1], '::', args[2], args[3], args[4], args[5], args[6])
            elif self.ip_ver == 'IPv6':
                xml_str = CE_NC_MERGE_NTP_CONFIG % (
                    args[0], '0.0.0.0', args[1], args[2], args[3], args[4], args[5], args[6])
            ret_xml = set_nc_config(self.module, xml_str)
            self.check_response(ret_xml, "NTP_CORE_CONFIG")
        else:
            if self.ip_ver == 'IPv4':
                xml_str = CE_NC_DELETE_NTP_CONFIG % (
                    args[0], args[1], '::', args[2], args[3])
            elif self.ip_ver == 'IPv6':
                xml_str = CE_NC_DELETE_NTP_CONFIG % (
                    args[0], '0.0.0.0', args[1], args[2], args[3])
            ret_xml = set_nc_config(self.module, xml_str)
            self.check_response(ret_xml, "UNDO_NTP_CORE_CONFIG")
コード例 #47
0
    def delete_peer_link(self):
        """delete peer link info"""

        eth_trunk_id = "Eth-Trunk"
        eth_trunk_id += self.eth_trunk_id
        conf_str = CE_NC_DELETE_PEER_LINK_INFO % (self.peer_link_id,
                                                  eth_trunk_id)
        recv_xml = set_nc_config(self.module, conf_str)
        if "<ok/>" not in recv_xml:
            self.module.fail_json(msg='Error: Delete peer link failed.')
        self.updates_cmd.append("undo peer-link %s" % self.peer_link_id)
        self.changed = True
コード例 #48
0
ファイル: ce_ospf.py プロジェクト: vharishgup/ansible-1
    def remove_area(self):
        """remove ospf area"""

        if not self.is_area_exist():
            return

        xml_area = CE_NC_XML_BUILD_DELETE_AREA % (self.get_area_ip(), "")
        xml_str = CE_NC_XML_BUILD_PROCESS % (self.process_id, xml_area)
        recv_xml = set_nc_config(self.module, xml_str)
        self.check_response(recv_xml, "DELETE_AREA")
        self.updates_cmd.append("ospf %s" % self.process_id)
        self.updates_cmd.append("undo area %s" % self.get_area_ip())
        self.changed = True
コード例 #49
0
    def config_delete_vni_protocol_type(self, nve_name, vni_id, protocol_type):
        """remove vni protocol type"""

        if not self.is_vni_protocol_exist(nve_name, vni_id, protocol_type):
            return

        cfg_xml = CE_NC_DELETE_VNI_PROTOCOL % (nve_name, vni_id, protocol_type)
        recv_xml = set_nc_config(self.module, cfg_xml)
        self.check_response(recv_xml, "DELETE_VNI_PEER_PROTOCOL")
        self.updates_cmd.append("interface %s" % nve_name)
        self.updates_cmd.append(
            "undo vni %s head-end peer-list protocol bgp " % vni_id)
        self.changed = True
コード例 #50
0
    def config_delete_source_ip(self, nve_name, source_ip):
        """nve source ip"""

        if not self.is_nve_source_ip_exist(nve_name, source_ip):
            return
        ipaddr = "0.0.0.0"
        cfg_xml = CE_NC_MERGE_NVE_SOURCE_IP_PROTOCOL % (
            nve_name, ipaddr)
        recv_xml = set_nc_config(self.module, cfg_xml)
        self.check_response(recv_xml, "DELETE_SOURCE_IP")
        self.updates_cmd.append("interface %s" % nve_name)
        self.updates_cmd.append("undo source %s" % source_ip)
        self.changed = True
コード例 #51
0
ファイル: ce_mlag_config.py プロジェクト: ernstp/ansible
    def delete_peer_link(self):
        """delete peer link info"""

        eth_trunk_id = "Eth-Trunk"
        eth_trunk_id += self.eth_trunk_id
        conf_str = CE_NC_DELETE_PEER_LINK_INFO % (
            self.peer_link_id, eth_trunk_id)
        recv_xml = set_nc_config(self.module, conf_str)
        if "<ok/>" not in recv_xml:
            self.module.fail_json(
                msg='Error: Delete peer link failed.')
        self.updates_cmd.append("undo peer-link %s" % self.peer_link_id)
        self.changed = True
コード例 #52
0
ファイル: ce_ospf.py プロジェクト: ernstp/ansible
    def remove_area(self):
        """remove ospf area"""

        if not self.is_area_exist():
            return

        xml_area = CE_NC_XML_BUILD_DELETE_AREA % (self.get_area_ip(), "")
        xml_str = CE_NC_XML_BUILD_PROCESS % (self.process_id, xml_area)
        recv_xml = set_nc_config(self.module, xml_str)
        self.check_response(recv_xml, "DELETE_AREA")
        self.updates_cmd.append("ospf %s" % self.process_id)
        self.updates_cmd.append("undo area %s" % self.get_area_ip())
        self.changed = True
コード例 #53
0
ファイル: ce_mlag_interface.py プロジェクト: ernstp/ansible
    def create_mlag_error_down(self):
        """create mlag error down info"""

        if self.is_mlag_error_down_info_change():
            conf_str = CE_NC_CREATE_MLAG_ERROR_DOWN_INFO % self.interface
            recv_xml = set_nc_config(self.module, conf_str)
            if "<ok/>" not in recv_xml:
                self.module.fail_json(
                    msg='Error: create mlag error down info failed.')

            self.updates_cmd.append("interface %s" % self.interface)
            self.updates_cmd.append("m-lag unpaired-port suspend")
            self.changed = True
コード例 #54
0
    def create_mlag_error_down(self):
        """create mlag error down info"""

        if self.is_mlag_error_down_info_change():
            conf_str = CE_NC_CREATE_MLAG_ERROR_DOWN_INFO % self.interface
            recv_xml = set_nc_config(self.module, conf_str)
            if "<ok/>" not in recv_xml:
                self.module.fail_json(
                    msg='Error: create mlag error down info failed.')

            self.updates_cmd.append("interface %s" % self.interface)
            self.updates_cmd.append("m-lag unpaired-port suspend")
            self.changed = True
コード例 #55
0
ファイル: ce_ospf.py プロジェクト: ernstp/ansible
    def remove_nexthop(self):
        """remove ospf nexthop weight"""

        if not self.is_nexthop_exist():
            return

        xml_nh = CE_NC_XML_DELETE_NEXTHOP % self.nexthop_addr
        xml_topo = CE_NC_XML_BUILD_TOPO % xml_nh
        xml_str = CE_NC_XML_BUILD_PROCESS % (self.process_id, xml_topo)
        recv_xml = set_nc_config(self.module, xml_str)
        self.check_response(recv_xml, "DELETE_NEXTHOP_WEIGHT")
        self.updates_cmd.append("ospf %s" % self.process_id)
        self.updates_cmd.append("undo nexthop %s" % self.nexthop_addr)
        self.changed = True
コード例 #56
0
ファイル: ce_vxlan_vap.py プロジェクト: ernstp/ansible
    def config_traffic_encap(self):
        """configure traffic encapsulation types"""

        if not self.l2sub_info:
            self.module.fail_json(msg="Error: Interface %s does not exist." % self.l2_sub_interface)

        if not self.encapsulation:
            return

        xml_str = ""
        if self.encapsulation in ["default", "untag"]:
            if self.state == "present":
                if self.encapsulation != self.l2sub_info.get("flowType"):
                    xml_str = CE_NC_SET_ENCAP % (
                        self.l2_sub_interface, self.encapsulation)
                    self.updates_cmd.append(
                        "interface %s" % self.l2_sub_interface)
                    self.updates_cmd.append(
                        "encapsulation %s" % self.encapsulation)
            else:
                if self.encapsulation == self.l2sub_info.get("flowType"):
                    xml_str = CE_NC_UNSET_ENCAP % self.l2_sub_interface
                    self.updates_cmd.append(
                        "interface %s" % self.l2_sub_interface)
                    self.updates_cmd.append(
                        "undo encapsulation %s" % self.encapsulation)
        elif self.encapsulation == "none":
            if self.state == "present":
                if self.encapsulation != self.l2sub_info.get("flowType"):
                    xml_str = CE_NC_UNSET_ENCAP % self.l2_sub_interface
                    self.updates_cmd.append(
                        "interface %s" % self.l2_sub_interface)
                    self.updates_cmd.append(
                        "undo encapsulation %s" % self.l2sub_info.get("flowType"))
        elif self.encapsulation == "dot1q":
            self.config_traffic_encap_dot1q()
            return
        elif self.encapsulation == "qinq":
            self.config_traffic_encap_qinq()
            return
        else:
            pass

        if not xml_str:
            return
        recv_xml = set_nc_config(self.module, xml_str)
        self.check_response(recv_xml, "CONFIG_INTF_ENCAP")
        self.changed = True
コード例 #57
0
ファイル: ce_vrf.py プロジェクト: ernstp/ansible
    def operate_vrf(self):
        """config/delete vrf"""
        if not self.changed:
            return
        if self.state == "present":
            if self.description is None:
                configxmlstr = CE_NC_CREATE_VRF % (self.vrf, '')
            else:
                configxmlstr = CE_NC_CREATE_VRF % (self.vrf, self.description)
        else:
            configxmlstr = CE_NC_DELETE_VRF % (self.vrf, self.description)

        conf_str = build_config_xml(configxmlstr)

        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "OPERATE_VRF")
コード例 #58
0
ファイル: ce_info_center_log.py プロジェクト: ernstp/ansible
    def netconf_load_config(self, xml_str):
        """load log config by netconf"""

        if not xml_str:
            return

        xml_cfg = """
            <config>
            <syslog xmlns="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
            %s
            </syslog>
            </config>""" % xml_str

        recv_xml = set_nc_config(self.module, xml_cfg)
        self.check_response(recv_xml, "SET_LOG")
        self.changed = True
コード例 #59
0
ファイル: ce_interface.py プロジェクト: ernstp/ansible
    def delete_interfaces(self, iftype):
        """ Delete interfaces with type."""

        xmlstr = ''
        intfs_list = self.intfs_info.get(iftype.lower())
        if not intfs_list:
            return

        for intf in intfs_list:
            xmlstr += CE_NC_XML_DELETE_INTF % intf['ifName']
            self.updates_cmd.append('undo interface %s' % intf['ifName'])

        conf_str = '<config> ' + xmlstr + ' </config>'
        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "DELETE_INTFS")
        self.changed = True
コード例 #60
0
ファイル: ce_ospf.py プロジェクト: ernstp/ansible
    def remove_area_network(self):
        """remvoe ospf area network"""

        if not self.is_network_exist():
            return

        xml_network = CE_NC_XML_DELETE_NETWORKS % (
            self.addr, self.get_wildcard_mask())
        xml_area = CE_NC_XML_BUILD_AREA % (self.get_area_ip(), xml_network)
        xml_str = CE_NC_XML_BUILD_PROCESS % (self.process_id, xml_area)
        recv_xml = set_nc_config(self.module, xml_str)
        self.check_response(recv_xml, "DELETE_AREA_NETWORK")
        self.updates_cmd.append("ospf %s" % self.process_id)
        self.updates_cmd.append("area %s" % self.get_area_ip())
        self.updates_cmd.append("undo network %s %s" %
                                (self.addr, self.get_wildcard_mask()))
        self.changed = True