Bug 625198

Summary: defaultValue for rhq:input-property element is ignored when used in a bundle recipe
Product: [Other] RHQ Project Reporter: Larry O'Leary <loleary>
Component: ProvisioningAssignee: John Mazzitelli <mazz>
Status: CLOSED CURRENTRELEASE QA Contact: Corey Welton <cwelton>
Severity: medium Docs Contact:
Priority: high    
Version: 3.0.0CC: mazz, skondkar
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-05-24 01:10:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Screenshot none

Description Larry O'Leary 2010-08-18 20:35:14 UTC
Description of problem:
When defining a default value for a user-provided variable within a bundle's deploy.xml, the default value is not used or appears to be ignored.  This results in the deployment of the bundle failing unless a value was explicitly specified by the user when deploying the bundle.

Version-Release number of selected component (if applicable):
JON 2.4

How reproducible:
Always

Steps to Reproduce:
1. Add a new bundle that defines a rhq:input-property with a defaultValue.

<?xml version="1.0"?>
<project name="calculator-bundle" default="main" 
    xmlns:rhq="antlib:org.rhq.bundle">

   <rhq:bundle name="Example Calculator App" version="1.0" description="an example bundle of the Calculator EAR">
      <rhq:input-property
         name="a.user.value"
         description="A user specified value to demonstrate the default value is not used"
         required="true"
         defaultValue="a default value"
         type="string"/>

      <rhq:deployment-unit name="calculator-ear" preinstallTarget="preinstall" postinstallTarget="postinstall">
         <rhq:archive name="ear-calculator.ear"/>
      </rhq:deployment-unit>
   </rhq:bundle>

   <target name="main" />

   <target name="preinstall">
      <echo>Deploying bundle ${rhq.deploy.name} to ${rhq.deploy.dir}...</echo>
      <property name="preinstallTargetExecuted" value="true"/>
   </target>

   <target name="postinstall">
      <echo>Done deploying bundle ${rhq.deploy.name} to ${rhq.deploy.dir}</echo>
      <property name="postinstallTargetExecuted" value="true"/>
   </target>
</project>

2. Once the bundle has been added, deploy it to a group
3. When prompted for a value for a.user.value, leave it blank
  
Actual results:
The deployment of the bundle fails with no evident reason/error

Expected results:
The deployment of the bundle should be successful

Additional info:
I would also expect that the default value would pre-populate the field in the UI.

Comment 1 John Mazzitelli 2010-12-19 23:47:56 UTC
git commits:

2c87326ad0fa9449ef0e351e0f241d36ec4566da
0e90bc94eb626e05b55fd5f2f1a2eeaac7e25c4e

This bug actually shows up in both ant and filetemplate bundle types (the bug description only mentions the ant input-property, but there was no way to set a default value in file template recipes, these commits fix that also).

This was a larger fix that anticipated. It turns out we were never persisting any default template with the config def object. The fix includes this now. The fix was in the core bundle subsystem, so it is supported for any bundle type (ant or file template recipes for now).

If you have any required properties OR properties that define a default value, the configuration definition will get assigned a default template. If a required property does not set a default in the recipe, null will be used.

Comment 2 Sunil Kondkar 2011-03-14 09:31:07 UTC
Verified on build#1090 (Version: 4.0.0-SNAPSHOT Build Number: f19c23e)

Uploaded the bundle that defines a rhq:input-property with defaultValue. While deploying the bundle to a group, observed that on prompting value (for a.user.value), it displayed the default value ("a default value" as defined in recipe). Please refer the attached screenshot.

The bundle got deployed successfully.

Marking the bug as verified.

Comment 3 Sunil Kondkar 2011-03-14 09:31:47 UTC
Created attachment 484112 [details]
Screenshot

Comment 4 Corey Welton 2011-05-24 01:10:08 UTC
Bookkeeping - closing bug - fixed in recent release.