BUG 6396 neutron-mapper project migration to blueprint 20/43720/4
authorMatej Perina <mperina@cisco.com>
Thu, 18 Aug 2016 12:42:32 +0000 (14:42 +0200)
committerVladimir Lavor <vlavor@cisco.com>
Thu, 25 Aug 2016 07:30:04 +0000 (07:30 +0000)
Change-Id: Ie529605fc79e185ef9e54d9ed6a83e4c228464db
Signed-off-by: Matej Perina <mperina@cisco.com>
neutron-mapper/src/main/config/default-config.xml
neutron-mapper/src/main/java/org/opendaylight/controller/config/yang/config/neutron_mapper/impl/NeutronMapperInstance.java [new file with mode: 0644]
neutron-mapper/src/main/java/org/opendaylight/controller/config/yang/config/neutron_mapper/impl/NeutronMapperModule.java
neutron-mapper/src/main/java/org/opendaylight/groupbasedpolicy/neutron/mapper/NeutronMapper.java
neutron-mapper/src/main/resources/org/opendaylight/blueprint/neutron-mapper.xml [new file with mode: 0644]
neutron-mapper/src/main/yang/neutron-mapper-impl.yang
neutron-mapper/src/test/java/org/opendaylight/groupbasedpolicy/neutron/mapper/NeutronMapperTest.java

index 2ba6576cf9c555ba5fbfcb172acd962456a942f9..725473dd851b0e66bf8630367a1e09753cad4f89 100644 (file)
                         neutron-mapper:neutron-mapper-impl
                     </type>
                     <name>neutron-mapper-impl</name>
-
-                    <rpc-registry>
-                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
-                        <name>binding-rpc-broker</name>
-                    </rpc-registry>
-
-                    <data-broker>
-                      <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
-                      <name>binding-data-broker</name>
-                    </data-broker>
                 </module>
             </modules>
         </data>
diff --git a/neutron-mapper/src/main/java/org/opendaylight/controller/config/yang/config/neutron_mapper/impl/NeutronMapperInstance.java b/neutron-mapper/src/main/java/org/opendaylight/controller/config/yang/config/neutron_mapper/impl/NeutronMapperInstance.java
new file mode 100644 (file)
index 0000000..dc03214
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.yang.config.neutron_mapper.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.groupbasedpolicy.neutron.mapper.NeutronMapper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.BaseEndpointService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.EndpointService;
+
+public class NeutronMapperInstance implements AutoCloseable{
+
+    private NeutronMapper mapper;
+
+    public NeutronMapperInstance (DataBroker dataBroker, EndpointService epService,
+            BaseEndpointService baseEndpointService) {
+        mapper = new NeutronMapper(dataBroker, epService, baseEndpointService);
+    }
+    @Override
+    public void close() throws Exception {
+        mapper.close();
+    }
+}
index 0d543416165febbe196c75057afd58b639516fd9..c3d97adac26dc9d51e1f9b9c0ae281763f7575f9 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.controller.config.yang.config.neutron_mapper.impl;
 
