|
44 | 44 | import java.util.Set; |
45 | 45 | import java.util.UUID; |
46 | 46 | import java.util.concurrent.ConcurrentHashMap; |
47 | | -import java.util.concurrent.ExecutionException; |
48 | | -import java.util.concurrent.ExecutorService; |
49 | | -import java.util.concurrent.Executors; |
50 | | -import java.util.concurrent.Future; |
51 | 47 | import java.util.regex.Matcher; |
52 | 48 | import java.util.regex.Pattern; |
53 | 49 |
|
|
88 | 84 | import com.cloud.agent.api.Command; |
89 | 85 | import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; |
90 | 86 | import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand; |
91 | | -import com.cloud.agent.api.CreateVolumeFromSnapshotAnswer; |
92 | | -import com.cloud.agent.api.CreateVolumeFromSnapshotCommand; |
93 | | -import com.cloud.agent.api.FenceAnswer; |
94 | | -import com.cloud.agent.api.FenceCommand; |
95 | 87 | import com.cloud.agent.api.HostVmStateReportEntry; |
96 | 88 | import com.cloud.agent.api.ManageSnapshotAnswer; |
97 | 89 | import com.cloud.agent.api.ManageSnapshotCommand; |
|
103 | 95 | import com.cloud.agent.api.PlugNicAnswer; |
104 | 96 | import com.cloud.agent.api.PlugNicCommand; |
105 | 97 | import com.cloud.agent.api.PvlanSetupCommand; |
106 | | -import com.cloud.agent.api.SecurityGroupRuleAnswer; |
107 | | -import com.cloud.agent.api.SecurityGroupRulesCmd; |
108 | 98 | import com.cloud.agent.api.SetupGuestNetworkCommand; |
109 | 99 | import com.cloud.agent.api.StartAnswer; |
110 | 100 | import com.cloud.agent.api.StartCommand; |
|
138 | 128 | import com.cloud.exception.InternalErrorException; |
139 | 129 | import com.cloud.host.Host.Type; |
140 | 130 | import com.cloud.hypervisor.Hypervisor.HypervisorType; |
141 | | -import com.cloud.hypervisor.kvm.resource.KVMHABase.NfsStoragePool; |
142 | 131 | import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.ClockDef; |
143 | 132 | import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.ConsoleDef; |
144 | 133 | import com.cloud.hypervisor.kvm.resource.LibvirtVMDef.CpuModeDef; |
@@ -1284,14 +1273,8 @@ public Answer executeRequest(final Command cmd) { |
1284 | 1273 | return execute((ManageSnapshotCommand)cmd); |
1285 | 1274 | } else if (cmd instanceof BackupSnapshotCommand) { |
1286 | 1275 | return execute((BackupSnapshotCommand)cmd); |
1287 | | - } else if (cmd instanceof CreateVolumeFromSnapshotCommand) { |
1288 | | - return execute((CreateVolumeFromSnapshotCommand)cmd); |
1289 | 1276 | } else if (cmd instanceof CreatePrivateTemplateFromSnapshotCommand) { |
1290 | 1277 | return execute((CreatePrivateTemplateFromSnapshotCommand)cmd); |
1291 | | - } else if (cmd instanceof SecurityGroupRulesCmd) { |
1292 | | - return execute((SecurityGroupRulesCmd)cmd); |
1293 | | - } else if (cmd instanceof FenceCommand) { |
1294 | | - return execute((FenceCommand)cmd); |
1295 | 1278 | } else if (cmd instanceof StartCommand) { |
1296 | 1279 | return execute((StartCommand)cmd); |
1297 | 1280 | } else if (cmd instanceof PlugNicCommand) { |
@@ -1450,28 +1433,6 @@ private CopyVolumeAnswer execute(final CopyVolumeCommand cmd) { |
1450 | 1433 | } |
1451 | 1434 | } |
1452 | 1435 |
|
1453 | | - protected FenceAnswer execute(final FenceCommand cmd) { |
1454 | | - final ExecutorService executors = Executors.newSingleThreadExecutor(); |
1455 | | - final List<NfsStoragePool> pools = _monitor.getStoragePools(); |
1456 | | - final KVMHAChecker ha = new KVMHAChecker(pools, cmd.getHostIp()); |
1457 | | - final Future<Boolean> future = executors.submit(ha); |
1458 | | - try { |
1459 | | - final Boolean result = future.get(); |
1460 | | - if (result) { |
1461 | | - return new FenceAnswer(cmd, false, "Heart is still beating..."); |
1462 | | - } else { |
1463 | | - return new FenceAnswer(cmd); |
1464 | | - } |
1465 | | - } catch (final InterruptedException e) { |
1466 | | - s_logger.warn("Unable to fence", e); |
1467 | | - return new FenceAnswer(cmd, false, e.getMessage()); |
1468 | | - } catch (final ExecutionException e) { |
1469 | | - s_logger.warn("Unable to fence", e); |
1470 | | - return new FenceAnswer(cmd, false, e.getMessage()); |
1471 | | - } |
1472 | | - |
1473 | | - } |
1474 | | - |
1475 | 1436 | protected Storage.StorageResourceType getStorageResourceType() { |
1476 | 1437 | return Storage.StorageResourceType.STORAGE_POOL; |
1477 | 1438 | } |
@@ -2265,25 +2226,6 @@ protected BackupSnapshotAnswer execute(final BackupSnapshotCommand cmd) { |
2265 | 2226 | return new BackupSnapshotAnswer(cmd, true, null, snapshotRelPath + File.separator + snapshotName, true); |
2266 | 2227 | } |
2267 | 2228 |
|
2268 | | - protected CreateVolumeFromSnapshotAnswer execute(final CreateVolumeFromSnapshotCommand cmd) { |
2269 | | - try { |
2270 | | - |
2271 | | - String snapshotPath = cmd.getSnapshotUuid(); |
2272 | | - final int index = snapshotPath.lastIndexOf("/"); |
2273 | | - snapshotPath = snapshotPath.substring(0, index); |
2274 | | - final KVMStoragePool secondaryPool = _storagePoolMgr.getStoragePoolByURI(cmd.getSecondaryStorageUrl() + snapshotPath); |
2275 | | - final KVMPhysicalDisk snapshot = secondaryPool.getPhysicalDisk(cmd.getSnapshotName()); |
2276 | | - |
2277 | | - final String primaryUuid = cmd.getPrimaryStoragePoolNameLabel(); |
2278 | | - final KVMStoragePool primaryPool = _storagePoolMgr.getStoragePool(cmd.getPool().getType(), primaryUuid); |
2279 | | - final String volUuid = UUID.randomUUID().toString(); |
2280 | | - final KVMPhysicalDisk disk = _storagePoolMgr.copyPhysicalDisk(snapshot, volUuid, primaryPool, 0); |
2281 | | - return new CreateVolumeFromSnapshotAnswer(cmd, true, "", disk.getName()); |
2282 | | - } catch (final CloudRuntimeException e) { |
2283 | | - return new CreateVolumeFromSnapshotAnswer(cmd, false, e.toString(), null); |
2284 | | - } |
2285 | | - } |
2286 | | - |
2287 | 2229 | protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromSnapshotCommand cmd) { |
2288 | 2230 | final String templateFolder = cmd.getAccountId() + File.separator + cmd.getNewTemplateId(); |
2289 | 2231 | final String templateInstallFolder = "template/tmpl/" + templateFolder; |
@@ -2450,32 +2392,6 @@ protected CreatePrivateTemplateAnswer execute(final CreatePrivateTemplateFromVol |
2450 | 2392 | } |
2451 | 2393 | } |
2452 | 2394 |
|
2453 | | - private Answer execute(final SecurityGroupRulesCmd cmd) { |
2454 | | - String vif = null; |
2455 | | - String brname = null; |
2456 | | - try { |
2457 | | - final Connect conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); |
2458 | | - final List<InterfaceDef> nics = getInterfaces(conn, cmd.getVmName()); |
2459 | | - vif = nics.get(0).getDevName(); |
2460 | | - brname = nics.get(0).getBrName(); |
2461 | | - } catch (final LibvirtException e) { |
2462 | | - return new SecurityGroupRuleAnswer(cmd, false, e.toString()); |
2463 | | - } |
2464 | | - |
2465 | | - final boolean result = |
2466 | | - add_network_rules(cmd.getVmName(), Long.toString(cmd.getVmId()), cmd.getGuestIp(), cmd.getSignature(), Long.toString(cmd.getSeqNum()), cmd.getGuestMac(), |
2467 | | - cmd.stringifyRules(), vif, brname, cmd.getSecIpsString()); |
2468 | | - |
2469 | | - if (!result) { |
2470 | | - s_logger.warn("Failed to program network rules for vm " + cmd.getVmName()); |
2471 | | - return new SecurityGroupRuleAnswer(cmd, false, "programming network rules failed"); |
2472 | | - } else { |
2473 | | - s_logger.debug("Programmed network rules for vm " + cmd.getVmName() + " guestIp=" + cmd.getGuestIp() + ",ingress numrules=" + cmd.getIngressRuleSet().length + |
2474 | | - ",egress numrules=" + cmd.getEgressRuleSet().length); |
2475 | | - return new SecurityGroupRuleAnswer(cmd); |
2476 | | - } |
2477 | | - } |
2478 | | - |
2479 | 2395 | protected PowerState convertToPowerState(final DomainState ps) { |
2480 | 2396 | final PowerState state = s_powerStatesTable.get(ps); |
2481 | 2397 | return state == null ? PowerState.PowerUnknown : state; |
@@ -4101,7 +4017,7 @@ public boolean configureDefaultNetworkRulesForSystemVm(final Connect conn, final |
4101 | 4017 | return true; |
4102 | 4018 | } |
4103 | 4019 |
|
4104 | | - private boolean add_network_rules(final String vmName, final String vmId, final String guestIP, final String sig, final String seq, final String mac, final String rules, final String vif, final String brname, |
| 4020 | + public boolean addNetworkRules(final String vmName, final String vmId, final String guestIP, final String sig, final String seq, final String mac, final String rules, final String vif, final String brname, |
4105 | 4021 | final String secIps) { |
4106 | 4022 | if (!_canBridgeFirewall) { |
4107 | 4023 | return false; |
|
0 commit comments