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
    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)
            if mode == "mode-l3":
                self.updates_cmd.append("mode l3")
            else:
                self.updates_cmd.append("undo mode l3")
            self.changed = True
    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
    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
    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
Exemple #6
0
    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
    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
    def delete_peer_link(self):
        """delete peer link info"""

        eth_trunk_id = "Eth-Trunk"
        eth_trunk_id += self.eth_trunk_id
        if self.eth_trunk_id and eth_trunk_id == self.peer_link_info.get(
                "portName"):
            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
Exemple #9
0
    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")
Exemple #10
0
    def set_multicast_global(self):
        """set multicast global"""
        if not self.changed:
            return
        version = self.version
        state = self.state
        if state == "present":
            configxmlstr = CE_NC_MERGE_MULTICAST_GLOBAL % (self.vrf, version)
        else:
            configxmlstr = CE_NC_DELETE_MULTICAST_GLOBAL % (self.vrf, version)

        conf_str = build_config_xml(configxmlstr)
        recv_xml = set_nc_config(self.module, conf_str)
        self._checkresponse_(recv_xml, "SET_MULTICAST_GLOBAL")
    def set_sysview_igmp(self):
        """set igmp of sysview"""
        if not self.changed:
            return
        version = self.addr_family
        state = self.state
        if state == "present":
            configxmlstr = CE_NC_MERGE_IGMP_SYSVIEW % (version)
        else:
            configxmlstr = CE_NC_DELETE_IGMP_SYSVIEW % (version)

        conf_str = build_config_xml(configxmlstr)
        recv_xml = set_nc_config(self.module, conf_str)
        self._checkresponse_(recv_xml, "SET_SYSVIEW_IGMP")
    def config_delete_vni2bd(self, bd_id, vni_id):
        """remove vni to bd id"""

        if not self.is_vni_bd_exist(vni_id, bd_id):
            return
        cfg_xml = CE_NC_DELETE_VNI_BD_ID % (vni_id, bd_id)
        recv_xml = set_nc_config(self.module, cfg_xml)
        self.check_response(recv_xml, "DELETE_VNI_BD")
        self.updates_cmd.append(
            "bridge-domain %s" % bd_id)
        self.updates_cmd.append(
            "undo vxlan vni %s" % vni_id)

        self.changed = True
Exemple #13
0
    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
Exemple #14
0
    def delete_mlag(self):
        """delete mlag info"""

        if self.is_mlag_info_exist():
            mlag_port = "Eth-Trunk"
            mlag_port += self.eth_trunk_id
            conf_str = CE_NC_DELETE_MLAG_INFO % (self.dfs_group_id, mlag_port)
            recv_xml = set_nc_config(self.module, conf_str)
            if "<ok/>" not in recv_xml:
                self.module.fail_json(msg='Error: delete mlag info failed.')

            self.updates_cmd.append("interface %s" % mlag_port)
            self.updates_cmd.append("undo dfs-group %s m-lag %s" %
                                    (self.dfs_group_id, self.mlag_id))
            self.changed = True
    def config_delete_mode(self, nve_name, mode):
        """nve mode"""

        if mode == "mode-l3":
            if not self.is_nve_mode_exist(nve_name, mode):
                return
            cfg_xml = CE_NC_MERGE_NVE_MODE % (nve_name, "mode-l2")

            recv_xml = set_nc_config(self.module, cfg_xml)
            self.check_response(recv_xml, "DELETE_MODE")
            self.updates_cmd.append("interface %s" % nve_name)
            self.updates_cmd.append("undo mode l3")
            self.changed = True
        else:
            self.module.fail_json(msg='Error: Can not configure undo mode l2.')
    def config_merge_vni_peer_ip(self, nve_name, vni_id, peer_ip_list):
        """config vni peer ip"""

        if self.is_vni_peer_list_change(nve_name, vni_id, peer_ip_list):
            cfg_xml = CE_NC_MERGE_VNI_PEER_ADDRESS_IP_HEAD % (nve_name, vni_id)
            for peer_ip in peer_ip_list:
                cfg_xml += CE_NC_MERGE_VNI_PEER_ADDRESS_IP_MERGE % peer_ip
            cfg_xml += CE_NC_MERGE_VNI_PEER_ADDRESS_IP_END
            recv_xml = set_nc_config(self.module, cfg_xml)
            self.check_response(recv_xml, "MERGE_VNI_PEER_IP")
            self.updates_cmd.append("interface %s" % nve_name)

            for peer_ip in peer_ip_list:
                cmd_output = "vni %s head-end peer-list %s" % (vni_id, peer_ip)
                self.updates_cmd.append(cmd_output)
            self.changed = True
    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")
    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
    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
    def config_merge_vni_protocol_type(self, nve_name, vni_id, protocol_type):
        """config vni protocol type"""

        if self.is_vni_protocol_change(nve_name, vni_id, protocol_type):
            cfg_xml = CE_NC_MERGE_VNI_PROTOCOL % (
                nve_name, vni_id, protocol_type)
            recv_xml = set_nc_config(self.module, cfg_xml)
            self.check_response(recv_xml, "MERGE_VNI_PEER_PROTOCOL")
            self.updates_cmd.append("interface %s" % nve_name)

            if protocol_type == "bgp":
                self.updates_cmd.append(
                    "vni %s head-end peer-list protocol %s" % (vni_id, protocol_type))
            else:
                self.updates_cmd.append(
                    "undo vni %s head-end peer-list protocol bgp" % vni_id)
            self.changed = True
