If you're using GenerateFlowFile, you could add a dynamic property to set
an attribute using the ${hostname} (or ip) on the created FlowFile.

If you're only running Generate on a single node before load balancing the
FlowFile (e.g. round-robin) and the expression needs to be calculated on
the destination host, you could use an UpdateAttribute to create the
attribute before ExecuteScript but after the load balancing.

Of course, this doesn't answer your original question about evaluating EL
within a script, but gives you a couple of alternate options.

Cheers,

Chris Sampson

On Sun, 18 Jul 2021, 12:46 James McMahon, <jsmcmah...@gmail.com> wrote:

> Lars, thank you so much. I was fixated on getting the host information
> from the flowFile itself and overlooked the obvious. Your suggestion will
> be ideal. Thank you once again!
> Jim
>
> On Sun, Jul 18, 2021 at 12:59 AM Lars Winderling <
> lars.winderl...@posteo.de> wrote:
>
>> James,
>>
>> maybe just use?
>> Import socket
>> socket.gethostname()
>> It will give you rather the hostname, but that should also help for
>> distinguishing between nodes.
>>
>> Best, Lars
>>
>> On 17 July 2021 22:25:47 CEST, James McMahon <jsmcmah...@gmail.com>
>> wrote:
>>>
>>> Looking closely at the flowFiles I am creating,in the subsequent output
>>> queue, I see they have a Node Address listed in FlowFile Details. It is not
>>> listed in the flowfile attributes.
>>> That is what I need to get at programmatically in my python script. How
>>> can I access Node Address?
>>>
>>> On Sat, Jul 17, 2021 at 2:59 PM James McMahon <jsmcmah...@gmail.com>
>>> wrote:
>>>
>>>> I have a single flowfile I generate on a periodic basis using a cron
>>>> scheduled GenerateFlowFile. This then flows into an ExecuteScript, where I
>>>> have a python script that will create multiple flowfiles from the one.
>>>>
>>>> My ExecuteScript is configured to run on all my cluster nodes. For each
>>>> instance of flowfile I am creating, I need to determine which cluster node
>>>> it associates with. There’s an expression language function called ip().
>>>> Can anyone tell me how to employ ${ip()} in my python to determine the
>>>> cluster node the newly created flowFile is associated with?
>>>>
>>>> I’d be using this after I execute
>>>> flowfile = session.create()
>>>>
>>>> Thanks in advance for your help.
>>>>
>>>

Reply via email to