KBEC-00289 Running ectool does not take default values for required parameters

Article ID:360032828332
2 minute readKnowledge base
On this page

Problem

When starting a job from ectool, if you don’t provide a required parameter it fails stating that there is a missing parameter, even though the parameter is defined to have a default value. This is counter intuitive since there is already a default value defined.

Non-required parameters get their default values.

Answer

This functionality actually works as designed, below we explain how it works. But to change the behavior, you will need to do one of the following:

  • If you want the runProcedure to take the default values, remove the "Required" check box, and the default values will be used

  • If you want the parameter to be required, you will have to supply the values on the command line using the --actualParameter option

When you run the procedure in the UI, the default parameter is shown in the UI but you still have to accept it by clicking the Run button. When you are running from the command line, the default values are not used, so you must supply a value for all required parameters. The web UI pre-populates the default value and passes it along across the wire.

If you tail the commander.log file, then interact with the UI to launch the procedure then you’ll see this:

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

<requests xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="commander.xsd" version="2.0" sessionId="[PROTECTED]">
 <request requestId="0">
 <runProcedure>
 <projectName>Default</projectName>
 <procedureName>Test</procedureName>
 <actualParameter>
 <actualParameterName>param1</actualParameterName>
 <value>asdf</value>
 </actualParameter>
 <priority>normal</priority>
 </runProcedure>
 </request>
 </requests>

If you try to launch on the command line:

<?xml version="1.0" encoding="UTF-8"?>
 <requests xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="commander.xsd" version="2.2" timeout="180" sessionId="AZKE2DSYCG39N6M1">
 <request requestId="1">
 <runProcedure>
 <projectName>Default</projectName>
 <procedureName>Test</procedureName>
 </runProcedure>
 </request>
 </requests>

<responses xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="commander.xsd" version="2.3" dispatchId="21488">
 <error requestId="1">
 <code>ParameterMissing</code>
 <where></where>
 <message><![CDATA[Missing parameter(s) to 'Test': param1]]></message>
 <details><![CDATA[]]></details>
 </error>
 </responses>

Notice in the web ui version we passed an actualParameter. In the command line invocation we did not.

You can get the default value through the API and pass it to your ectool command via script. Here is how you can get the default value on the formal parameter (as I said, the default value is stored in the db)

vagrant@commander4to5:~$ /opt/electriccloud/electriccommander/bin/ectool getFormalParameters Default --procedureName Test

<response requestId="1">
 <formalParameter>
 <formalParameterId>4254</formalParameterId>
 <formalParameterName>param1</formalParameterName>
 <createTime>2014-08-12T06:59:52.428Z</createTime>
 <defaultValue>asdf</defaultValue>
 <description />
 <expansionDeferred>0</expansionDeferred>
 <lastModifiedBy>admin</lastModifiedBy>
 <modifyTime>2014-08-12T07:08:41.570Z</modifyTime>
 <owner>admin</owner>
 <required>1</required>
 <type>entry</type>
 </formalParameter>
 </response>

If you tail the commander.log when viewing the "Run…​" page you will see that the web ui also issued the getFormalParameters query as well.

Our web UI merely issues multiple requests to get the default value and pre-populate the default value into the actualParameter.