7 minute read
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) 😉
- 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
|ArrowUp / i||move one item up|
|ArrowDown / k||move one item down|
|Shift+ArrowUp / I||select current item and move one item up (can use Alt instead of Shift)|
|Shift+ArrowDown / K||select current item and move one item down (can use Alt instead of Shift)|
|PgUp / u||move page of items up|
|PgDown / o||move page of items down|
|Shift+PgUp / U||select current item and move page of items up|
|Shift+PgDown / O||select current item and move page of items down|
|Home / a||move to first item|
|End / z||move to last item|
|Shift+Home / A||move to first item and select all items from current one to the first one|
|Shift+End / Z||move to last item and select all items from current one to the last one|
|ArrowLeft / j||scroll items left (usefull for long names)|
|ArrowRight / l||scroll items right (usefull for long names)|
|Space||select current item|
|TAB||switch from left to right panel and vice versa|
|F2/2||refresh focused pane (reload files/dirs)|
|F3/3||view current file|
|F5/5||copy selected (or current if none selected) directories and files|
|DEL/d||delete selected (or current if none selected) directories and files|
|n||find next string|
|p||find previous string|
|f||filter shown items by string|
|.||enter location (full path) for local file system|
|s||auto-synchronize selected directories (local to dp)|
|any-other-char||show help (+ hex value of key pressed visible in status bar)|
Navigational keys (except Left/Right can be used in combination with Shift for selections):
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!
QED2023 is very special as we will gather for the 15th time!
That’s why this year’s topic will be VALUE!