<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: vRO 8.8 / vRA 8.8 - Python action - referencing other vRO actions? in VMware Aria Automation Orchestrator Discussions</title>
    <link>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924252#M25887</link>
    <description>&lt;P&gt;But this would not work for a custom python environment. If I have to use some popular modules like requests, I would have to bundle my own modules and those I would normally add as a dependency in a custom env, which mean I'd have to update them all manually somewhere in the future.&lt;/P&gt;&lt;P&gt;This is an approach I was looking for though - create you own modules from python functions, and upload them into the custom environment, so every action that runs in that env can use it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I will settle for a "wrapper" function written in js for now, that would load all configuration elements and resource elements in the first step, and pass the values on to python actions, which would be referenced by the traditional System.getModule("my.py.actions") method.&lt;/P&gt;</description>
    <pubDate>Wed, 17 Aug 2022 06:57:46 GMT</pubDate>
    <dc:creator>Czernobog</dc:creator>
    <dc:date>2022-08-17T06:57:46Z</dc:date>
    <item>
      <title>vRO 8.8 / vRA 8.8 - Python action - referencing other vRO actions?</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924038#M25884</link>
      <description>&lt;P&gt;I have a bundle of Python actions in vRO and would like for a few of them to reference other (mostly also Python) vRO actions from different vRO modules.&lt;/P&gt;&lt;P&gt;What would be the best way to do this? At the moment the only way I can think of to accomplish this task, is to execute a REST query to launch the action, there does not seem a more "native" way to do it, like with System.getModule....&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 06:40:45 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924038#M25884</guid>
      <dc:creator>Czernobog</dc:creator>
      <dc:date>2022-08-16T06:40:45Z</dc:date>
    </item>
    <item>
      <title>Re: vRO 8.8 / vRA 8.8 - Python action - referencing other vRO actions?</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924246#M25886</link>
      <description>&lt;P&gt;If it is a workflow, I'd simply add actions as steps to it.&lt;/P&gt;&lt;P&gt;In an action, you can create python modules within the zip bundle, and import them in your script.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 06:00:59 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924246#M25886</guid>
      <dc:creator>xian_</dc:creator>
      <dc:date>2022-08-17T06:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: vRO 8.8 / vRA 8.8 - Python action - referencing other vRO actions?</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924252#M25887</link>
      <description>&lt;P&gt;But this would not work for a custom python environment. If I have to use some popular modules like requests, I would have to bundle my own modules and those I would normally add as a dependency in a custom env, which mean I'd have to update them all manually somewhere in the future.&lt;/P&gt;&lt;P&gt;This is an approach I was looking for though - create you own modules from python functions, and upload them into the custom environment, so every action that runs in that env can use it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I will settle for a "wrapper" function written in js for now, that would load all configuration elements and resource elements in the first step, and pass the values on to python actions, which would be referenced by the traditional System.getModule("my.py.actions") method.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 06:57:46 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924252#M25887</guid>
      <dc:creator>Czernobog</dc:creator>
      <dc:date>2022-08-17T06:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: vRO 8.8 / vRA 8.8 - Python action - referencing other vRO actions?</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924355#M25891</link>
      <description>&lt;P&gt;I'm downloading Python code into the container from other action scripts using the API and then adding them to the Python path so I can import them on the fly. Here's the bootstrap code.&lt;/P&gt;&lt;P&gt;&lt;FONT face="lucida sans unicode,lucida sans"&gt;onboardingUtils&lt;/FONT&gt; is just a plain Python module, i.e. no module.handler and not even called directly in vRO.&amp;nbsp;&lt;FONT face="lucida sans unicode,lucida sans"&gt;vacfg_constants&lt;/FONT&gt; is a set of constants in another Python module that is imported by&amp;nbsp;&lt;FONT face="lucida sans unicode,lucida sans"&gt;onboardingUtils&lt;/FONT&gt;. I.e.&amp;nbsp;&lt;FONT face="lucida sans unicode,lucida sans"&gt;onboardingUtils&lt;/FONT&gt; depends on&amp;nbsp;&lt;FONT face="lucida sans unicode,lucida sans"&gt;vacfg_constants&lt;/FONT&gt;. As long as you have the other Python action bits inside the container, you should be able to load them into your main action.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;onboardingUtils = None

_vcoUrl_ = None
_vcoToken_ = None
_headers_ = None

def handler(context, inputs):
    global onboardingUtils
    global _vcoUrl_
    global _vcoToken_
    global _headers_

    _vcoUrl_ = context['vcoUrl']
    _vcoToken_ = context['getToken']()

    _headers_ = {
        'accept': 'application/json',
        'authorization': "Bearer " + _vcoToken_
    }

    os.chdir(inputs['workdir'])
    sys.path.append(inputs['workdir'])

    downloadAction('com.client.vmware.vra.onboarding','onboardingUtils', 'onboardingUtils.py')
    downloadAction('com.client.vmware.vra.onboarding', 'vacfg_constants', 'vacfg_constants.py')

    import onboardingUtils
    onboardingUtils = sys.modules['onboardingUtils']

def downloadAction(module, action, file_path):

    url = f'{_vcoUrl_}/api/actions/{module}/{action}'
    response = requests.get(url, headers=_headers_)
    print(response.status_code)
    response.raise_for_status()

    r = json.loads(response.text)
    open(file_path, 'w').write(r['script'])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2022 13:40:58 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924355#M25891</guid>
      <dc:creator>bsaxe</dc:creator>
      <dc:date>2022-08-17T13:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: vRO 8.8 / vRA 8.8 - Python action - referencing other vRO actions?</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924527#M25898</link>
      <description>&lt;P&gt;Thank you for answering! This is a really interesting solution, I will definitely try this out soon.&lt;/P&gt;&lt;P&gt;What are the 'workdir' inputs used for? Are those paths to python within the container?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 09:54:24 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924527#M25898</guid>
      <dc:creator>Czernobog</dc:creator>
      <dc:date>2022-08-18T09:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: vRO 8.8 / vRA 8.8 - Python action - referencing other vRO actions?</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924565#M25899</link>
      <description>&lt;P&gt;The input &lt;FONT face="andale mono,times"&gt;workdir&lt;/FONT&gt; is the directory inside the container where the action is doing all of its work that needs file system write access. I think by default, the container logs into the &lt;FONT face="andale mono,times"&gt;/root&lt;/FONT&gt; or &lt;FONT face="andale mono,times"&gt;/&lt;/FONT&gt; (forget) directory, which is read-only. I think my input is just &lt;FONT face="andale mono,times"&gt;/tmp&lt;/FONT&gt; directory. I didn't feel like using absolute paths in all my functions, so I do all the work in &lt;FONT face="andale mono,times"&gt;/tmp&lt;/FONT&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2022 13:09:28 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924565#M25899</guid>
      <dc:creator>bsaxe</dc:creator>
      <dc:date>2022-08-18T13:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: vRO 8.8 / vRA 8.8 - Python action - referencing other vRO actions?</title>
      <link>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924715#M25901</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;I hope a similar solution will be developed for configuring a python environment in vRO, so you'll be able to load custom modules from a folder or maybe gitlab directly into the environment, so that a workaround with the additional actions and functions is not needed.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Aug 2022 07:37:06 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-Aria-Automation/vRO-8-8-vRA-8-8-Python-action-referencing-other-vRO-actions/m-p/2924715#M25901</guid>
      <dc:creator>Czernobog</dc:creator>
      <dc:date>2022-08-19T07:37:06Z</dc:date>
    </item>
  </channel>
</rss>

