Search in sources :

Example 1 with DhcpSnooperImpl

use of com.cloud.agent.dhcp.DhcpSnooperImpl in project CloudStack-archive by CloudStack-extras.

the class CloudZonesComputingResource method setupDhcpManager.

private void setupDhcpManager(Connect conn, String bridgeName) {
    _dhcpSnooper = new DhcpSnooperImpl(bridgeName, _dhcpTimeout);
    List<Pair<String, String>> macs = new ArrayList<Pair<String, String>>();
    try {
        int[] domainIds = conn.listDomains();
        for (int i = 0; i < domainIds.length; i++) {
            Domain vm = conn.domainLookupByID(domainIds[i]);
            if (vm.getName().startsWith("i-")) {
                List<InterfaceDef> nics = getInterfaces(conn, vm.getName());
                InterfaceDef nic = nics.get(0);
                macs.add(new Pair<String, String>(nic.getMacAddress(), vm.getName()));
            }
        }
    } catch (LibvirtException e) {
        s_logger.debug("Failed to get MACs: " + e.toString());
    }
    _dhcpSnooper.initializeMacTable(macs);
}
Also used : InterfaceDef(com.cloud.agent.resource.computing.LibvirtVMDef.InterfaceDef) LibvirtException(org.libvirt.LibvirtException) DhcpSnooperImpl(com.cloud.agent.dhcp.DhcpSnooperImpl) ArrayList(java.util.ArrayList) Domain(org.libvirt.Domain) Pair(com.cloud.utils.Pair)

Aggregations

DhcpSnooperImpl (com.cloud.agent.dhcp.DhcpSnooperImpl)1 InterfaceDef (com.cloud.agent.resource.computing.LibvirtVMDef.InterfaceDef)1 Pair (com.cloud.utils.Pair)1 ArrayList (java.util.ArrayList)1 Domain (org.libvirt.Domain)1 LibvirtException (org.libvirt.LibvirtException)1