diff options
author | Michael Dürre <michael.duerre@highstreet-technologies.com> | 2020-04-08 08:41:16 +0200 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2020-04-08 15:40:55 +0000 |
commit | ae2f7c1ce61c12d5f9908fb91fd98f9df5df1f14 (patch) | |
tree | ed91b351aa9a7b365e1b5bc6fded869ffa92a920 /sdnr | |
parent | 2ca8c3a4649ad8b552f24e8abbdd971bf7196911 (diff) |
switched capability request source
switched from data-provider to restconf
Issue-ID: SDNC-1151
Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Change-Id: I1d1c6d396100ccfb96a87cf02a1c1edd94c842a4
(cherry picked from commit 069d59228c389e25721a60cb993baab8f1cf636f)
Diffstat (limited to 'sdnr')
-rw-r--r-- | sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts | 18 | ||||
-rw-r--r-- | sdnr/wt/odlux/apps/configurationApp/src/services/restServices.ts | 7 |
2 files changed, 14 insertions, 11 deletions
diff --git a/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts b/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts index 5b4498df8..45cdfe64d 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts +++ b/sdnr/wt/odlux/apps/configurationApp/src/actions/deviceActions.ts @@ -40,23 +40,19 @@ export class UpdatViewDescription extends Action { } export const updateNodeIdAsyncActionCreator = (nodeId: string) => async (dispatch: Dispatch, getState: () => IApplicationStoreState ) => { - const { configuration: { connectedNetworkElements : { rows }} } = getState(); - dispatch(new SetCollectingSelectionData(true)); - const networkElement = rows.find(r => r.nodeId === nodeId) || await restService.getMountedNetworkElementByMountId(nodeId); - if (!networkElement) { - console.error(new Error(`NetworkElement : [${nodeId}] does not exist.`)); - return dispatch(new UpdateDeviceDescription("", { }, [ ])); - } - if (!networkElement.nodeDetails || !networkElement.nodeDetails.availableCapabilities) { + const availableCapabilities = await restService.getCapabilitiesByMoutId(nodeId); + + if (!availableCapabilities || availableCapabilities.length <= 0) { throw new Error(`NetworkElement : [${nodeId}] has no capabilities.`); } + const parser = new YangParser(); const capParser = /^\(.*\?revision=(\d{4}-\d{2}-\d{2})\)(\S+)$/i; - for (let i = 0; i < networkElement.nodeDetails.availableCapabilities.length; ++i){ - const capRaw = networkElement.nodeDetails.availableCapabilities[i]; - const capMatch = capRaw && capParser.exec(capRaw); + for (let i = 0; i < availableCapabilities.length; ++i){ + const capRaw = availableCapabilities[i]; + const capMatch = capRaw && capParser.exec(capRaw.capability); try { capMatch && await parser.addCapability(capMatch[2], capMatch[1]); } catch (err) { diff --git a/sdnr/wt/odlux/apps/configurationApp/src/services/restServices.ts b/sdnr/wt/odlux/apps/configurationApp/src/services/restServices.ts index d0ed03a8d..0d28e6653 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/services/restServices.ts +++ b/sdnr/wt/odlux/apps/configurationApp/src/services/restServices.ts @@ -22,6 +22,13 @@ import { convertPropertyNames, replaceHyphen } from "../../../../framework/src/u import { NetworkElementConnection } from "../models/networkElementConnection"; class RestService { + public async getCapabilitiesByMoutId(nodeId: string): Promise<{ "capabilityOrigin": string, "capability": string }[] | null> { + const path = `/restconf/operational/network-topology:network-topology/topology/topology-netconf/node/${nodeId}`; + const capabilitiesResult = await requestRest<{ node: { "node-id": string, "netconf-node-topology:available-capabilities": { "available-capability": { "capabilityOrigin": string, "capability": string }[] }}[] }>(path, { method: "GET" }); + return capabilitiesResult && capabilitiesResult.node && capabilitiesResult.node.length > 0 && + capabilitiesResult.node[0]["netconf-node-topology:available-capabilities"]["available-capability"].map(obj => convertPropertyNames(obj, replaceHyphen)) || null; + } + public async getMountedNetworkElementByMountId(nodeId: string): Promise<NetworkElementConnection | null> { // const path = 'restconf/operational/network-topology:network-topology/topology/topology-netconf/node/' + nodeId; // const connectedNetworkElement = await requestRest<NetworkElementConnection>(path, { method: "GET" }); |