Skip to content

Commit

Permalink
Update main.py ui/index.html ui/ui.js
Browse files Browse the repository at this point in the history
Add JS support for dynamic VRF selection based on config
Fix dict anomalies when VRF is not present on router
  • Loading branch information
knewell committed Jan 9, 2020
1 parent 082bc69 commit 8bec553
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ def loadFlowRouteConfig(self):

else:
for vrf in self.vrfs:
_vrf_data = dict()
_data = dict()
family = ''
if vrf == 'default':
try:
Expand Down Expand Up @@ -489,7 +491,7 @@ def loadFlowRouteConfig(self):
'srcPrefix': route['match']['source'] if 'source' in route['match'] else None
})

return True, self.flow_config
return True, self.flow_config, self.vrfs

def parseFlow(self, flow=None):
_flow = flow.split(',')
Expand Down
4 changes: 0 additions & 4 deletions ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ <h4 class="modal-title">Add new flow route</h4>
<label for="selectVrf" class="col-sm-2 col-form-label">VRF</label>
<div class="col-sm-3">
<select class="form-control" id="selectVrf">
<option selected="selected">default</option>
<option>trcps</option>
</select>
</div>
</div>
Expand Down Expand Up @@ -265,8 +263,6 @@ <h4 class="modal-title">Modify Flow Route</h4>
<label for="selectModVrf" class="col-sm-2 col-form-label">VRF</label>
<div class="col-sm-3">
<select class="form-control" id="selectModVrf">
<option>default</option>
<option>trcps</option>
</select>
</div>
</div>
Expand Down
17 changes: 17 additions & 0 deletions ui/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ $(document).ready(function () {

var return_data = new Array();

selectVrf = document.getElementById('selectVrf');
selectModVrf = document.getElementById('selectModVrf');

$.each( response[2], function( index, value ) {
var opt = document.createElement('option');
opt.text = value;
opt.value = value;
selectVrf.appendChild(opt);
});

$.each( response[2], function( index, value ) {
var opt = document.createElement('option');
opt.text = value;
opt.value = value;
selectModVrf.appendChild(opt);
});

$.each( response[1], function( name, flow ) {

var action_val = new Array();
Expand Down

0 comments on commit 8bec553

Please sign in to comment.