final NicTO nic = command.getNic(); final String dev = "eth" + nic.getDeviceId(); final String netmask = Long.toString(NetUtils.getCidrSize(nic.getNetmask()));
@Override public List<ConfigItem> generateConfig(final NetworkElementCommand cmd) { final SetupGuestNetworkCommand command = (SetupGuestNetworkCommand) cmd; final NicTO nic = command.getNic(); final String routerGIP = command.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP); final String gateway = command.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY); final String cidr = Long.toString(NetUtils.getCidrSize(nic.getNetmask())); final String netmask = nic.getNetmask(); final String domainName = command.getNetworkDomain(); String dns = command.getDefaultDns1(); if (dns == null || dns.isEmpty()) { dns = command.getDefaultDns2(); } else { final String dns2 = command.getDefaultDns2(); if (dns2 != null && !dns2.isEmpty()) { dns += "," + dns2; } } final GuestNetwork guestNetwork = new GuestNetwork(command.isAdd(), nic.getMac(), "eth" + nic.getDeviceId(), routerGIP, netmask, gateway, cidr, dns, domainName); return generateConfigItems(guestNetwork); }
private void createVif(final LibvirtVMDef vm, final NicTO nic, final String nicAdapter, Map<String, String> extraConfig) throws InternalErrorException, LibvirtException { if (nic.getType().equals(TrafficType.Guest) && nic.getBroadcastType().equals(BroadcastDomainType.Vsp)) { String vrIp = nic.getBroadcastUri().getPath().substring(1); vm.getMetaData().getMetadataNode(LibvirtVMDef.NuageExtensionDef.class).addNuageExtension(nic.getMac(), vrIp); if (s_logger.isDebugEnabled()) { s_logger.debug("NIC with MAC " + nic.getMac() + " and BroadcastDomainType " + nic.getBroadcastType() + " in network(" + nic.getGateway() + "/" + nic.getNetmask() + ") is " + nic.getType() + " traffic type. So, vsp-vr-ip " + vrIp + " is set in the metadata"); } } if (vm.getDevices() == null) { s_logger.error("LibvirtVMDef object get devices with null result"); throw new InternalErrorException("LibvirtVMDef object get devices with null result"); } vm.getDevices().addDevice(getVifDriver(nic.getType(), nic.getName()).plug(nic, vm.getPlatformEmulator(), nicAdapter, extraConfig)); }
xenstoreData.put(XENSTORE_DATA_IP, mgmtNic.getIp().toString().trim()); xenstoreData.put(XENSTORE_DATA_GATEWAY, mgmtNic.getGateway().toString().trim()); xenstoreData.put(XENSTORE_DATA_NETMASK, mgmtNic.getNetmask().toString().trim()); vmr.xenstoreData = xenstoreData;