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 java.util.Optional;
11 import javax.inject.Inject;
12 import javax.inject.Singleton;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.mdsal.binding.api.DataBroker;
15 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeLeafTagName;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.tag.name.map.ElanTagName;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
19 import org.opendaylight.yangtools.yang.common.Uint32;
22 public class ElanEtreeUtils {
23 private final DataBroker broker;
26 public ElanEtreeUtils(DataBroker broker) {
31 public EtreeLeafTagName getEtreeLeafTagByElanTag(long elanTag) {
32 InstanceIdentifier<ElanTagName> elanId = ElanUtils
33 .getElanInfoEntriesOperationalDataPath(Uint32.valueOf(elanTag));
34 Optional<ElanTagName> existingElanInfo = ElanUtils.read(broker,
35 LogicalDatastoreType.OPERATIONAL, elanId);
36 if (existingElanInfo.isPresent()) {
37 ElanTagName elanTagName = existingElanInfo.get();
38 return elanTagName.augmentation(EtreeLeafTagName.class);