|
35 | 35 | import java.util.ArrayList; |
36 | 36 | import java.util.Calendar; |
37 | 37 | import java.util.HashMap; |
38 | | -import java.util.Iterator; |
39 | 38 | import java.util.List; |
40 | 39 | import java.util.Map; |
41 | 40 | import java.util.Properties; |
42 | | -import java.util.Set; |
43 | | -import java.util.SortedMap; |
44 | 41 | import java.util.UUID; |
45 | 42 | import java.util.concurrent.ConcurrentHashMap; |
46 | 43 | import java.util.concurrent.ExecutionException; |
|
126 | 123 | import com.cloud.agent.api.StartCommand; |
127 | 124 | import com.cloud.agent.api.StartupCommand; |
128 | 125 | import com.cloud.agent.api.StartupRoutingCommand; |
| 126 | +import com.cloud.agent.api.StartupStorageCommand; |
129 | 127 | import com.cloud.agent.api.StopAnswer; |
130 | 128 | import com.cloud.agent.api.StopCommand; |
131 | 129 | import com.cloud.agent.api.VmStatsEntry; |
|
164 | 162 | import com.cloud.host.Host.Type; |
165 | 163 | import com.cloud.hypervisor.Hypervisor.HypervisorType; |
166 | 164 | import com.cloud.network.Networks.BroadcastDomainType; |
167 | | -import com.cloud.network.Networks.IsolationType; |
168 | 165 | import com.cloud.network.Networks.RouterPrivateIpStrategy; |
169 | 166 | import com.cloud.network.Networks.TrafficType; |
170 | 167 | import com.cloud.resource.ServerResource; |
@@ -288,6 +285,7 @@ protected String getDefaultScriptsDir() { |
288 | 285 | protected String _pool; |
289 | 286 | protected String _localGateway; |
290 | 287 | private boolean _can_bridge_firewall; |
| 288 | + protected String _localStoragePath; |
291 | 289 | private Pair<String, String> _pifs; |
292 | 290 | private final Map<String, vmStats> _vmStats = new ConcurrentHashMap<String, vmStats>(); |
293 | 291 |
|
@@ -544,6 +542,11 @@ public boolean configure(String name, Map<String, Object> params) |
544 | 542 | } |
545 | 543 | } |
546 | 544 |
|
| 545 | + _localStoragePath = (String)params.get("local.storage.path"); |
| 546 | + if (_localStoragePath == null) { |
| 547 | + _localStoragePath = "/var/lib/libvirt/images/"; |
| 548 | + } |
| 549 | + |
547 | 550 | value = (String)params.get("scripts.timeout"); |
548 | 551 | _timeout = NumbersUtil.parseInt(value, 30*60) * 1000; |
549 | 552 |
|
@@ -1309,7 +1312,6 @@ protected PrimaryStorageDownloadAnswer execute(final PrimaryStorageDownloadComma |
1309 | 1312 | StoragePool primaryPool = null; |
1310 | 1313 | StorageVol tmplVol = null; |
1311 | 1314 | StorageVol primaryVol = null; |
1312 | | - String result; |
1313 | 1315 | Connect conn = null; |
1314 | 1316 | try { |
1315 | 1317 | conn = LibvirtConnection.getConnection(); |
@@ -2370,14 +2372,31 @@ private Map<String, String> getVersionStrings() { |
2370 | 2372 | } |
2371 | 2373 |
|
2372 | 2374 | final List<Object> info = getHostInfo(); |
2373 | | - |
| 2375 | + |
2374 | 2376 | final StartupRoutingCommand cmd = new StartupRoutingCommand((Integer)info.get(0), (Long)info.get(1), (Long)info.get(2), (Long)info.get(4), (String)info.get(3), HypervisorType.KVM, RouterPrivateIpStrategy.HostLocal, changes); |
2375 | 2377 | fillNetworkInformation(cmd); |
2376 | 2378 | cmd.getHostDetails().putAll(getVersionStrings()); |
2377 | 2379 | cmd.setPool(_pool); |
2378 | 2380 | cmd.setCluster(_clusterId); |
2379 | | - |
2380 | | - return new StartupCommand[]{cmd}; |
| 2381 | + |
| 2382 | + StartupStorageCommand sscmd = null; |
| 2383 | + try { |
| 2384 | + Connect conn = LibvirtConnection.getConnection(); |
| 2385 | + com.cloud.agent.api.StoragePoolInfo pi = _storageResource.initializeLocalStorage(conn, _localStoragePath, cmd.getPrivateIpAddress()); |
| 2386 | + sscmd = new StartupStorageCommand(); |
| 2387 | + sscmd.setPoolInfo(pi); |
| 2388 | + sscmd.setGuid(pi.getUuid()); |
| 2389 | + sscmd.setDataCenter(_dcId); |
| 2390 | + sscmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL); |
| 2391 | + } catch (LibvirtException e) { |
| 2392 | + |
| 2393 | + } |
| 2394 | + |
| 2395 | + if (sscmd != null) { |
| 2396 | + return new StartupCommand[]{cmd, sscmd}; |
| 2397 | + } else { |
| 2398 | + return new StartupCommand[]{cmd}; |
| 2399 | + } |
2381 | 2400 | } |
2382 | 2401 |
|
2383 | 2402 | protected HashMap<String, State> sync() { |
|
0 commit comments