blob: eeb7cc5f0922c24244c6d16fa6110ea4bbdef165 [file] [log] [blame]
Claudine Chiu20cbd452017-08-30 19:23:11 -04001/*
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
17package org.onosproject.ofagent.impl;
18
19import org.onosproject.net.DeviceId;
20import org.onosproject.net.driver.DefaultDriverData;
21import org.onosproject.net.driver.DefaultDriverHandler;
22import org.onosproject.net.driver.Driver;
23import org.onosproject.net.driver.DriverHandler;
24import org.onosproject.net.driver.DriverService;
25import org.onosproject.provider.of.flow.util.FlowEntryBuilder;
26import org.projectfloodlight.openflow.protocol.OFFlowMod;
27import org.slf4j.Logger;
28import 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".
32public class OFAgentVirtualFlowEntryBuilder extends FlowEntryBuilder {
33 private static final Logger log = LoggerFactory.getLogger(OFAgentVirtualFlowEntryBuilder.class);
34 private static final String DRIVER_NAME = "ovs";
35
Claudine Chiu20cbd452017-08-30 19:23:11 -040036 public OFAgentVirtualFlowEntryBuilder(DeviceId deviceId, OFFlowMod fm, DriverService driverService) {
Claudine Chiu6cbce022017-11-29 17:44:01 -050037 super(deviceId, fm, getDriver(deviceId, driverService));
Claudine Chiu20cbd452017-08-30 19:23:11 -040038 }
39
Rodrigo Duarte Sousae37d1292017-08-29 17:01:24 -030040 protected static DriverHandler getDriver(DeviceId devId, DriverService driverService) {
Claudine Chiu20cbd452017-08-30 19:23:11 -040041 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}