|
41 | 41 | import javax.naming.ConfigurationException;
|
42 | 42 |
|
43 | 43 | import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
44 |
| -import org.apache.cloudstack.agent.manager.ExternalAgentManagerImpl; |
45 | 44 | import org.apache.cloudstack.annotation.AnnotationService;
|
46 | 45 | import org.apache.cloudstack.annotation.dao.AnnotationDao;
|
47 | 46 | import org.apache.cloudstack.api.ApiConstants;
|
|
60 | 59 | import org.apache.cloudstack.network.RoutedIpv4Manager;
|
61 | 60 | import org.apache.cloudstack.network.dao.NetworkPermissionDao;
|
62 | 61 | import org.apache.commons.collections.CollectionUtils;
|
63 |
| -import org.apache.commons.collections.MapUtils; |
64 | 62 | import org.apache.commons.lang3.BooleanUtils;
|
65 | 63 | import org.apache.commons.lang3.ObjectUtils;
|
66 | 64 | import org.apache.commons.lang3.StringUtils;
|
|
76 | 74 | import com.cloud.agent.api.CleanupPersistentNetworkResourceAnswer;
|
77 | 75 | import com.cloud.agent.api.CleanupPersistentNetworkResourceCommand;
|
78 | 76 | import com.cloud.agent.api.Command;
|
79 |
| -import com.cloud.agent.api.PrepareExternalProvisioningAnswer; |
80 |
| -import com.cloud.agent.api.PrepareExternalProvisioningCommand; |
81 | 77 | import com.cloud.agent.api.SetupPersistentNetworkAnswer;
|
82 | 78 | import com.cloud.agent.api.SetupPersistentNetworkCommand;
|
83 | 79 | import com.cloud.agent.api.StartupCommand;
|
84 | 80 | import com.cloud.agent.api.StartupRoutingCommand;
|
85 | 81 | import com.cloud.agent.api.routing.NetworkElementCommand;
|
86 | 82 | import com.cloud.agent.api.to.NicTO;
|
87 |
| -import com.cloud.agent.api.to.VirtualMachineTO; |
88 | 83 | import com.cloud.agent.api.to.deployasis.OVFNetworkTO;
|
89 | 84 | import com.cloud.alert.AlertManager;
|
90 | 85 | import com.cloud.api.query.dao.DomainRouterJoinDao;
|
|
132 | 127 | import com.cloud.host.Status;
|
133 | 128 | import com.cloud.host.dao.HostDao;
|
134 | 129 | import com.cloud.host.dao.HostDetailsDao;
|
135 |
| -import com.cloud.hypervisor.Hypervisor; |
136 | 130 | import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
137 |
| -import com.cloud.hypervisor.HypervisorGuru; |
138 | 131 | import com.cloud.hypervisor.HypervisorGuruManager;
|
139 | 132 | import com.cloud.network.IpAddress;
|
140 | 133 | import com.cloud.network.IpAddressManager;
|
|
264 | 257 | import com.cloud.vm.VirtualMachine.Type;
|
265 | 258 | import com.cloud.vm.VirtualMachineManager;
|
266 | 259 | import com.cloud.vm.VirtualMachineProfile;
|
267 |
| -import com.cloud.vm.VmDetailConstants; |
268 | 260 | import com.cloud.vm.dao.DomainRouterDao;
|
269 | 261 | import com.cloud.vm.dao.NicDao;
|
270 | 262 | import com.cloud.vm.dao.NicExtraDhcpOptionDao;
|
@@ -2239,64 +2231,65 @@ public NicProfile prepareNic(final VirtualMachineProfile vmProfile, final Deploy
|
2239 | 2231 | }
|
2240 | 2232 |
|
2241 | 2233 | private void prepareNicIfExternalProvisionerInvolved(VirtualMachineProfile vmProfile, DeployDestination dest, long nicId) {
|
2242 |
| - if (!Hypervisor.HypervisorType.External.equals(vmProfile.getHypervisorType())) { |
2243 |
| - return; |
2244 |
| - } |
2245 |
| - if (userVmDetailsDao.findDetail(vmProfile.getId(), VmDetailConstants.DEPLOY_VM) == null) { |
2246 |
| - return; |
2247 |
| - } |
2248 |
| - HypervisorGuru hvGuru = hvGuruMgr.getGuru(vmProfile.getHypervisorType()); |
2249 |
| - VirtualMachineTO vmTO = hvGuru.implement(vmProfile); |
2250 |
| - |
2251 |
| - HostVO host = _hostDao.findById(dest.getHost().getId()); |
2252 |
| - PrepareExternalProvisioningCommand command = new PrepareExternalProvisioningCommand(vmTO, host.getClusterId()); |
2253 |
| - Map<String, Object> externalDetails = extensionsManager.getExternalAccessDetails(host, vmTO.getExternalDetails()); |
2254 |
| - command.setExternalDetails(externalDetails); |
2255 |
| - final PrepareExternalProvisioningAnswer prepareExternalProvisioningAnswer; |
2256 |
| - try { |
2257 |
| - Long hostID = dest.getHost().getId(); |
2258 |
| - final Answer answer = _agentMgr.send(hostID, command); |
2259 |
| - |
2260 |
| - if (!(answer instanceof PrepareExternalProvisioningAnswer)) { |
2261 |
| - String errorMsg = String.format("Trying to prepare the instance on external hypervisor for the CloudStack instance %s failed: %s", vmProfile.getUuid(), answer.getDetails()); |
2262 |
| - logger.debug(errorMsg); |
2263 |
| - throw new CloudRuntimeException(errorMsg); |
2264 |
| - } |
2265 |
| - |
2266 |
| - prepareExternalProvisioningAnswer = (PrepareExternalProvisioningAnswer) answer; |
2267 |
| - } catch (AgentUnavailableException | OperationTimedoutException e) { |
2268 |
| - String errorMsg = String.format("Trying to prepare the instance on external hypervisor for the CloudStack instance %s failed: %s", vmProfile.getUuid(), e); |
2269 |
| - logger.debug(errorMsg); |
2270 |
| - throw new CloudRuntimeException(errorMsg); |
2271 |
| - } |
2272 |
| - |
2273 |
| - if (prepareExternalProvisioningAnswer == null || !prepareExternalProvisioningAnswer.getResult()) { |
2274 |
| - if (prepareExternalProvisioningAnswer != null && StringUtils.isNotBlank(prepareExternalProvisioningAnswer.getDetails())) { |
2275 |
| - throw new CloudRuntimeException(String.format("Unable to prepare the instance on external system due to %s", prepareExternalProvisioningAnswer.getDetails())); |
2276 |
| - } else { |
2277 |
| - throw new CloudRuntimeException("Unable to prepare the instance on external system, please check the access details"); |
2278 |
| - } |
2279 |
| - } |
2280 |
| - |
2281 |
| - Map<String, String> serverDetails = prepareExternalProvisioningAnswer.getServerDetails(); |
2282 |
| - if (ExternalAgentManagerImpl.expectMacAddressFromExternalProvisioner.valueIn(host.getClusterId())) { |
2283 |
| - String macAddress = serverDetails.get(VmDetailConstants.MAC_ADDRESS); |
2284 |
| - if (StringUtils.isEmpty(macAddress)) { |
2285 |
| - throw new CloudRuntimeException("Unable to fetch macaddress from the external provisioner while preparing the instance"); |
2286 |
| - } |
2287 |
| - final NicVO nic = _nicDao.findById(nicId); |
2288 |
| - nic.setMacAddress(macAddress); |
2289 |
| - _nicDao.update(nicId, nic); |
2290 |
| - } |
2291 |
| - |
2292 |
| - if (MapUtils.isNotEmpty(serverDetails)) { |
2293 |
| - UserVmVO userVm = _userVmDao.findById(vmProfile.getId()); |
2294 |
| - _userVmDao.loadDetails(userVm); |
2295 |
| - Map<String, String> details = userVm.getDetails(); |
2296 |
| - details.putAll(serverDetails); |
2297 |
| - userVm.setDetails(details); |
2298 |
| - _userVmDao.saveDetails(userVm); |
2299 |
| - } |
| 2234 | + logger.debug("SimpleEx {}, {}, {}", vmProfile.getId(), dest, nicId); |
| 2235 | +// if (!Hypervisor.HypervisorType.External.equals(vmProfile.getHypervisorType())) { |
| 2236 | +// return; |
| 2237 | +// } |
| 2238 | +// if (userVmDetailsDao.findDetail(vmProfile.getId(), VmDetailConstants.DEPLOY_VM) == null) { |
| 2239 | +// return; |
| 2240 | +// } |
| 2241 | +// HypervisorGuru hvGuru = hvGuruMgr.getGuru(vmProfile.getHypervisorType()); |
| 2242 | +// VirtualMachineTO vmTO = hvGuru.implement(vmProfile); |
| 2243 | +// |
| 2244 | +// HostVO host = _hostDao.findById(dest.getHost().getId()); |
| 2245 | +// PrepareExternalProvisioningCommand command = new PrepareExternalProvisioningCommand(vmTO, host.getClusterId()); |
| 2246 | +// Map<String, Object> externalDetails = extensionsManager.getExternalAccessDetails(host, vmTO.getExternalDetails()); |
| 2247 | +// command.setExternalDetails(externalDetails); |
| 2248 | +// final PrepareExternalProvisioningAnswer prepareExternalProvisioningAnswer; |
| 2249 | +// try { |
| 2250 | +// Long hostID = dest.getHost().getId(); |
| 2251 | +// final Answer answer = _agentMgr.send(hostID, command); |
| 2252 | +// |
| 2253 | +// if (!(answer instanceof PrepareExternalProvisioningAnswer)) { |
| 2254 | +// String errorMsg = String.format("Trying to prepare the instance on external hypervisor for the CloudStack instance %s failed: %s", vmProfile.getUuid(), answer.getDetails()); |
| 2255 | +// logger.debug(errorMsg); |
| 2256 | +// throw new CloudRuntimeException(errorMsg); |
| 2257 | +// } |
| 2258 | +// |
| 2259 | +// prepareExternalProvisioningAnswer = (PrepareExternalProvisioningAnswer) answer; |
| 2260 | +// } catch (AgentUnavailableException | OperationTimedoutException e) { |
| 2261 | +// String errorMsg = String.format("Trying to prepare the instance on external hypervisor for the CloudStack instance %s failed: %s", vmProfile.getUuid(), e); |
| 2262 | +// logger.debug(errorMsg); |
| 2263 | +// throw new CloudRuntimeException(errorMsg); |
| 2264 | +// } |
| 2265 | +// |
| 2266 | +// if (prepareExternalProvisioningAnswer == null || !prepareExternalProvisioningAnswer.getResult()) { |
| 2267 | +// if (prepareExternalProvisioningAnswer != null && StringUtils.isNotBlank(prepareExternalProvisioningAnswer.getDetails())) { |
| 2268 | +// throw new CloudRuntimeException(String.format("Unable to prepare the instance on external system due to %s", prepareExternalProvisioningAnswer.getDetails())); |
| 2269 | +// } else { |
| 2270 | +// throw new CloudRuntimeException("Unable to prepare the instance on external system, please check the access details"); |
| 2271 | +// } |
| 2272 | +// } |
| 2273 | +// |
| 2274 | +// Map<String, String> serverDetails = prepareExternalProvisioningAnswer.getServerDetails(); |
| 2275 | +// if (ExternalAgentManagerImpl.expectMacAddressFromExternalProvisioner.valueIn(host.getClusterId())) { |
| 2276 | +// String macAddress = serverDetails.get(VmDetailConstants.MAC_ADDRESS); |
| 2277 | +// if (StringUtils.isEmpty(macAddress)) { |
| 2278 | +// throw new CloudRuntimeException("Unable to fetch macaddress from the external provisioner while preparing the instance"); |
| 2279 | +// } |
| 2280 | +// final NicVO nic = _nicDao.findById(nicId); |
| 2281 | +// nic.setMacAddress(macAddress); |
| 2282 | +// _nicDao.update(nicId, nic); |
| 2283 | +// } |
| 2284 | +// |
| 2285 | +// if (MapUtils.isNotEmpty(serverDetails)) { |
| 2286 | +// UserVmVO userVm = _userVmDao.findById(vmProfile.getId()); |
| 2287 | +// _userVmDao.loadDetails(userVm); |
| 2288 | +// Map<String, String> details = userVm.getDetails(); |
| 2289 | +// details.putAll(serverDetails); |
| 2290 | +// userVm.setDetails(details); |
| 2291 | +// _userVmDao.saveDetails(userVm); |
| 2292 | +// } |
2300 | 2293 | }
|
2301 | 2294 |
|
2302 | 2295 | @Override
|
|
0 commit comments