@Override public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { if (vm.getHypervisorType() == HypervisorType.VMware && !isRouterVm(vm)) { NicProfile nicProf = new NicProfile(Nic.ReservationStrategy.Create, null, null, null, null); String mac = _networkMgr.getNextAvailableMacAddressInNetwork(config.getId()); nicProf.setMacAddress(mac); return nicProf; } if (nic != null) { throw new CloudRuntimeException("Does not support nic specification at this time: " + nic); } return new NicProfile(Nic.ReservationStrategy.Start, null, null, null, null); }
@Override public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException { DataCenterVO dc = _dcDao.findById(network.getDataCenterId()); ReservationStrategy rsStrategy = ReservationStrategy.Start; _dcDao.loadDetails(dc); String dhcpStrategy = dc.getDetail(ZoneConfig.DhcpStrategy.key()); if ("external".equalsIgnoreCase(dhcpStrategy)) { rsStrategy = ReservationStrategy.Create; } if (nic == null) { nic = new NicProfile(rsStrategy, null, null, null, null); } else if (nic.getIPv4Address() == null) { nic.setReservationStrategy(ReservationStrategy.Start); } else { nic.setReservationStrategy(ReservationStrategy.Create); } if (rsStrategy == ReservationStrategy.Create) { String mac = _networkModel.getNextAvailableMacAddressInNetwork(network.getId()); nic.setMacAddress(mac); } return nic; }
defaultNic.setIPv4Gateway(sourceNatIp.getGateway()); defaultNic.setIPv4Netmask(sourceNatIp.getNetmask()); defaultNic.setMacAddress(sourceNatIp.getMacAddress()); if (peerNic != null) { s_logger.info("Use same MAC as previous RvR, the MAC is " + peerNic.getMacAddress()); defaultNic.setMacAddress(peerNic.getMacAddress());
try { String macAddress = _networkModel.getNextAvailableMacAddressInNetwork(network.getId()); nicProfile.setMacAddress(macAddress); } catch (InsufficientAddressCapacityException e) { throw new CloudRuntimeException(String.format("Cannot get next available mac address in [network id='%s']", network.getId()), e);
@Override @DB public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { Host host = dest.getHost(); if (vm.getType() != Type.User || vm.getHypervisorType() != HypervisorType.BareMetal) { return false; } nic.setMacAddress(host.getPrivateMacAddress()); NicVO vo = _nicDao.findById(nic.getId()); assert vo != null : "Where ths nic " + nic.getId() + " going???"; vo.setMacAddress(nic.getMacAddress()); _nicDao.update(vo.getId(), vo); return true; }
private void getBaremetalIp(NicProfile nic, Pod pod, VirtualMachineProfile vm, Network network, String requiredIp) throws InsufficientAddressCapacityException, ConcurrentOperationException { DataCenter dc = _dcDao.findById(pod.getDataCenterId()); if (nic.getIPv4Address() == null) { s_logger.debug(String.format("Requiring ip address: %s", nic.getIPv4Address())); PublicIp ip = _ipAddrMgr.assignPublicIpAddress(dc.getId(), pod.getId(), vm.getOwner(), VlanType.DirectAttached, network.getId(), requiredIp, false, false); nic.setIPv4Address(ip.getAddress().toString()); nic.setFormat(AddressFormat.Ip4); nic.setIPv4Gateway(ip.getGateway()); nic.setIPv4Netmask(ip.getNetmask()); if (ip.getVlanTag() != null && ip.getVlanTag().equalsIgnoreCase(Vlan.UNTAGGED)) { nic.setIsolationUri(IsolationType.Ec2.toUri(Vlan.UNTAGGED)); nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(Vlan.UNTAGGED)); nic.setBroadcastType(BroadcastDomainType.Native); } nic.setReservationId(String.valueOf(ip.getVlanTag())); nic.setMacAddress(ip.getMacAddress()); } nic.setIPv4Dns1(dc.getDns1()); nic.setIPv4Dns2(dc.getDns2()); } }
nic.setMacAddress(mac); return; } else { nic.setMacAddress(mac); nic.setIPv4Address("0.0.0.0"); nic.setIPv4Netmask("0.0.0.0"); nic.setMacAddress(NetUtils.long2Mac(NetUtils.ip2Long(ip) | (14l << 40))); nic.setIPv4Netmask("255.255.0.0"); nic.setFormat(AddressFormat.Ip4);
nic.setFormat(AddressFormat.Ip4); if(nic.getMacAddress() == null) { nic.setMacAddress(_networkModel.getNextAvailableMacAddressInNetwork(network.getId()));
profile.setIPv4Netmask(publicIp.getNetmask()); profile.setIPv4Gateway(publicIp.getGateway()); profile.setMacAddress(publicIp.getMacAddress()); profile.setBroadcastType(network.getBroadcastDomainType()); profile.setTrafficType(network.getTrafficType());
defaultNic.setIPv4Gateway(ip.getGateway()); defaultNic.setIPv4Netmask(ip.getNetmask()); defaultNic.setMacAddress(ip.getMacAddress()); defaultNic.setBroadcastType(BroadcastDomainType.Vlan); defaultNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(ip.getVlanTag()));
@Override public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException { DataCenter dc = _dcDao.findById(network.getDataCenterId()); if (nic == null) { nic = new NicProfile(ReservationStrategy.Create, null, null, null, null); } else if (nic.getIPv4Address() == null && nic.getIPv6Address() == null) { nic.setReservationStrategy(ReservationStrategy.Start); } else { nic.setReservationStrategy(ReservationStrategy.Create); } allocateDirectIp(nic, network, vm, dc, nic.getRequestedIPv4(), nic.getRequestedIPv6()); nic.setReservationStrategy(ReservationStrategy.Create); if (nic.getMacAddress() == null) { nic.setMacAddress(_networkModel.getNextAvailableMacAddressInNetwork(network.getId())); if (nic.getMacAddress() == null) { throw new InsufficientAddressCapacityException("Unable to allocate more mac addresses", Network.class, network.getId()); } } return nic; }
nic.setMacAddress(ip.getMacAddress());
@Override public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { if (!_sNwMgr.isStorageIpRangeAvailable(dest.getDataCenter().getId())) { super.reserve(nic, network, vm, dest, context); return; } Pod pod = dest.getPod(); Integer vlan = null; StorageNetworkIpAddressVO ip = _sNwMgr.acquireIpAddress(pod.getId()); if (ip == null) { throw new InsufficientAddressCapacityException("Unable to get a storage network ip address", Pod.class, pod.getId()); } vlan = ip.getVlan(); nic.setIPv4Address(ip.getIpAddress()); nic.setMacAddress(NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ip.getMac(), NetworkModel.MACIdentifier.value()))); nic.setFormat(AddressFormat.Ip4); nic.setIPv4Netmask(ip.getNetmask()); nic.setBroadcastType(BroadcastDomainType.Storage); nic.setIPv4Gateway(ip.getGateway()); if (vlan != null) { nic.setBroadcastUri(BroadcastDomainType.Storage.toUri(vlan)); } else { nic.setBroadcastUri(null); } nic.setIsolationUri(null); s_logger.debug("Allocated a storage nic " + nic + " for " + vm); }
@Override @DB public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { if (vm.getType() != Type.User || vm.getHypervisorType() != HypervisorType.BareMetal) { return false; } VMInstanceVO vo = _vmDao.findById(vm.getId()); assert vo != null : "Where ths nic " + nic.getId() + " going???"; if (vo.getLastHostId() == null) { nic.setMacAddress(dest.getHost().getPrivateMacAddress()); NicVO nicVo = _nicDao.findById(nic.getId()); nicVo.setMacAddress(nic.getMacAddress()); _nicDao.update(nicVo.getId(), nicVo); /*This vm is just being created */ if (!_pxeMgr.prepare(vm, nic, network, dest, context)) { throw new CloudRuntimeException("Cannot prepare pxe server"); } } if (dest.getDataCenter().getNetworkType() == DataCenter.NetworkType.Advanced){ prepareVlan(network, dest); } return true; }
privateNicProfile.setMacAddress(newMacAddress); privateNicProfile.setFormat(AddressFormat.Ip4); privateNicProfile.setReservationId(String.valueOf(ip.getBroadcastUri())); privateNicProfile.setMacAddress(ip.getMacAddress());
@Override public void reserve(NicProfile nic, Network config, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { Pod pod = dest.getPod(); boolean forSystemVms = vm.getType().equals(VirtualMachine.Type.ConsoleProxy) || vm.getType().equals(VirtualMachine.Type.SecondaryStorageVm); PrivateAllocationData result = _dcDao.allocatePrivateIpAddress(dest.getDataCenter().getId(), dest.getPod().getId(), nic.getId(), context.getReservationId(), forSystemVms); if (result == null) { throw new InsufficientAddressCapacityException("Unable to get a management ip address", Pod.class, pod.getId()); } Integer vlan = result.getVlan(); nic.setIPv4Address(result.getIpAddress()); nic.setMacAddress(NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(result.getMacAddress(), NetworkModel.MACIdentifier.value()))); nic.setIPv4Gateway(pod.getGateway()); nic.setFormat(AddressFormat.Ip4); String netmask = NetUtils.getCidrNetmask(pod.getCidrSize()); nic.setIPv4Netmask(netmask); nic.setBroadcastType(BroadcastDomainType.Native); if (vlan != null) { nic.setBroadcastUri(BroadcastDomainType.Native.toUri(vlan)); } else { nic.setBroadcastUri(null); } nic.setIsolationUri(null); s_logger.debug("Allocated a nic " + nic + " for " + vm); }
protected void getIp(NicProfile nic, DataCenter dc, Network network) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { if (nic.getIPv4Address() == null) { PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(network.getDataCenterId(), network.getId(), null); String vlanTag = BroadcastDomainType.getValue(network.getBroadcastUri()); String netmask = NetUtils.getCidrNetmask(network.getCidr()); PrivateIpAddress ip = new PrivateIpAddress(ipVO, vlanTag, network.getGateway(), netmask, NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress(), NetworkModel.MACIdentifier.value()))); nic.setIPv4Address(ip.getIpAddress()); nic.setIPv4Gateway(ip.getGateway()); nic.setIPv4Netmask(ip.getNetmask()); nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getBroadcastUri())); nic.setBroadcastUri(IsolationType.Vlan.toUri(ip.getBroadcastUri())); nic.setBroadcastType(BroadcastDomainType.Vlan); nic.setFormat(AddressFormat.Ip4); nic.setReservationId(String.valueOf(ip.getBroadcastUri())); nic.setMacAddress(ip.getMacAddress()); } nic.setIPv4Dns1(dc.getDns1()); nic.setIPv4Dns2(dc.getDns2()); }
nic.setReservationId(String.valueOf(ip.getVlanTag())); if(nic.getMacAddress() == null) { nic.setMacAddress(ip.getMacAddress());
protected void getIp(NicProfile nic, DataCenter dc, VirtualMachineProfile vm, Network network) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException { if (nic.getIPv4Address() == null) { boolean forSystemVms = false; if (vm.getType().equals(VirtualMachine.Type.ConsoleProxy) || vm.getType().equals(VirtualMachine.Type.SecondaryStorageVm)) { forSystemVms = true; } PublicIp ip = _ipAddrMgr.assignPublicIpAddress(dc.getId(), null, vm.getOwner(), VlanType.VirtualNetwork, null, null, false, forSystemVms); nic.setIPv4Address(ip.getAddress().toString()); nic.setIPv4Gateway(ip.getGateway()); nic.setIPv4Netmask(ip.getNetmask()); if (network.getBroadcastDomainType() == BroadcastDomainType.Vxlan) { nic.setIsolationUri(BroadcastDomainType.Vxlan.toUri(ip.getVlanTag())); nic.setBroadcastUri(BroadcastDomainType.Vxlan.toUri(ip.getVlanTag())); nic.setBroadcastType(BroadcastDomainType.Vxlan); } else { nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag())); nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(ip.getVlanTag())); nic.setBroadcastType(BroadcastDomainType.Vlan); } nic.setFormat(AddressFormat.Ip4); nic.setReservationId(String.valueOf(ip.getVlanTag())); nic.setMacAddress(ip.getMacAddress()); } nic.setIPv4Dns1(dc.getDns1()); nic.setIPv4Dns2(dc.getDns2()); }
nic.setMacAddress(_networkModel.getNextAvailableMacAddressInNetwork(network.getId())); if (nic.getMacAddress() == null) { throw new InsufficientAddressCapacityException("Unable to allocate more mac addresses", Network.class, network.getId());