Passing relay property to client in software deployment task

We need to pass a custom property of the client’s primary relay to the target client during the execution of a task that installs a software package. The relay property will be used to create an INI file during the installation process. We have a working copy of the task but the INI file is currently being manually created and stored as part of the downloaded payload. This effort has resulted in more than 50 similar packages for one application.

How can we collect the relay property and include it in the task at runtime?

If I understand the mechanics correctly this would require a mix of session relevance (relay property) and client relevance mixed with actionscript (package download, INI creation, and installation)

Any help or guidance is appreciated.


Emil

You should be able to do it with just client relevance; the value of the Relay property is, after all, retrieved from the client to begin with.

You could either copy/paste the relevance behind the ‘Relay’ property from Tools-Manage Properties in the console, or start with ‘name of selected server’ in a relevance substitution to generate the INI file

I already have a relevance statement to identify the primary relay for the client as follows:
following texts of first "//" of preceding texts of first"." of (value of setting "__RelayServer1" of client as string)

What we need to do is identify the primary relay of each client at runtime and then retrieve a custom property from the relay object itself; let’s call it “APP_Location_Tag” . This tag/property will then be used in the task to create or edit the INI file that will in turn be used during the installation of the program. We are trying to avoid having to manually maintain a table/CSV of relay names and properties.

Is this possible?

====
Emil

Hm. No client will be able to contact the server to retrieve the value of some other computer’s property (the Relay’s property result). You’d either have to supply that in the console when taking an action, or use the REST API to programmatically look up the Relay property results and supply that when submitting the action.

Can you dynamically edit the .ini file in your action that does the installation?

This would allow you to use relevance on the endpoint to calculate it’s current relay and inject that value into your ini file.

1 Like

I think we’re trying to follow a chain of property results across different computers?

Something like Relay1’s “Customer ID” property is “Customer123”, so on a given client we want to detect that it is connected to Relay1 and then write the INI file with “Customer123” in it.

If I’m understanding the use case correctly…

@E_Frias if you need to have a dynamic INI file for each environment you can make the following:

Just for an example:

prefetch patch.exe sha1:92c643875dda80022b3ce3f1ad580f62704b754f size:813160 http://www.download.windowsupdate.com/msdownload
/update/v3-19990518/cabpool/q307869_f323efa52f460ea1e5f4201b011c071ea5b95110.exe

createfile until EOF
{some-dynamic-value}
EOF
move __createfile __Download\conf.ini
wait __Download\patch.exe --config __Download\conf.ini

That’s it exactly. We want to build the INI dynamically rather than have to maintain a large number of copies of the file.

is it possible to dynamically create a custom property on each client based on the parent relay property using an analysis?
i.e. If Relay1 is the primary relay for clientA, then the value of custom property, “APP_HOME”, on ClientA = the value of custom property “APP_HOME_TAG” on Relay1.

If so, can someone provide a code sample to follow?

Cheers and thanks,
Emil

1 Like

Yes; in fact there’s a way to use the Location Property Wizard to do this, if you have a two-column spreadsheet mapping the key:value pairs of Relay to Value.
I think we have another post here on it, will try to find it.

like

Appendfile hello world
appendfile MyRelay={value of setting "__RelayServer1"  of client}

copy __appendile c:\myconfig.ini

Or is your use case that we are getting some configuration from that Relay and the configuration is not present on the local endpoint?

1 Like

This post (and Brad’s LinkedIn post that goes into the details) should help. client settings automation?

Another technique I’ve used is to attach the key:value pairing as a text file that is attached to a Custom Site; then you can have an Action that reads the file to retrieve the mappings, search for the line that contains its relay, and assign the value as a client setting. Workflow considerations for using REST API to set Client Settings on a system-wide scale

Edit: added Brad’s link

2 Likes

Thanks.

Where can I find the session relevance QnA I have seen mentioned in several threads?

====
Emil

I started looking for a Forum tip on “Session Relevance vs Client Relevance”, only to find I haven’t actually written one yet, though I keep meaning to get around to that. I’ll try to write up something in the next week or two.

For now, the short version is that Session Relevance is evaluated on the server, not the client. Clients cannot use Session Relevance, at all, because it requires a Session on the server. To use Session Relevance, you must be logged on (authenticated) to the Server.

Session Relevance is useful in creating custom Dashboards, Web Reports, or REST API queries, all of which run in a session on the server.

For testing Session Relevance, the easiest place is probably the Web Reports QNA page ( https://web-reports-server.domain:8083/webreports?page=QNA ). Other options include the Presentation Debugger in the Console (need to enable Console Debug options first). There’s also a Session Relevance Query Tester and an Excel Connector standalone tool.
In either a Custom Web Report, or in a custom Console Dashboard, in any of the HTML areas you can perform simple relevance substitutions via the special tags <?relevance some relevance query /?>, for example <?relevance concatenation of ps of names of bes computers ?> would output a set of HTML <p> tags, with one computername in each paragraph.

Web Reports and Console Dashboards also provide a couple of JavaScript functions for relevance, that can be used inside script tags on either. Relevance(string) and EvaluateRelevance(string) are the most common. One returns a flat string of all the results, while the other returns an object allowing to step through each plural result and each property of the result.

https://developer.bigfix.com/other/dashboard-api/ goes into some detail on both the HTML tag and JavaScript session relevance usage.

You can also use Session Relevance via the REST API by posting to https://bes-root-server.domain:52311/api/query . Some good details at https://developer.bigfix.com/rest-api/ and its sub-topics.

2 Likes

I ended up taking a different approach. I created a table that I store in “__createfile” at runtime. My code is working fine in the Fixlet Debugger ACTION TAB but fails with a relevance substitution error when I run it against an actual BES client.

This is the code I am using:
createfile until @_end_create_file
Relay_1 = Value_A
Relay_2 = Value_B
Relay_3 = Value_C
Relay_4 = Value_D
Relay_5 = Value_E
@_end_create_file

parameter "Client_Primary_Relay" = "{following texts of first "//" of preceding texts of first "." of (value of setting "__RelayServer1" of client as string)}" 

parameter "APP_Custom_Attributes" = "{following texts of first "= " of lines whose ( it starts with (parameter "Client_Primary_Relay") ) of file "__createfile"}"

The substitution error is occurring in the [ parameter “APP_Custom_Attributes” ] statement above. I have looked through the logs but found no clear reason for the failure.

Thoughts?

====
Emil

Is the expected relay name actually in the __createfile? The following text of first "= " will throw a singular expression error if no lines were matched (and the comparison is case-sensitive so Relay1 will not match Relay1).

You can work around the case-sensitivity by casting ‘as lowercase’ and get an empty result instead of an error if you use the plural following texts of firsts "= " of ..

Is this a case of the parser doing checks and setting parameters before the file exists?

See Order of commands within an action

1 Like

Yes, that is it.

This should be files and not file otherwise it will throw an error in the pre-download phase. Should also be firsts and not first.

Before the client runs an action, it first downloads anything defined in a prefetch or a prefetch block.

Before the client downloads anything in a prefetch statement, it first does a first pass relevance substitution for all relevance substitution statements. It does this so that it can evaluate all if / else statements.

It then uses those resolved if statements to determine which prefetch statements should be downloaded.

This means all relevance substitution must evaluate without error BEFORE the action runs. This includes all parameters because parameters can be used in If / Else statements.

Once the action is actually running, all parameters and relevance substitutions are evaluated sequentially as they are encountered in the order of execution.

3 Likes