Import trycmd and ssh_execute from nova.

This change required adding basic unit tests as well as these were
both untested in nova.

Change-Id: If6843e57810198aab3c61f9eb3c3a6f42f710f7c
Merge "Import trycmd and ssh_execute from nova."