Beispiel #1
0
 /**
  * Bake the host
  *
  * @param Schema $schema
  * @param int    $terminal_width
  */
 public function bake(Schema $schema, $terminal_width = 180)
 {
     // Connect to host
     $con = $this->connect();
     if (!$con) {
         throw new ConnectionException("Unable to connect to bakery host");
     }
     // Get an SSH stream
     $this->status(Phase::ENVIRONMENT(), 0, 0, 'Configuring environment');
     $shell = $con->getShell(new Terminal($terminal_width, 25, TerminalUnit::CHARACTERS));
     $shell->setSmartConsole();
     // Traverse operations
     $total = $schema->getOperationCount();
     /** @var OperationInterface $operation */
     foreach ($schema as $pos => $operation) {
         $this->status(Phase::OPERATION(), $pos + 1, $total, 'Executing ' . $this->getOperationName($operation));
         $operation->setLogger($this->output);
         $operation->setCallback($this->status_callback);
         $operation->setPackagerType($schema->getPackagerType());
         $operation->setShell($shell);
         $operation->setConnection($con);
         try {
             $operation->execute();
         } catch (\Exception $e) {
             $this->status(Phase::ERROR(), $pos + 1, $total, 'Operation failed (' . $e->getMessage() . ')');
             $con->disconnectChain();
             throw $e;
         }
     }
     $con->disconnectChain();
 }