2 * Copyright © 2017 Red Hat, Inc. and others.
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 package org.opendaylight.netvirt.elan.utils;
10 import com.google.common.base.Optional;
11 import javax.inject.Inject;
12 import javax.inject.Singleton;
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTagName;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName;
17 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 public class ElanEtreeUtils {
21 private final DataBroker broker;
24 public ElanEtreeUtils(DataBroker broker) {
28 public EtreeLeafTagName getEtreeLeafTagByElanTag(long elanTag) {
29 InstanceIdentifier<ElanTagName> elanId = ElanUtils.getElanInfoEntriesOperationalDataPath(elanTag);
30 Optional<ElanTagName> existingElanInfo = ElanUtils.read(broker,
31 LogicalDatastoreType.OPERATIONAL, elanId);
32 if (existingElanInfo.isPresent()) {
33 ElanTagName elanTagName = existingElanInfo.get();
34 return elanTagName.augmentation(EtreeLeafTagName.class);