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 parameters
     $lv = $arguments['name'];
     $size = $arguments['size'];
     $vg = $arguments['volumegroup'];
     $node_id = $options['node'];
     $format = $options['format'];
     $persnapshotusage = $options['persnapshotusage'];
     /*
      * check if lv is a file disk instead
      * if is a file disk check if special volume group exists. if not create
      */
     $is_DiskFile = $vg == sfConfig::get('app_volgroup_disk_flag') ? 1 : 0;
     // get etva_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;
     }
     // get logical volume
     if ($etva_lv = $etva_node->retrieveLogicalvolumeByLv($lv)) {
         $msg_type = $is_DiskFile ? EtvaLogicalvolumePeer::_ERR_DISK_EXIST_ : EtvaLogicalvolumePeer::_ERR_LV_EXIST_;
         $msg = Etva::getLogMessage(array('name' => $lv), $msg_type);
         $msg_i18n = $context->getI18N()->__($msg_type, array('%name%' => $lv));
         $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     }
     if (!($etva_vg = $etva_node->retrieveVolumegroupByVg($vg))) {
         $msg = Etva::getLogMessage(array('name' => $vg), EtvaVolumegroupPeer::_ERR_NOTFOUND_);
         $msg_i18n = $context->getI18N()->__(EtvaVolumegroupPeer::_ERR_NOTFOUND_, array('%name%' => $vg));
         $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
         $this->log("[ERROR] " . $error['error']);
         return $error;
     }
     // prepare soap info....
     $etva_lv = new EtvaLogicalvolume();
     $etva_lv->setEtvaVolumegroup($etva_vg);
     $etva_lv->setLv($lv);
     $lv_va = new EtvaLogicalvolume_VA($etva_lv);
     $response = $lv_va->send_create($etva_node, $size, $format, $persnapshotusage);
     if (!$response['success']) {
         $this->log("[ERROR] " . $response['error']);
     } else {
         $this->log("[INFO] " . $response['response']);
     }
     return $response;
 }
Esempio n. 2
0
 /**
  * Create logical volume snapshot
  *
  * $request may contain the following keys:
  * - nid: node ID
  * - slv: snapshot name
  * - olv: logical volume
  * - size: size
  *
  */
 public function executeJsonCreateSnapshot(sfWebRequest $request)
 {
     // logical volume id
     $nid = $request->getParameter('nid');
     $slv = $request->getParameter('slv');
     $olv = $request->getParameter('olv');
     $size = $request->getParameter('size');
     if (!($etva_node = EtvaNodePeer::retrieveByPK($nid))) {
         $msg_i18n = $this->getContext()->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $nid));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         //notify system log
         $node_log = Etva::getLogMessage(array('id' => $nid), EtvaNodePeer::_ERR_NOTFOUND_ID_);
         $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $msg_i18n, 'priority' => EtvaEventLogger::ERR)));
         // if is a CLI soap request return json encoded data
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($error);
         }
         // if is browser request return text renderer
         $error = $this->setJsonError($error);
         return $this->renderText($error);
     }
     if (!($etva_lv = $etva_node->retrieveLogicalvolumeByLv($olv))) {
         $msg = Etva::getLogMessage(array('name' => $lv), EtvaLogicalvolumePeer::_ERR_NOTFOUND_);
         $msg_i18n = $this->getContext()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_NOTFOUND_, array('%name%' => $lv));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         //notify system log
         $this->dispatcher->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $msg_i18n, 'priority' => EtvaEventLogger::ERR)));
         // if is a CLI soap request return json encoded data
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($error);
         }
         // if is browser request return text renderer
         $error = $this->setJsonError($error);
         return $this->renderText($error);
     }
     if ($etva_slv = $etva_node->retrieveLogicalvolumeByLv($slv)) {
         $msg_type = $is_DiskFile ? EtvaLogicalvolumePeer::_ERR_DISK_EXIST_ : EtvaLogicalvolumePeer::_ERR_LV_EXIST_;
         $msg = Etva::getLogMessage(array('name' => $slv), $msg_type);
         $msg_i18n = $this->getContext()->getI18N()->__($msg_type, array('%name%' => $slv));
         $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
         //notify system log
         $message = Etva::getLogMessage(array('name' => $slv, 'info' => $msg), EtvaLogicalvolumePeer::_ERR_CREATESNAPSHOT_);
         $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         // if is a CLI soap request return json encoded data
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($error);
         }
         // if is browser request return text renderer
         $error = $this->setJsonError($error);
         return $this->renderText($error);
     }
     // HERE
     $etva_vg = $etva_lv->getEtvaVolumegroup();
     /*
      * send logical volume to VA
      */
     #$lv_va = new EtvaLogicalvolume_VA($etva_lv);
     // prepare soap info....
     $etva_slv = new EtvaLogicalvolume();
     $etva_slv->setEtvaVolumegroup($etva_vg);
     $etva_slv->setLv($slv);
     $slv_va = new EtvaLogicalvolume_VA($etva_slv);
     $response = $slv_va->send_createsnapshot($etva_node, $etva_lv, $size);
     if ($response['success']) {
         $return = json_encode($response);
         // if the request is made throught soap request...
         if (sfConfig::get('sf_environment') == 'soap') {
             return $return;
         }
         // if is browser request return text renderer
         $this->getResponse()->setHttpHeader('Content-type', 'application/json');
         return $this->renderText($return);
     } else {
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($response);
         }
         $return = $this->setJsonError($response);
         return $this->renderText($return);
     }
 }
