|
23 | 23 | import com.cloud.agent.api.Answer; |
24 | 24 | import com.cloud.agent.api.Command; |
25 | 25 | import com.cloud.agent.api.ListHostDeviceAnswer; |
| 26 | +import com.cloud.agent.api.ListHostHbaDeviceAnswer; |
26 | 27 | import com.cloud.agent.api.ListHostLunDeviceAnswer; |
27 | 28 | import com.cloud.agent.api.ListHostUsbDeviceAnswer; |
28 | 29 | import com.cloud.agent.api.StartupCommand; |
|
48 | 49 | import java.util.List; |
49 | 50 | import java.util.Locale; |
50 | 51 | import java.util.Map; |
51 | | -import javax.naming.ConfigurationException; |
52 | 52 | import org.apache.cloudstack.storage.command.browser.ListDataStoreObjectsAnswer; |
53 | 53 | import org.apache.cloudstack.storage.command.browser.ListRbdObjectsAnswer; |
54 | 54 | import org.apache.commons.collections.CollectionUtils; |
@@ -295,6 +295,28 @@ private boolean hasPartitionRecursive(JSONObject device) { |
295 | 295 | return false; |
296 | 296 | } |
297 | 297 |
|
| 298 | + protected Answer listHostHbaDevices(Command command) { |
| 299 | + List<String> hostDevicesText = new ArrayList<>(); |
| 300 | + List<String> hostDevicesNames = new ArrayList<>(); |
| 301 | + // lsscsi 대신 lspci 명령어로 HBA 조회 |
| 302 | + Script listCommand = new Script("/bin/bash"); |
| 303 | + listCommand.add("-c"); |
| 304 | + listCommand.add("lspci | grep -i 'scsi\\|sas\\|fibre\\|raid\\|hba'"); |
| 305 | + OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser(); |
| 306 | + String result = listCommand.execute(parser); |
| 307 | + if (result == null && parser.getLines() != null) { |
| 308 | + String[] lines = parser.getLines().split("\\n"); |
| 309 | + for (String line : lines) { |
| 310 | + String[] parts = line.split(" ", 2); |
| 311 | + if (parts.length >= 2) { |
| 312 | + hostDevicesNames.add(parts[0].trim()); |
| 313 | + hostDevicesText.add(parts[1].trim()); |
| 314 | + } |
| 315 | + } |
| 316 | + } |
| 317 | + return new ListHostHbaDeviceAnswer(true, hostDevicesNames, hostDevicesText); |
| 318 | + } |
| 319 | + |
298 | 320 | protected Answer createImageRbd(String poolUuid, String skey, String authUserName, String host, String names, long sizes, String poolPath) { |
299 | 321 | createRBDSecretKeyFileIfNoExist(poolUuid, DEFAULT_LOCAL_STORAGE_PATH, skey); |
300 | 322 | String cmdout = Script.runSimpleBashScript("rbd -p " + poolPath + " --id " + authUserName + " -m " + host + " -K " + DEFAULT_LOCAL_STORAGE_PATH + poolUuid + " create -s " + (sizes * 1024) + " " + names); |
|
0 commit comments