Beispiel #1
0
 /**
  * @large
  */
 public function testStuff()
 {
     $host = new Host('127.0.0.1', 22, new KeyCredential('jordon', null, '/home/jordon/.ssh/jordon.pem'));
     //$host = new Host('54.206.100.211', 22, new KeyCredential('ec2-user', null, '/home/jordon/.ssh/test-sydney.pem'));
     //$host = new Host('54.79.108.44', 22, new KeyCredential('ec2-user', null, '/home/jordon/.ssh/test-sydney.pem'));
     $logger_bake = new FileLogger("/tmp/bakery_bake.log", false, true);
     $logger_callback = new FileLogger("/tmp/bakery_callback.log", false, true);
     $logger_out = new FileLogger("/tmp/bakery_out.log", false, true);
     $logger_bake->debug("\n\n\n---");
     $logger_callback->debug("\n\n\n---");
     $logger_out->debug("\n\n\n---");
     $callback = function (Phase $phase, $progress, $total, $msg) use($logger_callback) {
         $logger_callback->info($phase->value() . ' ' . $progress . ' / ' . $total . ': ' . $msg);
     };
     $bakery = new Bakery($host, $logger_out, $callback);
     $bakery->setLogger($logger_bake);
     $repo = new Repository();
     $repo->setRepositoryType(RepositoryType::GIT());
     $repo->setCheckoutPath('/tmp/test-repo');
     $repo->setUri('git@github.com:jordonsc/hyperion_dbal.git');
     $repo->setPrivateKey(file_get_contents(__DIR__ . '/Resources/test-key.pem'));
     $repo->setPassword('password');
     $repo->setTag('c38a0835235003a08d3f5f851f57ba5914cff98e');
     $repo->setTag('0.0.4-beta');
     $repo->setHostFingerprint('16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48');
     $standards = new Repository();
     $standards->setRepositoryType(RepositoryType::GIT());
     $standards->setUri('https://github.com/bravo3/standards.git');
     $standards->setTag('1.0.0');
     $standards->setCheckoutPath('/tmp/bravo3/standards');
     $standards->setProxy(new SocksProxy('localhost', 5501));
     $schema = new Schema(PackagerType::YUM());
     $schema->addOperation(new EnvironmentOperation(['env' => 'bake', 'action' => '1234']))->addOperation(new CodeCheckoutOperation($standards));
     $bakery->bake($schema);
 }
 /**
  * Run the operation
  */
 public function execute()
 {
     $this->status(Phase::INSTALL_PACKAGES());
     $this->enterRoot();
     $this->payload = (array) $this->payload;
     // Prep the packager, pick the base command
     switch ($this->packager_type) {
         default:
         case PackagerType::YUM():
             $this->waitForYum(self::CMD_TIMEOUT);
             $cmd_base = 'yum -y install ';
             $allowed_errors = ['Existing lock '];
             break;
         case PackagerType::APT():
             $cmd_base = 'apt-get -y install ';
             $allowed_errors = ['Extracting templates from packages:'];
             if (!$this->sendCommand("apt-get -y update", self::CMD_TIMEOUT)) {
                 $this->exitRoot();
                 throw new ApplicationException("Update failed");
             }
             break;
     }
     // Install all packages
     $package = implode(' ', $this->payload);
     if (!$this->sendCommand($cmd_base . $package, self::CMD_TIMEOUT, $allowed_errors)) {
         $this->exitRoot();
         throw new ApplicationException("Installation of system packages failed");
     }
     $this->exitRoot();
 }
 /**
  * Run the operation
  */
 public function execute()
 {
     $this->enterRoot();
     $this->status(Phase::UPDATE_PACKAGES());
     switch ($this->packager_type) {
         default:
         case PackagerType::YUM():
             $this->waitForYum(self::CMD_TIMEOUT);
             $cmds = ['yum -y update'];
             $allowed_errors = ['Existing lock '];
             break;
         case PackagerType::APT():
             $cmds = ['apt-get -y update', 'apt-get -y upgrade'];
             $allowed_errors = ['Extracting templates from packages:'];
             break;
     }
     foreach ($cmds as $cmd) {
         if (!$this->sendCommand($cmd, self::CMD_TIMEOUT, $allowed_errors)) {
             $this->exitRoot();
             throw new ApplicationException("System packager failed during update");
         }
     }
     $this->exitRoot();
 }