Skip to content

Commit 47671b9

Browse files
committed
find local storage based on name label
1 parent 995bab6 commit 47671b9

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XcpOssResource.java‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.File;
2121
import java.util.ArrayList;
2222
import java.util.List;
23+
import java.util.Map;
2324
import java.util.Set;
2425

2526
import javax.ejb.Local;
@@ -44,6 +45,7 @@
4445
import com.cloud.utils.script.Script;
4546
import com.cloud.vm.VirtualMachine;
4647
import com.xensource.xenapi.Connection;
48+
import com.xensource.xenapi.SR;
4749
import com.xensource.xenapi.Types;
4850
import com.xensource.xenapi.VBD;
4951
import com.xensource.xenapi.VDI;
@@ -82,9 +84,18 @@ protected String getGuestOsType(String stdType, boolean bootFromCD) {
8284
}
8385

8486
protected VBD createPatchVbd(Connection conn, String vmName, VM vm) throws XmlRpcException, XenAPIException {
85-
if (_host.localSRuuid != null) {
87+
String localStorageUuid = null;
88+
Map<SR, SR.Record> map = SR.getAllRecords(conn);
89+
for (Map.Entry<SR, SR.Record> entry : map.entrySet()) {
90+
SR.Record srRec = entry.getValue();
91+
if (srRec.nameLabel.equalsIgnoreCase("local-storage")) {
92+
localStorageUuid = srRec.uuid;
93+
break;
94+
}
95+
}
96+
if (localStorageUuid != null) {
8697
//create an iso vdi on it
87-
String result = callHostPlugin(conn, "vmops", "createISOVHD", "uuid", _host.localSRuuid);
98+
String result = callHostPlugin(conn, "vmops", "createISOVHD", "uuid", localStorageUuid);
8899
if (result == null || result.equalsIgnoreCase("Failed")) {
89100
throw new CloudRuntimeException("can not create systemvm vdi");
90101
}

0 commit comments

Comments
 (0)