Skip to content

Commit 93511f8

Browse files
jeongda-youngDajeong-Park
authored andcommitted
hba 조회 agent
1 parent 97365e4 commit 93511f8

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

core/src/main/java/com/cloud/resource/ServerResourceBase.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.cloud.agent.api.Answer;
2424
import com.cloud.agent.api.Command;
2525
import com.cloud.agent.api.ListHostDeviceAnswer;
26+
import com.cloud.agent.api.ListHostHbaDeviceAnswer;
2627
import com.cloud.agent.api.ListHostLunDeviceAnswer;
2728
import com.cloud.agent.api.ListHostUsbDeviceAnswer;
2829
import com.cloud.agent.api.StartupCommand;
@@ -48,7 +49,6 @@
4849
import java.util.List;
4950
import java.util.Locale;
5051
import java.util.Map;
51-
import javax.naming.ConfigurationException;
5252
import org.apache.cloudstack.storage.command.browser.ListDataStoreObjectsAnswer;
5353
import org.apache.cloudstack.storage.command.browser.ListRbdObjectsAnswer;
5454
import org.apache.commons.collections.CollectionUtils;
@@ -295,6 +295,28 @@ private boolean hasPartitionRecursive(JSONObject device) {
295295
return false;
296296
}
297297

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+
298320
protected Answer createImageRbd(String poolUuid, String skey, String authUserName, String host, String names, long sizes, String poolPath) {
299321
createRBDSecretKeyFileIfNoExist(poolUuid, DEFAULT_LOCAL_STORAGE_PATH, skey);
300322
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

Comments
 (0)