|
32 | 32 | import com.cloud.agent.api.NetworkUsageAnswer; |
33 | 33 | import com.cloud.agent.api.NetworkUsageCommand; |
34 | 34 | import com.cloud.agent.api.StartupRoutingCommand; |
| 35 | +import com.cloud.agent.api.StartupStorageCommand; |
35 | 36 | import com.cloud.agent.api.StopAnswer; |
36 | 37 | import com.cloud.agent.api.StopCommand; |
| 38 | +import com.cloud.agent.api.StoragePoolInfo; |
37 | 39 | import com.cloud.resource.ServerResource; |
| 40 | +import com.cloud.storage.Storage; |
38 | 41 | import com.cloud.utils.exception.CloudRuntimeException; |
39 | 42 | import com.cloud.utils.script.Script; |
40 | 43 | import com.xensource.xenapi.Connection; |
| 44 | +import com.xensource.xenapi.Host; |
| 45 | +import com.xensource.xenapi.SR; |
41 | 46 | import com.xensource.xenapi.Types; |
42 | 47 | import com.xensource.xenapi.Types.XenAPIException; |
43 | 48 | import com.xensource.xenapi.VBD; |
@@ -69,6 +74,38 @@ protected void fillHostInfo(Connection conn, StartupRoutingCommand cmd) { |
69 | 74 | cmd.setCaps(cmd.getCapabilities() + " , hvm"); |
70 | 75 | } |
71 | 76 |
|
| 77 | + protected StartupStorageCommand initializeLocalSR(Connection conn) { |
| 78 | + SR extsr = getLocalEXTSR(conn); |
| 79 | + if (extsr != null) { |
| 80 | + try { |
| 81 | + String extuuid = extsr.getUuid(conn); |
| 82 | + _host.localSRuuid = extuuid; |
| 83 | + long cap = extsr.getPhysicalSize(conn); |
| 84 | + if (cap > 0) { |
| 85 | + long avail = cap - extsr.getPhysicalUtilisation(conn); |
| 86 | + String name = "Cloud Stack Local EXT Storage Pool for " + _host.uuid; |
| 87 | + extsr.setNameDescription(conn, name); |
| 88 | + Host host = Host.getByUuid(conn, _host.uuid); |
| 89 | + String address = host.getAddress(conn); |
| 90 | + StoragePoolInfo pInfo = new StoragePoolInfo(extsr.getNameLabel(conn), address, SRType.EXT.toString(), SRType.EXT.toString(), Storage.StoragePoolType.EXT, cap, avail); |
| 91 | + StartupStorageCommand cmd = new StartupStorageCommand(); |
| 92 | + cmd.setPoolInfo(pInfo); |
| 93 | + cmd.setGuid(_host.uuid); |
| 94 | + cmd.setDataCenter(Long.toString(_dcId)); |
| 95 | + cmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL); |
| 96 | + return cmd; |
| 97 | + } |
| 98 | + } catch (XenAPIException e) { |
| 99 | + String msg = "build local EXT info err in host:" + _host.uuid + e.toString(); |
| 100 | + s_logger.warn(msg); |
| 101 | + } catch (XmlRpcException e) { |
| 102 | + String msg = "build local EXT info err in host:" + _host.uuid + e.getMessage(); |
| 103 | + s_logger.warn(msg); |
| 104 | + } |
| 105 | + } |
| 106 | + return null; |
| 107 | + } |
| 108 | + |
72 | 109 | @Override |
73 | 110 | protected String getGuestOsType(String stdType, boolean bootFromCD) { |
74 | 111 | if (stdType.equalsIgnoreCase("Debian GNU/Linux 6(64-bit)")) { |
|
0 commit comments