##### SUMMARY
snow modules do not call refactored login function.  Login must be called to initialize connection.

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
snow_record.py
snow_record_find.py

##### ANSIBLE VERSION
```
ansible 2.9
  config file = /home/pknight/dci/ansible/servicenow/ansible.cfg
  configured module search path = [u'/home/pknight/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15+ (default, Nov 27 2018, 23:36:35) [GCC 7.3.0]
```

##### CONFIGURATION
```
DEFAULT_VAULT_PASSWORD_FILE(/home/pknight/dci/ansible/servicenow/ansible.cfg) = /home/pknight/.ansiblevault
YAML_FILENAME_EXTENSIONS(/home/pknight/dci/ansible/servicenow/ansible.cfg) = [u'.json', u'.yaml', u'.yml', u'.vault']
```

##### OS / ENVIRONMENT
Linux

##### STEPS TO REPRODUCE
ansible-playbook -i sandbox Test-Run.yml -vvvvv

sandbox/regions:
[sandbox]
yourinstance.service-now.com

Test-Run.yml:
```yaml
yaml
- name: Test Run
  hosts: all
  connection: local
  gather_facts: no
  ignore_errors: True
  tasks:

  - name: Gather facts on automation user
    snow_record_find:
      username: "ansible_user@domain.com"
      password: "S0m3P@ssw0rd"
      client_id: "1234567890abcdef01234567890abcde"
      client_secret: "S0m3S3cr3t"
      instance: "yourinstance"
      max_records: 1
      table: sys_user
      query:
        email: "servicenow_user@domain.com"
      return_fields:
        - email
        - name
        - sys_id
```

##### EXPECTED RESULTS
```
ansible-playbook 2.8.2
  config file = /home/pknight/dci/ansible/servicenow/ansible.cfg
  configured module search path = [u'/home/pknight/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.15+ (default, Nov 27 2018, 23:36:35) [GCC 7.3.0]
Using /home/pknight/dci/ansible/servicenow/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /home/pknight/dci/ansible/servicenow/sandbox/regions as it did not pass it's verify_file() method
script declined parsing /home/pknight/dci/ansible/servicenow/sandbox/regions as it did not pass it's verify_file() method
auto declined parsing /home/pknight/dci/ansible/servicenow/sandbox/regions as it did not pass it's verify_file() method
Parsed /home/pknight/dci/ansible/servicenow/sandbox/regions inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/dist-packages/ansible/plugins/callback/default.pyc

PLAYBOOK: Test-Run.yml ***********************************************************************************************
Positional arguments: Test-Run.yml
become_method: sudo
inventory: (u'/home/pknight/dci/ansible/servicenow/sandbox',)
forks: 5
tags: (u'all',)
verbosity: 4
connection: smart
timeout: 10
1 plays in Test-Run.yml

PLAY [Test SNow] *****************************************************************************************************
META: ran handlers

TASK [Gather facts on automation user] *******************************************************************************
task path: /home/pknight/dci/ansible/servicenow/Test-Run.yml:9
<delawarecalgarytest.service-now.com> ESTABLISH LOCAL CONNECTION FOR USER: pknight
<delawarecalgarytest.service-now.com> EXEC /bin/sh -c 'echo ~pknight && sleep 0'
<delawarecalgarytest.service-now.com> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/pknight/.ansible/tmp/ansible-tmp-1563393628.67-264175846363655 `" && echo ansible-tmp-1563393628.67-264175846363655="` echo /home/pknight/.ansible/tmp/ansible-tmp-1563393628.67-264175846363655 `" ) && sleep 0'
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/notification/snow_record_find.py
<delawarecalgarytest.service-now.com> PUT /home/pknight/.ansible/tmp/ansible-local-12354QW3EpR/tmp5q343Y TO /home/pknight/.ansible/tmp/ansible-tmp-1563393628.67-264175846363655/AnsiballZ_snow_record_find.py
<delawarecalgarytest.service-now.com> EXEC /bin/sh -c 'chmod u+x /home/pknight/.ansible/tmp/ansible-tmp-1563393628.67-264175846363655/ /home/pknight/.ansible/tmp/ansible-tmp-1563393628.67-264175846363655/AnsiballZ_snow_record_find.py && sleep 0'
<delawarecalgarytest.service-now.com> EXEC /bin/sh -c '/home/pknight/dci/ansible/servicenow/venv/bin/python2.7 /home/pknight/.ansible/tmp/ansible-tmp-1563393628.67-264175846363655/AnsiballZ_snow_record_find.py && sleep 0'
<delawarecalgarytest.service-now.com> EXEC /bin/sh -c 'rm -f -r /home/pknight/.ansible/tmp/ansible-tmp-1563393628.67-264175846363655/ > /dev/null 2>&1 && sleep 0'
ok: [yourinstance.service-now.com] => {
    "changed": false, 
    "instance": "yourinstance", 
    "invocation": {
        "module_args": {
            "client_id": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "client_secret": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "instance": "yourinstance", 
            "max_records": 1, 
            "order_by": "-created_on", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "query": {
                "email": "servicenow_user@domain.com"
            }, 
            "return_fields": [
                "email", 
                "name", 
                "sys_id"
            ], 
            "table": "sys_user", 
            "username": "ansible_user@domain.com"
        }
    }, 
    "max_records": 1, 
    "query": {
        "email": "servicenow_user@domain.com"
    }, 
    "record": [
        {
            "email": "servicenow_user@domain.com", 
            "name": "ServiceNow User", 
            "sys_id": "1234567890abcdef1234567890"
        }
    ], 
    "return_fields": [
        "email", 
        "name", 
        "sys_id"
    ], 
    "table": "sys_user"
}
META: ran handlers
META: ran handlers

