Topic
  • 8 replies
  • Latest Post - ‏2012-01-19T19:09:41Z by HermannSW
SystemAdmin
SystemAdmin
6772 Posts

Pinned topic how to copy a file from device local:///hd to local folder using SOMA

‏2012-01-18T07:18:16Z |
Hi all,

I am a newbie on Datapower appliance. I looked at the XML Interface Management redbook and only see the way to copy a file to the device.

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<dp:request xmlns:dp="http://www.datapower.com/schemas/management">
<dp:set-file name="local:///Testfile">
Base64_encoded_File
</dp:set-file>
</dp:request>
</soapenv:Body>
</soapenv:Envelope>

Is there anyway to copy a file from device local:///hd to a new folder( /home/epub/) using SOMA?

Thanks.
Updated on 2012-01-19T19:09:41Z at 2012-01-19T19:09:41Z by HermannSW
  • RCW
    RCW
    233 Posts

    Re: how to copy a file from device local:///hd to local folder using SOMA

    ‏2012-01-18T10:56:02Z  
    You can move a file using the MoveFile operation:
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Body>
    <dp:request domain="myDomain" xmlns:dp="http://www.datapower.com/schemas/management">
    <dp:do-action>
    <MoveFile>
    <sURL>local:///myoldDir/file.xml</sURL>
    <dURL>local:///mynewDir/file.xml</dURL>
    </MoveFile>
    </dp:do-action>
    </dp:request>
    </env:Body>
    </env:Envelope>
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: how to copy a file from device local:///hd to local folder using SOMA

    ‏2012-01-19T04:25:00Z  
    • RCW
    • ‏2012-01-18T10:56:02Z
    You can move a file using the MoveFile operation:
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Body>
    <dp:request domain="myDomain" xmlns:dp="http://www.datapower.com/schemas/management">
    <dp:do-action>
    <MoveFile>
    <sURL>local:///myoldDir/file.xml</sURL>
    <dURL>local:///mynewDir/file.xml</dURL>
    </MoveFile>
    </dp:do-action>
    </dp:request>
    </env:Body>
    </env:Envelope>
    Thanks RCW.

    But, I want to transfer a file to and from the WebSphere DataPower appliance via SCP protocol. Something like the CLI command as below.

    copy local:///hd/archive-production20111004110717.gz scp://trongbx@test.com//home/epub/dp/archives/archive-production20111004110717.gz

    Please advise.
  • HermannSW
    HermannSW
    7448 Posts

    Re: how to copy a file from device local:///hd to local folder using SOMA

    ‏2012-01-19T13:53:15Z  
    Thanks RCW.

    But, I want to transfer a file to and from the WebSphere DataPower appliance via SCP protocol. Something like the CLI command as below.

    copy local:///hd/archive-production20111004110717.gz scp://trongbx@test.com//home/epub/dp/archives/archive-production20111004110717.gz

    Please advise.
    Hi,

    > Thanks RCW.
    >
    > But, I want to transfer a file to and from the WebSphere DataPower appliance via SCP protocol. Something like the CLI command as below.
    >
    > copy local:///hd/archive-production20111004110717.gz scp://trongbx@test.com//home/epub/dp/archives/archive-production20111004110717.gz
    >
    > Please advise.

    For me it works, see below.
    As you already did correctly "scp://trongbx@test.com//home/..." is absolute path addressing.
    Copying to "scp://trongbx@test.com/file" would store as "/home/trongbx/file" instead.

    Does "dir local:///hd" show the archive file you want to copy?
    Did you execute the copy command in Global configuration mode ?
    
    $ ssh dp2-l3 (unknown) Unauthorized access prohibited. login: admin Password: ******   Welcome to DataPower XI50 console configuration. Copyright IBM Corporation 1999-2011   Version: XI50.3.8.2.0 build 193039 on 2011/02/04 15:25:39 Serial number: 13002M7   xi50# co Global configuration mode xi50(config)# dir local:
    ///   File Name              Last Modified              Size ---------              -------------              ---- b64hex/                Wed Dec 28 20:18:51 2011   1024 snowman/               Wed Dec 28 20:18:51 2011   1024 ... ... t.xml                  Thu Jan 19 08:41:00 2012   23 w520_datasheet.pdf     Thu Jan 19 08:42:22 2012   933526   44.0 MB available to local:
    ///   xi50(config)# copy local:
    ///w520_datasheet.pdf scp://stammw@9.152.4.11/ Password: ******** File copy success xi50(config)# copy local:
    ///w520_datasheet.pdf scp://stammw@9.152.4.11//home/stammw Password: ******** File copy success xi50(config)#
    

    Hermann<myXsltBlog/>
  • irazabal
    irazabal
    225 Posts

    Re: how to copy a file from device local:///hd to local folder using SOMA

    ‏2012-01-19T13:54:35Z  
    There is no CLI equivalent "copy" in SOMA - however you can upload a file to a directory (set-file as you correctly noted). The issue is getting the file in the first place...I would recommend a combination of a script (which gets the file and converts it to base64) and then calls SOMA set-file.
  • irazabal
    irazabal
    225 Posts

    Re: how to copy a file from device local:///hd to local folder using SOMA

    ‏2012-01-19T13:57:21Z  
    never mind - I gave you suggestions to copy TO the box not FROM the box. My apologies...Hermann has the correct answer.
  • HermannSW
    HermannSW
    7448 Posts

    Re: how to copy a file from device local:///hd to local folder using SOMA

    ‏2012-01-19T17:36:02Z  
    Trong pinged me and I misread the question.
    The question was on copying a file from DataPower box to an external server using SOAM command:
    > Is there anyway to copy a file from device local:///hd to a new folder( /home/epub/) using SOMA?

    It is possible to copy to and from a DataPower box from CLI:
    
    xi50(config)# help copy copy [-f] <source-URL> <destination-URL> [xmlmgr] Uses a specified protocol (HTTP, HTTPS, SCP, or SFTP) to copy a file to or from the device. ... ... For example: copy http:
    //www.datapower.com/FW/image.crypt image:///image.crypt using HTTP, copies the specified file to the firmware images storage area on the local flash copy scp:
    //jrb@ragnarok/BaseCfg.txt config:///BaseCfg.txt using Secure Copy, copies the specified file from the remote host to the configurations storage area copy logstore:
    ///Jan31.log scp://jrb@ragnarok/Logs/Jan31.txt  using Secure Copy, copies the specified file from the device flash to the remote host copy sftp:
    //jrb@ragnarok/BaseCfg.txt config:///BaseCfg.txt using Secured File Transfer Protocol, copies the specified file from the remotehost to the configurations storage area. copy config:
    ///startup-config store:///startup-config copies the specified file from the configuration storage area to the general user store area xi50(config)#
    


    It is possible to copy a file from a remote server to DataPower box by SOMA command "FetchFile".

    But there is no similar command to copy a file from DataPower box to remote server by a SOMA command:
    
    $ xpath++ 
    "//*[starts-with(@name,'Action')][.//xs:element[@name='URL']]/@name" xml-mgmt.xsd   ------------------------------------------------------------------------------- name=
    "ActionCacheSchema" ------------------------------------------------------------------------------- name=
    "ActionCacheStylesheet" ------------------------------------------------------------------------------- name=
    "ActionCacheWSDL" ------------------------------------------------------------------------------- name=
    "ActionExecConfig" ------------------------------------------------------------------------------- name=
    "ActionFetchFile" ------------------------------------------------------------------------------- name=
    "ActionTestURLMap" ------------------------------------------------------------------------------- name=
    "ActionTestURLRefresh" ------------------------------------------------------------------------------- name=
    "ActionTestURLRewrite" $
    


    A workaround for copying from DataPower box to remote server via SOMA command is:
    • use "get-file" SOMA command to get file "local:///hd/archive-production20111004110717.gz" from DataPower, store as "response"
    • xpath++ "/*/*/*/*/text()" response | base64 -id > decoded
    • scp decoded trongbx@test.com//home/epub/dp/archives/archive-production20111004110717.gz

     
    Hermann<myXsltBlog/>
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: how to copy a file from device local:///hd to local folder using SOMA

    ‏2012-01-19T18:17:08Z  
    • HermannSW
    • ‏2012-01-19T17:36:02Z
    Trong pinged me and I misread the question.
    The question was on copying a file from DataPower box to an external server using SOAM command:
    > Is there anyway to copy a file from device local:///hd to a new folder( /home/epub/) using SOMA?

    It is possible to copy to and from a DataPower box from CLI:
    <pre class="jive-pre"> xi50(config)# help copy copy [-f] <source-URL> <destination-URL> [xmlmgr] Uses a specified protocol (HTTP, HTTPS, SCP, or SFTP) to copy a file to or from the device. ... ... For example: copy http: //www.datapower.com/FW/image.crypt image:///image.crypt using HTTP, copies the specified file to the firmware images storage area on the local flash copy scp: //jrb@ragnarok/BaseCfg.txt config:///BaseCfg.txt using Secure Copy, copies the specified file from the remote host to the configurations storage area copy logstore: ///Jan31.log scp://jrb@ragnarok/Logs/Jan31.txt using Secure Copy, copies the specified file from the device flash to the remote host copy sftp: //jrb@ragnarok/BaseCfg.txt config:///BaseCfg.txt using Secured File Transfer Protocol, copies the specified file from the remotehost to the configurations storage area. copy config: ///startup-config store:///startup-config copies the specified file from the configuration storage area to the general user store area xi50(config)# </pre>

    It is possible to copy a file from a remote server to DataPower box by SOMA command "FetchFile".

    But there is no similar command to copy a file from DataPower box to remote server by a SOMA command:
    <pre class="jive-pre"> $ xpath++ "//*[starts-with(@name,'Action')][.//xs:element[@name='URL']]/@name" xml-mgmt.xsd ------------------------------------------------------------------------------- name= "ActionCacheSchema" ------------------------------------------------------------------------------- name= "ActionCacheStylesheet" ------------------------------------------------------------------------------- name= "ActionCacheWSDL" ------------------------------------------------------------------------------- name= "ActionExecConfig" ------------------------------------------------------------------------------- name= "ActionFetchFile" ------------------------------------------------------------------------------- name= "ActionTestURLMap" ------------------------------------------------------------------------------- name= "ActionTestURLRefresh" ------------------------------------------------------------------------------- name= "ActionTestURLRewrite" $ </pre>

    A workaround for copying from DataPower box to remote server via SOMA command is:
    • use "get-file" SOMA command to get file "local:///hd/archive-production20111004110717.gz" from DataPower, store as "response"
    • xpath++ "/*/*/*/*/text()" response | base64 -id > decoded
    • scp decoded trongbx@test.com//home/epub/dp/archives/archive-production20111004110717.gz

     
    Hermann<myXsltBlog/>
    Thanks Hermann.

    I just tried to get file with soma command and i got the response as below:

    <?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Body>
    <dp:response xmlns:dp="http://www.datapower.com/schemas/management">
    <dp:timestamp>2012-01-19T17:58:14Z</dp:timestamp>
    <dp:file name="local:///hd/TestFile">MTMyNTc5
    MTI0Mgo3IGRlZmF1bHQgMCAwIDAgMAoyMiBkZWZhdWx0LWF0dGVtcHQtc3RyZWFtIDAgMCAwIDAK
    </dp:file>
    </dp:response>
    </env:Body>
    </env:Envelope>
    However, i am not clear about step 2 and 3. Could you please make it clearer?
  • HermannSW
    HermannSW
    7448 Posts

    Re: how to copy a file from device local:///hd to local folder using SOMA

    ‏2012-01-19T19:09:41Z  
    Thanks Hermann.

    I just tried to get file with soma command and i got the response as below:

    <?xml version="1.0" encoding="UTF-8"?>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    <env:Body>
    <dp:response xmlns:dp="http://www.datapower.com/schemas/management">
    <dp:timestamp>2012-01-19T17:58:14Z</dp:timestamp>
    <dp:file name="local:///hd/TestFile">MTMyNTc5
    MTI0Mgo3IGRlZmF1bHQgMCAwIDAgMAoyMiBkZWZhdWx0LWF0dGVtcHQtc3RyZWFtIDAgMCAwIDAK
    </dp:file>
    </dp:response>
    </env:Body>
    </env:Envelope>
    However, i am not clear about step 2 and 3. Could you please make it clearer?
    > ...
    > I just tried to get file with soma command and i got the response as below:
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    > <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
    > <env:Body>
    > <dp:response xmlns:dp="http://www.datapower.com/schemas/management">
    > <dp:timestamp>2012-01-19T17:58:14Z</dp:timestamp>
    > <dp:file name="local:///hd/TestFile">MTMyNTc5
    > MTI0Mgo3IGRlZmF1bHQgMCAwIDAgMAoyMiBkZWZhdWx0LWF0dGVtcHQtc3RyZWFtIDAgMCAwIDAK
    > </dp:file>
    > </dp:response>
    > </env:Body>
    > </env:Envelope>
    >
    >
    > However, i am not clear about step 2 and 3. Could you please make it clearer?

    OK, you can find the file content base64 encoded in <dp:file> element of your response.
    There are many ways to extract that base64 string and decode it to get the "real" file content.

    What I proposed was the use of xpath++ tool from this posting:
    https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14511881#14511881

    You can use this tool under Linux or Cygwin under Windows.
    That tool works either with xsltproc or DataPower XSLT processor.

    What you need in addition is base64 and scp command.
    See how step 2 works here:
    
    $ xpath++ 
    "/*/*/*/*[name()='dp:file']/text()" trong.xml   ------------------------------------------------------------------------------- MTMyNTc5 MTI0Mgo3IGRlZmF1bHQgMCAwIDAgMAoyMiBkZWZhdWx0LWF0dGVtcHQtc3RyZWFtIDAgMCAwIDAK   $ $ xpath++ 
    "/*/*/*/*[name()='dp:file']/text()" trong.xml | base64 -id 1325791242 7 
    
    default 0 0 0 0 22 default-attempt-stream 0 0 0 0 $
    


    Hermann<myXsltBlog/>