src/pyams_scheduler/interfaces/ssh.py
changeset 0 48483b0b26fa
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_scheduler/interfaces/ssh.py	Wed Mar 11 11:52:59 2015 +0100
@@ -0,0 +1,62 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+from pyams_scheduler.interfaces import ITask
+
+# import packages
+from zope.interface import invariant, Interface, Invalid
+from zope.schema import TextLine, Int, Password
+
+from pyams_scheduler import _
+
+
+class ISSHCallerTaskInfo(Interface):
+    """SSH caller task info"""
+
+    hostname = TextLine(title=_("Target hostname of IP address"),
+                        description=_("Enter hostname or address of a remote hots; keep empty for local server host"),
+                        required=False)
+
+    port = Int(title=_("SSH port number"),
+               default=22,
+               required=False)
+
+    username = TextLine(title=_("User name"),
+                        required=False)
+
+    private_key = TextLine(title=_("Private key filename"),
+                           description=_("Enter name of private key file; use '~' to identify "
+                                         "running server user home directory, as in ~/.ssh/id_rsa"),
+                           required=False)
+
+    password = Password(title=_("Password"),
+                        description=_("If not using private key, you must provide user's password"),
+                        required=False)
+
+    cmdline = TextLine(title=_("Command line"),
+                       description=_("Enter command line, using absolute path names"),
+                       required=True)
+
+    @invariant
+    def check_remote_host(self):
+        if self.hostname and (bool(self.private_key) == bool(self.password)):
+            raise Invalid(_("You must provide a private key filename OR a password when defining remote tasks"))
+
+
+class ISSHCallerTask(ITask, ISSHCallerTaskInfo):
+    """SSH caller interface"""