8a9f4cb99637502ba8c2e696d2c19687c1c0daf5
[groupbasedpolicy.git] / renderers / vpp / src / main / java / org / opendaylight / groupbasedpolicy / renderer / vpp / util / InterfaceUtil.java
1 /*
2  * Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.groupbasedpolicy.renderer.vpp.util;
9
10 import com.google.common.base.Optional;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
15 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
16
17 import java.util.List;
18
19 /**
20  * Created by Shakib Ahmed on 7/18/17.
21  */
22 public class InterfaceUtil {
23
24     public static List<Interface> getOperationalInterfaces(DataBroker vppDataBroker) {
25         final Optional<InterfacesState> opInterfaceState = GbpNetconfTransaction.read(vppDataBroker,
26                 LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(InterfacesState.class),
27                 GbpNetconfTransaction.RETRY_COUNT);
28
29         if (!opInterfaceState.isPresent()) {
30             return null;
31         }
32
33         return opInterfaceState.get().getInterface();
34     }
35 }