blob: 7acc75bcdaee0415af206b2428db230c91eed922 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/*
* Copyright (c) 2016 Cisco and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fd.honeycomb.translate.v3po.initializers;
import com.google.common.collect.Lists;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubInterfaceStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.SubinterfaceStateAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.sub.interfaces.SubInterfaceKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.SubInterfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces.state._interface.sub.interfaces.SubInterface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.sub._interface.base.attributes.AclBuilder;
/**
* Utility class for sub interface initialization
*/
final class SubInterfaceInitializationUtils {
private SubInterfaceInitializationUtils() {
throw new UnsupportedOperationException("Utility class cannot be instantiated");
}
static void initializeSubinterfaceStateAugmentation(
final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface input,
final InterfaceBuilder builder) {
final SubinterfaceStateAugmentation subIfcAugmentation =
input.getAugmentation(SubinterfaceStateAugmentation.class);
if (subIfcAugmentation != null) {
final SubinterfaceAugmentationBuilder augmentBuilder = new SubinterfaceAugmentationBuilder();
final SubInterfaces subInterfaces = subIfcAugmentation.getSubInterfaces();
if (subInterfaces != null) {
setSubInterfaces(augmentBuilder, subInterfaces);
}
builder.addAugmentation(SubinterfaceAugmentation.class, augmentBuilder.build());
}
}
private static void setSubInterfaces(final SubinterfaceAugmentationBuilder augmentBuilder,
final SubInterfaces operationalData) {
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.SubInterfacesBuilder
subInterfacesCfgBuilder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.SubInterfacesBuilder();
subInterfacesCfgBuilder.setSubInterface(Lists.transform(operationalData.getSubInterface(),
SubInterfaceInitializationUtils::convertSubInterface));
augmentBuilder.setSubInterfaces(subInterfacesCfgBuilder.build());
}
private static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.sub.interfaces.SubInterface convertSubInterface(
final SubInterface operationalData) {
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.sub.interfaces.SubInterfaceBuilder subInterfaceCfgBuilder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev150527.interfaces._interface.sub.interfaces.SubInterfaceBuilder();
subInterfaceCfgBuilder.setEnabled(SubInterfaceStatus.Up.equals(operationalData.getAdminStatus()));
subInterfaceCfgBuilder.setIdentifier(operationalData.getIdentifier());
subInterfaceCfgBuilder.setKey(new SubInterfaceKey(operationalData.getIdentifier()));
subInterfaceCfgBuilder.setL2(operationalData.getL2());
subInterfaceCfgBuilder.setMatch(operationalData.getMatch());
subInterfaceCfgBuilder.setTags(operationalData.getTags());
subInterfaceCfgBuilder.setVlanType(operationalData.getVlanType());
subInterfaceCfgBuilder.setIpv4(operationalData.getIpv4());
subInterfaceCfgBuilder.setIpv6(operationalData.getIpv6());
if (operationalData.getAcl() != null) {
final AclBuilder aclBuilder = new AclBuilder();
aclBuilder.setL2Acl(operationalData.getAcl().getL2Acl());
aclBuilder.setIp4Acl(operationalData.getAcl().getIp4Acl());
aclBuilder.setIp6Acl(operationalData.getAcl().getIp6Acl());
subInterfaceCfgBuilder.setAcl(aclBuilder.build());
}
return subInterfaceCfgBuilder.build();
}
}
|