blob: ae14e070e909068779ebd3c1451199f512304a40 [file] [log] [blame]
Yuta HIGUCHId0f8d892018-04-09 12:14:00 -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 */
16package org.onosproject.odtn.behaviour;
17
18import static org.onosproject.odtn.utils.YangToolUtil.toCharSequence;
19import static org.onosproject.odtn.utils.YangToolUtil.toCompositeData;
20import static org.onosproject.odtn.utils.YangToolUtil.toResourceData;
21import static org.onosproject.odtn.utils.YangToolUtil.toXmlCompositeStream;
22
23import java.util.List;
24
25import org.onosproject.net.driver.AbstractHandlerBehaviour;
26import org.onosproject.odtn.utils.openconfig.Transceiver;
27import org.onosproject.yang.model.DataNode;
28import org.onosproject.yang.model.ResourceId;
29
30import com.google.common.collect.Lists;
31
32/**
33 * Plain OpenConfig based implementation.
34 */
35public class PlainTransceiver extends AbstractHandlerBehaviour
36 implements ConfigurableTransceiver {
37
38 @Override
39 public List<CharSequence> enable(String componentName, boolean enable) {
40 List<DataNode> nodes = Transceiver.enable(componentName, enable);
41
42 ResourceId empty = ResourceId.builder().build();
43 return Lists.transform(nodes,
44 node -> toCharSequence(toXmlCompositeStream(toCompositeData(toResourceData(empty, node)))));
45 }
46
47}