Esempio n. 3
0
 public function executeJsonImport(sfWebRequest $request)
 {
     $nid = $request->getParameter('nid');
     $import_data = json_decode($request->getParameter('import'), true);
     $server = $import_data;
     $vnc_keymap = EtvaSettingPeer::retrieveByPk('vnc_keymap');
     $server['vnc_keymap'] = $vnc_keymap->getValue();
     $server['uuid'] = EtvaServerPeer::generateUUID();
     $server['name'] = $import_data['name'];
     $server['vm_type'] = $import_data['vm_type'];
     $server['ip'] = '000.000.000.000';
     $server['boot'] = 'filesystem';
     $import_data['uuid'] = $server['uuid'];
     $import_data['vnc_keymap'] = $server['vnc_keymap'];
     // import validation check
     $result = $this->jsonImportCheck($request);
     if (!$result['success']) {
         // if is a CLI soap request return json encoded data
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($result);
         }
         // if is browser request return text renderer
         $error = $this->setJsonError($result);
         return $this->renderText($error);
     }
     if (!($etva_node = EtvaNodePeer::retrieveByPK($nid))) {
         $msg_i18n = $this->getContext()->getI18N()->__(EtvaNodePeer::_ERR_NOTFOUND_ID_, array('%id%' => $nid));
         $error = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n);
         //notify event log
         $node_log = Etva::getLogMessage(array('id' => $nid), EtvaNodePeer::_ERR_NOTFOUND_ID_);
         $message = Etva::getLogMessage(array('info' => $node_log), OvfEnvelope_VA::_ERR_IMPORT_);
         $this->dispatcher->notify(new sfEvent(sfConfig::get('config_acronym'), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         // if is a CLI soap request return json encoded data
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($error);
         }
         // if is browser request return text renderer
         $error = $this->setJsonError($error);
         return $this->renderText($error);
     }
     $disks = $import_data['disks'];
     $collVgs = array();
     foreach ($disks as $id => $info) {
         $vg = $info['vg'];
         $lv = $info['lv'];
         if ($etva_lv = $etva_node->retrieveLogicalvolumeByLv($lv)) {
             $msg_type = $is_DiskFile ? EtvaLogicalvolumePeer::_ERR_DISK_EXIST_ : EtvaLogicalvolumePeer::_ERR_LV_EXIST_;
             $msg = Etva::getLogMessage(array('name' => $lv), $msg_type);
             $msg_i18n = $this->getContext()->getI18N()->__($msg_type, array('%name%' => $lv));
             $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
             //notify system log
             $message = Etva::getLogMessage(array('name' => $lv, 'info' => $msg), OvfEnvelope_VA::_ERR_IMPORT_);
             $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             // if is a CLI soap request return json encoded data
             if (sfConfig::get('sf_environment') == 'soap') {
                 return json_encode($error);
             }
             // if is browser request return text renderer
             $error = $this->setJsonError($error);
             return $this->renderText($error);
         }
         if (!($etva_vg = $etva_node->retrieveVolumegroupByVg($vg))) {
             $msg = Etva::getLogMessage(array('name' => $vg), EtvaVolumegroupPeer::_ERR_NOTFOUND_);
             $msg_i18n = $this->getContext()->getI18N()->__(EtvaVolumegroupPeer::_ERR_NOTFOUND_, array('%name%' => $vg));
             $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
             //notify system log
             $message = Etva::getLogMessage(array('name' => $lv, 'info' => $msg), OvfEnvelope_VA::_ERR_IMPORT_);
             $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             // if is a CLI soap request return json encoded data
             if (sfConfig::get('sf_environment') == 'soap') {
                 return json_encode($error);
             }
             // if is browser request return text renderer
             $error = $this->setJsonError($error);
             return $this->renderText($error);
         }
         // fix lv path
         $is_DiskFile = $vg == sfConfig::get('app_volgroup_disk_flag') ? 1 : 0;
         $import_data['disks'][$id]['lv'] = $is_DiskFile ? $etva_node->getStoragedir() . '/' . $lv : $lv;
         $collVgs[$vg] = $etva_vg;
     }
     $networks = $import_data['networks'];
     $networks_va = $import_data['networks'];
     $collNetworks = array();
     $i = 0;
     // check if networks are available
     foreach ($networks as $network) {
         if ($etva_vlan = EtvaVlanPeer::retrieveByPk($network['vlan_id'])) {
             $import_data['networks'][$i]['network'] = $etva_vlan->getName();
             $import_data['networks'][$i]['macaddr'] = $network['mac'];
         }
         $etva_mac = EtvaMacPeer::retrieveByMac($network['mac']);
         /*
          * TODO improve this to add Mac Address to the pool
          */
         if (!$etva_mac || !$etva_vlan) {
             $msg = Etva::getLogMessage(array(), EtvaNetworkPeer::_ERR_);
             $msg_i18n = $this->getContext()->getI18N()->__(EtvaNetworkPeer::_ERR_, array());
             if (!$etva_mac) {
                 $msg = Etva::getLogMessage(array('%mac%' => $network['mac']), EtvaMacPeer::_ERR_INVALID_MAC_);
                 $msg_i18n = $this->getContext()->getI18N()->__(EtvaMacPeer::_ERR_INVALID_MAC_, array('%mac%' => $network['mac']));
             }
             $error = array('success' => false, 'agent' => $etva_node->getName(), 'error' => $msg_i18n, 'info' => $msg_i18n);
             //notify event log
             $message = Etva::getLogMessage(array('name' => $server['name'], 'info' => $msg), OvfEnvelope_VA::_ERR_IMPORT_);
             $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             // if is a CLI soap request return json encoded data
             if (sfConfig::get('sf_environment') == 'soap') {
                 return json_encode($error);
             }
             // if is browser request return text renderer
             $error = $this->setJsonError($error);
             return $this->renderText($error);
         }
         if ($etva_mac->getInUse()) {
             $msg = Etva::getLogMessage(array('%name%' => $etva_mac->getMac()), EtvaMacPeer::_ERR_ASSIGNED_);
             $msg_i18n = $this->getContext()->getI18N()->__(EtvaMacPeer::_ERR_ASSIGNED_, array('%name%' => $etva_mac->getMac()));
             $error = array('success' => false, 'agent' => $etva_node->getName(), 'info' => $msg_i18n, 'error' => $msg_i18n);
             //notify event log
             $message = Etva::getLogMessage(array('name' => $server['name'], 'info' => $msg), OvfEnvelope_VA::_ERR_IMPORT_);
             $this->dispatcher->notify(new sfEvent($error['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
             // if is a CLI soap request return json encoded data
             if (sfConfig::get('sf_environment') == 'soap') {
                 return json_encode($error);
             }
             // if is browser request return text renderer
             $error = $this->setJsonError($error);
             return $this->renderText($error);
         }
         $etva_network = new EtvaNetwork();
         $etva_network->fromArray($network, BasePeer::TYPE_FIELDNAME);
         $collNetworks[] = $etva_network;
         $i++;
     }
     $env = new OvfEnvelope_VA();
     $env->fromArray($import_data);
     /* get server copy VA server representation */
     $params = $env->_VA();
     $method = 'vm_ovf_import_may_fork';
     $response = $etva_node->soapSend($method, $params);
     if (!$response['success']) {
         $error_decoded = $response['error'];
         $result = $response;
         $msg_i18n = $this->getContext()->getI18N()->__(EtvaServerPeer::_ERR_CREATE_, array('%name%' => $server['name'], '%info%' => $error_decoded));
         $result['error'] = $msg_i18n;
         //notify event log
         $message = Etva::getLogMessage(array('name' => $server['name'], 'info' => $response['info']), EtvaServerPeer::_ERR_CREATE_);
         $this->dispatcher->notify(new sfEvent($response['agent'], 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         if (sfConfig::get('sf_environment') == 'soap') {
             return json_encode($result);
         }
         $return = $this->setJsonError($result);
         return $this->renderText($return);
     }
     $response_decoded = (array) $response['response'];
     $returned_object = (array) $response_decoded['_obj_'];
     $returned_lvs = (array) $returned_object['LVS'];
     $collLvs = array();
     foreach ($returned_lvs as $disk) {
         $disk_array = (array) $disk;
         $vg_info = (array) $disk_array[EtvaLogicalvolume::VOLUMEGROUP_MAP];
         $vg = $vg_info[EtvaVolumegroup::VG_MAP];
         $fake_lv_response = array('success' => true, 'response' => array('_obj_' => $disk_array));
         // create logical volume
         $etva_lv = new EtvaLogicalvolume();
         $etva_lv->setEtvaVolumegroup($collVgs[$vg]);
         $lv_va = new EtvaLogicalvolume_VA($etva_lv);
         $lv_response = $lv_va->processResponse($etva_node, $fake_lv_response, 'lvcreate');
         if (!$lv_response['success']) {
             $return = $this->setJsonError($lv_response);
             return $this->renderText($return);
         }
         $collLvs[] = $etva_lv;
     }
     $etva_server = new EtvaServer();
     $etva_server->fromArray($server, BasePeer::TYPE_FIELDNAME);
     $user_groups = $this->getUser()->getGroups();
     $server_sfgroup = array_shift($user_groups);
     //if user has group then put one of them otherwise put DEFAULT GROUP ID
     if ($server_sfgroup) {
         $etva_server->setsfGuardGroup($server_sfgroup);
     } else {
         $etva_server->setsfGuardGroup(sfGuardGroupPeer::getDefaultGroup());
     }
     foreach ($collNetworks as $coll) {
         $etva_server->addEtvaNetwork($coll);
     }
     $i = 0;
     foreach ($collLvs as $coll) {
         $server_disk = new EtvaServerLogical();
         $server_disk->setEtvaLogicalvolume($coll);
         $server_disk->setBootDisk($i);
         $etva_server->addEtvaServerLogical($server_disk);
         $i++;
     }
     //update some data from agent response
     $vm = (array) $returned_object['VM'];
     $etva_server->initData($vm);
     //$etva_server->setEtvaNode($etva_node);
     $etva_server->setEtvaCluster($etva_node->getEtvaCluster());
     try {
         $etva_server->save();
     } catch (Exception $e) {
         $msg = $e->getMessage();
         $result = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg, 'info' => $msg);
         $return = $this->setJsonError($result);
         return $this->renderText($return);
     }
     // assign To etva_node
     $etva_server->assignTo($etva_node);
     $msg_i18n = $this->getContext()->getI18N()->__(EtvaServerPeer::_OK_CREATE_, array('%name%' => $server['name']));
     $message = Etva::getLogMessage(array('name' => $server['name']), EtvaServerPeer::_OK_CREATE_);
     $this->dispatcher->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message)));
     $result = array('success' => true, 'agent' => $response['agent'], 'insert_id' => $etva_server->getId(), 'response' => $msg_i18n);
     $return = json_encode($result);
     $this->getResponse()->setHttpHeader('Content-type', 'application/json');
     // if is browser request return text renderer
     return $this->renderText($return);
 }
