|
16 | 16 | // under the License. |
17 | 17 | package com.cloud.vm; |
18 | 18 |
|
19 | | -import java.util.ArrayList; |
20 | | -import java.util.Arrays; |
21 | | -import java.util.Date; |
22 | | -import java.util.HashMap; |
23 | | -import java.util.HashSet; |
24 | | -import java.util.LinkedHashMap; |
25 | | -import java.util.List; |
26 | | -import java.util.Map; |
27 | | -import java.util.Map.Entry; |
28 | | -import java.util.Set; |
29 | | -import java.util.UUID; |
30 | | -import java.util.concurrent.ConcurrentHashMap; |
31 | | -import java.util.concurrent.ExecutorService; |
32 | | -import java.util.concurrent.Executors; |
33 | | -import java.util.concurrent.ScheduledExecutorService; |
34 | | -import java.util.concurrent.TimeUnit; |
35 | | - |
36 | | -import javax.ejb.Local; |
37 | | -import javax.inject.Inject; |
38 | | -import javax.naming.ConfigurationException; |
39 | | - |
40 | | -import org.apache.cloudstack.acl.ControlledEntity.ACLType; |
41 | | -import org.apache.cloudstack.acl.SecurityChecker.AccessType; |
42 | | -import org.apache.cloudstack.affinity.AffinityGroupService; |
43 | | -import org.apache.cloudstack.affinity.AffinityGroupVO; |
44 | | -import org.apache.cloudstack.affinity.dao.AffinityGroupDao; |
45 | | -import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; |
46 | | -import org.apache.cloudstack.api.ApiConstants; |
47 | | -import org.apache.cloudstack.api.BaseCmd.HTTPMethod; |
48 | | -import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd; |
49 | | -import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd; |
50 | | -import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd; |
51 | | -import org.apache.cloudstack.api.command.user.vm.DeployVMCmd; |
52 | | -import org.apache.cloudstack.api.command.user.vm.DestroyVMCmd; |
53 | | -import org.apache.cloudstack.api.command.user.vm.RebootVMCmd; |
54 | | -import org.apache.cloudstack.api.command.user.vm.RemoveNicFromVMCmd; |
55 | | -import org.apache.cloudstack.api.command.user.vm.ResetVMPasswordCmd; |
56 | | -import org.apache.cloudstack.api.command.user.vm.ResetVMSSHKeyCmd; |
57 | | -import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd; |
58 | | -import org.apache.cloudstack.api.command.user.vm.ScaleVMCmd; |
59 | | -import org.apache.cloudstack.api.command.user.vm.StartVMCmd; |
60 | | -import org.apache.cloudstack.api.command.user.vm.UpdateDefaultNicForVMCmd; |
61 | | -import org.apache.cloudstack.api.command.user.vm.UpdateVMCmd; |
62 | | -import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd; |
63 | | -import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd; |
64 | | -import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd; |
65 | | -import org.apache.cloudstack.context.CallContext; |
66 | | -import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity; |
67 | | -import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMNetworkMapDao; |
68 | | -import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; |
69 | | -import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService; |
70 | | -import org.apache.cloudstack.engine.service.api.OrchestrationService; |
71 | | -import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; |
72 | | -import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; |
73 | | -import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore; |
74 | | -import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory; |
75 | | -import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory; |
76 | | -import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; |
77 | | -import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService; |
78 | | -import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult; |
79 | | -import org.apache.cloudstack.framework.async.AsyncCallFuture; |
80 | | -import org.apache.cloudstack.framework.config.ConfigKey; |
81 | | -import org.apache.cloudstack.framework.config.Configurable; |
82 | | -import org.apache.cloudstack.framework.config.dao.ConfigurationDao; |
83 | | -import org.apache.cloudstack.framework.jobs.AsyncJobManager; |
84 | | -import org.apache.cloudstack.managed.context.ManagedContextRunnable; |
85 | | -import org.apache.cloudstack.storage.command.DeleteCommand; |
86 | | -import org.apache.cloudstack.storage.command.DettachCommand; |
87 | | -import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; |
88 | | -import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; |
89 | | -import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; |
90 | | -import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; |
91 | | -import org.apache.commons.codec.binary.Base64; |
92 | | -import org.apache.log4j.Logger; |
93 | | - |
94 | 19 | import com.cloud.agent.AgentManager; |
95 | 20 | import com.cloud.agent.api.Answer; |
96 | 21 | import com.cloud.agent.api.Command; |
|
283 | 208 | import com.cloud.vm.snapshot.VMSnapshotManager; |
284 | 209 | import com.cloud.vm.snapshot.VMSnapshotVO; |
285 | 210 | import com.cloud.vm.snapshot.dao.VMSnapshotDao; |
| 211 | +import org.apache.cloudstack.acl.ControlledEntity.ACLType; |
| 212 | +import org.apache.cloudstack.acl.SecurityChecker.AccessType; |
| 213 | +import org.apache.cloudstack.affinity.AffinityGroupService; |
| 214 | +import org.apache.cloudstack.affinity.AffinityGroupVO; |
| 215 | +import org.apache.cloudstack.affinity.dao.AffinityGroupDao; |
| 216 | +import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; |
| 217 | +import org.apache.cloudstack.api.ApiConstants; |
| 218 | +import org.apache.cloudstack.api.BaseCmd.HTTPMethod; |
| 219 | +import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd; |
| 220 | +import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd; |
| 221 | +import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd; |
| 222 | +import org.apache.cloudstack.api.command.user.vm.DeployVMCmd; |
| 223 | +import org.apache.cloudstack.api.command.user.vm.DestroyVMCmd; |
| 224 | +import org.apache.cloudstack.api.command.user.vm.RebootVMCmd; |
| 225 | +import org.apache.cloudstack.api.command.user.vm.RemoveNicFromVMCmd; |
| 226 | +import org.apache.cloudstack.api.command.user.vm.ResetVMPasswordCmd; |
| 227 | +import org.apache.cloudstack.api.command.user.vm.ResetVMSSHKeyCmd; |
| 228 | +import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd; |
| 229 | +import org.apache.cloudstack.api.command.user.vm.ScaleVMCmd; |
| 230 | +import org.apache.cloudstack.api.command.user.vm.StartVMCmd; |
| 231 | +import org.apache.cloudstack.api.command.user.vm.UpdateDefaultNicForVMCmd; |
| 232 | +import org.apache.cloudstack.api.command.user.vm.UpdateVMCmd; |
| 233 | +import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd; |
| 234 | +import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd; |
| 235 | +import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd; |
| 236 | +import org.apache.cloudstack.context.CallContext; |
| 237 | +import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity; |
| 238 | +import org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMNetworkMapDao; |
| 239 | +import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; |
| 240 | +import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService; |
| 241 | +import org.apache.cloudstack.engine.service.api.OrchestrationService; |
| 242 | +import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; |
| 243 | +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; |
| 244 | +import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore; |
| 245 | +import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory; |
| 246 | +import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory; |
| 247 | +import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; |
| 248 | +import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService; |
| 249 | +import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult; |
| 250 | +import org.apache.cloudstack.framework.async.AsyncCallFuture; |
| 251 | +import org.apache.cloudstack.framework.config.ConfigKey; |
| 252 | +import org.apache.cloudstack.framework.config.Configurable; |
| 253 | +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; |
| 254 | +import org.apache.cloudstack.framework.jobs.AsyncJobManager; |
| 255 | +import org.apache.cloudstack.managed.context.ManagedContextRunnable; |
| 256 | +import org.apache.cloudstack.storage.command.DeleteCommand; |
| 257 | +import org.apache.cloudstack.storage.command.DettachCommand; |
| 258 | +import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; |
| 259 | +import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; |
| 260 | +import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao; |
| 261 | +import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO; |
| 262 | +import org.apache.commons.codec.binary.Base64; |
| 263 | +import org.apache.log4j.Logger; |
| 264 | + |
| 265 | +import javax.ejb.Local; |
| 266 | +import javax.inject.Inject; |
| 267 | +import javax.naming.ConfigurationException; |
| 268 | +import java.util.ArrayList; |
| 269 | +import java.util.Arrays; |
| 270 | +import java.util.Date; |
| 271 | +import java.util.HashMap; |
| 272 | +import java.util.HashSet; |
| 273 | +import java.util.LinkedHashMap; |
| 274 | +import java.util.List; |
| 275 | +import java.util.Map; |
| 276 | +import java.util.Map.Entry; |
| 277 | +import java.util.Set; |
| 278 | +import java.util.UUID; |
| 279 | +import java.util.concurrent.ConcurrentHashMap; |
| 280 | +import java.util.concurrent.ExecutorService; |
| 281 | +import java.util.concurrent.Executors; |
| 282 | +import java.util.concurrent.ScheduledExecutorService; |
| 283 | +import java.util.concurrent.TimeUnit; |
286 | 284 |
|
287 | 285 | @Local(value = {UserVmManager.class, UserVmService.class}) |
288 | 286 | public class UserVmManagerImpl extends ManagerBase implements UserVmManager, VirtualMachineGuru, UserVmService, Configurable { |
@@ -514,6 +512,7 @@ public enum UserVmCloneType { |
514 | 512 | "number of threads for fetching vms ip address", true); |
515 | 513 |
|
516 | 514 |
|
| 515 | + |
517 | 516 | @Override |
518 | 517 | public UserVmVO getVirtualMachine(long vmId) { |
519 | 518 | return _vmDao.findById(vmId); |
@@ -3524,8 +3523,8 @@ public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, Depl |
3524 | 3523 | final String zoneName = _dcDao.findById(vm.getDataCenterId()).getName(); |
3525 | 3524 | boolean isWindows = _guestOSCategoryDao.findById(_guestOSDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows"); |
3526 | 3525 |
|
3527 | | - List<String[]> vmData = _networkModel.generateVmData(vm.getUserData(), serviceOffering, zoneName, vm.getInstanceName(), vm.getId(), |
3528 | | - (String) profile.getParameter(VirtualMachineProfile.Param.VmSshPubKey), (String) profile.getParameter(VirtualMachineProfile.Param.VmPassword), isWindows); |
| 3526 | + List<String[]> vmData = (VirtualMachineManager.ConfigDriveCreation.value()) ? (_networkModel.generateVmData(vm.getUserData(), serviceOffering, zoneName, vm.getInstanceName(), vm.getId(), |
| 3527 | + (String) profile.getParameter(VirtualMachineProfile.Param.VmSshPubKey), (String) profile.getParameter(VirtualMachineProfile.Param.VmPassword), isWindows)) : null; |
3529 | 3528 | String vmName = vm.getInstanceName(); |
3530 | 3529 | String configDriveIsoRootFolder = "/tmp"; |
3531 | 3530 | String isoFile = configDriveIsoRootFolder + "/" + vmName + "/configDrive/" + vmName + ".iso"; |
|
0 commit comments