public function GetFreeDeviceNameSNMP() { $DBFarm = $this->GetFarmObject(); $snmpClient = new Scalr_Net_Snmp_Client(); $port = $this->GetProperty(\SERVER_PROPERTIES::SZR_SNMP_PORT); $snmpClient->Connect($this->remoteIp, $port ? $port : 161, $DBFarm->Hash, false, false, true); $result = implode(":", $snmpClient->getTree("UCD-DISKIO-MIB::diskIODevice")); $map = array("f", "g", "h", "i", "j", "k", "l", "m", "n", "p"); $n_map = array("1", "2", "3", "4", "5", "6", "7", "8", "9"); $map_used = array(); preg_match_all("/(sd|xvd)([a-z][0-9]*)/", $result, $matches); foreach ($matches[2] as $v) { if (!in_array($map_used, $v)) { array_push($map_used, $v); } } if (count($map_used) == 0) { throw new Exception(_("Cannot get a list of used disk devices: {$result}")); } $device_l = false; foreach ($n_map as $v) { foreach ($map as $letter) { if (in_array($letter, $map_used)) { continue; } $device_l = "{$letter}{$v}"; if (!in_array($device_l, $map_used)) { break; } else { $device_l = false; } } if ($device_l) { break; } } if (!$device_l) { throw new Exception(_("There is no available device letter on instance for attaching EBS")); } return "/dev/sd{$device_l}"; }