Skip to content

pfioh command: pullPath using zip

Rudolph Pienaar edited this page Jul 26, 2019 · 14 revisions

pfioh command: pullPath (zip)

Abstract

This page describes the pullPath command to pfioh. It is used to pull a directory tree to a remote server. In this example, the tree is zipped up at the remote server, transferred locally, and then unzipped at the specified local destination.

Preconditions

  • A HOST_IP environment variable that denotes the IP of the host housing the service. In Linux, you can do:
export HOST_IP=$(ip route | grep -v docker | awk '{if(NF==11) print $9}')
  • Make sure that pfioh has been started (see here for more info):
pfioh --forever --httpResponse --storeBase=/tmp --createDirsAsNeeded

msg summary

The msg payload of the REST interaction with pfioh is:

{  "action": "pullPath",
    "meta": {
        "remote": {
            "path":         "/usr/sbin"
        },
        "local": {
            "path":         "/tmp/sbin",
            "createDir":    true
        },
        "transport": {
            "mechanism":    "compress",
            "compress": {
                "archive":  "zip",
                "unpack":   true,
                "cleanup":  true
            }
        }
    }
}

pullPath

pfurl calling syntax

Assuming satisfied preconditions, let's pull a directory tree from the remote machine/host to the remote local machine:

pfurl --verb POST --raw --httpResponseBodyParse \
      --http ${HOST_IP}:5055/api/v1/cmd \
      --msg \
'{  "action": "pullPath",
    "meta": {
        "remote": {
            "path":         "/usr/sbin"
        },
        "local": {
            "path":         "/tmp/sbin",
            "createDir":    true
        },
        "transport": {
            "mechanism":    "compress",
            "compress": {
                "archive":  "zip",
                "unpack":   true,
                "cleanup":  true
            }
        }
    }
}' --quiet --jsonpprintindent 4  

return payload

The above call returns the JSON string:

{
    "stdout": {
        "remoteCheck": {
            "size": "48",
            "msg": "Check on remote path successful.",
            "response": {
                "isdir": true,
                "status": true,
                "isfile": false
            },
            "timestamp": "2017-03-13 14:42:09.973829",
            "status": true
        },
        "localCheck": {
            "msg": "Check on local path successful.",
            "check": {
                "isdir": true,
                "status": true,
                "isfile": false
            },
            "status": true,
            "timestamp": "2017-03-13 14:42:09.969986"
        },
        "status": true,
        "msg": "unzip operation successful",
        "compress": {
            "remoteServer": {
                "size": "1,372,100",
                "msg": "PULL successful",
                "response": "<truncated>",
                "timestamp": "2017-03-13 14:42:10.235504",
                "status": true
            },
            "localOp": {
                "unzip": {
                    "path": "/tmp",
                    "msg": "unzip operation successful",
                    "fileProcessed": "/tmp/sbin.zip",
                    "status": true,
                    "timestamp": "2017-03-13 14:42:10.302147",
                    "filesize": "1,028,681",
                    "zipmode": "r"
                },
                "decode": {
                    "msg": "Decode successful",
                    "fileProcessed": "/tmp/sbin.zip",
                    "status": true
                }
            },
            "status": true,
            "msg": "unzip operation successful"
        }
    }
}

oneShot

If --oneShot is passed to purl, then a server control message is transmitted after the file IO event that effectively shuts down the remote server:

pfurl --verb POST --http ${HOST_IP}:5055/api/v1/cmd/ --oneShot --msg \

--30--