Exemplo n.º 1
0
 protected function execute($arguments = array(), $options = array())
 {
     $context = sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration('app', $options['env'], true));
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // add your code here
     // get node
     $node_id = $options['node'];
     $etva_node = EtvaNodePeer::getOrElectNodeFromArray(array_merge($options, $arguments));
     if (!$etva_node) {
         $msg_i18n = $context->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $node_id));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     }
     // logical volume to clone
     $lv = $arguments['logicalvolume'];
     $vg = $options['volumegroup'];
     // check if a logical volume exists
     if (!($etva_lv = $etva_node->retrieveLogicalvolumeByAny($lv, $vg))) {
         $msg = Etva::getLogMessage(array('name' => $lv), EtvaLogicalvolumePeer::_ERR_NOTFOUND_);
         $msg_i18n = $context->getI18N()->__(EtvaLogicalvolumePeer::_ERR_NOTFOUND_, array('%name%' => $lv));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     }
     // original logical volume
     $original_lv = $arguments['original'];
     $original_vg = $options['original-volumegroup'];
     // if cannot find logical volume
     if (!($etva_original_lv = $etva_node->retrieveLogicalvolumeByAny($original_lv, $original_vg))) {
         $msg = Etva::getLogMessage(array('name' => $original_lv), EtvaLogicalvolumePeer::_ERR_NOTFOUND_);
         $msg_i18n = $context->getI18N()->__(EtvaLogicalvolumePeer::_ERR_NOTFOUND_, array('%name%' => $original_lv));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     }
     // prepare soap info....
     $lv_va = new EtvaLogicalvolume_VA($etva_lv);
     $response = $lv_va->send_clone($etva_node, $etva_original_lv);
     if (!$response['success']) {
         $this->log("[ERROR] " . $response['error']);
     } else {
         $this->log("[INFO] " . $response['response']);
     }
     return $response;
 }