davidjumani commented on a change in pull request #4040: URL: https://github.com/apache/cloudstack/pull/4040#discussion_r419873040
########## File path: plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPvlanSetupCommandWrapper.java ########## @@ -66,41 +58,29 @@ public Answer execute(final PvlanSetupCommand command, final LibvirtComputingRes final String ovsPvlanDhcpHostPath = libvirtComputingResource.getOvsPvlanDhcpHostPath(); final Script script = new Script(ovsPvlanDhcpHostPath, timeout, s_logger); - if (add) { - final LibvirtUtilitiesHelper libvirtUtilitiesHelper = libvirtComputingResource.getLibvirtUtilitiesHelper(); - final Connect conn = libvirtUtilitiesHelper.getConnectionByVmName(dhcpName); - - final List<InterfaceDef> ifaces = libvirtComputingResource.getInterfaces(conn, dhcpName); - final InterfaceDef guestNic = ifaces.get(0); - script.add(opr, "-b", guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-n", dhcpName, "-d", dhcpIp, "-m", dhcpMac, "-I", - guestNic.getDevName()); - } else { - script.add(opr, "-b", guestBridgeName, "-p", primaryPvlan, "-i", isolatedPvlan, "-n", dhcpName, "-d", dhcpIp, "-m", dhcpMac); - } - + script.add(opr, pvlanType, "-b", guestBridgeName, "-p", primaryPvlan, "-s", isolatedPvlan, "-m", dhcpMac, "-d", dhcpIp); result = script.execute(); if (result != null) { s_logger.warn("Failed to program pvlan for dhcp server with mac " + dhcpMac); - return new Answer(command, false, result); } else { s_logger.info("Programmed pvlan for dhcp server with mac " + dhcpMac); } - } else if (command.getType() == PvlanSetupCommand.Type.VM) { - final String ovsPvlanVmPath = libvirtComputingResource.getOvsPvlanVmPath(); - - final Script script = new Script(ovsPvlanVmPath, timeout, s_logger); - script.add(opr, pvlanType, "-b", guestBridgeName, "-p", primaryPvlan, "-s", isolatedPvlan, "-v", vmMac); - result = script.execute(); + } - if (result != null) { - s_logger.warn("Failed to program pvlan for vm with mac " + vmMac); - return new Answer(command, false, result); - } else { - s_logger.info("Programmed pvlan for vm with mac " + vmMac); - } + // We run this even for DHCP servers since they're all vms after all + final String ovsPvlanVmPath = libvirtComputingResource.getOvsPvlanVmPath(); + final Script script = new Script(ovsPvlanVmPath, timeout, s_logger); + script.add(opr, pvlanType, "-b", guestBridgeName, "-p", primaryPvlan, "-s", isolatedPvlan, "-m", vmMac); + result = script.execute(); + + if (result != null) { + s_logger.warn("Failed to program pvlan for vm with mac " + vmMac); + return new Answer(command, false, result); + } else { + s_logger.info("Programmed pvlan for vm with mac " + vmMac); } - } catch (final LibvirtException e) { + } catch (final Exception e) { Review comment: fixed! ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org