@Override
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) {
UserVmVO userVm = _vmDao.findById(profile.getId());
List<NicVO> nics = _nicDao.listByVmId(userVm.getId());
for (NicVO nic : nics) {
NetworkVO network = _networkDao.findById(nic.getNetworkId());
if (network.getTrafficType() == TrafficType.Guest || network.getTrafficType() == TrafficType.Public) {
userVm.setPrivateIpAddress(nic.getIPv4Address());
userVm.setPrivateMacAddress(nic.getMacAddress());
_vmDao.update(userVm.getId(), userVm);
}
}
List<VolumeVO> volumes = _volsDao.findByInstance(userVm.getId());
VmDiskStatisticsVO diskstats = null;
for (VolumeVO volume : volumes) {
diskstats = _vmDiskStatsDao.findBy(userVm.getAccountId(), userVm.getDataCenterId(), userVm.getId(), volume.getId());
if (diskstats == null) {
diskstats = new VmDiskStatisticsVO(userVm.getAccountId(), userVm.getDataCenterId(), userVm.getId(), volume.getId());
_vmDiskStatsDao.persist(diskstats);
}
}
finalizeCommandsOnStart(cmds, profile);
return true;
}