Claudine Chiu | 20cbd45 | 2017-08-30 19:23:11 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.ofagent.impl; |
| 18 | |
| 19 | import org.onosproject.net.DeviceId; |
| 20 | import org.onosproject.net.driver.DefaultDriverData; |
| 21 | import org.onosproject.net.driver.DefaultDriverHandler; |
| 22 | import org.onosproject.net.driver.Driver; |
| 23 | import org.onosproject.net.driver.DriverHandler; |
| 24 | import org.onosproject.net.driver.DriverService; |
| 25 | import org.onosproject.provider.of.flow.util.FlowEntryBuilder; |
| 26 | import org.projectfloodlight.openflow.protocol.OFFlowMod; |
| 27 | import org.slf4j.Logger; |
| 28 | import org.slf4j.LoggerFactory; |
| 29 | |
| 30 | // FlowEntryBuilder customized for OFAgent. This builder will be used to build FlowEntry objects for |
| 31 | // virtual devices encountered by OFAgent. The driver has been hardcoded to "ovs". |
| 32 | public class OFAgentVirtualFlowEntryBuilder extends FlowEntryBuilder { |
| 33 | private static final Logger log = LoggerFactory.getLogger(OFAgentVirtualFlowEntryBuilder.class); |
| 34 | private static final String DRIVER_NAME = "ovs"; |
| 35 | |
Claudine Chiu | 20cbd45 | 2017-08-30 19:23:11 -0400 | [diff] [blame] | 36 | public OFAgentVirtualFlowEntryBuilder(DeviceId deviceId, OFFlowMod fm, DriverService driverService) { |
Claudine Chiu | 6cbce02 | 2017-11-29 17:44:01 -0500 | [diff] [blame] | 37 | super(deviceId, fm, getDriver(deviceId, driverService)); |
Claudine Chiu | 20cbd45 | 2017-08-30 19:23:11 -0400 | [diff] [blame] | 38 | } |
| 39 | |
Rodrigo Duarte Sousa | e37d129 | 2017-08-29 17:01:24 -0300 | [diff] [blame] | 40 | protected static DriverHandler getDriver(DeviceId devId, DriverService driverService) { |
Claudine Chiu | 20cbd45 | 2017-08-30 19:23:11 -0400 | [diff] [blame] | 41 | log.debug("calling getDriver for {}", devId); |
| 42 | Driver driver = driverService.getDriver(DRIVER_NAME); |
| 43 | DriverHandler handler = new DefaultDriverHandler(new DefaultDriverData(driver, devId)); |
| 44 | return handler; |
| 45 | } |
| 46 | } |