jboss-cli property format for path attribute - properties

As explained in JBoss EAP 7 documentation, one can pass in a properties file to the CLI instance with the --properties flag.
I'm trying to create a generic script for logging profiles.
This is my properties file:
profilename=myProfileName
filepath=/some/dir/somefile.log
And this is my script:
set profilename=${profilename}
set filepath=${filepath}
/profile=full-ha/subsystem=logging/logging-profile=$profilename:add
/profile=full-ha/subsystem=logging/logging-profile=$profilename/periodic-size-rotating-file-handler=myHandler:add(file={"relative-to" => "some.dir","path" => $filepath},suffix=.yyyy-MM-dd,max-backup-index=50,rotate-on-boot=true,rotate-size=20m)
The script doesn't generate any error and completes successfully, and the $profilename variable is correctly replaced by its value.
But the $filepath variable seems to be a problem:
<logging-profile name="myProfileName">
<periodic-size-rotating-file-handler name="myHandler" rotate-on-boot="true">
<file relative-to="some.dir" path="$filepath}"/>
<rotate-size value="20m"/>
<max-backup-index value="50"/>
<suffix value=".yyyy-MM-dd"/>
</periodic-size-rotating-file-handler>
</logging-profile>
What is the specific format to use so that a variable can be used for the path attribute?
Edit: tested with JBoss EAP 7.2, and now it works as expected, so I guess it was indeed a bug.

I know this is very late answer, but is the filepath variable last one in your list ?
Because this seems like a line ending issue if add new line at the end this would get picked up correctly.

Related

Jenkins. How to change file content

