--- /dev/null
+module sal-role {
+ namespace "urn:opendaylight:role:service";
+ prefix role;
+
+ import flow-capable-transaction {prefix tr; revision-date "2015-03-04";}
+ import opendaylight-inventory {prefix inv;revision-date "2013-08-19";}
+
+ description "Openflow role management.";
+
+ revision "2015-07-27" {
+ description "Initial revision of role service";
+ }
+
+ typedef ofp-role {
+ description "role of OFPlugin instance";
+ type enumeration {
+ enum NOCHANGE {
+ description "no change to role";
+ }
+
+ enum BECOMEMASTER {
+ description "promote current role to MASTER";
+ }
+
+ enum BECOMESLAVE {
+ description "demote current role to SLAVE";
+ }
+ }
+ }
+
+ rpc set-role {
+ description "Setting role to openflow device.";
+ input {
+ uses tr:transaction-metadata;
+ uses "inv:node-context-ref";
+ leaf controller-role {
+ type ofp-role;
+ }
+ }
+ output {
+ uses tr:transaction-aware;
+ }
+ }
+}
\ No newline at end of file
import org.opendaylight.controller.md.sal.binding.api.NotificationService;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.api.types.rev150327.OfpRole;
/**
* Created by Martin Bobak <mbobak@cisco.com> on 27.3.2015.
void setNotificationPublishService(NotificationPublishService notificationPublishService);
- /**
- * Method sets role of this application in clustered environment.
- */
- void setRole(OfpRole role);
-
/**
* Method initializes all DeviceManager, RpcManager and related contexts.
*/
+++ /dev/null
-module openflow-plugin-types {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:openflowplugin:api:types";
- prefix "openflow-plugin-types";
-
- description
- "Openflow plugin specific types.";
-
- revision "2015-03-27" {
- description
- "Initial revision";
- }
-
- typedef ofp-role {
- description "role of OFPlugin instance";
- type enumeration {
- enum NOCHANGE {
- description "no change to role";
- }
- enum BECOMEMASTER {
- description "promote current role to MASTER";
- }
- enum BECOMESLAVE {
- description "demote current role to SLAVE";
- }
- }
- }
-
-}
\ No newline at end of file
import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionConverterManager;
import org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionConverterManagerImpl;
import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.api.types.rev150327.OfpRole;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private ExtensionConverterManager extensionConverterManager;
private DataBroker dataBroker;
- private OfpRole role;
private Collection<SwitchConnectionProvider> switchConnectionProviders;
private boolean switchFeaturesMandatory = false;
private boolean isStatisticsPollingOff = false;
this.rpcProviderRegistry = rpcProviderRegistry;
}
- @Override
- public void setRole(final OfpRole role) {
- this.role = role;
- }
-
-
@Override
public void initialize() {
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. 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.openflowplugin.impl.services;
+
+import java.util.concurrent.Future;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SalRoleService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleOutput;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+
+public class SalRoleServiceImpl extends AbstractSimpleService<SetRoleInputBuilder, SetRoleOutput> implements SalRoleService {
+
+ public SalRoleServiceImpl(final RequestContextStack requestContextStack, final DeviceContext deviceContext) {
+ super(requestContextStack, deviceContext, SetRoleOutput.class);
+ }
+
+ @Override
+ protected OfHeader buildRequest(Xid xid, SetRoleInputBuilder input) {
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<SetRoleOutput>> setRole(SetRoleInput input) {
+ return null;
+ }
+}
import org.opendaylight.openflowplugin.impl.services.SalFlowServiceImpl;
import org.opendaylight.openflowplugin.impl.services.SalGroupServiceImpl;
import org.opendaylight.openflowplugin.impl.services.SalMeterServiceImpl;
+import org.opendaylight.openflowplugin.impl.services.SalRoleServiceImpl;
import org.opendaylight.openflowplugin.impl.services.SalTableServiceImpl;
import org.opendaylight.openflowplugin.impl.statistics.services.OpendaylightFlowStatisticsServiceImpl;
import org.opendaylight.yang.gen.v1.urn.opendaylight.echo.service.rev150305.SalEchoService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.SalMeterService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.NodeConfigService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SalRoleService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService;
public class MdSalRegistratorUtils {
rpcContext.registerRpcServiceImplementation(PacketProcessingService.class, new PacketProcessingServiceImpl(rpcContext, deviceContext));
rpcContext.registerRpcServiceImplementation(NodeConfigService.class, new NodeConfigServiceImpl(rpcContext, deviceContext));
rpcContext.registerRpcServiceImplementation(OpendaylightFlowStatisticsService.class, new OpendaylightFlowStatisticsServiceImpl(rpcContext, deviceContext));
+ rpcContext.registerRpcServiceImplementation(SalRoleService.class, new SalRoleServiceImpl(rpcContext, deviceContext));
}
}
OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl(getRpcRequestsQuota(), getGlobalNotificationQuota());
openflowPluginProvider.setSwitchConnectionProviders(getOpenflowSwitchConnectionProviderDependency());
- openflowPluginProvider.setRole(getRole());
openflowPluginProvider.setDataBroker(getDataBrokerDependency());
openflowPluginProvider.setRpcProviderRegistry(getRpcRegistryDependency());
openflowPluginProvider.setNotificationProviderService(getNotificationAdapterDependency());
import openflow-switch-connection-provider {prefix openflow-switch-connection-provider;revision-date 2014-03-28;}
import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
import opendaylight-sal-binding-broker-impl { prefix sal-broker; revision-date 2013-10-28;}
- import openflow-plugin-types { prefix ofp-types; revision-date 2015-03-27;}
import openflowplugin-extension-registry {prefix ofp-ext-reg; revision-date 2015-04-25;}
description
}
}
}
- leaf role {
- type ofp-types:ofp-role;
- default "NOCHANGE";
- }
leaf rpc-requests-quota {
type uint32;
default 500;
@RunWith(MockitoJUnitRunner.class)
public class RpcManagerImplTest {
- private static final int AWAITED_NUM_OF_CALL_ADD_ROUTED_RPC = 9;
+ private static final int AWAITED_NUM_OF_CALL_ADD_ROUTED_RPC = 10;
private RpcManagerImpl rpcManager;
@Mock
* Number of currently registrated services (can be changed) in {@link MdSalRegistratorUtils#registerServices
* (RpcContext, DeviceContext)}
*/
- private static final int NUMBER_OF_RPC_SERVICE_REGISTRATION = 9;
+ private static final int NUMBER_OF_RPC_SERVICE_REGISTRATION = 10;
@Test
public void registerServiceTest() {