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.setFormat(AddressFormat.Ip4); if(nic.getMacAddress() == null) { nic.setMacAddress(_networkModel.getNextAvailableMacAddressInNetwork(network.getId()));
nic.setFormat(AddressFormat.Ip4);
nic.setFormat(AddressFormat.Ip4); nic.setIPv4Gateway(ip.getGateway()); nic.setIPv4Netmask(ip.getNetmask());
nic.setIPv4Address("0.0.0.0"); nic.setIPv4Netmask("0.0.0.0"); nic.setFormat(AddressFormat.Ip4); nic.setIPv4Gateway("0.0.0.0"); return; nic.setMacAddress(NetUtils.long2Mac(NetUtils.ip2Long(ip) | (14l << 40))); nic.setIPv4Netmask("255.255.0.0"); nic.setFormat(AddressFormat.Ip4); nic.setIPv4Gateway(NetUtils.getLinkLocalGateway());
@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 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()); }
else nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(ip.getVlanTag())); nic.setFormat(AddressFormat.Ip4); nic.setReservationId(String.valueOf(ip.getVlanTag())); if(nic.getMacAddress() == null) {
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()); }
privateNicProfile.setFormat(AddressFormat.Ip4); privateNicProfile.setReservationId(String.valueOf(ip.getBroadcastUri())); privateNicProfile.setMacAddress(ip.getMacAddress());
nic.setFormat(AddressFormat.Ip4);