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.services;
10 import com.google.common.base.Function;
12 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.SalPortService;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
19 import org.opendaylight.yangtools.yang.common.RpcResult;
20 import org.slf4j.Logger;
21 import java.math.BigInteger;
22 import java.util.concurrent.Future;
24 public class SalPortServiceImpl extends CommonService implements SalPortService {
25 private static final Logger LOG = org.slf4j.LoggerFactory.getLogger(SalPortServiceImpl.class);
28 public Future<RpcResult<UpdatePortOutput>> updatePort(final UpdatePortInput input) {
29 return this.<UpdatePortOutput, Void> handleServiceCall(PRIMARY_CONNECTION,
30 new Function<BigInteger, Future<RpcResult<Void>>>() {
32 public Future<RpcResult<Void>> apply(final BigInteger IDConnection) {
33 final Port inputPort = input.getUpdatedPort().getPort().getPort().get(0);
34 final PortModInput ofPortModInput = PortConvertor.toPortModInput(inputPort, version);
35 final PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput);
36 mdInput.setXid(deviceContext.getNextXid().getValue());
37 return provideConnectionAdapter(IDConnection).portMod(mdInput.build());