PLAY RECAP ***********************************************************************************************************
yourinstance.service-now.com : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
```

##### ACTUAL RESULTS
```
ansible-playbook 2.8.2
  config file = /home/pknight/dci/ansible/servicenow/ansible.cfg
  configured module search path = [u'/home/pknight/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.15+ (default, Nov 27 2018, 23:36:35) [GCC 7.3.0]
Using /home/pknight/dci/ansible/servicenow/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /home/pknight/dci/ansible/servicenow/sandbox/regions as it did not pass it's verify_file() method
script declined parsing /home/pknight/dci/ansible/servicenow/sandbox/regions as it did not pass it's verify_file() method
auto declined parsing /home/pknight/dci/ansible/servicenow/sandbox/regions as it did not pass it's verify_file() method
Parsed /home/pknight/dci/ansible/servicenow/sandbox/regions inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/dist-packages/ansible/plugins/callback/default.pyc

PLAYBOOK: Test-Run.yml ***********************************************************************************************
Positional arguments: Test-Run.yml
become_method: sudo
inventory: (u'/home/pknight/dci/ansible/servicenow/sandbox',)
forks: 5
tags: (u'all',)
verbosity: 4
connection: smart
timeout: 10
1 plays in Test-Run.yml

PLAY [Test SNow] *****************************************************************************************************
META: ran handlers

TASK [Gather facts on automation user] *******************************************************************************
task path: /home/pknight/dci/ansible/servicenow/Test-Run.yml:9
<delawarecalgarytest.service-now.com> ESTABLISH LOCAL CONNECTION FOR USER: pknight
<delawarecalgarytest.service-now.com> EXEC /bin/sh -c 'echo ~pknight && sleep 0'
<delawarecalgarytest.service-now.com> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/pknight/.ansible/tmp/ansible-tmp-1563393553.59-213692823755979 `" && echo ansible-tmp-1563393553.59-213692823755979="` echo /home/pknight/.ansible/tmp/ansible-tmp-1563393553.59-213692823755979 `" ) && sleep 0'
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/notification/snow_record_find.py
<delawarecalgarytest.service-now.com> PUT /home/pknight/.ansible/tmp/ansible-local-12069E5RReh/tmpeVAB5I TO /home/pknight/.ansible/tmp/ansible-tmp-1563393553.59-213692823755979/AnsiballZ_snow_record_find.py
<delawarecalgarytest.service-now.com> EXEC /bin/sh -c 'chmod u+x /home/pknight/.ansible/tmp/ansible-tmp-1563393553.59-213692823755979/ /home/pknight/.ansible/tmp/ansible-tmp-1563393553.59-213692823755979/AnsiballZ_snow_record_find.py && sleep 0'
<delawarecalgarytest.service-now.com> EXEC /bin/sh -c '/home/pknight/dci/ansible/servicenow/venv/bin/python2.7 /home/pknight/.ansible/tmp/ansible-tmp-1563393553.59-213692823755979/AnsiballZ_snow_record_find.py && sleep 0'
<delawarecalgarytest.service-now.com> EXEC /bin/sh -c 'rm -f -r /home/pknight/.ansible/tmp/ansible-tmp-1563393553.59-213692823755979/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_snow_record_find_payload_GdXZXi/__main__.py", line 255, in run_module
    record = conn.query(table=module.params['table'],

fatal: [yourinstance.service-now.com]: FAILED! => {
    "changed": false, 
    "instance": "yourinstance", 
    "invocation": {
        "module_args": {
            "client_id": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "client_secret": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "instance": "yourinstance", 
            "max_records": 1, 
            "order_by": "-created_on", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "query": {
                "email": "servicenow_user@domain.com"
            }, 
            "return_fields": [
                "email", 
                "name", 
                "sys_id"
            ], 
            "table": "sys_user", 
            "username": "ansible_user@domain.com"
        }
    }, 
    "max_records": 1, 
    "msg": "Failed to find record: 'NoneType' object has no attribute 'query'", 
    "query": {
        "email": "servicenow_user@domain.com"
    }, 
    "return_fields": [
        "email", 
        "name", 
        "sys_id"
    ], 
    "table": "sys_user"
}
...ignoring
META: ran handlers
META: ran handlers

PLAY RECAP ***********************************************************************************************************
yourinstance.service-now.com : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=1
```

from __future__ import absolute_import, division, print_function
__metaclass__ = type
import traceback
from ansible.module_utils.basic import missing_required_lib
HAS_PYSNOW = False
PYSNOW_IMP_ERR = None
try:
    import pysnow
    HAS_PYSNOW = True
except ImportError:
    PYSNOW_IMP_ERR = traceback.format_exc()
class ServiceNowClient(object):
    def __init__(self, module):
        """
        Constructor
        """
        if not HAS_PYSNOW:
            module.fail_json(msg=missing_required_lib('pysnow'), exception=PYSNOW_IMP_ERR)
        self.module = module
        self.params = module.params
        self.client_id = self.params['client_id']
        self.client_secret = self.params['client_secret']
        self.username = self.params['username']
        self.password = self.params['password']
        self.instance = self.params['instance']
        self.session = {'token': None}
        self.conn = None
    def login(self):