DX Unified Infrastructure Management

  • 1.  NodeJS interface for pu.exe

    Posted Feb 13, 2017 08:56 AM

    Hi,

     

    I recently work on a NodeJS "interface/binding" to communicate with pu.exe. It's not really complete but i'm working to out a first release in few weeks.

     

    GitHub - fraxken/NodeUIM: CA UIM NodeJS interface to work with pu.exe in a full async way. 

     

    ----- 

    Each call to pu take between 350 - 500ms on my system. Not crazy but it's acceptable.  And the parsing only take few MS (very good on this side). 

     

    All request return a promise and the stdout from pu is parsed into a ES6 Map (With Array for PDS_PPDS and normal JavaScript object for PDS_PDS). 

     

    When PDS_PDS is not included into PDS_PPDS it's a ES6 Map.

    ----- 

     

    Pull-request or questions are welcome ! I'm working a first test script to compare code speed / efficiency with the Perl SDK.

     

    On the side i'm working a FFI binding for the C SDK with V8 Engine (C++ JavaScript Engine) for NodeJS. In hopes to being able to provide an official NodeJS SDK to create Nimsoft probe like we do with Perl SDK or Java SDK. 

     

    Best Regards,

    Thomas



  • 2.  Re: NodeJS interface for pu.exe

    Posted Feb 13, 2017 01:23 PM

    Code updated ! 

     

    I get hubs and robots in asynchrone. It take ~ 7 MS to retrieve 24,000 robots and 43 hubs.  Tomorrow i do the same with perl (in sync) to take the time with the natif C layer.

     

     

    Note : I use async.js to iterate in async.



  • 3.  Re: NodeJS interface for pu.exe

    Posted Feb 14, 2017 08:51 AM

    Hi,

     

    Time are pretty close. NodeJS seems faster to handle the timeout (But perl SDK does'nt support timeout so...). 

     

    Node : 6 - 10s (async with pu.exe)

    Perl SDK :  9 - 20s (sync with C Layer)

     

    To retrieve 24,000 robots on 43 hubs. Lower value are best. Because of Async execution, communication error are less impacting on the maximum time for NodeJS.

     

    NodeJS seem to be able to launch hundred of pu on one core with no problems (however not sure if the robot can support this kind of charge). But more we code complicated thing, more NodeJS will be faster than perl. ( EG : Database etc.. ).

     

    If we compare both code, perl require less code ( but it's normal because we have no multi-threads here).

     

    NodeUIM R1

     

    Less code but only with my framework ^^ ! 

     

    Perluim (Perl code)

     

    I'm waiting to make some tests on the JAVA SDK.

     

    Not perfect, but still pretty cool if you want to work on a local Script with something more structured than shell.

     

    Best Regards,

    Thomas



  • 4.  Re: NodeJS interface for pu.exe

    Posted May 26, 2018 02:44 PM

    Hi,

     

    Node UIM Version 2.0.0 is coming soon. On this new major release a lot of features has been removed around the PU interface (Most of them was useless).

     

    This major release bring/refactor :

     

    - Clean request constructor/handler

    - Response with native JavaScript object ( ES6 Map was complicated for nothing ).

    - Improved stdout parser.

    - Now available with a probes and callbacks list (backed with a TypeScript definition).

     

    // Require dependencie(s)
    const {
        ProbeUtility,
        callbacks: {
            controller,
            hub
        }
    } = require('./index');

    // Setup NIM ROOT
    process.env.NIM_ROOT = "/opt/nimsoft";

    // Create pu Object
    const pu = new ProbeUtility("administrator", "NimSoft!01");

    // Main handler
    async function main() {
        const [{interface}, {robotlist}] = await Promise.all([
            pu.exec(controller.get_info({ interfaces: true })),
            pu.exec(hub.getrobots())
        ]);

        console.log('\nInterfaces : ');
        console.log(interface);

        console.log('\n\nRobotslist: ');
        for(const robot of robotlist) {
            console.log(robot.ip);
        }
    }
    main().catch(console.error);

     

    Depending on the situation, the mechanism is capable to translate boolean value into integer value (a lot of callbacks ask for a 1/0 value). 

     

    The base code is ready, however it request a lot of works to retrieve all callbacks from all probes (without making errors).

     

    declare namespace ProbeUtility {

        // Probes callbacks interface
        export interface callbacks {
            hub: hub_callbacks;
        }

        // Hub probe callbacks
        interface hub_callbacks {
            _restart: () => any;
            _status: ({ detail: boolean }) => any;
            _stop: () => any;
            _suspend: ({ seconds: number }) => any;
            getrobots: ({ name: number, detail: boolean }) => any;
        }

    }

     

    Best Regards,

    Thomas