xenon-middleware / xenon-cli

Perform files and jobs operations with Xenon library from command line
http://nlesc.github.io/Xenon/
Apache License 2.0
2 stars 3 forks source link

Support a via host #45

Closed sverhoeven closed 6 years ago

sverhoeven commented 6 years ago

Xenon now supports a via in the location string, CLI should to.

Using default credentials:

xenon scheduler ssh --location 'headnode via gatewaynode' exec /bin/hostname

To use different username than local, both the via and end host use someone as username.

xenon scheduler ssh --location 'headnode via gatewaynode' --username someone exec /bin/hostname

To use different password/passphrase and certfile than local for via and end host use --password and --certfile resp.

To use different username than the end host.

xenon scheduler ssh --location 'headnode via gatewaynode' --via-username someone exec /bin/hostname

To use different password/passphrase and certfile on via node use --via-password and --via-certfile resp.

Using single set of --via-* for credentials, will allow CLI to only support one cred for the end host and optionally one cred for all via hosts.

sverhoeven commented 6 years ago

The xenon filesystem sftp copy command allows to give a --target-location which could contain a via host.

When source and target both have vias, for example

xenon filesystem sftp \
--location 'sourcehost via:sourcegatewaynode'  \
--username sourcehost_user
--via-username gatewaynode_user
copy 
--target-location 'targethost via:targetgatewaynode' \
--target-user targethost_user
 /file/on/sourcehost /file/on/targethost

The username for the sourcegatewaynode and targetgatewaynode should be gatewaynode_user.

sverhoeven commented 6 years ago

Instead of a single --via-username username we could also use any number of --via-username hostport=username. Where hostport should match the via in the somehost via:hostport location. The --username username option can than be used as the default cred inside CredentialMap.

The copy command will then be

xenon filesystem sftp \
--location 'sourcehost via:sourcegatewaynode'  \
--username sourcehost_user
--via-username sourcegatewaynode=sourcegatewaynode_user
--via-username targetgatewaynode=targetgatewaynode_user
copy 
--target-location 'targethost via:targetgatewaynode' \
--target-user targethost_user
 /file/on/sourcehost /file/on/targethost

This maps much more nicer to the CredentialMap class as the location does not have to be parsed, so going for this functionality.