2 * Copyright (C) 2014 SDN Hub, LLC.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 * Authors : Srini Seetharaman
11 package org.opendaylight.ovsdb.openstack.netvirt;
13 import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
14 import org.opendaylight.controller.networkconfig.neutron.NeutronPort;
15 import org.opendaylight.controller.networkconfig.neutron.Neutron_IPs;
16 import java.util.Iterator;
17 import java.util.List;
19 public class NeutronCacheUtils {
22 * Look up in the NeutronPortsCRUD cache and return the MAC address for a corresponding IP address
23 * @param ipAddr IP address of a member or VM
24 * @return MAC address registered with that IP address
26 public static String getMacAddress(INeutronPortCRUD neutronPortsCache, String ipAddr) {
30 List<Neutron_IPs> fixedIPs;
31 Iterator<Neutron_IPs> fixedIPIterator;
34 List<NeutronPort> allPorts = neutronPortsCache.getAllPorts();
35 Iterator<NeutronPort> i = allPorts.iterator();
37 NeutronPort port = i.next();
38 fixedIPs = port.getFixedIPs();
39 if (fixedIPs != null && fixedIPs.size() > 0) {
40 fixedIPIterator = fixedIPs.iterator();
41 while (fixedIPIterator.hasNext()) {
42 ip = fixedIPIterator.next();
43 if (ip.getIpAddress().equals(ipAddr))
44 return port.getMacAddress();