-import org.opendaylight.groupbasedpolicy.neutron.mapper.NeutronMapper;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -31,9 +31,7 @@ public class NeutronMapperModule extends org.opendaylight.controller.config.yang
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        final NeutronMapper neutronMapper = new NeutronMapper(getDataBrokerDependency(), getRpcRegistryDependency());
-        LOG.info("Neutron mapper started.");
-        return neutronMapper;
+        return NoopAutoCloseable.INSTANCE;
     }
 
     public static boolean isDebugEnabled() {
index 71456e34497b4cd594c2ea2e7f83408de08eda9f..ea1ea847c51de79d647e818b5787c842f46e2ca5 100644 (file)
@@ -22,7 +22,6 @@ import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.groupbasedpolicy.neutron.mapper.mapping.NeutronAware;
 import org.opendaylight.groupbasedpolicy.neutron.mapper.mapping.NeutronFloatingIpAware;
 import org.opendaylight.groupbasedpolicy.neutron.mapper.mapping.NeutronNetworkAware;
@@ -105,9 +104,8 @@ public class NeutronMapper implements DataTreeChangeListener<Neutron>, AutoClose
     private Neutron neutronBefore;
     private Neutron neutronAfter;
 
-    public NeutronMapper(DataBroker dataProvider, RpcProviderRegistry rpcProvider) {
-        EndpointService epService = rpcProvider.getRpcService(EndpointService.class);
-        BaseEndpointService baseEpService = rpcProvider.getRpcService(BaseEndpointService.class);
+    public NeutronMapper(DataBroker dataProvider, EndpointService epService,
+            BaseEndpointService baseEpService) {
         EndpointRegistrator epRegistrator = new EndpointRegistrator(epService, baseEpService);
         networkAware = new NeutronNetworkAware(dataProvider);
         securityGroupAware = new NeutronSecurityGroupAware(dataProvider);
diff --git a/neutron-mapper/src/main/resources/org/opendaylight/blueprint/neutron-mapper.xml b/neutron-mapper/src/main/resources/org/opendaylight/blueprint/neutron-mapper.xml
new file mode 100644 (file)
index 0000000..513b844
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           odl:use-default-for-reference-types="true">
+
+    <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+    <odl:rpc-service id="epService" interface="org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.EndpointService"/>
+    <odl:rpc-service id="baseEpService" interface="org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.base_endpoint.rev160427.BaseEndpointService"/>
+
+    <bean id="neutronMapper" class="org.opendaylight.controller.config.yang.config.neutron_mapper.impl.NeutronMapperInstance"
+        destroy-method="close">
+        <argument ref="dataBroker"/>
+        <argument ref="epService"/>
+        <argument ref="baseEpService"/>
+    </bean>
+</blueprint>
\ No newline at end of file
index 2bc1066a8c1c02a6c909e206375a49de9b31b810..d56137bc0c939ab981e1788d2985ddddf9f524db 100644 (file)
@@ -28,25 +28,6 @@ module neutron-mapper-impl {
     augment "/config:modules/config:module/config:configuration" {
         case neutron-mapper-impl {
             when "/config:modules/config:module/config:type = 'neutron-mapper-impl'";
-
-            container data-broker {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity mdsal:binding-async-data-broker;
-                    }
-                }
-            }
-
-            container rpc-registry {
-                uses config:service-ref {
-                    refine type {
-                        mandatory true;
-                        config:required-identity mdsal:binding-rpc-registry;
-                    }
-                }
-            }
-
         }
     }
 }
\ No newline at end of file
index b68e3e16044501066110422bedd36ecdda27a462..059ef8d08e3b12006823da545be68245428f072a 100644 (file)
@@ -19,9 +19,6 @@ import static org.mockito.Mockito.when;
 import java.io.IOException;
 import java.util.Set;
 
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -55,6 +52,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.groups.attributes.security.groups.SecurityGroupBuilder;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
 public class NeutronMapperTest extends NeutronMapperDataBrokerTest {
 
     private final Uuid tenantUuid = new Uuid("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
@@ -82,11 +83,8 @@ public class NeutronMapperTest extends NeutronMapperDataBrokerTest {
         dataBroker = getDataBroker();
         epService = mock(EndpointService.class);
         baseEpService = mock(BaseEndpointService.class);
-        rpcProvider = mock(RpcProviderRegistry.class);
-        when(rpcProvider.getRpcService(EndpointService.class)).thenReturn(epService);
-        when(rpcProvider.getRpcService(BaseEndpointService.class)).thenReturn(baseEpService);
 
-        mapper = new NeutronMapper(dataBroker, rpcProvider);
+        mapper = new NeutronMapper(dataBroker, epService, baseEpService);
 
         networkL3Extension = new NetworkL3ExtensionBuilder().setExternal(true).build();
 
@@ -119,7 +117,7 @@ public class NeutronMapperTest extends NeutronMapperDataBrokerTest {
     @Test
     public void testConstructor() throws IOException {
         DataBroker dataBrokerSpy = spy(dataBroker);
-        NeutronMapper other = new NeutronMapper(dataBrokerSpy, rpcProvider);
+        NeutronMapper other = new NeutronMapper(dataBrokerSpy, epService, baseEpService);
 
         verify(dataBrokerSpy).registerDataTreeChangeListener(new DataTreeIdentifier<>(
                 LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(Neutron.class).build()), other);