2 * Copyright (c) 2015 Brocade Communications Systems, Inc. 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
8 package org.opendaylight.ovsdb.utils.neutron.utils;
10 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
11 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
12 import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortKey;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
23 public class NeutronModelsDataStoreHelper {
25 private static final Logger LOG = LoggerFactory.getLogger(MdsalUtils.class);
26 private DataBroker databroker = null;
27 private MdsalUtils mdsalClient = null;
30 * Class constructor setting the data broker.
32 * @param dataBroker the {@link org.opendaylight.controller.md.sal.binding.api.DataBroker}
34 public NeutronModelsDataStoreHelper(DataBroker dataBroker) {
35 this.databroker = dataBroker;
36 this.mdsalClient = new MdsalUtils(this.databroker);
39 public Routers readAllNeutronRouters() {
40 Routers routers = this.mdsalClient.read(LogicalDatastoreType.CONFIGURATION, getNeutrounRoutersPath());
41 if(routers != null ) {
42 LOG.debug("{} routers present in data store", routers.getRouter()!=null? routers.getRouter().size():0);
47 public Ports readAllNeutronPorts() {
48 Ports ports = this.mdsalClient.read(LogicalDatastoreType.CONFIGURATION, getNeutrounPortsPath());
50 LOG.debug("{} ports present in data store", ports.getPort()!=null? ports.getPort().size():0);
54 public Port readNeutronPort(Uuid portId) {
55 Port mdsalPort = this.mdsalClient.read(LogicalDatastoreType.CONFIGURATION, getNeutronPortPath(portId));
56 if (mdsalPort != null) {
57 LOG.debug("Port {} fetched from config data store for router interface {}",mdsalPort, portId);
62 private InstanceIdentifier<Routers> getNeutrounRoutersPath() {
63 return InstanceIdentifier
64 .create(Neutron.class)
65 .child(Routers.class);
68 private InstanceIdentifier<Ports> getNeutrounPortsPath() {
69 return InstanceIdentifier
70 .create(Neutron.class)
74 private InstanceIdentifier<Port> getNeutronPortPath(Uuid portId) {
75 return InstanceIdentifier
76 .create(Neutron.class)
78 .child(Port.class,new PortKey(portId));