Nodeum Docs
HomepageBlog
  • ✨What is Nodeum?
    • Data Management Software
  • 👣GETTING STARTED
    • Step by Step
  • 🏨ARCHITECTURE
    • Standalone
    • High Availability
    • Fully Scalable & Resilience
  • Install and Deploy Nodeum
    • Platform Support
    • Nodeum v1
      • Ansible based installation
    • Nodeum v2 - Data Mover
      • Ansible based Installation
        • Customize your Installation
      • Docker Based Deployment
    • SLURM Integration
    • Software License Application
  • Interfaces
    • ND Client
    • Console
      • Manual for Administrator
        • Login
        • Dashboard & Reports
        • Catalog
        • Data Mover Management
        • Advanced Task Management
        • Data Container
        • Primary Storage Configuration
        • Pool Management
        • TCO Calculator
        • Toolbox
        • System Settings
          • Information
          • Configuration
          • Date & Time
          • Backup
          • Services
          • Hostname and DNS Configuration
          • NAS Storage Configuration
          • Object Storage Configuration
          • Tape Library Configuration
          • User Management
          • Audits
      • Manual for End User
    • For Developers
      • RESTful API
      • Configuration through RestAPI Console
      • Software Developement Kits (SDK)
      • Nodeum API
        • API Terms of Use
        • release v1.x
        • release v2.x
  • DATA MOVER
    • Policy-Based Task orchestration
      • Pool Management
      • Scheduler
      • Data Integrity
      • Priority Management
      • Filtering (Basic or Advanced)
      • Hook service (callback)
    • Content traceability
    • Metadata Management
  • IDENTITY MANAGEMENT
    • Right - Authentication & Authorization
    • LDAP Plugin for JWT Token
  • Container Configuration
    • Prerequisites
    • About Container
    • Authorization and Authentication
    • Access your Container
  • HYBRID STORAGE MANAGEMENT
    • File System Managment
    • Object Storage Management
      • Customize your S3 connection
    • Tape Library Management
      • Tape Writing Format : LTFS
      • Tape Compression
      • Tape Rehydratation
      • Import a LTFS Tape
      • Task Maintenance for Tapes
  • ⏰Alert & Monitoring
    • Alerts
    • Monitoring
    • Log Management
  • 🏥Recover after Hardware Failure
    • Failover - Active/Passive
    • Failover Procedure - One Site
    • Backup & Restore
  • 🔐Security Guide
    • Advanced Network Configuration
    • Add a SSL Certificate on Web Console
    • Enable SSL Certificate Container accessible on S3 Protocol
  • Compatibility guide
    • Software requirement
    • Supported Storage
  • PRODUCT SPECIFICATIONS
    • Character Set Support
    • Limitations
    • Files Status
    • Task Status
Powered by GitBook
On this page
  • About Callback
  • Plugins oriented
  • Python Code Structure
  • JS Code Structure
  • Callback definition
  • Tips & Trick

Was this helpful?

  1. DATA MOVER
  2. Policy-Based Task orchestration

Hook service (callback)

Last updated 1 year ago

Was this helpful?

About Callback

Callbacks are codes which are executed at a specific stage of each data movement.

Each task can contains multiple callbacks. For each callback, the code has to be defined and when it has to be triggered.

Callbacks are executed into a 'safe' - sandbox environment, which prevent any border effect with the overall system and attached storage.

The executed task information are available into each block of code, and can be manipulated.

Plugins oriented

This feature supports multiple language, each of them is defined into a specific plugins. For now, two languages are supported: python and JS.

This means that two plugins are available and have to be loaded:

Extract of the Nodeum Ansible inventory/group_vars/all/options.yml file

...
###! Install the plugin for handling callbacks in JavaScript
# dispatcher_plugin_javascript_hooks_enabled: true
###! Install the plugin for handling callbacks in Python
# dispatcher_plugin_python_hooks_enabled: true
...

Python Code Structure

This is the standard block code of a callback written in Python. The code logic has to be included into the def run(req)

import utils
import sys

def run(req):
  ...
  return True

The req structure can then be manipulated where there are information to be retrieved from the task itself. The list of standard information is the following:

This provides the ID of the task: req.id

This retrieve all information about the task

info = utils.get_node_info(req)

then following information are available:

  • File path: info.path

  • File Mode: info.mode

  • File UID: info.uid

  • File GID: info.gid

  • File size: info.size

  • File access time: info.atime.ToDatetime()

  • File modification time: info.mtime.ToDatetime()

  • File creation time: info.ctime.ToDatetime()

  • File additional metadata: metadata = info.metadata and then metadataKey = metadata['key']

JS Code Structure

The logic is the same in JS, with a different logic b

const utils = require('./utils')

module.exports = function(req) {
  ....
  return true
}

The req structure can still be manipulated where there are information to be retrieved from the task itself. The list of standard information is the following:

This provides the ID of the task: const id = req.getId()

And then it is possible to retrieve all information about the task:

const info = utils.getNodeInfo(req)

then following information are available:

  • File path: info?.getPath()

  • File Mode: info?.getMode()

  • File UID: info?.getUid()

  • File GID: info?.getGid()

  • File size: info?.getSize()

  • File access time: info?.getAtime()?.toDate()

  • File modification time: info?.getMtime()?.toDate()

  • File creation time: info?.getCtime()?.toDate()

  • File additional metadata: metadataMap = info?.getMetadataMap() and then metadataKey = metadataMap.get('key')

Callback definition

Console

The Console allows the creation and definition of callback. It has to be done per task creation:

Terminal

The callbacks are stored into separated folders: /opt/nodeum/plugins/javascript-hooks/ and /opt/nodeum/plugins/python-hooks/. These folders are present into the Nodeum Data Mover nodes.

Tips & Trick

Task Status Verification

Previous task status can be checked in the callback "Before task is executed".

Example in js:

task.getLastExecution()?.getProgress()

export enum Progress {
  PROGRESS_UNSPECIFIED = 0,
  PROGRESS_INIT_STARTED = 1,
  PROGRESS_INIT_DONE = 2,
  PROGRESS_PROCESS_STARTED = 4,
  PROGRESS_PROCESS_DONE = 8,
  PROGRESS_FINAL_STARTED = 16,
  PROGRESS_FINAL_DONE = 32,
  PROGRESS_HAS_ERROR = 64,
  PROGRESS_STOPPED = 128,
  PROGRESS_STOPPED_BY_USER = 256,
  PROGRESS_PAUSED = 512,
}