public function register(EtvaNode $etva_node, $vg_info = null) { $etva_cluster = $etva_node->getEtvaCluster(); // check if volumegroup is shared $shared = $this->etva_vg->getStorageType() != EtvaVolumegroup::STORAGE_TYPE_LOCAL_MAP; // force to load volume groups $bulk_responses = array(); if ($shared) { $bulk_responses = $etva_cluster->soapSend(self::GET_SYNC_VOLUMEGROUPS, array('force' => 1)); } else { $node_id = $etva_node->getId(); $bulk_responses[$node_id] = $etva_node->soapSend(self::GET_SYNC_VOLUMEGROUPS, array('force' => 1)); } $vg_info_sync = $this->getVolumegroupInfo($etva_node, $bulk_responses); // merge vg info if ($vg_info_sync) { $vg_info = $vg_info ? array_merge($vg_info_sync, $vg_info) : $vg_info_sync; } // set vg info if needed if ($vg_info) { $this->etva_vg->initData($vg_info); } // for none local storage devices if ($shared) { // check if all nodes see that $check_res = $this->check_all_see_it($etva_node, $bulk_responses); if (!$check_res['success']) { return array('success' => false, 'errors' => $check_res['errors'], 'debug' => 'check_all_see_it'); } } $etva_volgroup = $this->etva_vg; // set cluster $etva_cluster = $etva_node->getEtvaCluster(); $etva_volgroup->setEtvaCluster($etva_cluster); // save it $etva_volgroup->save(); // create relation node_volumegorup $etva_node_volgroup = new EtvaNodeVolumegroup(); $etva_node_volgroup->setEtvaVolumegroup($etva_volgroup); $etva_node_volgroup->setEtvaNode($etva_node); $etva_node_volgroup->save(); if ($vg_info) { /* * associate pvs with vg and update info */ $pvs = isset($vg_info[EtvaVolumegroup::PHYSICALVOLUMES_MAP]) ? (array) $vg_info[EtvaVolumegroup::PHYSICALVOLUMES_MAP] : array(); foreach ($pvs as $pv => $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]; //error_log(sprintf("node name=%s id=%d device=%s uuid=%s type=%s",$etva_node->getName(),$etva_node->getId(),$pv_device,$pv_uuid,$pv_type)); //get physical volume based on node, type, uuid and device $etva_physical = EtvaPhysicalvolumePeer::retrieveByNodeTypeUUIDDevice($etva_node->getId(), $pv_type, $pv_uuid, $pv_device); if (!$etva_physical) { $etva_physical = new EtvaPhysicalvolume(); } $etva_physical->setEtvaCluster($etva_cluster); $etva_physical->initData($pv_info); $etva_physical->save(); $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(); } } // for no local storage type $errors = $this->sync_update($bulk_responses); if (!empty($errors)) { return array('success' => false, 'errors' => $errors); } // update logical volumes $lv_va = new EtvaLogicalvolume_VA(); $lv_errors = $lv_va->send_update($etva_node, true, $shared); if (!empty($lv_errors)) { return array('success' => false, 'errors' => $lv_errors); } return array('success' => true); }
public function register(EtvaNode $etva_node, $dev_info = null) { // set device info if needed if ($dev_info) { $this->etva_pv->initData($dev_info); } // check if physical volume is shared $shared = $this->etva_pv->getStorageType() != EtvaPhysicalvolume::STORAGE_TYPE_LOCAL_MAP; $etva_cluster = $etva_node->getEtvaCluster(); $bulk_responses = array(); if ($shared) { // lookup new disk devices $etva_cluster->soapSend(self::LOOKUP_DISKDEVICES); // force to load disk devices $bulk_responses = $etva_cluster->soapSend(self::GET_SYNC_DISKDEVICES, array('force' => 1)); } else { $node_id = $etva_node->getId(); // lookup new disk devices $etva_node->soapSend(self::LOOKUP_DISKDEVICES); // force to load disk devices $bulk_responses[$node_id] = $etva_node->soapSend(self::GET_SYNC_DISKDEVICES, array('force' => 1)); } // for none local storage devices if ($shared) { // check if all nodes see that $check_res = $this->check_all_see_it($etva_node, $bulk_responses); if (!$check_res['success']) { return array('success' => false, 'errors' => $check_res['errors'], 'debug' => 'check_all_see_it'); } } $etva_physicalvol = $this->etva_pv; // set cluster $etva_cluster = $etva_node->getEtvaCluster(); $etva_physicalvol->setEtvaCluster($etva_cluster); // save it $etva_physicalvol->save(); $dev_device = $etva_physicalvol->getDevice(); // create relation node_physicalvolume $etva_node_physicalvol = new EtvaNodePhysicalvolume(); $etva_node_physicalvol->setEtvaPhysicalvolume($etva_physicalvol); $etva_node_physicalvol->setEtvaNode($etva_node); $etva_node_physicalvol->setDevice($dev_device); $etva_node_physicalvol->save(); $return = array('success' => true); $errors = $this->sync_update($bulk_responses); if (!empty($errors)) { $return = array('success' => false, 'errors' => $errors); } return $return; }