Yuta HIGUCHI | 48f4cb7 | 2018-03-29 20:30:56 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-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 | */ |
Yuta HIGUCHI | d0f8d89 | 2018-04-09 12:14:00 -0700 | [diff] [blame] | 16 | package org.onosproject.odtn.utils.openconfig; |
Yuta HIGUCHI | 48f4cb7 | 2018-03-29 20:30:56 -0700 | [diff] [blame] | 17 | |
| 18 | import static org.onosproject.odtn.utils.YangToolUtil.toDataNode; |
| 19 | |
| 20 | import java.math.BigDecimal; |
| 21 | import java.math.BigInteger; |
| 22 | import java.util.List; |
| 23 | |
| 24 | import org.onosproject.yang.gen.v1.openconfigplatform.rev20161222.openconfigplatform.platformcomponenttop.DefaultComponents; |
| 25 | import org.onosproject.yang.gen.v1.openconfigplatform.rev20161222.openconfigplatform.platformcomponenttop.components.Component; |
| 26 | import org.onosproject.yang.gen.v1.openconfigterminaldevice.rev20170708.openconfigterminaldevice.components.component.DefaultAugmentedOcPlatformComponent; |
| 27 | import org.onosproject.yang.gen.v1.openconfigterminaldevice.rev20170708.openconfigterminaldevice.terminalopticalchanneltop.DefaultOpticalChannel; |
| 28 | import org.onosproject.yang.gen.v1.openconfigterminaldevice.rev20170708.openconfigterminaldevice.terminalopticalchanneltop.opticalchannel.Config; |
| 29 | import org.onosproject.yang.gen.v1.openconfigterminaldevice.rev20170708.openconfigterminaldevice.terminalopticalchanneltop.opticalchannel.DefaultConfig; |
| 30 | import org.onosproject.yang.gen.v1.openconfigtransporttypes.rev20170816.openconfigtransporttypes.FrequencyType; |
| 31 | import org.onosproject.yang.model.DataNode; |
| 32 | |
| 33 | import com.google.common.annotations.Beta; |
| 34 | import com.google.common.collect.ImmutableList; |
| 35 | |
| 36 | /** |
| 37 | * Utility methods dealing with OpenConfig optical-channel. |
| 38 | * <p> |
| 39 | * Split into classes for the purpose of avoiding "Config" class collisions. |
| 40 | */ |
| 41 | @Beta |
| 42 | public abstract class OpticalChannel { |
| 43 | |
| 44 | public static List<DataNode> preconf(String componentName) { |
| 45 | |
| 46 | DefaultComponents components = new DefaultComponents(); |
| 47 | |
| 48 | Component component = PlainPlatform.componentWithName(componentName); |
| 49 | components.addToComponent(component); |
| 50 | |
| 51 | // augmented 'component' shim |
| 52 | DefaultAugmentedOcPlatformComponent acomponent = new DefaultAugmentedOcPlatformComponent(); |
| 53 | |
| 54 | DefaultOpticalChannel channel = new DefaultOpticalChannel(); |
| 55 | |
| 56 | Config config = new DefaultConfig(); |
| 57 | // TODO make these configurable |
| 58 | config.frequency(FrequencyType.of(BigInteger.valueOf(191500000))); |
| 59 | config.targetOutputPower(BigDecimal.valueOf(0.0)); |
| 60 | |
| 61 | channel.config(config); |
| 62 | acomponent.opticalChannel(channel); |
| 63 | component.addAugmentation(acomponent); |
| 64 | |
| 65 | return ImmutableList.of(toDataNode(components)); |
| 66 | } |
| 67 | |
| 68 | } |