'The work function'

def work(self):

    self.check_args()
    self.get_proposed()
    self.get_existing()
    find_flag = False
    find_undo_flag = False
    tmp_interface = None
    if (self.state == 'present'):
        if self.feature_name:
            if self.trap_name:
                tmp_cfg = ('feature-name    %s    trap-name    %s' % (self.feature_name, self.trap_name.lower()))
            else:
                tmp_cfg = ('feature-name    %s' % self.feature_name)
            find_undo_flag = False
            if self.cur_cfg['undo    snmp-agent    trap']:
                for item in self.cur_cfg['undo    snmp-agent    trap']:
                    if (item == tmp_cfg):
                        find_undo_flag = True
                    elif (tmp_cfg in item):
                        find_undo_flag = True
                    elif (self.feature_name == 'all'):
                        find_undo_flag = True
            if find_undo_flag:
                self.set_trap_feature_name()
            if (not find_undo_flag):
                find_flag = False
                if self.cur_cfg['snmp-agent    trap']:
                    for item in self.cur_cfg['snmp-agent    trap']:
                        if (item == 'enable'):
                            find_flag = True
                        elif (item == tmp_cfg):
                            find_flag = True
                if (not find_flag):
                    self.set_trap_feature_name()
        if self.interface_type:
            find_flag = False
            tmp_interface = (self.interface_type + self.interface_number)
            if ('trap    source    interface' in self.cur_cfg.keys()):
                if (self.cur_cfg['trap    source    interface'] == tmp_interface):
                    find_flag = True
            if (not find_flag):
                self.set_trap_source_interface()
        if self.port_number:
            find_flag = False
            if ('trap    source-port' in self.cur_cfg.keys()):
                if (self.cur_cfg['trap    source-port'] == self.port_number):
                    find_flag = True
            if (not find_flag):
                self.set_trap_source_port()
    else:
        if self.feature_name:
            if self.trap_name:
                tmp_cfg = ('feature-name    %s    trap-name    %s' % (self.feature_name, self.trap_name.lower()))
            else:
                tmp_cfg = ('feature-name    %s' % self.feature_name)
            find_flag = False
            if self.cur_cfg['snmp-agent    trap']:
                for item in self.cur_cfg['snmp-agent    trap']:
                    if (item == tmp_cfg):
                        find_flag = True
                    elif (item == 'enable'):
                        find_flag = True
                    elif (tmp_cfg in item):
                        find_flag = True
            else:
                find_flag = True
            find_undo_flag = False
            if self.cur_cfg['undo    snmp-agent    trap']:
                for item in self.cur_cfg['undo    snmp-agent    trap']:
                    if (item == tmp_cfg):
                        find_undo_flag = True
                    elif (tmp_cfg in item):
                        find_undo_flag = True
            if find_undo_flag:
                pass
            elif find_flag:
                self.undo_trap_feature_name()
        if self.interface_type:
            if ('trap    source    interface' in self.cur_cfg.keys()):
                self.undo_trap_source_interface()
        if self.port_number:
            if ('trap    source-port' in self.cur_cfg.keys()):
                self.undo_trap_source_port()
    self.get_end_state()
    self.results['changed'] = self.changed
    self.results['proposed'] = self.proposed
    self.results['existing'] = self.existing
    self.results['end_state'] = self.end_state
    self.results['updates'] = self.updates_cmd
    self.module.exit_json(**self.results)