Exemple #21
0
    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
    def default_interfaces(self, iftype):
        """ Set interface config to default by type."""

        change = False
        xmlstr = ''
        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'])

            # set description default
            if intf['ifDescr']:
                xmlstr += CE_NC_XML_MERGE_INTF_DES % (intf['ifName'], '')
                self.updates_cmd.append("undo description")
                if_change = True

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

            # set portswitch default
            if is_portswitch_enalbe(
                    self.intf_type) and intf["isL2SwitchPort"] != "true":
                xmlstr += CE_NC_XML_MERGE_INTF_L2ENABLE % (intf['ifName'],
                                                           'enable')
                self.updates_cmd.append("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, "SET_INTFS_DEFAULT")
        self.changed = True
    def merge_vlan(self, vlan_id, name, description):
        """Merge vlan."""

        conf_str = None

        if not name and description:
            conf_str = CE_NC_MERGE_VLAN_DES % (vlan_id, description)
        if not description and name:
            conf_str = CE_NC_MERGE_VLAN_NAME % (vlan_id, name)
        if description and name:
            conf_str = CE_NC_MERGE_VLAN % (vlan_id, name, description)

        if not conf_str:
            return

        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "MERGE_VLAN")
        self.changed = True
    def merge_debug_global(self):
        """ Merge debug global """

        conf_str = CE_MERGE_DEBUG_GLOBAL_HEADER

        if self.debug_time_stamp:
            conf_str += "<debugTimeStamp>%s</debugTimeStamp>" % self.debug_time_stamp.upper()

        conf_str += CE_MERGE_DEBUG_GLOBAL_TAIL

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

        if self.debug_time_stamp:
            cmd = "info-center timestamp debugging " + TIME_STAMP_DICT.get(self.debug_time_stamp)
            self.updates_cmd.append(cmd)

        self.changed = True
