public function initialize(EtvaNode $etva_node, $vgs, $force_regist = false)
 {
     $etva_cluster = $etva_node->getEtvaCluster();
     $volumegroup_names = array();
     $errors = array();
     /*
      * check shared vgs consistency
      */
     $check_res = $this->check_consistency($etva_node, $vgs);
     if (!$check_res['success']) {
         $errors = $check_res['errors'];
         $inconsistent_message = Etva::getLogMessage(array('info' => ''), EtvaVolumegroupPeer::_ERR_INCONSISTENT_);
         $etva_node->setErrorMessage(self::VGINIT);
         $message = Etva::getLogMessage(array('info' => $inconsistent_message), EtvaVolumegroupPeer::_ERR_SOAPUPDATE_);
         sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR)));
         //return array('success'=>false,'error'=>$errors);
     }
     /*$consist = $this->check_shared_consistency($etva_node,$vgs); 
     
             if(!$consist){
                 $errors = $this->missing_vgs[$etva_node->getId()];
     
                 $inconsistent_message = Etva::getLogMessage(array('info'=>''), EtvaVolumegroupPeer::_ERR_INCONSISTENT_);
     
                 $etva_node->setErrorMessage(self::VGINIT);
     
                 $message = Etva::getLogMessage(array('info'=>$inconsistent_message), EtvaVolumegroupPeer::_ERR_SOAPUPDATE_);
                 sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(),'event.log',array('message' =>$message,'priority'=>EtvaEventLogger::ERR)));
     
                 return array('success'=>false,'error'=>$errors);
             }*/
     foreach ($vgs as $vgInfo) {
         $vg_info = (array) $vgInfo;
         $vg_name = $vg_info[EtvaVolumegroup::VG_MAP];
         $vg_type = $vg_info[EtvaVolumegroup::STORAGE_TYPE_MAP];
         //error_log(sprintf("node name=%s id=%d vg_name=%s uuid=%s type=%s",$etva_node->getName(),$etva_node->getId(),$vg_name,$vg_info[EtvaVolumegroup::UUID_MAP],$vg_type));
         //error_log(print_r($vg_info,true));
         if ($vg_type == EtvaVolumegroup::STORAGE_TYPE_LOCAL_MAP) {
             $etva_volgroup = EtvaVolumegroupPeer::retrieveByNodeTypeVg($etva_node->getId(), $vg_type, $vg_name);
         } else {
             $vg_uuid = $vg_info[EtvaVolumegroup::UUID_MAP];
             $etva_volgroup = EtvaVolumegroupPeer::retrieveByUUID($vg_uuid);
         }
         if ($force_regist && !$etva_volgroup) {
             // no vg in db... and force registration ... so create new one
             $etva_node_volgroup = new EtvaNodeVolumegroup();
             $etva_volgroup = new EtvaVolumegroup();
         } else {
             if ($etva_volgroup) {
                 //if vg  already in DB we need to make sure if already exists association with node. if not create new one
                 $etva_node_volgroup = EtvaNodeVolumegroupPeer::retrieveByPK($etva_node->getId(), $etva_volgroup->getId());
                 if (!$etva_node_volgroup) {
                     $etva_node_volgroup = new EtvaNodeVolumegroup();
                 }
             }
         }
         if ($etva_volgroup) {
             // only if vg in db...
             $etva_volgroup->initData($vg_info);
             $etva_volgroup->setEtvaCluster($etva_cluster);
             $etva_node_volgroup->setEtvaVolumegroup($etva_volgroup);
             $etva_node_volgroup->setEtvaNode($etva_node);
             $etva_node_volgroup->save();
             /*
              * associate pvs with vg
              */
             $pvs = isset($vg_info[EtvaVolumegroup::PHYSICALVOLUMES_MAP]) ? (array) $vg_info[EtvaVolumegroup::PHYSICALVOLUMES_MAP] : array();
             foreach ($pvs as $pvInfo) {
                 $pv_info = (array) $pvInfo;
                 $pv_type = $pv_info[EtvaPhysicalvolume::STORAGE_TYPE_MAP];
                 $pv_uuid = isset($pv_info[EtvaPhysicalvolume::UUID_MAP]) ? $pv_info[EtvaPhysicalvolume::UUID_MAP] : '';
                 $pv_device = $pv_info[EtvaPhysicalvolume::DEVICE_MAP];
                 //get physical volume based on node, type, uuid and device
                 $etva_physical = EtvaPhysicalvolumePeer::retrieveByNodeTypeUUIDDevice($etva_node->getId(), $pv_type, $pv_uuid, $pv_device);
                 $etva_node_physical = EtvaNodePhysicalvolumePeer::retrieveByPK($etva_node->getId(), $etva_physical->getId());
                 if (!$etva_node_physical) {
                     $etva_node_physical = new EtvaNodePhysicalvolume();
                     $etva_node_physical->setEtvaPhysicalvolume($etva_physical);
                     $etva_node_physical->setEtvaNode($etva_node);
                 }
                 $etva_node_physical->setDevice($pv_device);
                 $etva_node_physical->save();
                 $etva_volgroup_physical = EtvaVolumePhysicalPeer::retrieveByPK($etva_volgroup->getId(), $etva_physical->getId());
                 if (!$etva_volgroup_physical) {
                     $etva_volgroup_physical = new EtvaVolumePhysical();
                 }
                 $etva_volgroup_physical->setEtvaPhysicalvolume($etva_physical);
                 $etva_volgroup_physical->setEtvaVolumegroup($etva_volgroup);
                 $etva_volgroup_physical->save();
             }
             $volumegroup_names[] = $etva_volgroup->getVg();
         }
     }
     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_VGS);
         }
         $etva_node->clearErrorMessage(self::VGINIT);
         $message = Etva::getLogMessage(array('info' => implode(', ', $volumegroup_names)), EtvaVolumegroupPeer::_OK_SOAPUPDATE_);
         sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message)));
         return array('success' => true, 'response' => $volumegroup_names);
     }
 }