3.4.8. RE-WORKER-SERVICENOW

Release Engine Worker Plugin that does basic interaction with Service Now.

This worker takes two configuration files. The first is the SERVICE NOW configuration file. It should look like this:

{
    "servicenow_user": "username",
    "servicenow_password": "secret",
    "api_root_url": "https://127.0.0.1/api/now/v1"
}
  • Set the MQ config file parameters to sane values (see also: Setting Up The Bus)
  • Run the worker
    • From source: python ./replugin/servicenowworker/__init__.py -w $YOUR_SERVICE_NOW_CONF.json $YOUR_MQ_CONF.json
    • From install: re-worker-servicenow -w $YOUR_SERVICE_NOW_CONF.json $YOUR_MQ_CONF.json

We should see output similar to the following if everything well:

[user@frober]$ re-worker-servicenow -w servicenow.json mq.json`
2014-05-19 14:39:47,080 - ServiceNowWorker - WARNING - No app logger passed in. Defaulting to Streamandler with level INFO.
2014-05-19 14:39:47,083 - ServiceNowWorker - INFO - Attempting connection with amqp://inceptadmin:***@messagebus.example.com:5672/
2014-05-19 14:39:47,412 - ServiceNowWorker - INFO - Connection and channel open.
2014-05-19 14:39:47,413 - ServiceNowWorker - INFO - Consuming on queue worker.servicenow

3.4.8.1. Creating Change Records

Note

Creating change records requires a non-trivial amount of integration work. The CreateChangeRecord subcommand will not work out-of-the-box.

Creating change records requires additional information in your worker configuration file. Below is an example (omitting already covered details from above):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
{
    "api_import_url": "https://127.0.0.1/api/now/v1/import/u_test_change_creation",
    "auto_create_change_if_missing": false,
    "change_record_payload":
    {
        "u_change_location": "0503586769dd3000df63506980241089",
        "u_assignment_group": "f3b9bd00d0000000ec0be80b207ce954",
        "u_end_date": null,
        "u_change_plan": "Frobnicate all the things",
        "u_backout_plan": "Frob them back again",
        "u_short_description": "Test the Megafrobber Enterprise Suite",
        "u_start_date": null
    },
    "start_date_diff": {
        "days": 7
    },
    "end_date_diff": {
        "days": 7,
        "hours": 8
    }
}

Description of Fields

Field Description
api_import_url Full URL to import set table API endpoint
auto_create_change_if_missing Boolean - Will create a change record automatically if a DoesChangeRecordExist step is false
change_record_payload Dictionary - Scaffolding of new record inserted into import set table (see notes below)
start_date_diff Dictionary - Used to calculate the future start time from now (see notes below)
end_date_diff Dictionary - Used to calculate the future end time from now (see notes below)

3.4.8.1.1. change_record_payload

The change_record_payload dictionary is a template for new draft change records. Any reference field in your instance (in this example, u_change_location and u_assignment_group) must be defined using the sys_id of the target reference.

Leave the u_start_date and u_end_date fields as null. These are filled in automatically using the start_date_diff and end_date_diff by means of:

u_start_date = datetime.datetime.now() + datetime.timedelta(**start_date_diff)
u_end_date = datetime.datetime.now() + datetime.timedelta(**end_date_diff)

3.4.8.1.2. start/end_date_diff

These dictionaries must conform to the method signature of the datetime.timedelta() object.

3.4.8.2. Commands

The ServiceNow Worker steps are documented in Worker Steps: ServiceNow.