Execution class - API Usage

Path: /src/index.coffee compiled to /lib/index.js

This is an object oriented implementation around the core process.spawn command and alternatively ssh connections.

Class Initialization

Exec.setup

Set the modules config paths and validation schema.

Usage: staticExec.setup(cb)

Parameter
  • cb - Function(<Error>) callback with possible error

Exec.init

Set the modules config paths, validation schema and initialize the configuration.

Usage: staticExec.init(cb)

Parameter
  • cb - Function(<Error>) callback with possible error

Exec.run

Easy call to directly run execution in one statement.

Usage: staticExec.run(setup, cb)

Parameter
  • setup - Object the job definition like in the constructor
  • cb - Function(<Error>, <Exec>) callback with possible error and the execution job which was used

Exec.close

Close remote connections

Usage: staticExec.close

Instance Methods

Exec

Create a new execution object to specify and call later.

Usage:new Exec(setup)

Parameter
  • setup - Object the job definition
Return

Exec object containing the following properties:

setup - Schema Definition
  • id - Integer unique id of element

  • setup - Object configuration of job Index.coffee.schema Data

    An object with the following keys allowed: remote, cmd, args, cwd, uid, gid, env, priority, timeout, check, retry. The following entries have a specific format:

    remote

    SSH Connection is the ssh connection to use.

    It has to be one of the following types:

    • SSH Connection Reference is the reference name for an defined ssh connection under config ‘/ssh/NAME’.

      A text entry in which all control characters will be removed.

    • SSH Connections are a list of ssh connection alternatives.

      A list. Each entry has to be of type object:

      SSH Connection is a ssh connection setting.

      An object with the following keys have to be present: host, port. The following keys are allowed: forceIPv4, forceIPv6, username, password, privateKey, passphrase, localHostname, localUsername, keepaliveInterval, keepaliveCountMax, readyTimeout, strictVendor, algorithms, compress, debug. The following entries have a specific format:

      host

      Hostname or IP Address is the hostname or IP address to connect to.

      It has to be one of the following types:

      • Hostname is the hostname to connect to.

        A valid hostname. This has to be a valid name according to RFC 1123

      • IP Address is the IP address to connect to.

        A valid IP address as string.

      port

      Port Number is the port on which to connect using ssh protocol.

      A TCP/UDP port number or name which is optional and will be set to 22 if not specified. It has to be one of the following types:

      • An integer value. The value should be between 0 and 65535.
      • A text entry in which all control characters will be removed. Only the values: ‘rtmp’, ‘acr-nema’, ‘afbackup’, ‘afmbackup’, ‘afpovertcp’, ‘afs3-bos’, ‘afs3-callback’, ‘afs3-errors’, ‘afs3-fileserver’, ‘afs3-kaserver’, ‘afs3-prserver’, ‘afs3-rmtsys’, ‘afs3-update’, ‘afs3-vlserver’, ‘afs3-volser’, ‘amanda’, ‘amandaidx’, ‘amidxtape’, ‘amqp’, ‘aol’, ‘asf-rmcp’, ‘asp’, ‘at-echo’, ‘at-nbp’, ‘at-rtmp’, ‘at-zis’, ‘auth’, ‘bacula-dir’, ‘bacula-fd’, ‘bacula-sd’, ‘bgp’, ‘bgpd’, ‘bgpsim’, ‘biff’, ‘binkp’, ‘bootpc’, ‘bootps’, ‘bpcd’, ‘bpdbm’, ‘bpjava-msvc’, ‘bprd’, ‘canna’, ‘cfengine’, ‘cfinger’, ‘chargen’, ‘cisco-sccp’, ‘clc-build-daemon’, ‘clearcase’, ‘cmip-agent’, ‘cmip-man’, ‘codaauth2’, ‘codasrv’, ‘codasrv-se’, ‘conference’, ‘courier’, ‘csnet-ns’, ‘csync2’, ‘customs’, ‘cvspserver’, ‘daap’, ‘datametrics’, ‘daytime’, ‘db-lsp’, ‘dcap’, ‘dhcpv6-client’, ‘dhcpv6-server’, ‘dicom’, ‘dict’, ‘dircproxy’, ‘discard’, ‘distcc’, ‘distmp3’, ‘domain’, ‘echo’, ‘eklogin’, ‘enbd-cstatd’, ‘enbd-sstatd’, ‘epmd’, ‘exec’, ‘f5-globalsite’, ‘f5-iquery’, ‘fatserv’, ‘fax’, ‘fido’, ‘finger’, ‘font-service’, ‘freeciv’, ‘frox’, ‘fsp’, ‘ftp’, ‘ftp-data’, ‘ftps’, ‘ftps-data’, ‘gdomap’, ‘gds-db’, ‘ggz’, ‘git’, ‘gnunet’, ‘gnutella-rtr’, ‘gnutella-svc’, ‘gopher’, ‘gpsd’, ‘gris’, ‘groupwise’, ‘gsidcap’, ‘gsiftp’, ‘gsigatekeeper’, ‘hkp’, ‘hmmp-ind’, ‘hostmon’, ‘hostnames’, ‘http’, ‘http-alt’, ‘https’, ‘hylafax’, ‘iax’, ‘icpv2’, ‘idfp’, ‘imap2’, ‘imap3’, ‘imaps’, ‘imsp’, ‘ingreslock’, ‘ipp’, ‘iprop’, ‘ipsec-nat-t’, ‘ipx’, ‘irc’, ‘ircd’, ‘ircs’, ‘isakmp’, ‘iscsi-target’, ‘isdnlog’, ‘isisd’, ‘iso-tsap’, ‘kamanda’, ‘kazaa’, ‘kerberos4’, ‘kerberos’, ‘kerberos-adm’, ‘kerberos-master’, ‘kermit’, ‘klogin’, ‘knetd’, ‘kpasswd’, ‘kpop’, ‘krb-prop’, ‘krbupdate’, ‘kshell’, ‘kx’, ‘l2f’, ‘ldap’, ‘ldaps’, ‘link’, ‘linuxconf’, ‘loc-srv’, ‘login’, ‘log-server’, ‘lotusnote’, ‘mailq’, ‘mandelspawn’, ‘mdns’, ‘microsoft-ds’, ‘mmcc’, ‘moira-db’, ‘moira-update’, ‘moira-ureg’, ‘mon’, ‘mrtd’, ‘msnp’, ‘msp’, ‘ms-sql-m’, ‘ms-sql-s’, ‘mtn’, ‘mtp’, ‘munin’, ‘mysql’, ‘mysql-proxy’, ‘nameserver’, ‘nbd’, ‘nbp’, ‘nessus’, ‘netbios-dgm’, ‘netbios-ns’, ‘netbios-ssn’, ‘netnews’, ‘netstat’, ‘netwall’, ‘nextstep’, ‘nfs’, ‘ninstall’, ‘nntp’, ‘nntps’, ‘noclog’, ‘npmp-gui’, ‘npmp-local’, ‘nqs’, ‘nrpe’, ‘nsca’, ‘ntalk’, ‘ntp’, ‘nut’, ‘omirr’, ‘omniorb’, ‘openvpn’, ‘ospf6d’, ‘ospfapi’, ‘ospfd’, ‘passwd-server’, ‘pawserv’, ‘pcrd’, ‘pipe-server’, ‘pop2’, ‘pop3’, ‘pop3s’, ‘poppassd’, ‘postgresql’, ‘predict’, ‘printer’, ‘proofd’, ‘prospero’, ‘prospero-np’, ‘pwdgen’, ‘qmqp’, ‘qmtp’, ‘qotd’, ‘radius’, ‘radius-acct’, ‘radmin-port’, ‘re-mail-ck’, ‘remctl’, ‘remotefs’, ‘remoteping’, ‘rfe’, ‘ripd’, ‘ripngd’, ‘rje’, ‘rlp’, ‘rmiregistry’, ‘rmtcfg’, ‘rootd’, ‘route’, ‘rpc2portmap’, ‘rplay’, ‘rsync’, ‘rtcm-sc104’, ‘rtelnet’, ‘rtsp’, ‘saft’, ‘sa-msg-port’, ‘sane-port’, ‘search’, ‘sftp’, ‘sge-execd’, ‘sge-qmaster’, ‘sgi-cad’, ‘sgi-cmsd’, ‘sgi-crsd’, ‘sgi-gcd’, ‘shell’, ‘sieve’, ‘silc’, ‘sip’, ‘sip-tls’, ‘skkserv’, ‘smsqp’, ‘smtp’, ‘smux’, ‘snmp’, ‘snmp-trap’, ‘snpp’, ‘socks’, ‘spamd’, ‘ssh’, ‘submission’, ‘sunrpc’, ‘supdup’, ‘supfiledbg’, ‘supfilesrv’, ‘support’, ‘suucp’, ‘svn’, ‘svrloc’, ‘swat’, ‘syslog’, ‘syslog-tls’, ‘sysrqd’, ‘systat’, ‘tacacs’, ‘tacacs-ds’, ‘talk’, ‘tcpmux’, ‘telnet’, ‘telnets’, ‘tempo’, ‘tfido’, ‘tftp’, ‘time’, ‘timed’, ‘tinc’, ‘tproxy’, ‘ulistserv’, ‘unix-status’, ‘urd’, ‘uucp’, ‘uucp-path’, ‘vboxd’, ‘venus’, ‘venus-se’, ‘vnetd’, ‘vopied’, ‘webmin’, ‘webster’, ‘who’, ‘whois’, ‘wipld’, ‘wnn6’, ‘x11-1’, ‘x11-2’, ‘x11-3’, ‘x11-4’, ‘x11-5’, ‘x11’, ‘x11-6’, ‘x11-7’, ‘xdmcp’, ‘xinetd’, ‘xmms2’, ‘xmpp-client’, ‘xmpp-server’, ‘xpilot’, ‘xtel’, ‘xtell’, ‘xtelw’, ‘z3950’, ‘zabbix-agent’, ‘zabbix-trapper’, ‘zebra’, ‘zebrasrv’, ‘zephyr-clt’, ‘zephyr-hm’, ‘zephyr-srv’, ‘zip’, ‘zope’, ‘zope-ftp’, ‘zserv’ are allowed.
      forceIPv4

      Force to use IPv4 is a flag to only use resolved IPv4 address for host.

      A boolean value, which will be true for ‘true’, ‘1’, ‘on’, ‘yes’, ‘+’, 1, true and will be considered as false for ‘false’, ‘0’, ‘off’, ‘no’, ‘-’, 0, false. It’s optional.

      forceIPv6

      Force to use IPv6 is a flag to only use resolved IPv6 address for host.

      A boolean value, which will be true for ‘true’, ‘1’, ‘on’, ‘yes’, ‘+’, 1, true and will be considered as false for ‘false’, ‘0’, ‘off’, ‘no’, ‘-’, 0, false. It’s optional.

      username

      Username is the username to use for the connection.

      A text entry which is optional. All control characters will be removed.

      password

      Password is the password for user based authentication.

      A text entry which is optional. All control characters will be removed.

      privateKey

      Private Key is the private key file to use for OpenSSH authentication.

      A text entry which is optional. All control characters will be removed.

      passphrase

      Passphrase is the passphrase used to decrypt an encrypted private key.

      A text entry which is optional. All control characters will be removed.

      localHostname

      Local Hostname is the host used for hostbased user authentication.

      A text entry which is optional. All control characters will be removed.

      localUsername

      Local User is the username used for hostbased user authentication.

      A text entry which is optional. All control characters will be removed.

      keepaliveInterval

      Keepalive Interval is the interval for the keepalive packets to be send.

      A time interval as float, in time format or as text which may use a combination of values with the units: ms, s, m, h, d which is optional and will be set to 1000 if not specified. The result will be given as the number of ms. A numeric floating point number.

      keepaliveCountMax

      Keepalive Tries are the number of unanswered SSH-level keepalive packets that can be sent to the server before disconnection.

      An integer value which is optional. The value should be greater than 0.

      readyTimeout

      Ready TImeout is the time to wait for the ssh handshake to succeed.

      A time interval as float, in time format or as text which may use a combination of values with the units: ms, s, m, h, d which is optional and will be set to 20000 if not specified. The result will be given as the number of ms. A numeric floating point number.

      strictVendor

      Strict Vendor Check is a flag to performs a strict server vendor check before sending vendor-specific requests, etc…

      A boolean value, which will be true for ‘true’, ‘1’, ‘on’, ‘yes’, ‘+’, 1, true and will be considered as false for ‘false’, ‘0’, ‘off’, ‘no’, ‘-’, 0, false. It’s optional.

      algorithms

      Algotithms are the transport layer algorithms to use.

      A list which is optional. Each entry has to be of type string:

      Algorithm is an allowed transport layer algorithm.

      A text entry in which all control characters will be removed. Only the values: ‘kex’, ‘cipher’, ‘serverHostKey’, ‘hmac’, ‘compress’ are allowed.

      compress

      Compression is a flag to enable compression if server supports it or force it.

      It has to be one of the following types (optional):

      • Force Compression is a setting to force compression use.

        A text entry in which all control characters will be removed. Only the values: ‘force’ are allowed.

      • Compression Allowed is a flag to allow/disallow compression.

        A boolean value, which will be true for ‘true’, ‘1’, ‘on’, ‘yes’, ‘+’, 1, true and will be considered as false for ‘false’, ‘0’, ‘off’, ‘no’, ‘-’, 0, false.

      debug

      Extended Debug is the DEBUG=exec.ssh messages are extended with server communication.

      A boolean value, which will be true for ‘true’, ‘1’, ‘on’, ‘yes’, ‘+’, 1, true and will be considered as false for ‘false’, ‘0’, ‘off’, ‘no’, ‘-’, 0, false. It’s optional. The list will be shuffled to get a random order.

    cmd

    Command is the command to execute (with optional parameters).

    A text entry in which all control characters will be removed.

    args

    Arguments are the list of command arguments (if not given in command).

    A list.

    cwd

    A text entry in which all control characters will be removed.

    uid

    A value of any type.

    gid

    A value of any type.

    env

    An object.

    priority

    A text entry in which all control characters will be removed.

    timeout

    An integer value.

    check

    An object.

    retry

    An object.

  • name - String connection URI for debug messages

  • host - String used in vital data list

  • result - Object

    • start - Date of execution start
    • end - Date of execution end

exec.run

Start execution

Usage:exec.run(cb)

Parameter
  • cb - Function(<Error>) callback with possible error