Exemple #1
0
# See the License for the specific language governing permissions and
# limitations under the License.
*/
$_SERVER['SCRIPT_NAME'] !== "/controller.php" ? require_once __DIR__ . "/classes/Requires.php" : (Links::$pretty = true);
//Make sure we can connect and select the executions collection in MongoDB
MongoConnection::connect();
MongoConnection::selectCollection("executions");
//Get groups
$groups = array();
$result = MySQLQueries::get_groups();
while ($row = MySQLConnection::fetch_object($result)) {
    $groups[] = $row;
}
//Get the servers in the default group
$servers_in_default_group = array();
$result = MySQLQueries::get_servers_by_groups(array());
while ($row = MySQLConnection::fetch_object($result)) {
    $servers_in_default_group[] = $row;
}
//Get recipes
$recipes = array();
$result = MySQLQueries::get_recipes();
while ($row = MySQLConnection::fetch_object($result)) {
    $recipes[] = $row;
}
Header::set_title("Commando.io - Execute");
Header::render(array("chosen", "codemirror"));
?>
	<div id="execute-working" class="progress progress-striped active">
  		<div class="bar" style="width: 100%;"></div>
	</div>
Exemple #2
0
Functions::check_required_parameters(array($_POST['groups'], $_POST['recipe']));
if (!CSRF::is_valid()) {
    Error::halt(400, 'bad request', 'Missing required security token.');
}
$result = MySQLQueries::get_recipe($_POST['recipe']);
$recipe = MySQLConnection::fetch_object($result);
if (empty($recipe)) {
    //Output error details
    Error::halt(400, 'bad request', 'The recipe \'' . $_POST['recipe'] . '\' does not exist.');
}
//Default group handling
if (count($_POST['groups']) === 1 && empty($_POST['groups'][0])) {
    $_POST['groups'] = array();
}
$servers = array();
$results = MySQLQueries::get_servers_by_groups($_POST['groups']);
while ($row = MySQLConnection::fetch_object($results)) {
    $servers[] = $row;
}
$returned_results = array();
foreach ($servers as $server) {
    try {
        $ssh = new SSH($server->address, $server->ssh_port, THROW_ERROR);
    } catch (Exception $ex) {
        $ex = json_decode($ex->getMessage());
        $returned_results[] = array("server" => $server->id, "server_label" => $server->label, "stream" => "error", "result" => $ex->error->message);
        continue;
    }
    try {
        $ssh_auth = $ssh->auth($server->ssh_username, SSH_PUBLIC_KEY_PATH, SSH_PRIVATE_KEY_PATH, THROW_ERROR);
    } catch (Exception $ex) {