Subscribe to our 0800-DEVOPS Newsletter

    Get in touch

    Not sure where to start? Let our experts guide you. Send us your query through this contact form.






      Get in touch

      Contact us for all inquiries regarding services and general information






        Use the form below to apply for course





          Get in touch

          Contact us for all inquiries regarding services and general information






          Blog

          DataPower Commander

          clock7 minute read

          13.09.2019

          DataPower Commander (dpcmder) is a command line tool I created for easier maintenance of files on DataPower appliances and easier development of DataPower appliance solutions. And now it’s also available on Github (croz-ltd/dpcmder) 😉

          Current functions:

          • basic file maintenance
            • view, edit, copy and delete file hierarchies (DataPower and local file system)
            • filter and search files in current directory
          • sync mode
            • turn on to automatically upload new and changed files from local file system to DataPower
            • useful for development to automatically propagate your changes from any IDE/editor you are using to DataPower

          A bit of history of dpcmder

          When I started to work with DataPower (beginning of 2008) I plunged into world of XSLT-s and I find out it is very verbose functional programming world. As a Java developer I used Eclipse IDE a lot and I found it a good tool to work with XML/XSL files. There were some parts of XLST logic I could even test without uploading them to DataPower (using functionalities available in Eclipse) but for some DataPower-specific parts only way to test it was to upload them to DataPower appliance.

          Soon I realized it is a bit cumbersome to upload files to DataPower appliance during development. I found IBM created an eclipse plug-in which enabled us to quickly copy files from local eclipse workspace to DataPower appliance (and vice versa) which made development cycle much more comfortable and faster. Unfortunately, IBM shipped this plug-in only until DataPower firmware 3.8.2 and stopped maintaining this plug-in to be compatible with new DataPower versions. There were some work-around solutions but none of them felt right for me.

          At some point I thought about developing Eclipse plug-in myself but decided to go other direction because of the following reasons:

          • all information sources I checked said Eclipse plug in development is not a fulfilling experience
          • I thought it would be nice to have a tool which could be used to maintain files on DataPower by system administrators (not only by developers)

           

          At first, I created a bash shell script which had basic functionalities I planned to implement but even on my Linux box it was working a bit slow. Then I started this script in Linux bash console using cmder Console Emulator and realized it is so slow it is almost unusable. I wanted to have:

          • application which would work on at least 3 major OS-es (both my company and our clients use all 3 of them)
          • command line application so it can be used through ssh on some jump server if required
          • application which would work fast
          • application which would be simple to use (and similar to Midnight Commander and/or Total Commander)

           

          I evaluated few technologies to implement this. After some investigation time I checked Node.js pkg and Golang – both of these enabled me to build executables for all target platforms on my Linux machine. At the end I decided to go with the Go as it produced smaller executables and felt a better fit for this task.

          One issue which is still left partially unsolved is handling key presses for some of the special keys on Windows (probably also on macOS) environment (dpcmder is developed on Ubuntu Linux). Seems like it is not quite easy to crate portable application which can correctly use arrow keys, Home & End key etc. For that reason I added alternative keys for each of those actions. Best of all, if you are not sure just press ‘h’ key (or any other unmapped key) and help will be shown.

          dpcmder funcions help

          Command list:

          Key(s)Description
          ArrowUp / imove one item up
          ArrowDown / kmove one item down
          Shift+ArrowUp / Iselect current item and move one item up (can use Alt instead of Shift)
          Shift+ArrowDown / Kselect current item and move one item down (can use Alt instead of Shift)
          PgUp / umove page of items up
          PgDown / omove page of items down
          Shift+PgUp / Uselect current item and move page of items up
          Shift+PgDown / Oselect current item and move page of items down
          Home / amove to first item
          End / zmove to last item
          Shift+Home / Amove to first item and select all items from current one to the first one
          Shift+End / Zmove to last item and select all items from current one to the last one
          ArrowLeft / jscroll items left (usefull for long names)
          ArrowRight / lscroll items right (usefull for long names)
          Spaceselect current item
          TABswitch from left to right panel and vice versa
          Returnenter directory
          F2/2refresh focused pane (reload files/dirs)
          F3/3view current file
          F4/4edit file
          F5/5copy selected (or current if none selected) directories and files
          F7/7create directory
          DEL/ddelete selected (or current if none selected) directories and files
          /find string
          nfind next string
          pfind previous string
          ffilter shown items by string
          .enter location (full path) for local file system
          sauto-synchronize selected directories (local to dp)
          qquit
          any-other-charshow help (+ hex value of key pressed visible in status bar)

           

          Navigational keys (except Left/Right can be used in combination with Shift for selections):

          PgUpUpPgDn
          LeftDownRight
          HomeEnd

           

          Alternative keys:

           u i o
           j k l
           a z

           

          Custom Viewer/Editor commands:
          dpcmder configuration is saved to ~/.dpcmder/config.json where commands used for calling viewer and editor are set. By default these are “less” and “vi” but could be any commands although edit command should not be started in background (for example: a new tab in editor which is already open) for editing to work as expected.

           

          SOMA (+ AMP) vs REST:
          SOMA and AMP interfaces have one shortcoming – you can’t see domain list if you don’t have proper rights. With REST you can get domain list without any credentials.

          Project source code

          The complete source code is now also available on Github (croz-ltd/dpcmder) so go ahead and try it out!

          Vedran Vidović is a proactive and experienced software developer. Since 2001, he works in IT industry, and has gained extensive experience in development, analysis, design, and architecture, applying different technologies on many projects from various business domains. He has broad experience in J2EE technologies on projects of various complexity. Since 2009, he gathered extensive experience in the enterprise integration projects, using mostly IBM DataPower Gateway and IBM API Connect.

          CONTACT

          Get in touch

          Contact us