@Override public void deallocate(Network network, NicProfile nic, VirtualMachineProfile vm) { if (s_logger.isDebugEnabled()) { s_logger.debug("Deallocate network: networkId: " + nic.getNetworkId() + ", ip: " + nic.getIPv4Address()); } PrivateIpVO ip = _privateIpDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIPv4Address()); if (ip != null) { _privateIpDao.releaseIpAddress(nic.getIPv4Address(), nic.getNetworkId()); } nic.deallocate(); }
@Override public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { // signal to the dns server that this vm is up and running and set the ip address to hostname mapping. vm.getHostName(); nic.getIPv4Address(); nic.getIPv6Address(); return true; }
@Override public boolean release(Network network, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { vm.getHostName(); nic.getIPv4Address(); nic.getIPv6Address(); // signal to the dns server that the vm is being shutdown and remove the mapping. return true; }
@Override public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException { if (nic.getIPv4Address() == null) { getIp(nic, dest.getDataCenter(), vm, network); } }
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 release(NicProfile nic, VirtualMachineProfile vm, String reservationId) { Network nw = _nwDao.findById(nic.getNetworkId()); if (!_sNwMgr.isStorageIpRangeAvailable(nw.getDataCenterId())) { return super.release(nic, vm, reservationId); } _sNwMgr.releaseIpAddress(nic.getIPv4Address()); s_logger.debug("Release an storage ip " + nic.getIPv4Address()); nic.deallocate(); return true; }
public VspNic buildVspNic(String nicUuid, NicProfile nicProfile) { return buildVspNic(nicUuid, nicProfile.getMacAddress(), nicProfile.getIPv4Address(), nicProfile.getNetworkId(), null); }
protected void finalizeSshAndVersionOnStart(final Commands cmds, final VirtualMachineProfile profile, final DomainRouterVO router, final NicProfile controlNic) { cmds.addCommand("checkSsh", new CheckSshCommand(profile.getInstanceName(), controlNic.getIPv4Address(), 3922)); // Update internal lb vm template/scripts version final GetDomRVersionCmd command = new GetDomRVersionCmd(); command.setAccessDetail(NetworkElementCommand.ROUTER_IP, controlNic.getIPv4Address()); command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); cmds.addCommand("getDomRVersion", command); }
@Override public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException { if (nic.getIPv4Address() == null && nic.getIPv6Address() == null) { allocateDirectIp(nic, network, vm, dest.getDataCenter(), null, null); nic.setReservationStrategy(ReservationStrategy.Create); } }
@Override public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { if (nic.getIPv4Address() == null) { getIp(nic, _entityMgr.findById(DataCenter.class, network.getDataCenterId()), network); nic.setReservationStrategy(ReservationStrategy.Create); } }
public PrivateIpVO retrivePrivateIP(final NetworkTopologyVisitor visitor) { final PrivateIpVO ipVO = visitor.getVirtualNetworkApplianceFactory().getPrivateIpDao().findByIpAndSourceNetworkId(_nicProfile.getNetworkId(), _nicProfile.getIPv4Address()); return ipVO; }
protected void finalizeSshAndVersionAndNetworkUsageOnStart(final Commands cmds, final VirtualMachineProfile profile, final DomainRouterVO router, final NicProfile controlNic) { final DomainRouterVO vr = _routerDao.findById(profile.getId()); cmds.addCommand("checkSsh", new CheckSshCommand(profile.getInstanceName(), controlNic.getIPv4Address(), 3922)); // Update router template/scripts version final GetDomRVersionCmd command = new GetDomRVersionCmd(); command.setAccessDetail(NetworkElementCommand.ROUTER_IP, controlNic.getIPv4Address()); command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); cmds.addCommand("getDomRVersion", command); // Network usage command to create iptables rules final boolean forVpc = vr.getVpcId() != null; if (!forVpc) { cmds.addCommand("networkUsage", new NetworkUsageCommand(controlNic.getIPv4Address(), router.getHostName(), "create", forVpc)); } }
@Override public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { TrafficType trafficType = config.getTrafficType(); assert trafficType == TrafficType.Management || trafficType == TrafficType.Storage : "Well, I can't take care of this config now can I? " + config; if (nic != null) { if (nic.getRequestedIPv4() != null) { throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic); } nic.setReservationStrategy(nic.getIPv4Address() != null ? ReservationStrategy.Create : ReservationStrategy.Start); } else { nic = new NicProfile(ReservationStrategy.Start, null, null, null, null); } return nic; }
protected NicProfile getNicProfileForVm(final Network network, final NicProfile requested, final VirtualMachine vm) { NicProfile nic = null; if (requested != null && requested.getBroadCastUri() != null) { final String broadcastUri = requested.getBroadCastUri().toString(); final String ipAddress = requested.getIPv4Address(); final NicVO nicVO = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(network.getId(), vm.getId(), broadcastUri); if (nicVO != null) { if (ipAddress == null || nicVO.getIPv4Address().equals(ipAddress)) { nic = _networkModel.getNicProfile(vm, network.getId(), broadcastUri); } } } else { final NicVO nicVO = _nicDao.findByNtwkIdAndInstanceId(network.getId(), vm.getId()); if (nicVO != null) { nic = _networkModel.getNicProfile(vm, network.getId(), null); } } return nic; }
@Override @DB public boolean release(final Network network, NicProfile nic, final VirtualMachineProfile vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { if (!isTypeSupported(vm.getType())) { s_logger.info("GloboDNS only manages records for VMs of type User, ConsoleProxy and DomainRouter. VM " + vm + " is " + vm.getType()); return false; } Long zoneId = network.getDataCenterId(); final DataCenter zone = _dcDao.findById(zoneId); if (zone == null) { throw new CloudRuntimeException("Could not find zone associated to this network"); } RemoveRecordCommand cmd = new RemoveRecordCommand(hostNameOfVirtualMachine(vm), nic.getIPv4Address(), network.getNetworkDomain(), GloboDNSOverride.value()); callCommand(cmd, zoneId); return true; }
@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; }
@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; }
@Override public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException { _router = router; String op = "add"; if (!_isAddPvlan) { op = "delete"; } NetworkDao networkDao = visitor.getVirtualNetworkApplianceFactory().getNetworkDao(); final Network network = networkDao.findById(_nic.getNetworkId()); NetworkModel networkModel = visitor.getVirtualNetworkApplianceFactory().getNetworkModel(); final String networkTag = networkModel.getNetworkTag(_router.getHypervisorType(), network); _setupCommand = PvlanSetupCommand.createDhcpSetup(op, _nic.getBroadCastUri(), networkTag, _router.getInstanceName(), _nic.getMacAddress(), _nic.getIPv4Address()); return visitor.visit(this); }
protected void applyProfileToNicForRelease(final NicVO vo, final NicProfile profile) { vo.setIPv4Gateway(profile.getIPv4Gateway()); vo.setAddressFormat(profile.getFormat()); vo.setIPv4Address(profile.getIPv4Address()); vo.setIPv6Address(profile.getIPv6Address()); vo.setMacAddress(profile.getMacAddress()); if (profile.getReservationStrategy() != null) { vo.setReservationStrategy(profile.getReservationStrategy()); } vo.setBroadcastUri(profile.getBroadCastUri()); vo.setIsolationUri(profile.getIsolationUri()); vo.setIPv4Netmask(profile.getIPv4Netmask()); }
private boolean configureConfigDriveData(final VirtualMachineProfile profile, final NicProfile nic) { final UserVmVO vm = _userVmDao.findById(profile.getId()); if (vm.getType() != VirtualMachine.Type.User) { return false; } final Nic defaultNic = _networkModel.getDefaultNic(vm.getId()); if (defaultNic != null) { final String sshPublicKey = getSshKey(profile); final String serviceOffering = _serviceOfferingDao.findByIdIncludingRemoved(vm.getId(), vm.getServiceOfferingId()).getDisplayText(); boolean isWindows = _guestOSCategoryDao.findById(_guestOSDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows"); final List<String[]> vmData = _networkModel.generateVmData(vm.getUserData(), serviceOffering, vm.getDataCenterId(), vm.getInstanceName(), vm.getHostName(), vm.getId(), vm.getUuid(), nic.getIPv4Address(), sshPublicKey, (String) profile.getParameter(VirtualMachineProfile.Param.VmPassword), isWindows); profile.setVmData(vmData); profile.setConfigDriveLabel(VirtualMachineManager.VmConfigDriveLabel.value()); } return true; }