Skip to content

Commit

Permalink
ptp try for dynamic parent discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
demx8as6 committed Jun 30, 2017
1 parent 669ebce commit 4895ae7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2501,6 +2501,23 @@ define(
return deferred.promise;
};

service.getParent = function(nodeId) {
var deferred = $q.defer();
var request = {
method: 'GET',
url: 'operational/network-topology:network-topology/topology/topology-netconf/node/' + nodeId + '/yang-ext:mount/ietf-ptp-dataset:instance-list/1/parent-ds/parent-port-identity'
};

$mwtnCommons.genericRequest(request).then(function(success){
console.warn(JSON.stringify(success));
deferred.resolve(success.data['parent-port-identity']);
}, function(error) {
console.error(JSon.stringify(error));
deferred.reject();
});
return deferred.promise;
};

return service;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4233,16 +4233,6 @@ define(['app/mwtnCommons/bower_components/lodash/dist/lodash',
});
};

// var setDevicesActive = function (nodeIds) {
// // console.warn(nodeIds);
// cy.nodes().filter(function (node) {
// node.data('active', 'false');
// return node.data('type') === 'ptp-clock' && nodeIds.contains(node.data('id'));
// }).map(function (node) {
// node.data('active', 'true');
// });
// };

var setAllDevicesInactive = function () {
cy.nodes().map(function (node) {
node.data('active', 'false');
Expand All @@ -4265,22 +4255,6 @@ define(['app/mwtnCommons/bower_components/lodash/dist/lodash',
});
};

var nodeId = function (base64) {
if (base64 === undefined || base64 === '') return '';

var selector = "[type = 'ptp-clock']";
var result = cy.nodes(selector).filter(function (graphClock) {
// console.error(base64, graphClock.data('base64'), graphClock.data('base64') === base64);
return graphClock.data('base64') === base64;
});
if (result.length === 0) {
console.warn('Clock', base64, 'not found!');
return '';
} else {
return result[0].id();
}
};

var init = function () {
setAllDevicesInactive();
$mwtnPtp.getPtpClocks().then(function (clocks) {
Expand Down Expand Up @@ -4323,14 +4297,43 @@ define(['app/mwtnCommons/bower_components/lodash/dist/lodash',
};
// init();

var getNodeId = function (base64) {
if (base64 === undefined || base64 === '') return '';

var selector = "[type = 'ptp-clock']";
var result = cy.nodes(selector).filter(function (graphClock) {
// console.error(base64, graphClock.data('base64'), graphClock.data('base64') === base64);
return graphClock.data('base64') === base64;
});
if (result.length === 0) {
console.warn('Clock', base64, 'not found!');
return '';
} else {
return result[0].id();
}
};

var getParentClock = function(nodeId) {
$mwtnPtp.getParent(nodeId).then(function(parentPortIdentity){
var parentNode = getNodeId(parentPortIdentity['clock-identity']);
console.log(JSON.stringify(parentPortIdentity), parentNode);
if (parentNode) {
getParentClock(parentNode);
}
});
};

cy.on('tap', function (event) {
console.log('tap');
clearPtpPath();
if (event.target !== cy) {
if (event.target.data('type') === 'ptp-clock') {
highlightPtpMaster(event.target.id());
getParentClock(event.target.id());
// highlightPtpMaster(event.target.id());
} else if (event.target.data('type') === 'port') {
var parent = cy.getElementById(event.target.data('parent'));
highlightPtpMaster(parent.id());
// highlightPtpMaster(parent.id());
getParentClock(event.target.id());
}
} else {
// init();
Expand Down Expand Up @@ -4388,7 +4391,7 @@ define(['app/mwtnCommons/bower_components/lodash/dist/lodash',
{
field: "grandMaster",
type: "string",
displayName: "grandMaster",
displayName: "grandmaster",
width: 300
},
{
Expand Down

0 comments on commit 4895ae7

Please sign in to comment.