2 * Copyright (c) 2013 Cisco 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.openflowplugin.test
10 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
11 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration
12 import org.opendaylight.controller.sal.binding.api.NotificationProviderService
13 import org.opendaylight.controller.sal.binding.api.data.DataProviderService
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInput
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInput
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInput
23 import org.opendaylight.yangtools.concepts.CompositeObjectRegistration
24 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
25 import org.slf4j.LoggerFactory
27 class OpenflowpluginTestServiceProvider implements AutoCloseable, SalMeterService {
30 static val LOG = LoggerFactory.getLogger(OpenflowpluginTestServiceProvider);
33 DataProviderService dataService;
36 RoutedRpcRegistration<SalMeterService> meterRegistration;
40 NotificationProviderService notificationService;
44 LOG.info("SalMeterServiceProvider Started.");
50 LOG.info("SalMeterServiceProvide stopped.");
51 meterRegistration.close;
54 override addMeter(AddMeterInput input) {
55 LOG.info("addMeter - " + input);
60 override removeMeter(RemoveMeterInput input) {
61 LOG.info("removeMeter - " + input);
65 override updateMeter(UpdateMeterInput input) {
66 LOG.info("updateMeter - " + input);
71 def CompositeObjectRegistration<OpenflowpluginTestServiceProvider> register(ProviderContext ctx) {
72 val builder = CompositeObjectRegistration
73 .<OpenflowpluginTestServiceProvider> builderFor(this);
75 meterRegistration = ctx.addRoutedRpcImplementation(SalMeterService, this);
76 val nodeIndentifier = InstanceIdentifier.builder(Nodes).child(Node, new NodeKey(new NodeId(OpenflowpluginTestActivator.NODE_ID)));
77 meterRegistration.registerPath(NodeContext, nodeIndentifier.toInstance());
78 builder.add(meterRegistration);
80 return builder.toInstance();