Mod aaa-12 1)版本回滚到o-sr4版本;2)修复yangtools模块的bug(代码在git的yangtools路径下)。

RCA:
SOL:
修改人:dongxiancun
检视人:dongxiancun
This commit is contained in:
dongxiancun 2019-09-04 14:37:17 +08:00
parent 08101f68d7
commit bb1d7b86bb
2 changed files with 93 additions and 17 deletions

View File

@ -38,11 +38,11 @@ module tp-extension {
}
leaf tx-rate {
type int16 ;
default "单位为Mbps";
description "单位为Mbps";
}
leaf rx-rate {
type int16 ;
default "单位为Mbps";
description "单位为Mbps";
}
list ip-address {
leaf ip {

View File

@ -26,6 +26,8 @@ import org.opendaylight.yang.gen.v1.http.www.huawei.com.netconf.vrp.huawei.ifm.r
import org.opendaylight.yang.gen.v1.http.www.huawei.com.netconf.vrp.huawei.ifm.rev181123.IfmcommAdminStaType;
import org.opendaylight.yang.gen.v1.http.www.huawei.com.netconf.vrp.huawei.ifm.rev181123.ifm.Interfaces;
import org.opendaylight.yang.gen.v1.http.www.huawei.com.netconf.vrp.huawei.ifm.rev181123.ifm.interfaces.Interface;
//import org.opendaylight.yang.gen.v1.http.www.huawei.com.netconf.vrp.huawei.ifm.rev181123.ifm.interfaces._interface.ipv4config.am4cfgaddrs.Am4CfgAddr;
//import org.opendaylight.yang.gen.v1.http.www.huawei.com.netconf.vrp.huawei.ifm.rev181123.ifm.interfaces._interface.ipv6config.am6cfgaddrs.Am6CfgAddr;
import org.opendaylight.yang.gen.v1.http.www.huawei.com.netconf.vrp.huawei.ifm.rev181123.ifm.interfaces._interface.ipv4config.am4cfgaddrs.Am4CfgAddr;
import org.opendaylight.yang.gen.v1.http.www.huawei.com.netconf.vrp.huawei.ifm.rev181123.ifm.interfaces._interface.ipv6config.am6cfgaddrs.Am6CfgAddr;
import org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.NodeCpu;
@ -486,6 +488,67 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
// }
// });
InstanceIdentifier<Interfaces> interfacesIID =
InstanceIdentifier.create(Ifm.class).child(Interfaces.class);
Optional<Interfaces> interfacesOptional;
try {
// Read from a transaction is asynchronous, but a simple
// get/checkedGet makes the call synchronous
interfacesOptional = hwNodeReadTx.read(LogicalDatastoreType.OPERATIONAL, interfacesIID).checkedGet();
} catch (ReadFailedException e) {
throw new IllegalStateException("Unexpected error reading data from " + nodeId, e);
}
List<TpInfos> tpInfosList = new ArrayList<>();
if (interfacesOptional.isPresent()) {
List<Interface> interfaceList = interfacesOptional.get().getInterface();
for (Interface intf : interfaceList) {
LOG.info("Show NodeId {}, IfName is {},IfIndex is {} ",
nodeId, intf.getIfName().getValue(), intf.getIfIndex());
TpInfosBuilder tpInfosBuilder = new TpInfosBuilder();
List<IpAddress> ipsOnIntf = getiplist(intf);
tpInfosBuilder.setIpAddress(ipsOnIntf);
if (Objects.nonNull(intf.getIfMtu())) {
tpInfosBuilder.setMtu(intf.getIfMtu().shortValue());
}
tpInfosBuilder.setTpName(intf.getIfName().getValue());
tpInfosBuilder.setTpNumber(intf.getIfNumber());
tpInfosBuilder.setTpAdminStatus(buildTpAdmin(intf.getIfAdminStatus()));
tpInfosBuilder.setTpPhyType(intf.getIfPhyType().getName());
tpInfosList.add(tpInfosBuilder.build());
}
} else {
LOG.info("No data present on path '{}' for mountpoint: {}",
iid, nodeId);
}
//write interface information to layer
final WriteTransaction writeTransaction3 = dataBroker.newWriteOnlyTransaction();
for (int i = 0; i < tpInfosList.size(); i++) {
InstanceIdentifier<TpExt> tpinfosIID = NETCONF_TOPO_IID
.child(Node.class, new NodeKey(new NodeId(nodeId)))
.child(TerminationPoint.class, new TerminationPointKey(new TpId(tpInfosList.get(i).getTpName())))
.augmentation(TpExt.class);
writeTransaction3.put(LogicalDatastoreType.OPERATIONAL, tpinfosIID,
new TpExtBuilder()
.setTpInfos(tpInfosList.get(i))
.build(),
true
);
}
Futures.addCallback(writeTransaction3.submit(), new FutureCallback<Void>() {
@Override
public void onFailure(Throwable throwable) {
LOG.error("Write tp information information failed." + throwable.getMessage());
}
@Override
public void onSuccess(Void avoid) {
LOG.info("Write tp information information success.");
}
});
}
private TpAdminStatus buildTpAdmin(IfmcommAdminStaType ifAdminStatus) {
@ -496,23 +559,36 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener<ConnectorInf
}
private List<IpAddress> getiplist(Interface intf) {
List<Am4CfgAddr> list = intf.getIpv4Config().getAm4CfgAddrs().getAm4CfgAddr();
List<Am6CfgAddr> am6CfgAddrList = intf.getIpv6Config().getAm6CfgAddrs().getAm6CfgAddr();
List<IpAddress> addressList = new ArrayList<>();
for (Am4CfgAddr cfg : list) {
IpAddressBuilder builder = new IpAddressBuilder();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress ip = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress(Ipv4Address.getDefaultInstance(cfg.getIfIpAddr().getValue()));
builder.setIp(ip);
IpAddress tmpAddress = builder.build();
addressList.add(tmpAddress);
List<Am4CfgAddr> list = null;
List<Am6CfgAddr> am6CfgAddrList = null;
try {
list = intf.getIpv4Config().getAm4CfgAddrs().getAm4CfgAddr();
} catch (NullPointerException e) {
LOG.debug("端口:{}无ipv4配置.", intf.getIfName());
}
for (Am6CfgAddr am6CfgAddr : am6CfgAddrList) {
IpAddressBuilder builder = new IpAddressBuilder();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress ip = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress(Ipv6Address.getDefaultInstance(am6CfgAddr.getIfIp6Addr().getValue()));
builder.setIp(ip);
IpAddress tmpAddress = builder.build();
addressList.add(tmpAddress);
if(Objects.nonNull(list)) {
for (Am4CfgAddr cfg : list) {
IpAddressBuilder builder = new IpAddressBuilder();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress ip = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress(Ipv4Address.getDefaultInstance(cfg.getIfIpAddr().getValue()));
builder.setIp(ip);
IpAddress tmpAddress = builder.build();
addressList.add(tmpAddress);
}
}
try {
am6CfgAddrList = intf.getIpv6Config().getAm6CfgAddrs().getAm6CfgAddr();
} catch (NullPointerException e) {
LOG.debug("端口:{}无ipv6配置.", intf.getIfName());
}
if(Objects.nonNull(am6CfgAddrList)) {
for (Am6CfgAddr am6CfgAddr : am6CfgAddrList) {
IpAddressBuilder builder = new IpAddressBuilder();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress ip = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress(Ipv6Address.getDefaultInstance(am6CfgAddr.getIfIp6Addr().getValue()));
builder.setIp(ip);
IpAddress tmpAddress = builder.build();
addressList.add(tmpAddress);
}
}
return addressList;
}