private NicProfile findNicProfileById(final VirtualMachineProfile vm, final long id) { for (final NicProfile nic : vm.getNics()) { if (nic.getId() == id) { return nic; } } return null; }
protected NicProfile getNicProfileByTrafficType(final VirtualMachineProfile profile, final TrafficType trafficType) { for (final NicProfile nic : profile.getNics()) { if (nic.getTrafficType() == trafficType && nic.getIPv4Address() != null) { return nic; } } return null; }
@Override public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) { //NetScalerLB vm starts up with 3 Nics //Nic #1 - NS IP //Nic #2 - locallink(guest network) //Nic #3 - public nic for (final NicProfile nic : profile.getNics()) { if(nic.getTrafficType() == TrafficType.Control) { nic.setTrafficType(TrafficType.Guest); } } return true; }
Network guestNetwork = null; for (final NicProfile nic : profile.getNics()) { final int deviceId = nic.getDeviceId(); buf.append(" eth").append(deviceId).append("ip=").append(nic.getIPv4Address());
for (NicProfile nic : profile.getNics()) { int deviceId = nic.getDeviceId(); if (nic.getIPv4Address() == null) {
@Override public boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) { List<NicProfile> elbNics = profile.getNics(); Long guestNtwkId = null; for (NicProfile routerNic : elbNics) { String defaultDns2 = null; for (NicProfile nic : profile.getNics()) { int deviceId = nic.getDeviceId(); buf.append(" eth").append(deviceId).append("ip=").append(nic.getIPv4Address());
String defaultDns2 = null; final Iterator<NicProfile> it = profile.getNics().iterator(); while (it.hasNext()) { final NicProfile nic = it.next();
protected NicProfile getControlNic(final VirtualMachineProfile profile) { final DomainRouterVO router = _routerDao.findById(profile.getId()); final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId()); NicProfile controlNic = null; if (profile.getHypervisorType() == HypervisorType.VMware && dcVo.getNetworkType() == NetworkType.Basic) { // TODO this is a ugly to test hypervisor type here // for basic network mode, we will use the guest NIC for control NIC for (final NicProfile nic : profile.getNics()) { if (nic.getTrafficType() == TrafficType.Guest && nic.getIPv4Address() != null) { controlNic = nic; } } } else { for (final NicProfile nic : profile.getNics()) { if (nic.getTrafficType() == TrafficType.Control && nic.getIPv4Address() != null) { controlNic = nic; } } } return controlNic; }
String defaultIp6Dns1 = null; String defaultIp6Dns2 = null; for (final NicProfile nic : profile.getNics()) { final int deviceId = nic.getDeviceId(); boolean ipv4 = false, ipv6 = false;
@Override public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile profile) { NicProfile managementNic = null; NicProfile controlNic = null; for (NicProfile nic : profile.getNics()) { if (nic.getTrafficType() == TrafficType.Management) { managementNic = nic; } else if (nic.getTrafficType() == TrafficType.Control && nic.getIPv4Address() != null) { controlNic = nic; } } if (controlNic == null) { if (managementNic == null) { s_logger.error("Management network doesn't exist for the console proxy vm " + profile.getVirtualMachine()); return false; } controlNic = managementNic; } // verify ssh access on management nic for system vm running on HyperV if(profile.getHypervisorType() == HypervisorType.Hyperv) { controlNic = managementNic; } CheckSshCommand check = new CheckSshCommand(profile.getInstanceName(), controlNic.getIPv4Address(), 3922); cmds.addCommand("checkSsh", check); return true; }
@Override public boolean finalizeDeployment(final Commands cmds, final VirtualMachineProfile profile, final DeployDestination dest, final ReservationContext context) throws ResourceUnavailableException { final DomainRouterVO internalLbVm = _internalLbVmDao.findById(profile.getId()); final List<NicProfile> nics = profile.getNics(); for (final NicProfile nic : nics) { if (nic.getTrafficType() == TrafficType.Control) { internalLbVm.setPrivateIpAddress(nic.getIPv4Address()); internalLbVm.setPrivateMacAddress(nic.getMacAddress()); } } _internalLbVmDao.update(internalLbVm.getId(), internalLbVm); finalizeCommandsOnStart(cmds, profile); return true; }
final List<Command> nicExpungeCommands = hvGuru.finalizeExpungeNics(vm, profile.getNics()); _networkMgr.cleanupNics(profile);
@Override public boolean finalizeDeployment(final Commands cmds, final VirtualMachineProfile profile, final DeployDestination dest, final ReservationContext context) throws ResourceUnavailableException { final DomainRouterVO router = _routerDao.findById(profile.getId()); final List<NicProfile> nics = profile.getNics(); for (final NicProfile nic : nics) { if (nic.getTrafficType() == TrafficType.Public) { router.setPublicIpAddress(nic.getIPv4Address()); router.setPublicNetmask(nic.getIPv4Netmask()); router.setPublicMacAddress(nic.getMacAddress()); } else if (nic.getTrafficType() == TrafficType.Control) { router.setPrivateIpAddress(nic.getIPv4Address()); router.setPrivateMacAddress(nic.getMacAddress()); } } _routerDao.update(router.getId(), router); finalizeCommandsOnStart(cmds, profile); return true; }
@Override public final VirtualMachineTO implement(VirtualMachineProfile vm) { VirtualMachineTO to = toVirtualMachineTO(vm); List<NicProfile> nicProfiles = vm.getNics();
@Override public void rollbackNicForMigration(final VirtualMachineProfile src, final VirtualMachineProfile dst) { for (final NicProfile nicDst : dst.getNics()) { final NetworkVO network = _networksDao.findById(nicDst.getNetworkId()); final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName()); final NicProfile nicSrc = findNicProfileById(src, nicDst.getId()); final ReservationContext src_context = new ReservationContextImpl(nicSrc.getReservationId(), null, null); final ReservationContext dst_context = new ReservationContextImpl(nicDst.getReservationId(), null, null); if (guru instanceof NetworkMigrationResponder) { ((NetworkMigrationResponder)guru).rollbackMigration(nicDst, network, dst, src_context, dst_context); } final List<Provider> providersToImplement = getNetworkProviders(network.getId()); for (final NetworkElement element : networkElements) { if (providersToImplement.contains(element.getProvider())) { if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network), element.getProvider().getName())) { throw new CloudRuntimeException("Service provider " + element.getProvider().getName() + " either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId()); } if (element instanceof NetworkMigrationResponder) { ((NetworkMigrationResponder)element).rollbackMigration(nicDst, network, dst, src_context, dst_context); } } } } }
@Override public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException { DomainRouterVO elbVm = _routerDao.findById(profile.getVirtualMachine().getId()); List<NicProfile> nics = profile.getNics(); for (NicProfile nic : nics) { if (nic.getTrafficType() == TrafficType.Public) { elbVm.setPublicIpAddress(nic.getIPv4Address()); elbVm.setPublicNetmask(nic.getIPv4Netmask()); elbVm.setPublicMacAddress(nic.getMacAddress()); } else if (nic.getTrafficType() == TrafficType.Control) { elbVm.setPrivateIpAddress(nic.getIPv4Address()); elbVm.setPrivateMacAddress(nic.getMacAddress()); } } _routerDao.update(elbVm.getId(), elbVm); finalizeCommandsOnStart(cmds, profile); return true; }
to.setBootArgs(vmProfile.getBootArgs()); List<NicProfile> nicProfiles = vmProfile.getNics(); NicTO[] nics = new NicTO[nicProfiles.size()]; int i = 0;
@Override public void commitNicForMigration(final VirtualMachineProfile src, final VirtualMachineProfile dst) { for (final NicProfile nicSrc : src.getNics()) { final NetworkVO network = _networksDao.findById(nicSrc.getNetworkId()); final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName()); final NicProfile nicDst = findNicProfileById(dst, nicSrc.getId()); final ReservationContext src_context = new ReservationContextImpl(nicSrc.getReservationId(), null, null); final ReservationContext dst_context = new ReservationContextImpl(nicDst.getReservationId(), null, null); if (guru instanceof NetworkMigrationResponder) { ((NetworkMigrationResponder)guru).commitMigration(nicSrc, network, src, src_context, dst_context); } final List<Provider> providersToImplement = getNetworkProviders(network.getId()); for (final NetworkElement element : networkElements) { if (providersToImplement.contains(element.getProvider())) { if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network), element.getProvider().getName())) { throw new CloudRuntimeException("Service provider " + element.getProvider().getName() + " either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId()); } if (element instanceof NetworkMigrationResponder) { ((NetworkMigrationResponder)element).commitMigration(nicSrc, network, src, src_context, dst_context); } } } // update the reservation id final NicVO nicVo = _nicDao.findById(nicDst.getId()); nicVo.setReservationId(nicDst.getReservationId()); _nicDao.persist(nicVo); } }
@Override public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) { finalizeCommandsOnStart(cmds, profile); ConsoleProxyVO proxy = _consoleProxyDao.findById(profile.getId()); DataCenter dc = dest.getDataCenter(); List<NicProfile> nics = profile.getNics(); for (NicProfile nic : nics) { if ((nic.getTrafficType() == TrafficType.Public && dc.getNetworkType() == NetworkType.Advanced) || (nic.getTrafficType() == TrafficType.Guest && (dc.getNetworkType() == NetworkType.Basic || dc.isSecurityGroupEnabled()))) { proxy.setPublicIpAddress(nic.getIPv4Address()); proxy.setPublicNetmask(nic.getIPv4Netmask()); proxy.setPublicMacAddress(nic.getMacAddress()); } else if (nic.getTrafficType() == TrafficType.Management) { proxy.setPrivateIpAddress(nic.getIPv4Address()); proxy.setPrivateMacAddress(nic.getMacAddress()); } } _consoleProxyDao.update(proxy.getId(), proxy); return true; }