Exemple #25
0
    def delete_debug_global(self):
        """ Delete debug global """

        conf_str = CE_MERGE_DEBUG_GLOBAL_HEADER

        if self.debug_time_stamp:
            conf_str += "<debugTimeStamp>DATE_MILLISECOND</debugTimeStamp>"

        conf_str += CE_MERGE_DEBUG_GLOBAL_TAIL

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

        if self.debug_time_stamp:
            cmd = "undo info-center timestamp debugging"
            self.updates_cmd.append(cmd)

        self.changed = True
    def merge_dot1qtunnel_vlan(self, ifname, default_vlan):
        """Merge dot1qtunnel"""

        change = False
        conf_str = ""

        self.updates_cmd.append("interface %s" % ifname)
        if self.state == "present":
            if self.intf_info["linkType"] == "dot1qtunnel":
                if default_vlan and self.intf_info["pvid"] != default_vlan:
                    self.updates_cmd.append("port default vlan %s" %
                                            default_vlan)
                    conf_str = CE_NC_SET_PORT % (ifname, "dot1qtunnel",
                                                 default_vlan, "", "")
                    change = True
            else:
                self.updates_cmd.append("port link-type dot1qtunnel")
                if default_vlan:
                    self.updates_cmd.append("port default vlan %s" %
                                            default_vlan)
                    conf_str = CE_NC_SET_PORT % (ifname, "dot1qtunnel",
                                                 default_vlan, "", "")
                else:
                    conf_str = CE_NC_SET_PORT % (ifname, "dot1qtunnel", "1",
                                                 "", "")
                change = True
        elif self.state == "absent":
            if self.intf_info["linkType"] == "dot1qtunnel":
                if default_vlan and self.intf_info[
                        "pvid"] == default_vlan and default_vlan != "1":
                    self.updates_cmd.append("undo port default vlan %s" %
                                            default_vlan)
                    conf_str = CE_NC_SET_PORT % (ifname, "dot1qtunnel", "1",
                                                 "", "")
                    change = True
        if not change:
            self.updates_cmd.pop()  # remove interface
            return
        conf_str = "<config>" + conf_str + "</config>"
        rcv_xml = set_nc_config(self.module, conf_str)
        self.check_response(rcv_xml, "MERGE_DOT1QTUNNEL_PORT")
        self.changed = True
    def operate_static_route(self, version, prefix, mask, nhp_interface,
                             next_hop, vrf, destvrf, state):
        """operate ipv4 static route"""

        description_xml = """\n"""
        preference_xml = """\n"""
        tag_xml = """\n"""
        if next_hop is None:
            next_hop = '0.0.0.0'
        if nhp_interface is None:
            nhp_interface = "Invalid0"

        if vrf is None:
            vpn_instance = "_public_"
        else:
            vpn_instance = vrf

        if destvrf is None:
            dest_vpn_instance = "_public_"
        else:
            dest_vpn_instance = destvrf
        if self.description:
            description_xml = CE_NC_SET_DESCRIPTION % self.description
        if self.pref:
            preference_xml = CE_NC_SET_PREFERENCE % self.pref
        if self.tag:
            tag_xml = CE_NC_SET_TAG % self.tag

        if state == "present":
            configxmlstr = CE_NC_SET_STATIC_ROUTE % (
                vpn_instance, version, prefix, mask, nhp_interface,
                dest_vpn_instance, next_hop, description_xml, preference_xml,
                tag_xml)
        else:
            configxmlstr = CE_NC_DELETE_STATIC_ROUTE % (
                vpn_instance, version, prefix, mask, nhp_interface,
                dest_vpn_instance, next_hop)

        conf_str = build_config_xml(configxmlstr)

        recv_xml = set_nc_config(self.module, conf_str)
        self.check_response(recv_xml, "OPERATE_STATIC_ROUTE")
Exemple #28
0
    def delete_debug_source(self):
        """ Delete debug source """

        if self.debug_enable == 'no_use' and not self.debug_level:
            conf_str = CE_DELETE_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
            conf_str += CE_DELETE_DEBUG_SOURCE_TAIL
        else:
            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>" % CHANNEL_DEFAULT_DBG_STATE.get(
                    self.channel_id)
            if self.debug_level:
                conf_str += "<dbgEnLevel>%s</dbgEnLevel>" % CHANNEL_DEFAULT_DBG_LEVEL.get(
                    self.channel_id)
            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: Delete debug source failed.')

        cmd = "undo 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':
            cmd += " debug state"
        if self.debug_level:
            cmd += " level"

        self.updates_cmd.append(cmd)
        self.changed = True
    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 = False

        nve_peer_info = list()
        for nve_peer in self.nve_info["vni_peer_ips"]:
            if nve_peer["vniId"] == vni_id:
                nve_peer_info = nve_peer.get("peerAddr")
        for peer in nve_peer_info:
            if peer not in peer_ip_list:
                config = True

        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
Exemple #30
0
    def default_switchport(self, ifname):
        """Set interface default or unconfigured"""

        change = False
        if self.intf_info["linkType"] != "access":
            self.updates_cmd.append("interface %s" % ifname)
            self.updates_cmd.append("port link-type access")
            self.updates_cmd.append("port default vlan 1")
            change = True
        else:
            if self.intf_info["pvid"] != "1":
                self.updates_cmd.append("interface %s" % ifname)
                self.updates_cmd.append("port default vlan 1")
                change = True

        if not change:
            return

        conf_str = CE_NC_SET_DEFAULT_PORT % ifname
        rcv_xml = set_nc_config(self.module, conf_str)
        self.check_response(rcv_xml, "DEFAULT_INTF_VLAN")
        self.changed = True