Skip to content

Commit

Permalink
Added the ability to import routing policies to VN.
Browse files Browse the repository at this point in the history
Added the multiselect to select the routing polices in VN.
Also added some validations for routing policy creation.
Closes-Bug: #1743038

Change-Id: I9a0ab9ec21dfbd74eab4932d2894f3548df21338
  • Loading branch information
manojgn committed Mar 23, 2018
1 parent a7e4a94 commit a8bfa36
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 0 deletions.
20 changes: 20 additions & 0 deletions webroot/config/networking/networks/ui/js/models/vnCfgModel.js
Expand Up @@ -103,6 +103,7 @@ define([
'virtual_network_fat_flow_protocols': {
'fat_flow_protocol':[]
},
'routing_policy_refs':[]
},

formatModelConfig: function (modelConfig) {
Expand All @@ -117,6 +118,9 @@ define([
modelConfig['route_table_refs'] =
formatVNCfg.staticRouteFormatter(null, null,
null, -1, modelConfig);
modelConfig['routing_policy_refs'] =
formatVNCfg.routingPolicyFormatter(null, null,
null, -1, modelConfig);
var vnUUID = getValueByJsonPath(modelConfig, 'uuid', null);

if (vnUUID != null) {
Expand Down Expand Up @@ -687,6 +691,21 @@ define([
attr['route_table_refs'] = routeList;
},

getRoutingPolicyList: function(attr) {
var policies = [], routingPolicyList = [];

if (attr.routing_policy_refs.length) {
policies =
attr.routing_policy_refs.split(cowc.DROPDOWN_VALUE_SEPARATOR);
}
policies.every(function(policy) {
routingPolicyList.push({'to': policy.split(':')});
return true;
});

attr['routing_policy_refs'] = routingPolicyList;
},

setDHCPOptionList: function(subnet, dhcpOption) {
if (typeof subnet.dhcp_option_list == "function") {
subnet.dhcp_option_list().dhcp_option = dhcpOption;
Expand Down Expand Up @@ -1247,6 +1266,7 @@ define([
this.getEcmpHashing(newVNCfgData);
this.getQoS(newVNCfgData);
this.getBridgeDomains(newVNCfgData);
this.getRoutingPolicyList(newVNCfgData);

//ip fabric forwarding
if(newVNCfgData.user_created_ip_fabric_forwarding === true) {
Expand Down
48 changes: 48 additions & 0 deletions webroot/config/networking/networks/ui/js/views/vnCfgEditView.js
Expand Up @@ -1514,6 +1514,54 @@ define([
}]
}]
},
{
columns: [
{
elementId: 'import_policy_accordian',
view: "AccordianView",
viewConfig: [
{
elementId: 'import_policy_vcfg',
title: 'Import Policy',
view: "SectionView",
active:false,
viewConfig: {
rows: [
{
columns: [
{
elementId: 'routing_policy_refs',
view: 'FormMultiselectView',
viewConfig: {
label: 'Routing Policy(s)',
path: 'routing_policy_refs',
class: 'col-xs-12',
dataBindValue: 'routing_policy_refs',
elementConfig: {
placeholder: 'Select Routing Policies',
dataTextField: "text",
dataValueField: "id",
separator: cowc.DROPDOWN_VALUE_SEPARATOR,
dataSource : {
type: 'remote',
requestType: 'POST',
postData: JSON.stringify({'data':
[{'type':'routing-policys'}]}),
url:
'/api/tenants/config/get-config-list',
parse:
formatVNCfg.routingPolicyMSFormatter,
}
}
}
}
]
},
]
}
}]
}]
},
{
columns: [{
elementId: 'bridge_domains_accordion',
Expand Down
38 changes: 38 additions & 0 deletions webroot/config/networking/networks/ui/js/views/vnCfgFormatters.js
Expand Up @@ -780,6 +780,27 @@ define([
staticRouteList.length ?
staticRouteList.join('<br/>'): '-';
};

/*
* @routingPolicyFormatter
*/
this.routingPolicyFormatter = function(d, c, v, cd, dc) {
var routingPolicies = getValueByJsonPath(dc,
'routing_policy_refs', []);
var routingPolicyList = [], routingPolicyArr = [];

$.each(routingPolicies, function (i, obj) {
var flatName = '';
cd == -1 ? flatName = obj.to.join(':') :
flatName = obj['to'][2] + ' (' + obj['to'][1] + ')';
routingPolicyList.push(flatName);
routingPolicyArr.push(flatName);
});

return cd == -1 ? routingPolicyArr :
routingPolicyList.length ?
routingPolicyList.join('<br/>'): '-';
};
/*
* @polMSFormatter
*/
Expand All @@ -797,6 +818,23 @@ define([
return polList;
};

/*
* @routingPolicyMSFormatter
*/
this.routingPolicyMSFormatter = function(response) {
var routingPolicyResponse = getValueByJsonPath(response,
'0;routing-policys', []);
var routingPolicyList = [];

$.each(routingPolicyResponse, function (i, obj) {
var flatName = obj.fq_name;
routingPolicyList.push({id: obj.fq_name.join(':'),
text: flatName[2]+ ' (' + flatName[1] + ')'});
});

return routingPolicyList;
};

/*
* @allProjMSFormatter
*/
Expand Down
12 changes: 12 additions & 0 deletions webroot/config/networking/networks/ui/js/views/vnCfgGridView.js
Expand Up @@ -461,6 +461,14 @@ define([
formatter: 'staticRouteFormatter',
}
},
{
label: 'Attached Routing Policies',
key: 'uuid',
templateGenerator: 'TextGenerator',
templateGeneratorConfig: {
formatter: 'routingPolicyFormatter',
}
},
{
label: 'Floating IP Pool(s)',
key: 'uuid',
Expand Down Expand Up @@ -763,6 +771,10 @@ define([
return formatVNCfg.staticRouteFormatter(null,
null, null, null, dc);
}
this.routingPolicyFormatter = function (v, dc) {
return formatVNCfg.routingPolicyFormatter(null,
null, null, null, dc);
}
this.QoSFormatter = function (v, dc) {
return formatVNCfg.qosExpansionFormatter(null,
null, null, null, dc);
Expand Down
Expand Up @@ -85,6 +85,14 @@ define([
return "Local preference has to be a number.";
}
}
if (finalObj.name == "as-path") {
var vals = value.split(',');
for(var i = 0; i < vals.length; i++) {
if (!isNumber(String(vals[i]).trim())){
return "AS path value has to be a number.";
}
}
}
}
}
}
Expand Down
Expand Up @@ -333,6 +333,7 @@ define([
returnThenObj["update"]["as_path"]['expand'] = {};
//assuming asn-list is comma separated
var asnList = val.split(',');
asnList = asnList.map(function(d,i){return d.trim();});
returnThenObj["update"]["as_path"]['expand']['asn_list'] = asnList;
break;
}
Expand Down

0 comments on commit a8bfa36

Please sign in to comment.