/**
  * Executes the task
  *
  * @param Node $node
  * @param Application $application
  * @param Deployment $deployment
  * @param array $options
  * @throws InvalidConfigurationException
  * @throws TaskExecutionException
  * @return void
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     if (empty($options['sourceNode']) || !is_array($options['sourceNode'])) {
         throw new InvalidConfigurationException('SourceNode is missing', 1409263510);
     }
     $sourceNode = $this->nodeFactory->getNodeByArray($options['sourceNode']);
     $options = array_replace_recursive($this->options, $options);
     $source = $this->getArgument($sourceNode, $application, $options['sourcePath'], $options['sourceFile']);
     $target = $this->getArgument($node, $application, $options['targetPath'], $options['targetFile']);
     $command = 'scp -o BatchMode=\'yes\' ' . $source . ' ' . $target;
     $this->shell->executeOrSimulate($command, $node, $deployment);
 }
 /**
  * @param array $configurations
  * @return AbstractApplication[]
  * @throws Exception
  */
 public function getApplicationsByConfiguration(array $configurations)
 {
     $applications = array();
     $iteration = 0;
     foreach ($configurations as $configuration) {
         $iteration++;
         if (empty($configuration['type'])) {
             throw new Exception('No type is given in application configuration', 1408396056);
         }
         $applicationClass = '\\Lightwerk\\SurfRunner\\Domain\\Model\\Application\\' . $configuration['type'] . 'Application';
         if (!class_exists($applicationClass)) {
             break;
         }
         // Do not change the Application name!
         // @see \Lightwerk\SurfRunner\Application\AbstractApplication
         // ->getTaskNameForApplication()
         /** @var AbstractApplication $application */
         $application = new $applicationClass('#' . $iteration . ' ' . $configuration['type']);
         if (!empty($configuration['options']) && is_array($configuration['options'])) {
             $application->addOptions($configuration['options']);
         }
         if (!empty($configuration['tasks']) && is_array($configuration['tasks'])) {
             $application->addTasks($configuration['tasks']);
         }
         if (!empty($configuration['taskOptions']) && is_array($configuration['taskOptions'])) {
             $application->addTaskOptions($configuration['taskOptions']);
         }
         if (empty($configuration['nodes']) || !is_array($configuration['nodes'])) {
             throw new Exception('No nodes are given in application configuration', 1408396220);
         }
         foreach ($configuration['nodes'] as $nodeConfiguration) {
             try {
                 $node = $this->nodeFactory->getNodeByArray($nodeConfiguration);
                 $application->addNode($node);
             } catch (InvalidConfigurationException $e) {
                 throw new Exception('cannot create node from configuration', 1437474964);
             }
         }
         $applications[] = $application;
     }
     return $applications;
 }
Beispiel #3
0
 /**
  * @param Node $node
  * @param Application $application
  * @param Deployment $deployment
  * @param array $options
  * @return void
  * @throws InvalidConfigurationException
  * @throws TaskExecutionException
  */
 public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
 {
     // Get nodes
     if (empty($options['sourceNode']) || !is_array($options['sourceNode'])) {
         throw new InvalidConfigurationException('No sourceNode given in options.', 1409078366);
     }
     $sourceNode = $this->nodeFactory->getNodeByArray($options['sourceNode']);
     $localNode = $deployment->getNode('localhost');
     $targetNode = $node;
     // Get shared paths
     $sourceSharedPath = $this->getSharedPathFromNode($sourceNode, $deployment, $options['sourceNodeOptions'], $application);
     $localSharedPath = $deployment->getWorkspacePath($application) . '_shared/';
     $targetSharedPath = $this->getSharedPathFromNode($node, $deployment, $options, $application);
     // maybe we should change this behaviour ...
     if ($targetNode->isLocalhost() === TRUE || $sourceNode->isLocalhost() === TRUE) {
         // sync direct
         $this->sync($sourceNode, $sourceSharedPath, $targetNode, $targetSharedPath, $deployment, $options);
     } else {
         // cached
         $this->sync($sourceNode, $sourceSharedPath, $localNode, $localSharedPath, $deployment, $options);
         $this->sync($localNode, $localSharedPath, $targetNode, $targetSharedPath, $deployment, $options);
     }
 }