6 Replies Latest reply on Feb 14, 2017 7:45 AM by Sae Park

    Bladelogic with REST and setting parameters for NSH Script

    Narahari Lakshminarayana

      Hello:

       

      I have a NSHScript job that takes 2 parameters

      a. FolderName

      b.Version

       

      I would like to invoke this job with Bladelogic using REST. 

      https://blwebservices.es.ad.adp.com:9843/group/Jobs/USS%20Job%20Workspace/Presentation%20Services/Portal/Users/Narahari/NSH_Generic_CopyFilesPaaS_Job?username=XXXXX&password=XXXXXX&role=USS_DEV_Packaging&authType=ADK_PASSWORD

       

      But where I am faltering is how to set parameters of this NSHScript Job. 

       

      Please help by posting sample code on how to set the parameters of the NSHScript.

       

      -Narahari

        • 2. Re: Bladelogic with REST and setting parameters for NSH Script
          Narahari Lakshminarayana

          Thanks for your answer Bill.  So I can execute a job but I cannot set parameters for the job with BL REST API.

          Am I understanding that right ?

           

          -Narahari

          • 3. Re: Bladelogic with REST and setting parameters for NSH Script
            Bill Robinson

            Yep.  you can use soap.  But that sets it for the job, it’s not a runtime set.  if you want to have a per-run set you should look at the execution task (still soap though)

            • 4. Re: Bladelogic with REST and setting parameters for NSH Script
              Bill Robinson

              actually, i was wrong, you can:

               

               

              So more or less:

               

              this: https://localhost:9843/type/PropertySetClasses/SystemObject/depot%20object/NSH%20Script/?username=BLAdmin&password=&role=BLAdmins&version=8.5&bquery=select%20PARAMETERS*.PARAMETER_NAME,PARAMETERS*.DEFAULT_VALUE,PARAMETERS*.PARAMETER_ID,PARAMETERS*.COMMAND_ARGUMENT,PARAMETERS*.PARAMETER_FLAGS%20where%20name=%22nsh_script%22

               

              Should dump the parameter uris.  find the one you want and feed it into a xml file (below) w/ the value you want and then i do a post and feed in the below xml from a file. or json (2nd one)

               

              <?xml version="1.0" encoding="UTF-8" ?>

              <RESTXMLRequest>

               

                 <PropertySetInstance name="NSH Sript Job" objectId="b4dd51da-bf8d-47af-b6fc-28937fb36bc8" type="/type/PropertySetClasses/SystemObject/Job/NSH Script Job"   description="Deploy Job - Created by Automation">

               

                 <PropertyValue name="DEPOT_OBJECT*" isList="true" type="/type/PropertySetClasses/SystemObject/Depot Object/" isNull="false" isNoAccess="false" value="">

                          <uris>

                              <uri>/id/SystemObject/Depot Object/NSH Script/3d88550d-d3af-4d86-9e02-9d827bf43db5</uri>

                          </uris>

                 </PropertyValue>

               

                      <Parameters>

                      <ParameterValue uri="/id/SystemObject/NSH Script Parameter/b1a5aadf-1776-41f1-a57e-e2f32923bd30" value="finalUpdate" isSkipFlag="true" isSkipValue="true"/>

                  </Parameters>

              </PropertySetInstance>

              </RESTXMLRequest>

               

               

               

              {

               

                 "PropertySetInstance":{

                    "name":"RESTDeployJob1340115275610",

                    "type":"/type/PropertySetClasses/SystemObject/job/deploy job",

                    "description":"deploy job",

                    "Parameters":[

                       {

                          "uri":"/id/SystemObject/NSH Script Parameter/b1a5aadf-1776-41f1-a57e-e2f32923bd30",

                          "value":"finalUpdate",

                          "isSkipFlag":"true",

                          "isSkipValue":"true"

                       }

                    ]      "PropertyValues":[

                       {

                          "name":"DESCRIPTION",

                          "type":"String",

                          "value":"deploy job"

                       },

                       {

                          "name":"NAME",

                          "type":"String",

                          "value":"RESTDeployJob1340115275610"

                       },

                       {

                          "name":"DEPOT_OBJECT*",

                          "type":"/type/PropertySetClasses/SystemObject/Depot Object",

                          "uris":[

                             "/id/SystemObject/Depot Object/BLPackage/a0e3fd5b-9ef1-44f2-9f78-014dd662f3d8"

                          ]

                       }

                    ]

                 }

              }

              • 5. Re: Bladelogic with REST and setting parameters for NSH Script
                Raja Vairaashtak

                Hi,

                {

                   "PropertySetInstance":{

                      "name":"UserAddJob",

                      "type":"/type/PropertySetClasses/SystemObject/Depot Object/NSH Script",

                      "description":"",

                      "Parameters":[

                        {

                            "uri":"/id/SystemObject/NSH Script Parameter/3e5a2a41-b3b5-4947-a122-9d0aa50f3283",

                            "value":"servername1",

                            "isSkipFlag":"true",

                            "isSkipValue":"true"

                         }

                      ],

                      "PropertyValues":[

                         {

                            "name":"DESCRIPTION",

                            "type":"String",

                            "value":""

                         },

                         {

                            "name":"NAME",

                            "type":"String",

                            "value":"SampleJob"

                         },

                         {

                            "name":"DEPOT_OBJECT*",

                            "type":"/type/PropertySetClasses/SystemObject/Depot Object",

                            "uris":[

                               "/id/SystemObject/Depot Object/NSH Script/c0db2b2e-777e-4eb7-937a-ef0b6ca2b785"

                            ]

                         }

                      ]

                   }

                }

                Above is the json I am posting in similar way, but I don't see parameters are setting in the script. My NSH script takes only single parameter.

                The using REST url for invoking the JOB:

                 

                https://abcd.com:9843/group/Jobs/Workspace/job_folder/dev1/UserAddJob/Operations/execute

                 

                I am able to get the URI information through URL

                 

                https://abcd.com:9843/type/PropertySetClasses/SystemObject/depot%20object/NSH%20Script/?username=BLAdmin&password=&role=…

                 

                which returns the below response:

                {

                  "PropertySetClassChildrenResponse": {

                  "PropertySetClassChildren": {

                  "PropertySetClasses": {

                  "Elements": []

                  },

                  "PropertySetInstances": {

                  "Elements": [{

                  "name": "UserAddJob",

                  "description": "",

                  "type": "/type/PropertySetClasses/SystemObject/Depot Object/NSH Script",

                  "dbKey": "DBKey:SDepotObjectModelKeyImpl:2712873-1-167218019",

                  "objectId": "c0db2b2e-777e-4eb7-937a-ef0b6ca2b785",

                  "uri": "/id/SystemObject/Depot Object/NSH Script/c0db2b2e-777e-4eb7-937a-ef0b6ca2b785",

                  "modelType": "NSHSCRIPT",

                  "modelTypeId": "1",

                  "PropertyValues": {

                  "Elements": [{

                  "name": "PARAMETERS*",

                  "isList": "true",

                  "type": "/type/PropertySetClasses/SystemObject/NSH Script Parameter",

                  "uri": "/id/SystemObject/Depot Object/NSH Script/c0db2b2e-777e-4eb7-937a-ef0b6ca2b785/PropertyValues/PARAMETERS*/",

                  "isNull": "false",

                  "isNoAccess": "false",

                  "value": "",

                  "PropertyValueElements": {

                  "Elements": [{

                  "isNull": "false",

                  "isNoAccess": "false",

                  "value": "",

                  "PropertySetInstance": {

                  "name": "",

                  "description": "",

                  "type": "/type/PropertySetClasses/SystemObject/NSH Script Parameter",

                  "dbKey": "",

                  "objectId": "3e5a2a41-b3b5-4947-a122-9d0aa50f3283",

                  "uri": "/id/SystemObject/NSH Script Parameter/3e5a2a41-b3b5-4947-a122-9d0aa50f3283",

                  "modelType": "NSH_PARAM",

                  "modelTypeId": "19399",

                  "PropertyValues": {

                  "Elements": [{

                  "name": "PARAMETER_NAME",

                  "isList": "false",

                  "type": "String",

                  "uri": "/id/SystemObject/NSH Script Parameter/3e5a2a41-b3b5-4947-a122-9d0aa50f3283/PropertyValues/PARAMETER_NAME",

                  "isNull": "false",

                  "isNoAccess": "false",

                  "value": "HOSTNAME"

                  },

                  {

                  "name": "DEFAULT_VALUE",

                  "isList": "false",

                  "type": "String",

                  "uri": "/id/SystemObject/NSH Script Parameter/3e5a2a41-b3b5-4947-a122-9d0aa50f3283/PropertyValues/DEFAULT_VALUE",

                  "isNull": "false",

                  "isNoAccess": "false",

                  "value": "%h"

                  },

                  {

                  "name": "PARAMETER_ID",

                  "isList": "false",

                  "type": "Integer",

                  "uri": "/id/SystemObject/NSH Script Parameter/3e5a2a41-b3b5-4947-a122-9d0aa50f3283/PropertyValues/PARAMETER_ID",

                  "isNull": "false",

                  "isNoAccess": "false",

                  "value": "1"

                  },

                  {

                  "name": "COMMAND_ARGUMENT",

                  "isList": "false",

                  "type": "String",

                  "uri": "/id/SystemObject/NSH Script Parameter/3e5a2a41-b3b5-4947-a122-9d0aa50f3283/PropertyValues/COMMAND_ARGUMENT",

                  "isNull": "true",

                  "isNoAccess": "false",

                  "value": ""

                  },

                  {

                  "name": "PARAMETER_FLAGS",

                  "isList": "false",

                  "type": "Integer",

                  "uri": "/id/SystemObject/NSH Script Parameter/3e5a2a41-b3b5-4947-a122-9d0aa50f3283/PropertyValues/PARAMETER_FLAGS",

                  "isNull": "false",

                  "isNoAccess": "false",

                  "value": "5"

                  }]  }  }  }]  }  }]  }  }]  }  }  }}

                 

                 

                Can you please help?

                • 6. Re: Bladelogic with REST and setting parameters for NSH Script
                  Sae Park

                  I know this is a bit old, but I was wondering if anyone had any luck with this.

                  I'm trying to accomplish the same thing and I can't seem to figure this out either.

                   

                  Once I construct the JSON input, what do I post against?