Package: nowcli
This project shows you how to set up theNOW CLIand use it to interact with a ServiceNow instance either locally from your workstation or from a CI/CD Pipeline like JenkinsPrerequisitesPython3 InstalledPiPy Account to deploy packageInstallInstall Package using PIPpip3 install nowcliContributeClone Projectgit clone git@github.com:advlab/cronus.git nowcli
cd nowcliMake the appropriate editsRun locally to testpython -m cronus COMMANDSInstall Locally to testsudo python3 setup.py installUninstall Packagesudo pip3 uninstall -y nowcliDeploy Package to PiPiInstall Twinepip3 install twineCreate Source Distributionpython3 setup.py sdistDeploy Packagetwine upload dist/*UsageCreate default profile in ~/.now/credentials$now configureSetup additional profiles (e.g. newyork) and use your instance specifics$ now -p newyork configure
table_api [/api/now/table]:
cmdb_api [/api/x_snc_labs_atlas/v1/register/services]: 
em_api [/api/x_snc_labs_atlas/v1/create/event]: 
server []: YOURSERVERURL
username []: YOURUSERID
password []: YOURPASSWORDRegister Service (e.g. bookinfo.json)$ now -p newyork -d bookinfo.json cmdb register-services
Called CMDB...
{'result': {'code': '200', 'type': 'register_services', 'message': 'Services created in ServiceNow: 7'}}Create EventResolve IncidentExample Payloadsbookinfo.json{
"name": "Bookworms",
"comments": "Bookworms 2019 Reviews",
"services": [{
        "name": "bookinfo",
        "uri": "http://bookinfo.com"
    },
    {
        "name": "productpage",
        "uri": "http://bookinfo.com/product"
    },
    {
        "name": "details",
        "uri": "http://bookinfo.com/details"
    },
    {
        "name": "reviews-v1",
        "uri": "http://bookinfo.com/reviews-v1"
    },
    {
        "name": "reviews-v2",
        "uri": "http://bookinfo.com/reviews-v2"
    },
    {
        "name": "reviews-v3",
        "uri": "http://bookinfo.com/reviews-v3"
    },
    {
        "name": "ratings",
        "uri": "http://bookinfo.com/ratings"
    }
],
"relationships": [{
        "parent": null,
        "child": "bookinfo"
    },
    {
        "parent": "bookinfo",
        "child": "productpage"
    },
    {
        "parent": "productpage",
        "child": "reviews-v1"
    },
    {
        "parent": "productpage",
        "child": "reviews-v2"
    },
    {
        "parent": "productpage",
        "child": "reviews-v3"
    },
    {
        "parent": "productpage",
        "child": "details"
    },
    {
        "parent": "reviews-v2",
        "child": "ratings"
    },
    {
        "parent": "reviews-v3",
        "child": "ratings"
    }
]
}startreck.json{
"name": "USS Enteprise NCC-1701",
"comments": "NCC-1701 Constitution Class Starship",
"services": [{
        "name": "ncc1701",
        "uri": "http://ncc1701.net"
    },
    {
        "name": "weapons",
        "uri": "http://weapons.ncc1701.net"
    },
    {
        "name": "phasers",
        "uri": "http://phasers.ncc1701.net"
    },
    {
        "name": "lifesuppport",
        "uri": "http://lifesupport.ncc1701.net"
    }
],
"relationships": [{
        "parent": null,
        "child": "ncc1701"
    },
    {
        "parent": "ncc1701",
        "child": "weapons"
    },
    {
        "parent": "weapons",
        "child": "phasers"
    },
    {
        "parent": "ncc1701",
        "child": "lifesuppport"
    }
]
}ReferencePython 3This section describes how to install Python 3.7.2 in Ubuntu 18.04 / 18.10Install Python 3sudo add-apt-repository ppa:ubuntu-toolchain-r/ppa
sudo apt install -y python3.7Install Pipsudo apt install -y python3-pipTo check versionsapt list --installed | grep pythonInstall Unit Testerpip3 install noseInstall Nose Testersudo apt install python-noseRun Unit Testernosetests --with-xunit tests/test_project.pyFreeze Requirementspip3 freeze > requirements.txt