private UnPlugNicAnswer execute(final UnPlugNicCommand cmd) { if (s_logger.isInfoEnabled()) { s_logger.info("Executing resource UnPlugNicCommand " + s_gson.toJson(cmd)); } try { final String vmName = cmd.getVmName(); final NicTO nic = cmd.getNic(); final URI broadcastUri = nic.getBroadcastUri(); if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) { throw new InternalErrorException("Unable to unassign a public IP to a VIF on network " + nic.getBroadcastUri()); } final String vlanId = BroadcastDomainType.getValue(broadcastUri); int publicNicInfo = -1; publicNicInfo = getVmNics(vmName, vlanId); if (publicNicInfo > 0) { modifyNicVlan(vmName, "2", publicNicInfo, false, ""); } return new UnPlugNicAnswer(cmd, true, "success"); } catch (final Exception e) { s_logger.error("Unexpected exception: ", e); return new UnPlugNicAnswer(cmd, false, "Unable to execute unPlugNicCommand due to " + e.toString()); } }
final URI broadcastUri = nic.getBroadcastUri(); if (broadcastUri != null && broadcastUri.getScheme().equalsIgnoreCase(Networks.BroadcastDomainType.Vsp.scheme())) { final String path = broadcastUri.getPath();
private PlugNicAnswer execute(final PlugNicCommand cmd) { if (s_logger.isInfoEnabled()) { s_logger.info("Executing resource PlugNicCommand " + s_gson.toJson(cmd)); } try { final String vmName = cmd.getVmName(); final NicTO nic = cmd.getNic(); final URI broadcastUri = nic.getBroadcastUri(); if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) { throw new InternalErrorException("Unable to assign a public IP to a VIF on network " + nic.getBroadcastUri()); } final String vlanId = BroadcastDomainType.getValue(broadcastUri); int publicNicInfo = -1; publicNicInfo = getVmFreeNicIndex(vmName); if (publicNicInfo > 0) { modifyNicVlan(vmName, vlanId, publicNicInfo, true, cmd.getNic().getName()); return new PlugNicAnswer(cmd, true, "success"); } final String msg = " Plug Nic failed for the vm as it has reached max limit of NICs to be added"; s_logger.warn(msg); return new PlugNicAnswer(cmd, false, msg); } catch (final Exception e) { s_logger.error("Unexpected exception: ", e); return new PlugNicAnswer(cmd, false, "Unable to execute PlugNicCommand due to " + e.toString()); } }
if (network == null) { s_logger.error("Network is not configured on the backend for nic " + nic.toString()); throw new CloudRuntimeException("Network for the backend is not configured correctly for network broadcast domain: " + nic.getBroadcastUri()); final URI uri = nic.getBroadcastUri(); final BroadcastDomainType type = nic.getBroadcastType(); if (uri != null && uri.toString().contains("untagged")) { throw new CloudRuntimeException("Unable to support this type of network broadcast domain: " + nic.getBroadcastUri());
protected ExecutionResult prepareNetworkElementCommand(final SetupGuestNetworkCommand cmd) { final NicTO nic = cmd.getNic(); final String domrName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); try { final URI broadcastUri = nic.getBroadcastUri(); final String vlanId = BroadcastDomainType.getValue(broadcastUri); final int ethDeviceNum = getVmNics(domrName, vlanId); if (ethDeviceNum > 0) { nic.setDeviceId(ethDeviceNum); } else { return new ExecutionResult(false, "Prepare SetupGuestNetwork failed due to unable to find the nic"); } } catch (final Exception e) { final String msg = "Prepare SetupGuestNetwork failed due to " + e.toString(); s_logger.warn(msg, e); return new ExecutionResult(false, msg); } return new ExecutionResult(true, null); }
private ExecutionResult prepareNetworkElementCommand(final SetNetworkACLCommand cmd) { final NicTO nic = cmd.getNic(); final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); try { final URI broadcastUri = nic.getBroadcastUri(); final String vlanId = BroadcastDomainType.getValue(broadcastUri); final int ethDeviceNum = getVmNics(routerName, vlanId); if (ethDeviceNum > 0) { nic.setDeviceId(ethDeviceNum); } else { return new ExecutionResult(false, "Prepare SetNetworkACL failed due to unable to find the nic"); } } catch (final Exception e) { final String msg = "Prepare SetNetworkACL failed due to " + e.toString(); s_logger.error(msg, e); return new ExecutionResult(false, msg); } return new ExecutionResult(true, null); }
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)); }
final HashMap<String, String> args = citrixResourceBase.parseDefaultOvsRuleComamnd(BroadcastDomainType.getValue(nic.getBroadcastUri())); final OvsSetTagAndFlowCommand flowCmd = new OvsSetTagAndFlowCommand(args.get("vmName"), args.get("tag"), args.get("vlans"), args.get("seqno"), Long.parseLong(args.get("vmId")));
String logicalSwitchUuid = null; if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) { vlanId = Networks.BroadcastDomainType.getValue(nic.getBroadcastUri()); } else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) { logicalSwitchUuid = Networks.BroadcastDomainType.getValue(nic.getBroadcastUri()); } else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan) { vlanId = NetUtils.getPrimaryPvlanFromUri(nic.getBroadcastUri()); intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), networkRateKBps); } else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vswitch) { String vnetId = Networks.BroadcastDomainType.getValue(nic.getBroadcastUri()); String brName = "OVSTunnel" + vnetId; s_logger.debug("nic " + nic + " needs to be connected to LogicalSwitch " + brName);
String protocol = null; if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan) { vNetId = Networks.BroadcastDomainType.getValue(nic.getBroadcastUri()); protocol = Networks.BroadcastDomainType.getSchemeValue(nic.getBroadcastUri()).scheme(); String logicalSwitchUuid = null; if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) { vlanId = Networks.BroadcastDomainType.getValue(nic.getBroadcastUri()); } else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) { logicalSwitchUuid = Networks.BroadcastDomainType.getValue(nic.getBroadcastUri()); } else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan) { vlanId = NetUtils.getPrimaryPvlanFromUri(nic.getBroadcastUri());
protected String getNetwork(NicTO nic) throws XmlRpcException { String vlanId = null; String bridgeName = null; if (nic.getBroadcastType() == BroadcastDomainType.Vlan) { vlanId = BroadcastDomainType.getValue(nic.getBroadcastUri()); } if (nic.getType() == TrafficType.Guest) { if (nic.getBroadcastType() == BroadcastDomainType.Vlan && !vlanId.equalsIgnoreCase("untagged")) { bridgeName = createVlanBridge(_guestNetworkName, vlanId); } else { bridgeName = _guestNetworkName; } } else if (nic.getType() == TrafficType.Control) { throw new CloudRuntimeException("local link network is not supported"); } else if (nic.getType() == TrafficType.Public) { throw new CloudRuntimeException("public network for system vm is not supported"); } else if (nic.getType() == TrafficType.Management) { bridgeName = _privateNetworkName; } else { throw new CloudRuntimeException("Unkonw network traffic type:" + nic.getType()); } return bridgeName; }
String protocol = null; if (isBroadcastTypeVlanOrVxlan(nic)) { vNetId = Networks.BroadcastDomainType.getValue(nic.getBroadcastUri()); protocol = Networks.BroadcastDomainType.getSchemeValue(nic.getBroadcastUri()).scheme(); } else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) { throw new InternalErrorException("Nicira NVP Logicalswitches are not supported by the BridgeVifDriver");
String bridgeName = null; if (nic.getBroadcastType() == BroadcastDomainType.Vlan) { vlanId = BroadcastDomainType.getValue(nic.getBroadcastUri());