blob: 5be34a410c300f6fd807e6a461d5564c6698e41a [file] [log] [blame]
MaoLu937cf422017-03-03 23:31:46 -08001/*
2 * Copyright 2016-present Open Networking Laboratory
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.driver.optical.power;
18
19import java.util.Optional;
20
21import com.google.common.collect.Range;
22import org.onosproject.net.driver.AbstractHandlerBehaviour;
23import org.onosproject.net.PortNumber;
24import org.onosproject.net.behaviour.PowerConfig;
25
26/**
27 * Port Power implementation for Oplink protection switch device.
28 *
29 * Intruduction:
30 * _____
31 * _____________________ | | 0 VIRTUAL
32 * | | | 1 |
33 * CLIENT | |---|-----|--- PRIMARY
34 * -----------| OPS | | | NETWORK
35 * 3 | |---|-----|--- SECONDARY
36 * |_____________________| | 2 |
37 * |_____|
38 * Uses flow to set switch path.
39 * network port = 0, client port = 3, AUTO mode.
40 * network port = 1 or 2, client port = 3, MANUAL mode.
41 *
42 */
43
44public class OplinkSwitchPowerConfig extends AbstractHandlerBehaviour
45 implements PowerConfig<Object> {
46
47 // oplink power config utility
48 private OplinkPowerConfigUtil oplinkUtil = new OplinkPowerConfigUtil(this);
49
50 @Override
51 public Optional<Long> getTargetPower(PortNumber port, Object component) {
52 return Optional.ofNullable(null);
53 }
54
55 @Override
56 public Optional<Long> currentPower(PortNumber port, Object component) {
57 return Optional.ofNullable(oplinkUtil.getCurrentPower(port, component));
58 }
59
60 @Override
61 public void setTargetPower(PortNumber port, Object component, long power) {
62 return;
63 }
64
65 @Override
66 public Optional<Range<Long>> getTargetPowerRange(PortNumber port, Object component) {
67 return Optional.ofNullable(oplinkUtil.getTargetPowerRange(port, component));
68 }
69
70 @Override
71 public Optional<Range<Long>> getInputPowerRange(PortNumber port, Object component) {
72 return Optional.ofNullable(oplinkUtil.getInputPowerRange(port, component));
73 }
74}