'configure traffic encapsulation type dot1q'

def config_traffic_encap_dot1q(self):

    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_DOT1Q % (self.l2_sub_interface, vlan_bitmap, vlan_bitmap))
                self.updates_cmd.append(('encapsulation    %s    vid    %s' % (self.encapsulation, self.ce_vid)))
            else:
                xml_str = (CE_NC_SET_ENCAP % (self.l2_sub_interface, self.encapsulation))
                self.updates_cmd.append(('encapsulation    %s' % self.encapsulation))
        elif (self.ce_vid and (not is_vlan_in_bitmap(self.ce_vid, self.l2sub_info.get('dot1qVids')))):
            vlan_bitmap = vlan_vid_to_bitmap(self.ce_vid)
            xml_str = (CE_NC_SET_ENCAP_DOT1Q % (self.l2_sub_interface, vlan_bitmap, vlan_bitmap))
            self.updates_cmd.append(('encapsulation    %s    vid    %s' % (self.encapsulation, self.ce_vid)))
    elif (self.encapsulation == self.l2sub_info.get('flowType')):
        if self.ce_vid:
            if is_vlan_in_bitmap(self.ce_vid, self.l2sub_info.get('dot1qVids')):
                xml_str = (CE_NC_UNSET_ENCAP % self.l2_sub_interface)
                self.updates_cmd.append(('undo    encapsulation    %s    vid    %s' % (self.encapsulation, 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_DOT1Q')
    self.changed = True
