/** * {@inheritdoc} * Example: * // $node1, $node2, $node3, $node4 are instances of \Assimtech\Tempo\Node\NodeInterface * new Environment(array( * 'name' => 'test', * 'nodes' => array( * $node1, * $node2, * $node3, * $node4, * ), * 'roles' => array( * 'role1' => array( * $node1, * $node2, * ), * 'role2' => array( * $node3, * ), * ), * )) */ public function __construct($input = array(), $flags = 0, $iteratorClass = 'ArrayIterator') { // Handle string shortcut setup if (is_string($input)) { $input = array('name' => $input); } // Defaults if (is_array($input)) { $input = array_replace_recursive(array('nodes' => array(), 'roles' => array()), $input); } parent::__construct($input, $flags, $iteratorClass); }
/** * {@inheritdoc} * * Built-in properties are: * [Mandatory] * [ssh][host] - The hostname or IP address for the ssh connection * * [Optional] * [ssh][user] - The user to use for the ssh connection * * [ssh][options] - An associative array of ssh options, see -o option in ssh(1) * * [ssh][control][useControlMaster] - Use control master connection? * [ssh][control][ControlPath] - see ControlPath in ssh_config(5) * [ssh][control][ControlPersist] - see ControlPersist in ssh_config(5) * [ssh][control][closeOnDestruct] - Should the control master connection be destroyed when this node is? * * @throws \InvalidArgumentException */ public function __construct($input = array(), $flags = 0, $iteratorClass = 'ArrayIterator') { // Handle string shortcut setup if (is_string($input)) { $userHost = explode('@', $input); if (count($userHost) === 2) { $input = array('ssh' => array('user' => $userHost[0], 'host' => $userHost[1])); } else { $input = array('ssh' => array('host' => $input)); } } // Defaults $input = array_replace_recursive(array('ssh' => array('host' => null, 'options' => array('RequestTTY' => 'no'), 'control' => array('useControlMaster' => true))), $input); if ($input['ssh']['control']['useControlMaster']) { $input['ssh']['control'] = array_merge(array('ControlPath' => '~/.ssh/tempo_ctl_%r@%h:%p', 'ControlPersist' => '5m', 'closeOnDestruct' => false), $input['ssh']['control']); } parent::__construct($input, $flags, $iteratorClass); }