2 * Copyright (c) 2015 Inocybe Technologies and others. All rights reserved.
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
9 package org.opendaylight.groupbasedpolicy.renderer.iovisor.utils;
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.groupbasedpolicy.util.DataStoreHelper;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.iovisor.rev151030.IovisorModule;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.iovisor.rev151030.IovisorModuleInstances;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.iovisor.rev151030.iovisor.module.instances.IovisorModuleInstance;
19 import com.google.common.base.Optional;
21 public class IovisorModuleUtils {
23 private IovisorModuleUtils() {
27 * Make sure the specified IOvisor module Uri exists in the datastore.
28 * @param dataBroker An instance of the {@link DataBroker}
29 * @param iovisorModuleUri The Uri of the {@link IovisorModule} we want to validate
30 * @return <code>true</code> if validated, else, <code>false</code>
32 public static boolean validateIovisorModuleInstance(DataBroker dataBroker, Uri iovisorModuleUri) {
33 Optional<IovisorModuleInstances> res = DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION,
34 IovisorIidFactory.iovisorModuleInstanceWildCardIid(),
35 dataBroker.newReadOnlyTransaction());
36 if (res.isPresent()) {
37 for (IovisorModuleInstance instance : res.get().getIovisorModuleInstance()) {
38 if (instance.getUri().equals(iovisorModuleUri)) {