diff --git a/ControlPlatform/driver-layer/adaptation-layer/src/main/yang/device-status.yang b/ControlPlatform/driver-layer/adaptation-layer/src/main/yang/device-status.yang index 03f8ad40b..2ae2220d9 100644 --- a/ControlPlatform/driver-layer/adaptation-layer/src/main/yang/device-status.yang +++ b/ControlPlatform/driver-layer/adaptation-layer/src/main/yang/device-status.yang @@ -26,9 +26,7 @@ module device-status { container memory-infos { description "内存的状态信息"; leaf memory-total { - type int16 { - range "0..100"; - } + type int64 ; } leaf usage-rate { type int16 { diff --git a/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiDriverProvider.java b/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiDriverProvider.java index 6f00cfb99..dd5c37807 100644 --- a/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiDriverProvider.java +++ b/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiDriverProvider.java @@ -8,6 +8,7 @@ package com.cmcc.cmhi.huawei.impl; import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.MountPointService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -16,13 +17,15 @@ public class HuaweiDriverProvider { private static final Logger LOG = LoggerFactory.getLogger(HuaweiDriverProvider.class); private final DataBroker dataBroker; + private final MountPointService mountService; private HuaweiDriverRegister register = null; private HuaweiNetconfSpeaker netconfSpeaker = null; - public HuaweiDriverProvider(final DataBroker dataBroker) { + public HuaweiDriverProvider(final DataBroker dataBroker, final MountPointService mountService) { this.dataBroker = dataBroker; + this.mountService = mountService; this.register = new HuaweiDriverRegister(this.dataBroker); - this.netconfSpeaker = new HuaweiNetconfSpeaker(this.dataBroker); + this.netconfSpeaker = new HuaweiNetconfSpeaker(this.dataBroker, this.mountService); } /** diff --git a/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiNetconfSpeaker.java b/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiNetconfSpeaker.java index 55146d1fe..18735c1da 100644 --- a/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiNetconfSpeaker.java +++ b/ControlPlatform/driver-layer/drivers/huawei/src/main/java/com/cmcc/cmhi/huawei/impl/HuaweiNetconfSpeaker.java @@ -52,12 +52,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev15 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; @@ -75,7 +77,7 @@ import static org.opendaylight.controller.md.sal.binding.api.DataObjectModificat public class HuaweiNetconfSpeaker implements DataTreeChangeListener, - BindingAwareProvider, AutoCloseable { + AutoCloseable { private final ListenerRegistration configurationReg; private MountPointService mountService; @@ -93,8 +95,9 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener connectPath = InstanceIdentifier.create(ConnectorInfo.class); final DataTreeIdentifier dataTreeIdentifier = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, connectPath); configurationReg = dataBroker.registerDataTreeChangeListener(dataTreeIdentifier, this); @@ -131,7 +134,7 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener() { @@ -143,7 +146,7 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener - * The skeleton for this method was generated with the MD-SAL application - * archetype. - * - * @param session Reference to the established MD-SAL session - */ - @Override - public void onSessionInitiated(BindingAwareBroker.ProviderContext session) { - LOG.info("HuaweiNetconfSpeaker Session Initiated"); - this.mountService = session.getSALService(MountPointService.class); - } +// /** +// * A method called when the session to MD-SAL is established. It initializes +// * references to MD-SAL services needed throughout the lifetime of the +// * huawei netconf application and registers its RPC implementation and Data change +// * Listener with the MD-SAL +// *

+// * The skeleton for this method was generated with the MD-SAL application +// * archetype. +// * +// * @param session Reference to the established MD-SAL session +// */ +// @Override +// public void onSessionInitiated(BindingAwareBroker.ProviderContext session) { +// LOG.info("HuaweiNetconfSpeaker Session Initiated"); +// this.mountService = session.getSALService(MountPointService.class); +// } @Override @@ -213,7 +216,7 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener { + oldEntry.getRemoteDevices().forEach(d -> { disConnectDevice(d.getId().getValue()); }); @@ -261,15 +264,19 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener { - readInfoFromDevice(nodeId); - }, 0, 10000, TimeUnit.MILLISECONDS); + try { + readInfoFromDevice(nodeId); + } catch (Exception e) { + LOG.error("捕获一个异常:{}", e); + } + }, 180000, 10000, TimeUnit.MILLISECONDS); if (Objects.nonNull(threads.get(nodeId))) { LOG.info("remove exist pool in thread map"); if (!threads.get(nodeId).isShutdown()) { threads.get(nodeId).shutdownNow(); } } - LOG.info("put pool in thread map with key {}",nodeId); + LOG.info("put pool in thread map with key {}", nodeId); threads.put(nodeId, pool); } @@ -285,13 +292,15 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener hwNodeOptional = mountService.getMountPoint(NETCONF_TOPO_IID .child(Node.class, new NodeKey(new NodeId(nodeId)))); - + LOG.info("开始向华为设备获取cpu信息2!"); Preconditions.checkArgument(hwNodeOptional.isPresent(), "Unable to locate mountpoint: %s, not mounted yet or not configured", nodeId); final MountPoint hwNode = hwNodeOptional.get(); + LOG.info("Get the DataBroker for the mounted node !"); // Get the DataBroker for the mounted node final DataBroker hwNodeBroker = hwNode.getService(DataBroker.class).get(); @@ -308,7 +317,7 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener iid = InstanceIdentifier.create(Devm.class).child(CpuInfos.class); Optional cupInfos; - LOG.info("开始向华为设备获取cpu信息!"); + LOG.info("开始向华为设备读取cupInfos!"); try { // Read from a transaction is asynchronous, but a simple // get/checkedGet makes the call synchronous @@ -331,9 +340,10 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener cpuIid = NETCONF_TOPO_IID.child(Node.class). - augmentation(NodeCpu.class). - child(org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.cpu.status.CpuInfos.class); + InstanceIdentifier cpuIid = NETCONF_TOPO_IID + .child(Node.class, new NodeKey(new NodeId(nodeId))) + .augmentation(NodeCpu.class) + .child(org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.cpu.status.CpuInfos.class); for (int i = 0; i < ifcList.size(); i++) { final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); writeTransaction.put(LogicalDatastoreType.OPERATIONAL, cpuIid, ifcList.get(i)); @@ -369,7 +379,8 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener customMemoryIID = NETCONF_TOPO_IID.child(Node.class). - augmentation(NodeMemory.class). - child(org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.mem.status.MemoryInfos.class); + InstanceIdentifier customMemoryIID = NETCONF_TOPO_IID + .child(Node.class, new NodeKey(new NodeId(nodeId))) + .augmentation(NodeMemory.class) + .child(org.opendaylight.yang.gen.v1.urn.cmcc.cmhi.adaptation.layer.device.status.rev190809.mem.status.MemoryInfos.class); for (int i = 0; i < memoryList.size(); i++) { final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); writeTransaction.put(LogicalDatastoreType.OPERATIONAL, customMemoryIID, memoryList.get(i)); @@ -433,9 +445,11 @@ public class HuaweiNetconfSpeaker implements DataTreeChangeListener tpinfosIID = NETCONF_TOPO_IID.child(Node.class). - child(TerminationPoint.class).augmentation(TpExt.class).child(TpInfos.class); for (int i = 0; i < tpInfosList.size(); i++) { + InstanceIdentifier 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).child(TpInfos.class); final WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction(); writeTransaction.put(LogicalDatastoreType.OPERATIONAL, tpinfosIID, tpInfosList.get(i)); Futures.addCallback(writeTransaction.submit(), new FutureCallback() { diff --git a/ControlPlatform/driver-layer/drivers/huawei/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/ControlPlatform/driver-layer/drivers/huawei/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml index 66dc04a06..212ba5b7b 100644 --- a/ControlPlatform/driver-layer/drivers/huawei/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ b/ControlPlatform/driver-layer/drivers/huawei/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -14,11 +14,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html + +