@Override public void reserve( NicProfile nic, Network config, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException { assert nic.getTrafficType() == TrafficType.Control; if (dest.getHost().getHypervisorType() == HypervisorType.VmWare && vm.getType() == VirtualMachine.Type.DomainRouter) { super.reserve(nic, config, vm, dest, context); String mac = _networkMgr.getNextAvailableMacAddressInNetwork(config.getId()); nic.setMacAddress(mac); return; } String ip = _dcDao.allocateLinkLocalIpAddress( dest.getDataCenter().getId(), dest.getPod().getId(), nic.getId(), context.getReservationId()); nic.setIp4Address(ip); nic.setMacAddress(NetUtils.long2Mac(NetUtils.ip2Long(ip) | (14l << 40))); nic.setNetmask("255.255.0.0"); nic.setFormat(AddressFormat.Ip4); nic.setGateway(NetUtils.getLinkLocalGateway()); }
@Override public boolean release( NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, String reservationId) { assert nic.getTrafficType() == TrafficType.Control; if (vm.getHypervisorType() == HypervisorType.VmWare && vm.getType() == VirtualMachine.Type.DomainRouter) { super.release(nic, vm, reservationId); return true; } _dcDao.releaseLinkLocalIpAddress(nic.getId(), reservationId); nic.setIp4Address(null); nic.setMacAddress(null); nic.setNetmask(null); nic.setFormat(null); nic.setGateway(null); return true; }
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { super.configure(name, params); ComponentLocator locator = ComponentLocator.getCurrentLocator(); ConfigurationDao configDao = locator.getDao(ConfigurationDao.class); Map<String, String> dbParams = configDao.getConfiguration(params); _cidr = dbParams.get(Config.ControlCidr); if (_cidr == null) { _cidr = "169.254.0.0/16"; } _gateway = dbParams.get(Config.ControlGateway); if (_gateway == null) { _gateway = NetUtils.getLinkLocalGateway(); } s_logger.info("Control network setup: cidr=" + _cidr + "; gateway = " + _gateway); return true; }