blob: 17220e0064755e4e806b7072e8306f3bf240905e [file] [log] [blame]
Yuta HIGUCHI48f4cb72018-03-29 20:30:56 -07001/*
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 HIGUCHId0f8d892018-04-09 12:14:00 -070016package org.onosproject.odtn.utils.openconfig;
Yuta HIGUCHI48f4cb72018-03-29 20:30:56 -070017
Yuta HIGUCHI48f4cb72018-03-29 20:30:56 -070018import java.util.List;
19
20import org.onosproject.yang.gen.v1.openconfigplatform.rev20161222.openconfigplatform.platformcomponenttop.DefaultComponents;
21import org.onosproject.yang.gen.v1.openconfigplatform.rev20161222.openconfigplatform.platformcomponenttop.components.Component;
22import org.onosproject.yang.gen.v1.openconfigplatformtransceiver.rev20170708.openconfigplatformtransceiver.components.component.DefaultAugmentedOcPlatformComponent;
23import org.onosproject.yang.gen.v1.openconfigplatformtransceiver.rev20170708.openconfigplatformtransceiver.porttransceivertop.DefaultTransceiver;
24import org.onosproject.yang.gen.v1.openconfigplatformtransceiver.rev20170708.openconfigplatformtransceiver.porttransceivertop.transceiver.Config;
25import org.onosproject.yang.gen.v1.openconfigplatformtransceiver.rev20170708.openconfigplatformtransceiver.porttransceivertop.transceiver.DefaultConfig;
26import org.onosproject.yang.gen.v1.openconfigtransporttypes.rev20170816.openconfigtransporttypes.Eth100GbaseLr4;
27import org.onosproject.yang.gen.v1.openconfigtransporttypes.rev20170816.openconfigtransporttypes.Qsfp28;
28import org.onosproject.yang.model.DataNode;
29
30import com.google.common.annotations.Beta;
31import com.google.common.collect.ImmutableList;
32
Ai Hamanobd51cdd2018-10-18 11:30:07 +090033import static org.onosproject.odtn.utils.YangToolUtil.toDataNode;
34
Yuta HIGUCHI48f4cb72018-03-29 20:30:56 -070035/**
36 * Utility methods dealing with OpenConfig transceiver.
37 * <p>
38 * Split into classes for the purpose of avoiding "Config" class collisions.
39 */
40@Beta
41public abstract class Transceiver {
42
Yuta HIGUCHI48f4cb72018-03-29 20:30:56 -070043 public static List<DataNode> preconf(String componentName) {
44 DefaultComponents components = new DefaultComponents();
45
46 Component component = PlainPlatform.componentWithName(componentName);
47 components.addToComponent(component);
48
49 // augmented 'component' shim
50 DefaultAugmentedOcPlatformComponent tcomponent = new DefaultAugmentedOcPlatformComponent();
51
52 DefaultTransceiver transceiver = new DefaultTransceiver();
53
54 Config configt = new DefaultConfig();
55 // TODO make these configurable
56 configt.formFactorPreconf(Qsfp28.class);
57 configt.ethernetPmdPreconf(Eth100GbaseLr4.class);
58 transceiver.config(configt);
59 tcomponent.transceiver(transceiver);
60 component.addAugmentation(tcomponent);
61
62 return ImmutableList.of(toDataNode(components));
63 }
64
65}