How to - custom portlet

This guide explains how to write custom portlets like calling Aspera Console or displaying failed assets for recovery purpose.

 

Overview

 

Custom portlets are customized monitoring views integrated within the Orchestrator dashboard.

 

They are based on HTML code.

 

Ruby code can be inserted within the HTML code with this syntax:

 

Declaration:

<% my ruby code %>

Example:

<% my_var = 123 %>

 

Variable substitution:

<%=my_ruby_variable%>

Example:

<p> My variable is equal to <%=my_var%>  </p>

 

Note: don’t use spaces in Ruby variable names. Don’t use capital as first variable letter (as it would be considered a constant).

 

The mode of operation to create a custom portlet is:

  • Define a new portlet in Engine + Portlets + Define Custom Portlet
  • Add the HTML code in the View section  + Save
  • Create a dashboard page in Preferences + Define new dashboard + Create
  • Configure the new page with Choose portlet (“Custom Portlet”) + click on Select
  • In Custom Portlet configuration, select the custom portlet that you created before
  • Save + Done Configuring + Activate
  • View your page in the dashboard

 

We provide here below some sample code for a number of use cases.

 

Use case: resubmit failed assets

 

Failed assets are found and displayed based on a matching pattern. A recovery workflow can be called by clicking on a “re-submit” link sitting next to each matching asset.

 

<h1>Assets with failures</h1>

<br/>

<div id="asset_list" style="padding: 5px">

<ul style="padding: 5px">

<% error_folders = SimpleParameterLookup.find_by_name("Lookup asset").column_values("error_folder")

   error_folders.each do |folder|

     failed_assets = Dir.glob(File.join(folder,"*.xml"))[0..39]

     failed_assets.each do |asset| %>

        <li><%=asset%></li>

<a href="/aspera/orchestrator/work_orders/initiate/xml?login=admin&password=aspera&work_order[workflow_id]=1&external_parameters[asset]=<%=asset%>" target="_blank">Re-submit</a></li>

     <% end %>

   <% end %>

</ul>

</div>

 

We assume that a lookup table (“Lookup asset”) holds the names of the error folders (column “error_folder”). For each error folder, we search files matching the “*.xml” glob pattern, meaning all files with an xml extension into the error folder. Then a workflow (id 1 in the example above) with a run-time input parameter as the asset file path can be called by clicking on the “Re-submit” link.

 

If the lookup table has 2 lines with error_folder values /mnt/watchfolder/errorfolder/Assets /mnt/watchfolder/errorfolder/Series

the dashboard page may then display something like:

Asset with failures

    /mnt/watchfolder/errorfolder/Assets/titi.xml

    Re-submit

    /mnt/watchfolder/errorfolder/Series/tyty.xml

    Re-submit

 

The same behavior could be obtained by having a single error folder (“error_folder”) in a mass parameter set (“Central Config”) with:

 

<h1>Assets with failures</h1>

<br/>

<div id="asset_list" style="padding: 5px">

<ul style="padding: 5px">

<%

  parameter_hash = eval(MassParameterSetter.find_by_name("Central Config").parameters)

  failed_assets = Dir.glob(File.join(parameter_hash["error_folder"][0],"*.xml"))[0..39]

  failed_assets.each do |asset| %>

    <li><%=asset%>  <a href="/aspera/orchestrator/work_orders/initiate/xml?login=admin&password=aspera&work_order[workflow_id]=1&external_parameters[asset]=<%=asset%>" target="_blank">Re-Submit</a></li>

  <% end %>

</ul>

</div>

 

 

Attachments

1 Comments

  • Avatar
    Christophe Thiebot

    Add up to this article showing how to add a parameter (e.g. URL for a HTTP request) to a custom portlet.

Please sign in to leave a comment.
Powered by Zendesk