-
Notifications
You must be signed in to change notification settings - Fork 15
pfioh command: pushPath (absolute) using zip
This page describes the pushPath
command to pfioh
. It is used to push
a directory tree to a remote server. In this example, the tree is zipped up at the source, and then unzipped to a specific location on the remote server. For an example of using the keystore
mechanism, see here
- This page assumes that
pfioh
is listening on:${HOST_IP}:5055
.
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
The msg
payload of the REST interaction with pfioh
is:
{ "action": "pushPath",
"meta": {
"remote": {
"path": "/tmp/sbin"
},
"local": {
"path": "/usr/sbin"
},
"transport": {
"mechanism": "compress",
"compress": {
"archive": "zip",
"unpack": true,
"cleanup": true
}
}
}
}
Assuming satisfied preconditions, let's push a directory tree from the machine/host running purl
to the remote machine:
pfurl --verb POST --httpResponseBodyParse \
--raw --http ${HOST_IP}:5055/api/v1/cmd \
--msg \
'{ "action": "pushPath",
"meta": {
"remote": {
"path": "/tmp/sbin"
},
"local": {
"path": "/usr/sbin"
},
"transport": {
"mechanism": "compress",
"compress": {
"archive": "zip",
"unpack": true,
"cleanup": true
}
}
}
}' --quiet --jsonpprintindent 4
To use the dockerized version of pfurl
, and assuming a pfioh
on the given IP:
The helper script just creates a docker run
command line string. You can run this string directly without using the helper script and directly calling the docker
app:
docker run --name pfurl -v /home:/Users \
--rm -ti fnndsc/pfurl --verb POST \
--httpResponseBodyParse --raw \
--http ${HOST_IP}:5055/api/v1/cmd \
--msg \
'{ "action": "pushPath",
"meta": {
"remote": {
"path": "/tmp/sbin"
},
"local": {
"path": "/usr/sbin"
},
"transport": {
"mechanism": "compress",
"compress": {
"archive": "zip",
"unpack": true,
"cleanup": true
}
}
}
}' --quiet --jsonpprintindent 4
This will push the local /usr/sbin
directory out to the remote machine and unpack to the remote machine's /tmp
directory. Note that the zip
compression will not preserve file mode bits (executable files need to have their execute bit explicitly set again).
The above call returns the JSON string:
{
"stdout": {
"remoteCheck": {
"size": "48",
"msg": "Check on remote path successful.",
"response": {
"isdir": true,
"isfile": false,
"status": true
},
"timestamp": "2017-03-13 13:36:09.146058",
"status": true
},
"msg": "push OK.",
"localCheck": {
"check": {
"isfile": false,
"isdir": true,
"status": true
},
"status": true,
"timestamp": "2017-03-13 13:36:09.143503",
"msg": "Check on local path successful."
},
"compress": {
"msg": "push OK.",
"local": {
"zip": {
"fileProcessed": "a20eebf8-9788-456b-8ea9-d33b842ca60e.zip",
"filesize": "1,028,644",
"msg": "zip operation successful",
"path": "/usr/sbin",
"zipmode": "w",
"status": true
}
},
"status": true,
"remoteServer": {
"stdout": {
"User-agent": "PycURL/7.43.0 libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3",
"decode": {},
"unzip": {
"fileProcessed": "/tmp/sbin.zip",
"filesize": "1,028,644",
"msg": "unzip operation successful",
"path": "/tmp",
"zipmode": "r",
"status": true
},
"msg": "unzip operation successful",
"status": true
},
"msg": "push OK.",
"status": true
}
},
"status": true
}
}
If --oneShot
is passed to pfurl
, then a server control message is transmitted after the file IO event that effectively shuts down the remote server after processing the JSON directive:
pfurl --verb POST --http ${HOST_IP}:5055/api/v1/cmd/ --oneShot --msg \
--30--