public function check_consistency(EtvaNode $etva_node, $sync_node_vgs) { $errors = array(); $etva_node->getId(); $etva_cluster = $etva_node->getEtvaCluster(); // get node database VGs $node_vgs = $etva_node->getEtvaNodeVolumegroups(); // get shared database VGs $shared_vgs = $etva_cluster->getSharedVgs(); $node_inconsistent = 0; foreach ($node_vgs as $rvg) { $vg = $rvg->getEtvaVolumegroup(); $error = array(); $uuid = $vg->getUuid(); $vgname = $vg->getVg(); // init $inconsistent = 0; // look at volume groups list $found_lvm = 0; foreach ($sync_node_vgs as $hvg) { $arr_hvg = (array) $hvg; if ($arr_hvg[EtvaVolumegroup::STORAGE_TYPE_MAP] == $vg->getStorageType()) { if (isset($arr_hvg[EtvaVolumegroup::UUID_MAP])) { if ($arr_hvg[EtvaVolumegroup::UUID_MAP] == $uuid) { $found_lvm = 1; } } else { if ($arr_hvg[EtvaVolumegroup::VG_MAP] == $vgname) { $found_lvm = 1; } } } } $inconsistent = $inconsistent || !$found_lvm; if (!$found_lvm) { $error['not_found_lvm'] = 1; } $found_shared_lvm = 0; $inconsistent_shared_vgs = 0; foreach ($shared_vgs as $s_vg) { $s_uuid = $s_vg->getUuid(); if ($s_uuid == $uuid) { if ($s_vg->getStorageType() != $vg->getStorageType()) { $inconsistent_shared_vgs = 1; } else { $found_shared_lvm = 1; } } else { if ($s_vg->getStorageType() == $vg->getStorageType()) { if ($arr_hvg[EtvaVolumegroup::VG_MAP] == $vgname) { $found_shared_lvm = 1; } } } } if ($vg->getStorageType() != EtvaVolumegroup::STORAGE_TYPE_LOCAL_MAP) { $inconsistent = $inconsistent || !$found_shared_lvm; if (!$found_shared_lvm) { $error['not_found_shared_lvm'] = 1; } } $inconsistent = $inconsistent || $inconsistent_shared_vgs; if ($inconsistent_shared_vgs) { $error['diff_storage_type'] = 1; } // update data-base $etva_volumegroup = EtvaVolumegroupPeer::retrieveByNodeTypeUUIDVg($etva_node->getId(), $vg->getStorageType(), $vg->getUuid(), $vg->getVg()); if ($etva_volumegroup) { $etva_volumegroup->setInconsistent($inconsistent); $etva_volumegroup->save(); } $etva_node_volumegroup = EtvaNodeVolumegroupPeer::retrieveByPK($etva_node->getId(), $vg->getId()); if ($etva_node_volumegroup) { $etva_node_volumegroup->setInconsistent($inconsistent); $etva_node_volumegroup->save(); } if ($inconsistent) { $message = sfContext::getInstance()->getI18N()->__(EtvaVolumegroupPeer::_ERR_INCONSISTENT_, array('%info%' => sprintf('volume group "%s" with uuid "%s"', $vg->getVg(), $vg->getUuid()))); if ($error['not_found_shared_lvm'] || $error['diff_storage_type']) { $message = sfContext::getInstance()->getI18N()->__(EtvaVolumegroupPeer::_ERR_SHARED_INCONSISTENT_, array('%info%' => sprintf('volume group "%s" with uuid "%s"', $vg->getVg(), $vg->getUuid()))); } sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR))); $error['node'] = array('name' => $etva_node->getName(), 'id' => $etva_node->getId(), 'uuid' => $etva_node->getUuid()); $error['volumegroup'] = $vg->getVg(); $error['uuid'] = $vg->getUuid(); $error['message'] = $message; } if (!empty($error)) { $errors[] = $error; } $node_inconsistent = $node_inconsistent || $inconsistent; } // check consistency for shared Volume groups foreach ($shared_vgs as $vg) { $error = array(); $uuid = $vg->getUuid(); $vgname = $vg->getVg(); // init $inconsistent = 0; // look at physical volumes list $found_lvm = 0; foreach ($sync_node_vgs as $hvg) { $arr_hvg = (array) $hvg; if ($arr_hvg[EtvaVolumegroup::STORAGE_TYPE_MAP] == $vg->getStorageType()) { if (isset($arr_hvg[EtvaVolumegroup::UUID_MAP])) { if ($arr_hvg[EtvaVolumegroup::UUID_MAP] == $uuid) { $found_lvm = 1; } } else { if ($arr_hvg[EtvaVolumegroup::VG_MAP] == $vgname) { $found_lvm = 1; } } } } $inconsistent = $inconsistent || !$found_lvm; if (!$found_lvm) { $error['not_found_lvm'] = 1; } // update data-base $etva_volumegroup = EtvaVolumegroupPeer::retrieveByNodeTypeUUIDVg($etva_node->getId(), $vg->getStorageType(), $vg->getUuid(), $vg->getVg()); if ($etva_volumegroup) { $etva_volumegroup->setInconsistent($inconsistent); $etva_volumegroup->save(); } $etva_node_volumegroup = EtvaNodeVolumegroupPeer::retrieveByPK($etva_node->getId(), $vg->getId()); if ($etva_node_volumegroup) { $etva_node_volumegroup->setInconsistent($inconsistent); $etva_node_volumegroup->save(); } if ($inconsistent) { $message = sfContext::getInstance()->getI18N()->__(EtvaVolumegroupPeer::_ERR_SHARED_INCONSISTENT_, array('%info%' => sprintf('volumegroup "%s" with uuid "%s"', $vg->getVg(), $vg->getUuid()))); sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR))); $error['node'] = array('name' => $etva_node->getName(), 'id' => $etva_node->getId(), 'uuid' => $etva_node->getUuid()); $error['volumegroup'] = $vg->getVg(); $error['uuid'] = $vg->getUuid(); $error['message'] = $message; } if (!empty($error)) { $errors[] = $error; } $node_inconsistent = $node_inconsistent || $inconsistent; } $return = array(); if ($node_inconsistent) { $etva_node->setErrorMessage(self::VGINIT); $return = array('success' => false, 'errors' => $errors); } else { $etva_node->clearErrorMessage(self::VGINIT); $return = array('success' => true); } return $return; }
private function check_pvs(EtvaNode $etva_node) { $node_response = $etva_node->soapSend('getpvs_arr', array('force' => 1)); if (!$node_response['success']) { $errors = $node_response['error']; Etva::getLogMessage(array('info' => ''), EtvaPhysicalvolumePeer::_ERR_INCONSISTENT_); //$etva_node->setErrorMessage(EtvaPhysicalvolume_VA::LVINIT); $message = $this->getContext()->getI18N()->__(EtvaPhysicalvolumePeer::_ERR_SOAPUPDATE_, array('%info%' => $node_response['info'])); sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR))); $response = array('success' => false, 'error' => $message, 'agent' => $etva_node->getName()); $return = $this->setJsonError($response); return $this->renderText($return); } //verify if cluster has any logical volume that belongs to another cluster... $cluster_id = $etva_node->getClusterId(); $my_pvs = $node_response['response']; $my_pvs = (array) $my_pvs; foreach ($my_pvs as $my_pv) { $pv_info = (array) $my_pv; if ($pv_info['type'] == EtvaPhysicalvolume::STORAGE_TYPE_LOCAL_MAP) { continue; } $c_uuid = new criteria(); $c_uuid->add(EtvaPhysicalvolumePeer::UUID, $pv_info['uuid']); $c_uuid->addAnd(EtvaPhysicalvolumePeer::CLUSTER_ID, $cluster_id, Criteria::NOT_EQUAL); $e_pv = EtvaPhysicalvolumePeer::doSelectOne($c_uuid); if ($e_pv) { $c_c = new Criteria(); $c_c->add(EtvaClusterPeer::ID, $e_pv->getClusterId()); $etva_cluster = EtvaClusterPeer::doSelectOne($c_c); $msg_i18n = $this->getContext()->getI18N()->__(EtvaPhysicalvolumePeer::_ERR_INIT_OTHER_CLUSTER_, array('%name%' => $etva_cluster->getName())); $response = array('success' => false, 'agent' => sfConfig::get('config_acronym'), 'error' => $msg_i18n, 'info' => $msg_i18n); $return = $this->setJsonError($response); return $this->renderText($return); } } }
public function check_consistency(EtvaNode $etva_node, $sync_node_pvs) { $errors = array(); $etva_node->getId(); $etva_cluster = $etva_node->getEtvaCluster(); // get node database PVs //$node_pvs = $etva_node->getEtvaPhysicalvolumes(); $node_pvs = $etva_node->getEtvaNodePhysicalvolumes(); // get shared database PVs $shared_pvs = $etva_cluster->getSharedPvs(); $node_inconsistent = 0; foreach ($node_pvs as $rpv) { $pv = $rpv->getEtvaPhysicalvolume(); $error = array(); $uuid = $pv->getUuid(); $device = $pv->getDevice(); // init $inconsistent = 0; // look at physical volumes list $found_lvm = 0; foreach ($sync_node_pvs as $hpv) { $arr_hpv = (array) $hpv; if ($arr_hpv[EtvaPhysicalvolume::STORAGE_TYPE_MAP] == $pv->getStorageType()) { if (isset($arr_hpv[EtvaPhysicalvolume::UUID_MAP])) { if ($arr_hpv[EtvaPhysicalvolume::UUID_MAP] == $uuid) { $found_lvm = 1; } } else { if ($arr_hpv[EtvaPhysicalvolume::DEVICE_MAP] == $device) { $found_lvm = 1; } } } } $inconsistent = $inconsistent || !$found_lvm; if (!$found_lvm) { $error['not_found_lvm'] = 1; } /* TODO * check when have multipath */ $found_shared_lvm = 0; $inconsistent_shared_pvs = 0; foreach ($shared_pvs as $s_pv) { $s_uuid = $s_pv->getUuid(); $s_device = $s_pv->getDevice(); if ($s_uuid == $uuid) { if ($s_pv->getStorageType() != $pv->getStorageType()) { $inconsistent_shared_pvs = 1; } else { $found_shared_lvm = 1; } } else { if ($s_pv->getStorageType() == $pv->getStorageType()) { if ($arr_hpv[EtvaPhysicalvolume::DEVICE_MAP] == $device) { $found_shared_lvm = 1; } } } } if ($pv->getStorageType() != EtvaPhysicalvolume::STORAGE_TYPE_LOCAL_MAP) { $inconsistent = $inconsistent || !$found_shared_lvm; if (!$found_shared_lvm) { $error['not_found_shared_lvm'] = 1; } } $inconsistent = $inconsistent || $inconsistent_shared_pvs; if ($inconsistent_shared_pvs) { $error['diff_storage_type'] = 1; } // update data-base $etva_physicalvol = EtvaPhysicalvolumePeer::retrieveByNodeTypeUUIDDevice($etva_node->getId(), $pv->getStorageType(), $pv->getUuid(), $pv->getDevice()); if ($etva_physicalvol) { $etva_physicalvol->setInconsistent($inconsistent); $etva_physicalvol->save(); } $etva_node_physicalvol = EtvaNodePhysicalvolumePeer::retrieveByPK($etva_node->getId(), $pv->getId()); if ($etva_node_physicalvol) { $etva_node_physicalvol->setInconsistent($inconsistent); $etva_node_physicalvol->save(); } if ($inconsistent) { $message = sfContext::getInstance()->getI18N()->__(EtvaPhysicalvolumePeer::_ERR_INCONSISTENT_, array('%info%' => sprintf('device "%s" with uuid "%s"', $pv->getDevice(), $pv->getUuid()))); if ($error['not_found_shared_lvm'] || $error['diff_storage_type']) { $message = sfContext::getInstance()->getI18N()->__(EtvaPhysicalvolumePeer::_ERR_SHARED_INCONSISTENT_, array('%info%' => sprintf('device "%s" with uuid "%s"', $pv->getDevice(), $pv->getUuid()))); } sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR))); $error['node'] = array('name' => $etva_node->getName(), 'id' => $etva_node->getId(), 'uuid' => $etva_node->getUuid()); $error['device'] = $pv->getDevice(); $error['device_id'] = $pv->getId(); $error['uuid'] = $pv->getUuid(); $error['message'] = $message; } if (!empty($error)) { $errors[] = $error; } $node_inconsistent = $node_inconsistent || $inconsistent; } // check consistency for shared PVs foreach ($shared_pvs as $pv) { $error = array(); $uuid = $pv->getUuid(); $device = $pv->getDevice(); // init $inconsistent = 0; // look at physical volumes list $found_lvm = 0; foreach ($sync_node_pvs as $hpv) { $arr_hpv = (array) $hpv; if ($arr_hpv[EtvaPhysicalvolume::STORAGE_TYPE_MAP] == $pv->getStorageType()) { if (isset($arr_hpv[EtvaPhysicalvolume::UUID_MAP])) { if ($arr_hpv[EtvaPhysicalvolume::UUID_MAP] == $uuid) { $found_lvm = 1; } } else { if ($arr_hpv[EtvaPhysicalvolume::DEVICE_MAP] == $device) { $found_lvm = 1; } } } } $inconsistent = $inconsistent || !$found_lvm; if (!$found_lvm) { $error['not_found_lvm'] = 1; } /* TODO * check when have multipath */ // update data-base $etva_physicalvol = EtvaPhysicalvolumePeer::retrieveByNodeTypeUUIDDevice($etva_node->getId(), $pv->getStorageType(), $pv->getUuid(), $pv->getDevice()); if ($etva_physicalvol) { $etva_physicalvol->setInconsistent($inconsistent); $etva_physicalvol->save(); } $etva_node_physicalvol = EtvaNodePhysicalvolumePeer::retrieveByPK($etva_node->getId(), $pv->getId()); if ($etva_node_physicalvol) { $etva_node_physicalvol->setInconsistent($inconsistent); $etva_node_physicalvol->save(); } if ($inconsistent) { $message = sfContext::getInstance()->getI18N()->__(EtvaPhysicalvolumePeer::_ERR_SHARED_INCONSISTENT_, array('%info%' => sprintf('device "%s" with uuid "%s"', $pv->getDevice(), $pv->getUuid()))); sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR))); $error['node'] = array('name' => $etva_node->getName(), 'id' => $etva_node->getId(), 'uuid' => $etva_node->getUuid()); $error['device'] = $pv->getDevice(); $error['device_id'] = $pv->getId(); $error['uuid'] = $pv->getUuid(); $error['message'] = $message; } if (!empty($error)) { $errors[] = $error; } $node_inconsistent = $node_inconsistent || $inconsistent; } $return = array(); if ($node_inconsistent) { $etva_node->setErrorMessage(self::PVINIT); $return = array('success' => false, 'errors' => $errors); } else { $etva_node->clearErrorMessage(self::PVINIT); $return = array('success' => true); } return $return; //($node_inconsistent) ? false : true; }
public function calcState(EtvaNode $etva_node, $newstate = EtvaNode::NODE_ACTIVE) { $res_state = $newstate; if ($newstate == EtvaNode::NODE_ACTIVE) { if ($etva_node->getState() == EtvaNode::NODE_FAIL || $etva_node->getState() == EtvaNode::NODE_FAIL_UP) { $res_state = EtvaNode::NODE_FAIL_UP; } elseif ($etva_node->getState() == EtvaNode::NODE_MAINTENANCE || $etva_node->getState() == EtvaNode::NODE_MAINTENANCE_UP) { $res_state = EtvaNode::NODE_MAINTENANCE_UP; } elseif ($etva_node->getState() < EtvaNode::NODE_INACTIVE) { $res_state = $etva_node->getState(); } } else { if ($etva_node->getState() == EtvaNode::NODE_FAIL || $etva_node->getState() == EtvaNode::NODE_FAIL_UP) { $res_state = EtvaNode::NODE_FAIL; } elseif ($etva_node->getState() == EtvaNode::NODE_MAINTENANCE || $etva_node->getState() == EtvaNode::NODE_MAINTENANCE_UP) { $res_state = EtvaNode::NODE_MAINTENANCE; } elseif ($etva_node->getState() < EtvaNode::NODE_INACTIVE) { $res_state = $etva_node->getState(); } } error_log(sprintf('calcState node=%s oldstate=%s newstate=%s', $etva_node->getName(), $etva_node->getState(), $res_state)); return $res_state; }
public function check_consistency(EtvaNode $etva_node, $sync_node_lvs, $sync_node_dtable, $sync_bulk_dtable) { $errors = array(); $etva_node->getId(); $etva_cluster = $etva_node->getEtvaCluster(); // get node database LVs $node_lvs = $etva_node->getEtvaLogicalvolumes(); $node_inconsistent = 0; foreach ($node_lvs as $lv) { $error = array(); $uuid = $lv->getUuid(); $device = $lv->getLvdevice(); $etva_vg = $lv->getEtvaVolumegroup(); $vgname = $etva_vg->getVg(); $is_FileDiskVG = $vgname == sfConfig::get('app_volgroup_disk_flag') ? true : false; // init $inconsistent = 0; // look at logical volumes list $found_lvm = 0; foreach ($sync_node_lvs as $hlv) { $arr_hlv = (array) $hlv; if ($arr_hlv[EtvaLogicalvolume::STORAGE_TYPE_MAP] == $lv->getStorageType()) { if ($arr_hlv[EtvaLogicalvolume::UUID_MAP]) { if ($arr_hlv[EtvaLogicalvolume::UUID_MAP] == $uuid) { $found_lvm = 1; } } else { if ($arr_hlv[EtvaLogicalvolume::LVDEVICE_MAP] == $device) { $found_lvm = 1; } } } } $inconsistent = $inconsistent || !$found_lvm; if (!$found_lvm) { $error['not_found_lvm'] = 1; } if (!$is_FileDiskVG) { // if not file disk volume // look at devices table $clvdev = $device; $clvdev = str_replace("/dev/", "", $clvdev); $clvdev = str_replace("-", "--", $clvdev); $clvdev = str_replace("/", "-", $clvdev); $re_clvdev = "/" . $clvdev . ":/"; // found device table of node $node_lv_dtable_aux = preg_grep($re_clvdev, $sync_node_dtable); // ignore snapshots $node_lv_dtable = preg_grep("/(?:(?! snapshot ).)/", $node_lv_dtable_aux); // check if found $found_node_dt = empty($node_lv_dtable) ? 0 : 1; $inconsistent = $inconsistent || !$found_node_dt; if (!$found_node_dt) { $error['not_found_node_device_table'] = 1; } } // update data-base $etva_logicalvol = EtvaLogicalvolumePeer::retrieveByNodeTypeUUIDLv($etva_node->getId(), $lv->getStorageType(), $lv->getUuid(), $lv->getLv()); if ($etva_logicalvol) { $etva_logicalvol->setInconsistent($inconsistent); $etva_logicalvol->save(); } $etva_node_logicalvol = EtvaNodeLogicalvolumePeer::retrieveByPK($etva_node->getId(), $lv->getId()); if ($etva_node_logicalvol) { $etva_node_logicalvol->setInconsistent($inconsistent); $etva_node_logicalvol->save(); } if ($inconsistent) { $message = sfContext::getInstance()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_INCONSISTENT_, array('%info%' => sprintf('device "%s" with uuid "%s"', $lv->getLvdevice(), $lv->getUuid()))); sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR))); $error['node'] = array('name' => $etva_node->getName(), 'id' => $etva_node->getId(), 'uuid' => $etva_node->getUuid()); $error['device'] = $lv->getLvdevice(); $error['uuid'] = $lv->getUuid(); $error['message'] = $message; } if (!empty($error)) { $errors[] = $error; } $node_inconsistent = $node_inconsistent || $inconsistent; } // get shared database LVs $shared_lvs = $etva_cluster->getSharedLvs(); // check consistency for shared LVs foreach ($shared_lvs as $lv) { $error = array(); $uuid = $lv->getUuid(); $device = $lv->getLvdevice(); $etva_vg = $lv->getEtvaVolumegroup(); $vgname = $etva_vg->getVg(); // init $inconsistent = 0; // look at logical volumes list $found_lvm = 0; foreach ($sync_node_lvs as $hlv) { $arr_hlv = (array) $hlv; if ($arr_hlv[EtvaLogicalvolume::STORAGE_TYPE_MAP] == $lv->getStorageType()) { if (isset($arr_hlv[EtvaLogicalvolume::UUID_MAP])) { if ($arr_hlv[EtvaLogicalvolume::UUID_MAP] == $uuid) { $found_lvm = 1; } } else { if ($arr_hlv[EtvaLogicalvolume::LVDEVICE_MAP] == $device) { $found_lvm = 1; } } } } $inconsistent = $inconsistent || !$found_lvm; if (!$found_lvm) { $error['not_found_lvm'] = 1; } // look at devices table $clvdev = $device; $clvdev = str_replace("/dev/", "", $clvdev); $clvdev = str_replace("-", "--", $clvdev); $clvdev = str_replace("/", "-", $clvdev); $re_clvdev = "/" . $clvdev . ":/"; // found device table of node $node_lv_dtable_aux = preg_grep($re_clvdev, $sync_node_dtable); // ignore snapshots $node_lv_dtable = preg_grep("/(?:(?! snapshot ).)/", $node_lv_dtable_aux); // check if found $found_node_dt = empty($node_lv_dtable) ? 0 : 1; $inconsistent = $inconsistent || !$found_node_dt; if (!$found_node_dt) { $error['not_found_node_device_table'] = 1; } // look at all nodes devices table $found_all_nodes_dt = 1; foreach ($sync_bulk_dtable as $e_id => $e_response) { if ($e_response['success']) { //response received ok $dtable = (array) $e_response['response']; // found device table of node $lv_dtable = preg_grep($re_clvdev, $dtable); $found = empty($lv_dtable) ? 0 : 1; $is_eq = count($lv_dtable) == count($node_lv_dtable) ? 1 : 0; if ($is_eq) { foreach ($lv_dtable as $e_line) { // TODO fix this if (!in_array($e_line, $node_lv_dtable)) { $is_eq = 0; } } } $found_all_nodes_dt = $found_all_nodes_dt && $found && $is_eq; } } $inconsistent = $inconsistent || !$found_all_nodes_dt; if (!$found_all_nodes_dt) { $error['not_found_all_nodes_device_table'] = 1; } // update data-base $etva_logicalvol = EtvaLogicalvolumePeer::retrieveByNodeTypeUUIDLv($etva_node->getId(), $lv->getStorageType(), $lv->getUuid(), $lv->getLv()); if ($etva_logicalvol) { $etva_logicalvol->setInconsistent($inconsistent); $etva_logicalvol->save(); } $etva_node_logicalvol = EtvaNodeLogicalvolumePeer::retrieveByPK($etva_node->getId(), $lv->getId()); if ($etva_node_logicalvol) { $etva_node_logicalvol->setInconsistent($inconsistent); $etva_node_logicalvol->save(); } if ($inconsistent) { $message = sfContext::getInstance()->getI18N()->__(EtvaLogicalvolumePeer::_ERR_SHARED_INCONSISTENT_, array('%info%' => sprintf('device "%s" with uuid "%s"', $lv->getLvdevice(), $lv->getUuid()))); sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent($etva_node->getName(), 'event.log', array('message' => $message, 'priority' => EtvaEventLogger::ERR))); $error['node'] = array('name' => $etva_node->getName(), 'id' => $etva_node->getId(), 'uuid' => $etva_node->getUuid()); $error['device'] = $lv->getLvdevice(); $error['uuid'] = $lv->getUuid(); $error['message'] = $message; } if (!empty($error)) { $errors[] = $error; } $node_inconsistent = $node_inconsistent || $inconsistent; } $return = array(); if ($node_inconsistent) { $etva_node->setErrorMessage(self::LVINIT); $return = array('success' => false, 'errors' => $errors); } else { $etva_node->clearErrorMessage(self::LVINIT); $return = array('success' => true); } return $return; }
public function send_start(EtvaNode $etva_node, $extra = null, $ignoreAdmissionGate = false) { $etva_server = $this->etva_server; $method = self::SERVER_START; $mem_available = $etva_node->getMemfree(); $server_mem_mb = $etva_server->getMem(); $server_mem = Etva::MB_to_Byteconvert($server_mem_mb); error_log(" start_vm mem_available=" . $mem_available . " server_mem=" . $server_mem); if ($server_mem > $mem_available) { //notify event log $msg_i18n = Etva::makeNotifyLogMessage($error['agent'], EtvaNodePeer::_ERR_MEM_AVAILABLE_, array('name' => $etva_node->getName(), 'info' => $server_mem_mb), EtvaServerPeer::_ERR_START_, array('name' => $server)); $error = array('success' => false, 'agent' => $etva_node->getName(), 'info' => $msg_i18n, 'error' => $msg_i18n); return $error; } $etva_cluster = $etva_node->getEtvaCluster(); if (!$ignoreAdmissionGate && $etva_cluster->getHasNodeHA()) { $admissiongate_response = $etva_cluster->getAdmissionGate($etva_server); if (!$admissiongate_response['success']) { //notify event log $msg_i18n = Etva::makeNotifyLogMessage($error['agent'], EtvaClusterPeer::_ERR_ADMISSION_GATE_FAIL_, array('name' => $etva_server->getName(), 'info' => $admissiongate_response['info']), EtvaServerPeer::_ERR_START_, array('name' => $server)); $error = array('success' => false, 'agent' => $etva_node->getName(), 'info' => $msg_i18n, 'error' => $msg_i18n); return $error; } } $params = $extra ? $extra : array(); $params['uuid'] = $etva_server->getUuid(); $boot = $etva_server->getBoot(); $location = $etva_server->getLocation(); $vm_type = $etva_server->getVmType(); $first_boot = $etva_server->getFirstBoot(); if ($first_boot) { $params['first_boot'] = $first_boot; if ($location && $vm_type == 'pv') { $boot = 'location'; } } $params['boot'] = $boot; if ($boot == 'location' || $boot == 'cdrom') { $params['location'] = $location; } $params['vnc_keymap'] = $etva_server->getVncKeymap(); $response = $etva_node->soapSend($method, $params); return $this->processStartStop($etva_node, $response, $method); }