I've created a new project in Jenkins.
But now I want to change some information in my .properties file
How can I do that? (I've already read about Environment Injector, but I don't think, that it's what I need)
So, and one more questions - will this changes commit in file? (I don't want to do that)
Thank you!
Try using a scripted pipeline and you can use groovy for this task. For instance:
Properties props = new Properties()
File propsFile = new File(".properties")
props.load(propsFile.newDataInputStream())
props.setProperty('key', 'value')
props.store(propsFile.newWriter(), null)
You open the properties file, change the value of a specific key element and write to the same file when done.
If you are making use of Jenkins and it is on a windows machine. You can make use of PowerShell to change the file content
Here in this example,
I am actually trying to modify the string occurrence 'Memory Usage' with Jenkins build number
(Get-Content C:\proj\Jenkins\workspace\QA.I9.Api\Sample.txt).replace('Memory Usage', $env:BUILD_NUMBER) | Set-Content C:\proj\Jenkins\workspace\QA.I9.Api\Sample.txt
Thanks,
xyzcoder.github.io

How to read values dynamically from a file for a property in updateAttribute?

I added some custom properties in the 'updateAttribute' processor using the '+' button. For example: I declared a property 'DBConnectionURL' and gave the value as 'jdbc:mysql://localhost:3306/test'. Then, in the 'DBCPConnectionPool' service controller, I simple used the value'${DBConnectionURL}' for 'Database Connection URL' property. But, I manually gave the value for 'DBConnectionURL' property.I want a way where I can feed the value dynamically from a file, so that i just need to change the value in the file and the value for 'DBConnectionURL' changes dynamically based on the value present in the file. Is there a way to do it?
Rishab,
You have to use nifi variable registry.
In conf/nifi.properties, you could configure the below configuration in it for dynamically update a value in your data flow.
nifi.variable.registry.properties=./dynamic.properties
You can give your variables in that file dynamic.properties it should present in conf directory.
For an example, If dynamic.properties files contains below values
DBCPURL= jdbc://<host>:<port>
you can use that in your data flow by using ${DBCPURL}
Note: You should restart nifi services if you change any configuration in conf/nifi.properties.Otherwise your changes not worked in dataflow.
Feel free to accept it be answer if it worked for you.

getting a "need project id error" in Keen

I get the following error:
Keen.delete(:iron_worker_analytics, filters: [{:property_name => 'start_time', :operator => 'eq', :property_value => '0001-01-01T00:00:00Z'}])
Keen::ConfigurationError: Keen IO Exception: Project ID must be set
However, when I set the value, I get the following:
warning: already initialized constant KEEN_PROJECT_ID
iron.io/env.rb:36: warning: previous definition of KEEN_PROJECT_ID was here
Keen works fine when I run the app and load the values from a env.rb file but from the console I cannot get past this.
I am using the ruby gem.
I figured it out. The documentation is confusing. Per the documentation:
https://github.com/keenlabs/keen-gem
The recommended way to set keys is via the environment. The keys you
can set are KEEN_PROJECT_ID, KEEN_WRITE_KEY, KEEN_READ_KEY and
KEEN_MASTER_KEY. You only need to specify the keys that correspond to
the API calls you'll be performing. If you're using foreman, add this
to your .env file:
KEEN_PROJECT_ID=aaaaaaaaaaaaaaa
KEEN_MASTER_KEY=xxxxxxxxxxxxxxx
KEEN_WRITE_KEY=yyyyyyyyyyyyyyy KEEN_READ_KEY=zzzzzzzzzzzzzzz If not,
make a script to export the variables into your shell or put it before
the command you use to start your server.
But I had to set it explicitly as Keen.project_id after doing a Keen.methods.
It's sort of confusing since from the docs, I assumed I just need to set the variables. Maybe I am misunderstanding the docs but it was confusing at least to me.

BURN: Logging BURN_PACKAGE-> sczLogPathVariable to be used to create complete Log file

I am using WIX 3.7, and I am wanting to have my MSI and BURN log files, be created at my desired location. I tried verbatim both the approaches, mentioned in How to set or get all logs in a custom bootstrapper application newsgroup post. However, Log File gets created in the default location. Since I had time on hand, I decided to explore WIX 3.7 through WIX 3.9 Source Code, attempting to find where BURN_PACKAGE-> sczLogPathVariable data member is used.
However I found just 5 references to BURN_PACKAGE-> sczLogPathVariable
\wix38-debug\src\burn\engine\logging.cpp(191):
if ((!fRollback && pPackage->sczLogPathVariable && *pPackage->sczLogPathVariable) ||
\wix38-debug\src\burn\engine\logging.cpp(197): hr = VariableSetString(pVariables, fRollback ? pPackage->sczRollbackLogPathVariable : pPackage->sczLogPathVariable, sczLogPath, FALSE);
\wix38-debug\src\burn\engine\package.cpp(152):
hr = XmlGetAttributeEx(pixnNode, L"LogPathVariable", &pPackage->sczLogPathVariable);
\wix38-debug\src\burn\engine\package.cpp(303):
ReleaseStr(pPackage->sczLogPathVariable);
\wix38-debug\src\burn\engine\package.h(165):
LPWSTR sczLogPathVariable; // name of the variable that will be set to the log path.
I was expecting some code that would actually retrieve the value of MY VARIABLE and then CONCATENATE that value with the Log File Name that was synthesized, to create the complete file path. Maybe I am missing something obvious ? Do you guys have any suggestions ?
*Package/#LogPathVariable is used to specify a variable that gets the path to the log. To control the logging, use the Log element.

Loading properties of Property file JBOSS-7

I have done my configuration as per https://community.jboss.org/message/750465
I need to load a key from properties-service.xml which has below attributes.
<attribute name="Properties">
project.userName=xxxxx
project.userType=xxxxx
project.userToken=xxxx
My code access these properties as below
Properties globalSystemProperties = System.getProperties();
Enumeration keys = (Enumeration) globalSystemProperties.propertyNames();
I am not seeing my key list when iterate , What Could be the reason?
The reason is that it isn't supported anymore, like the thread you linked says:
jaikiran pai Dec 19, 2011 10:53 PM (in response to David Robison)
It doesn't exist in AS7.
This page tells a way of doing it with modules, but that will not work using System.getProperties(), it will only place them on classpath.
If you want your properties in the System.getProperties() code, I only can think of these options:
use --property or -P startup parameter pointing to your file, like explained here
populate them as <system-property/> in the configuration file
set them to actual system properties on startup or in code
use Spring or similar to add them as system properties
The first option is I guess the closest you can have.