2 * Copyright (c) 2015 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.impl.device;
10 import java.util.concurrent.ExecutionException;
12 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
13 import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager;
14 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
15 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
16 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceContextReadyHandler;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder;
22 import org.opendaylight.yangtools.yang.binding.DataObject;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 import com.google.common.util.concurrent.Futures;
27 import com.google.common.util.concurrent.ListenableFuture;
32 public class DeviceManagerImpl implements DeviceManager {
34 private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerImpl.class);
39 public void deviceConnected(ConnectionContext connectionContext) {
41 DeviceContextImpl deviceContextImpl = new DeviceContextImpl();
44 FlowCapableNode description = queryDescription(connectionContext, xid.getNextValue()).get();
46 } catch (InterruptedException | ExecutionException e) {
47 // TODO Auto-generated catch block
48 LOG.info("Failed to retrieve node static info: {}", e.getMessage());
53 * @param connectionContext
56 private static ListenableFuture<FlowCapableNode> queryDescription(ConnectionContext connectionContext, long nextXid) {
57 MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
58 builder.setType(MultipartType.OFPMPDESC);
59 builder.setVersion(connectionContext.getFeatures().getVersion());
60 builder.setFlags(new MultipartRequestFlags(false));
61 builder.setMultipartRequestBody(new MultipartRequestDescCaseBuilder()
63 builder.setXid(nextXid);
64 connectionContext.getConnectionAdapter().multipartRequest(builder.build());
66 //TODO: involve general wait-for-answer mechanism and return future with complete value
67 //TODO: translate message
68 return Futures.immediateFuture(null);
72 public void sendMessage(DataObject dataObject, RequestContext requestContext) {
73 // TODO Auto-generated method stub
78 public Xid sendRequest(DataObject dataObject, RequestContext requestContext) {
79 // TODO Auto-generated method stub
84 public void addRequestContextReadyHandler(DeviceContextReadyHandler deviceContextReadyHandler) {
85 // TODO Auto-generated method stub