Esempio n. 4
0
 public function get_sync_logicalvolumes($force_sync = false, $sharedonly = false)
 {
     $elements = array();
     $criteria = new Criteria();
     $criteria->add(EtvaNodeLogicalvolumePeer::NODE_ID, $this->etva_node->getId());
     $db_node_lvs = EtvaNodeLogicalvolumePeer::doSelectJoinEtvaLogicalvolume($criteria);
     $force_flag = $force_sync ? 1 : 0;
     $response_lvs = $this->etva_node->soapSend(EtvaLogicalvolume_VA::GET_SYNC_LOGICALVOLUMES, array('force' => $force_flag));
     if ($response_lvs['success']) {
         $lvs = $response_lvs['response'];
         foreach ($lvs as $k => $e) {
             $lv_e = (array) $e;
             if (!$sharedonly || $lv_e[EtvaLogicalvolume::STORAGE_TYPE_MAP] != EtvaLogicalvolume::STORAGE_TYPE_LOCAL_MAP) {
                 $found = false;
                 foreach ($db_node_lvs as $data) {
                     $lv = $data->getEtvaLogicalvolume();
                     if ($lv_e[EtvaLogicalvolume::STORAGE_TYPE_MAP] == $lv->getStorageType()) {
                         if ($lv->getUuid() && $lv_e[EtvaLogicalvolume::UUID_MAP]) {
                             if ($lv->getUuid() == $lv_e[EtvaLogicalvolume::UUID_MAP]) {
                                 $found = true;
                             }
                         } else {
                             if ($lv->getLvdevice() == $lv_e[EtvaLogicalvolume::LVDEVICE_MAP]) {
                                 $found = true;
                             }
                         }
                     }
                 }
                 $etva_lv = new EtvaLogicalvolume();
                 $etva_volgroup = new EtvaVolumegroup();
                 $etva_volgroup->initData((array) $lv_e[EtvaLogicalvolume::VOLUMEGROUP_MAP]);
                 /*$vg_ar = $lv_e[EtvaLogicalvolume::VOLUMEGROUP_MAP];
                   $vg_type = $vg_ar[EtvaVolumegroup::STORAGE_TYPE_MAP];
                   $vg_uuid = $vg_ar[EtvaVolumegroup::UUID_MAP];
                   $vg_name = $vg_ar[EtvaVolumegroup::VG_MAP];
                   $etva_volgroup = EtvaVolumegroupPeer::retrieveByNodeTypeUUIDVg($this->etva_node->getId(), $vg_type, $vg_uuid, $vg_name);*/
                 $etva_lv->initData($lv_e);
                 $etva_lv->setEtvaVolumegroup($etva_volgroup);
                 $arr_e = $etva_lv->_VA();
                 $arr_e['registered'] = $found;
                 $elements[] = $arr_e;
             }
         }
     }
     foreach ($db_node_lvs as $data) {
         $lv = $data->getEtvaLogicalvolume();
         if (!$sharedonly || $lv->getStorageType() != EtvaLogicalvolume::STORAGE_TYPE_LOCAL_MAP) {
             $found = false;
             foreach ($lvs as $k => $e) {
                 $lv_e = (array) $e;
                 if ($lv_e[EtvaLogicalvolume::STORAGE_TYPE_MAP] == $lv->getStorageType()) {
                     if ($lv->getUuid() && $lv_e[EtvaLogicalvolume::UUID_MAP]) {
                         if ($lv->getUuid() == $lv_e[EtvaLogicalvolume::UUID_MAP]) {
                             $found = true;
                         }
                     } else {
                         if ($lv->getLvdevice() == $lv_e[EtvaLogicalvolume::LVDEVICE_MAP]) {
                             $found = true;
                         }
                     }
                 }
             }
             if (!$found) {
                 $arr_e = $lv->_VA();
                 $arr_e['inconsistent'] = true;
                 $arr_e['registered'] = true;
                 $elements[] = $arr_e;
             }
         }
     }
     return $elements;
 }
 public function initialize(EtvaNode $etva_node, $lvs, $dtable, $bulk_dtable)
 {
     $etva_cluster = $etva_node->getEtvaCluster();
     $logical_names = array();
     $errors = array();
     /*
      * check lv consistency
      */
     $check_res = $this->check_consistency($etva_node, $lvs, $dtable, $bulk_dtable);
     if (!$check_res['success']) {
         $errors = $check_res['errors'];
         $inconsistent_message = sfContext::getInstance()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_INCONSISTENT_, array('%info%' => ''));
         $etva_node->setErrorMessage(self::LVINIT);
         $message = Etva::getLogMessage(array('info' => $inconsistent_message), EtvaLogicalvolumePeer::_ERR_SOAPUPDATE_);
         sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         // dont stop process
         //return array('success'=>false,'error'=>$errors);
     }
     /*
      * check shared lvs consistency
      */
     /*$consist = $this->check_shared_consistency($etva_node,$lvs);        
             $consist_dtable = $this->check_shared_devicetable_consistency($etva_node,$dtable,$bulk_dtable);
     
             if(!$consist || !$consist_dtable){
                 $errors = $this->get_missing_lv_devices($etva_node);
                 $inconsistent_message = $errors ? $errors['message'] :
                                 sfContext::getInstance()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_INCONSISTENT_,array('%info%'=>'initialize'));
     
                 $etva_node->setErrorMessage(self::LVINIT);
     
                 $message = Etva::getLogMessage(array('info'=>$inconsistent_message), EtvaLogicalvolumePeer::_ERR_SOAPUPDATE_);
                 sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(),'event.log',array('message' =>$message,'priority'=>EtvaEventLogger::ERR)));
     
                 // dont stop process
                 //return array('success'=>false,'error'=>$errors);
             }*/
     foreach ($lvs as $lvInfo) {
         if (!empty($lvInfo)) {
             $lv_info = (array) $lvInfo;
             // set mounted 0 when not mounted
             if (!isset($lv_info[EtvaLogicalvolume::MOUNTED_MAP])) {
                 $lv_info[EtvaLogicalvolume::MOUNTED_MAP] = 0;
             }
             //error_log("device " . $lv_info[EtvaLogicalvolume::LVDEVICE_MAP] . " EtvaLogicalvolume::MOUNTED_MAP " . $lv_info[EtvaLogicalvolume::MOUNTED_MAP]);
             $lv_dev = $lv_info[EtvaLogicalvolume::LVDEVICE_MAP];
             $lv_type = $lv_info[EtvaLogicalvolume::STORAGE_TYPE_MAP];
             $lv_uuid = isset($lv_info[EtvaLogicalvolume::UUID_MAP]) ? $lv_info[EtvaLogicalvolume::UUID_MAP] : '';
             // vg info
             $vg_info = (array) $lv_info[EtvaLogicalvolume::VOLUMEGROUP_MAP];
             $vg_name = $vg_info[EtvaVolumegroup::VG_MAP];
             $vg_type = $vg_info[EtvaVolumegroup::STORAGE_TYPE_MAP];
             $vg_uuid = isset($vg_info[EtvaVolumegroup::UUID_MAP]) ? $vg_info[EtvaVolumegroup::UUID_MAP] : '';
             //get volume group based on node, type, uuid and vg
             $etva_volgroup = EtvaVolumegroupPeer::retrieveByNodeTypeUUIDVg($etva_node->getId(), $vg_type, $vg_uuid, $vg_name);
             if ($etva_volgroup) {
                 if ($lv_type == EtvaLogicalvolume::STORAGE_TYPE_LOCAL_MAP) {
                     $etva_logicalvol = EtvaLogicalvolumePeer::retrieveByNodeTypeLvDevice($etva_node->getId(), $lv_type, $lv_dev);
                 } else {
                     $etva_logicalvol = EtvaLogicalvolumePeer::retrieveByUUID($lv_uuid);
                 }
                 if (!$etva_logicalvol) {
                     // no lv in db...so create new one
                     $etva_node_logicalvol = new EtvaNodeLogicalvolume();
                     $etva_logicalvol = new EtvaLogicalvolume();
                 } else {
                     //if lv already in DB we need to make sure if already exists association with node. if not create new one
                     $etva_node_logicalvol = EtvaNodeLogicalvolumePeer::retrieveByPK($etva_node->getId(), $etva_logicalvol->getId());
                     if (!$etva_node_logicalvol) {
                         $etva_node_logicalvol = new EtvaNodeLogicalvolume();
                     }
                 }
                 $etva_logicalvol->initData($lv_info);
                 $etva_logicalvol->setEtvaVolumegroup($etva_volgroup);
                 $etva_logicalvol->setEtvaCluster($etva_cluster);
                 $etva_logicalvol->save();
                 $etva_node_logicalvol->setEtvaLogicalvolume($etva_logicalvol);
                 $etva_node_logicalvol->setEtvaNode($etva_node);
                 $etva_node_logicalvol->save();
                 $logical_names[] = $etva_logicalvol->getLv();
             }
         }
     }
     if (!empty($errors)) {
         // if have some errors, return it
         return array('success' => false, 'error' => $errors);
     } else {
         /*
          * check if is an appliance restore operation...
          */
         $apli = new Appliance();
         $action = $apli->getStage(Appliance::RESTORE_STAGE);
         if ($action) {
             $apli->setStage(Appliance::RESTORE_STAGE, Appliance::VA_UPDATE_LVS);
         }
         $etva_node->clearErrorMessage(self::LVINIT);
         $message = Etva::getLogMessage(array('info' => implode(', ', $logical_names)), EtvaLogicalvolumePeer::_OK_SOAPUPDATE_);
         sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message)));
         return array('success' => true, 'response' => $logical_names);
     }
 }