'Merge interface attributes by type.'

def merge_interfaces(self, iftype, description, admin_state, mode):

    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
