Skip to content

Commit

Permalink
Resolved Special Character issues in Policy, Security group pages
Browse files Browse the repository at this point in the history
Issues detail descriptions

1)UI, Tilde symbol is not supported in Policy
2)UI, Need a support for the special character comma in policy and security
    group
3)UI, Getting an error "At least one of source or destination addresses must be
'local'" while creating security group name with Tilde symbol

Handled Special characters in all config pages for Multiselect and
Dropdown controls

Closes-bug: #1546553
Closes-bug: #1546900
Closes-bug: #1546907

Change-Id: Iba7fc4ac953648a868d3c7ff889cbe624eea98cb
  • Loading branch information
sbavanasi committed May 3, 2016
1 parent 9a35da8 commit 59b927d
Show file tree
Hide file tree
Showing 31 changed files with 178 additions and 156 deletions.
3 changes: 2 additions & 1 deletion webroot/common/ui/js/controller.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,6 @@ define([
// FIP Config Constants
this.URL_CFG_FIP_DETAILS =
'/api/tenants/config/floating-ips';
this.FLOATING_IP_PORT_DELIMITER = ";";

// Service Template Config Constants
this.URL_CFG_SVC_TEMPLATE_DETAILS =
Expand Down Expand Up @@ -752,6 +751,8 @@ define([
this.URL_GET_CONFIG_DETAILS = "/api/tenants/config/get-config-details";
this.URL_CREATE_CONFIG_OBJECT = "/api/tenants/config/create-config-object";
this.URL_UPDATE_CONFIG_OBJECT = "/api/tenants/config/update-config-object";

this.MULTISELECT_VALUE_SEPARATOR = ";;";
};

//str will be [0-9]+(m|h|s|d)
Expand Down
11 changes: 7 additions & 4 deletions webroot/config/dns/servers/ui/js/models/dnsServersModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ define([
var ipamStr = '';
for(var i = 0; i < ipamBackRefs.length; i++) {
var ipam = ipamBackRefs[i];
var formattedString = ipam.to[0] + ':' + ipam.to[1] + ':' + ipam.to[2] + '**' + ipam.uuid;
var formattedString = ipam.to[0] + ':' + ipam.to[1] + ':' +
ipam.to[2] + cowc.DROPDOWN_VALUE_SEPARATOR + ipam.uuid;
if(i === 0) {
ipamStr = formattedString;
} else {
ipamStr += ',' + formattedString;
ipamStr += ctwc.MULTISELECT_VALUE_SEPARATOR +
formattedString;
}
}
modelConfig['user_created_network_ipams'] = ipamStr;
Expand Down Expand Up @@ -101,11 +103,12 @@ define([
var nwIpamBackRefs = [];
var nwIpams = newdnsServerData[
'user_created_network_ipams'].split(
',');
ctwc.MULTISELECT_VALUE_SEPARATOR);
var nwIpamBackRefsCnt = nwIpams.length;
for (var i = 0; i < nwIpamBackRefsCnt; i++) {
var nwIpam = nwIpams[i];
var parts = nwIpam ? nwIpam.split('**') : [];
var parts = nwIpam ?
nwIpam.split(cowc.DROPDOWN_VALUE_SEPARATOR) : [];
if(parts.length === 2) {
var nwIpamBackRef = {};
var fqn = parts[0].split(':');
Expand Down
3 changes: 2 additions & 1 deletion webroot/config/dns/servers/ui/js/views/dnsServersEditView.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ define([
}

function getIpamId(fqnString, ipamUUID) {
return fqnString + '**' + ipamUUID;
return fqnString + cowc.DROPDOWN_VALUE_SEPARATOR + ipamUUID;
}

function getAddDnsServerViewConfig(isDisable) {
Expand Down Expand Up @@ -343,6 +343,7 @@ define([
elementConfig: {
dataTextField: "text",
dataValueField: "id",
separator: ctwc.MULTISELECT_VALUE_SEPARATOR,
dataSource: {
type: 'remote',
parse: formatNetworkIpams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ define([
var len = intfCollection.length;
for (var i = 0; i < len; i++) {
var intfName = intfCollection[i]['interface_name']();
var piRefsEntryArr = intfName.split(';');
var piRefsEntryArr =
intfName.split(cowc.DROPDOWN_VALUE_SEPARATOR);
var intfType =
intfCollection[i]['interface_type']().toLowerCase();
intfType = intfType.replace(/ /g, '');
Expand Down Expand Up @@ -207,7 +208,8 @@ define([
svcApplIntfModel =
new SvcAppliInterfaceModel({
interface_type: intfType,
interface_name: intfs[i]['to'].join(':') + ';' +
interface_name: intfs[i]['to'].join(':') +
cowc.DROPDOWN_VALUE_SEPARATOR +
intfs[i]['uuid']
});
if (null == tmpLoadedIntfTypeObjs[intfType]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ define([
for (var i = 0; i < len; i++) {
results.push({'text': piData[i]['fq_name'][2] + " (" +
piData[i]['fq_name'][1] + ")",
'id': piData[i]['fq_name'].join(':') + ';' +
'id': piData[i]['fq_name'].join(':') +
cowc.DROPDOWN_VALUE_SEPARATOR +
piData[i]['uuid']});
}
window.svcApplData.piList = results;
Expand Down
4 changes: 2 additions & 2 deletions webroot/config/networking/fip/ui/js/models/fipCfgModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ define([
if (vmiRef) {
var fqName = getValueByJsonPath(vmiRef,'to', []);
fqName = fqName.join(":");
fqName = fqName + ctwc.FLOATING_IP_PORT_DELIMITER + fixedIP;
fqName = fqName + cowc.DROPDOWN_VALUE_SEPARATOR + fixedIP;
modelConfig['virtual_machine_interface_refs'] = fqName;
} else {
modelConfig['virtual_machine_interface_refs'] = null;
Expand Down Expand Up @@ -186,7 +186,7 @@ define([
newFipCfgData['virtual_machine_interface_refs'] = [];
} else {
var fqName = newFipCfgData['virtual_machine_interface_refs'];
fqName = fqName.split(ctwc.FLOATING_IP_PORT_DELIMITER);
fqName = fqName.split(cowc.DROPDOWN_VALUE_SEPARATOR);
if(fqName.length === 2) {
newFipCfgData['virtual_machine_interface_refs'] = [];
newFipCfgData['virtual_machine_interface_refs'][0] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ define([
var uuid = getValueByJsonPath(obj,
'virtual-machine-interface;uuid', '');
$.each(ips, function(j, ip) {
actId = fqName + ctwc.FLOATING_IP_PORT_DELIMITER + ip;
actId = fqName + cowc.DROPDOWN_VALUE_SEPARATOR + ip;
fipPortList.push({id: actId,
text: ip + ' (' + uuid + ')'});
});
Expand Down
21 changes: 11 additions & 10 deletions webroot/config/networking/networks/ui/js/models/vnCfgModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,12 @@ define([
var fipPoolObj = fipPoolCollection[i];
var fipFQN = vnFQN.concat(fipPoolObj.name());
if (fipPoolObj.projects()) {
var projList = fipPoolObj.projects().split(',');
var projList = fipPoolObj.projects().
split(cowc.DROPDOWN_VALUE_SEPARATOR);
var projects = []
_.each(projList, function (proj) {
var projData = proj.trim().split('~');
if (projData.length != 2) {
return;
}
projects.push({'uuid': projData[1]});
var projData = proj ? proj.trim() : proj;
projects.push({'uuid': projData});
});
fipPoolArray.push({'to': fipFQN, 'projects': projects});
} else {
Expand Down Expand Up @@ -421,7 +419,8 @@ define([
var policies = [], policyList = [];

if (attr.network_policy_refs.length) {
policies = attr.network_policy_refs.split(',');
policies = attr.network_policy_refs.split(
cowc.DROPDOWN_VALUE_SEPARATOR);
}
policies.every(function(policy) {
policyList.push({'to': policy.split(':'),
Expand All @@ -436,7 +435,8 @@ define([
var routes = [], routeList = [];

if (attr.route_table_refs.length) {
routes = attr.route_table_refs.split(',');
routes =
attr.route_table_refs.split(cowc.DROPDOWN_VALUE_SEPARATOR);
}
routes.every(function(route) {
routeList.push({'to': route.split(':')});
Expand Down Expand Up @@ -531,7 +531,7 @@ define([
ipamAssocArr[ipam_fqn].push(subnet);
}
for (var ipam in ipamAssocArr) {
subnetArray.push({'to': ipam.split(':'),
subnetArray.push({'to': ipam.split(cowc.DROPDOWN_VALUE_SEPARATOR),
'attr' :
{'ipam_subnets': ipamAssocArr[ipam]}
});
Expand Down Expand Up @@ -626,7 +626,8 @@ define([
var phyRouters = getValueByJsonPath(attr,
'physical_router_back_refs', '');

attr['physical-routers'] = phyRouters.length ? phyRouters.split(',') : [];
attr['physical-routers'] = phyRouters.length ?
phyRouters.split(cowc.DROPDOWN_VALUE_SEPARATOR) : [];
delete attr['physical_router_back_refs'];
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ define([
placeholder: 'Select Network Policies',
dataTextField: "text",
dataValueField: "id",
separator: cowc.DROPDOWN_VALUE_SEPARATOR,
dataSource : {
type: 'remote',
url:
Expand Down Expand Up @@ -708,6 +709,7 @@ define([
placeholder: 'Select Physical Router(s)',
dataTextField: "text",
dataValueField: "id",
separator: cowc.DROPDOWN_VALUE_SEPARATOR,
dataSource : {
type: 'remote',
url:
Expand All @@ -730,6 +732,7 @@ define([
placeholder: 'Select Static Route(s)',
dataTextField: "text",
dataValueField: "id",
separator: cowc.DROPDOWN_VALUE_SEPARATOR,
dataSource : {
type: 'remote',
requestType: 'POST',
Expand Down Expand Up @@ -951,6 +954,7 @@ define([
elementConfig: {
dataTextField: "text",
dataValueField: "id",
separator: cowc.DROPDOWN_VALUE_SEPARATOR,
dataSource : {
type: 'remote',
url:
Expand Down
22 changes: 16 additions & 6 deletions webroot/config/networking/networks/ui/js/views/vnCfgFormatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,13 @@ define([
var poolProjects = getValueByJsonPath(obj, 'projects', []);
var projects = [], projectsStr = [];
$.each(poolProjects, function (projIdx, proj) {
projects.push(proj.to.join(':') + '~' + proj.uuid);
projects.push(proj.uuid);
projectsStr.push(proj.to.join(':'));
});

poolArr.push({'name': poolName,
'projects': projects.join(','), 'disable': disable});
'projects': projects.join(cowc.DROPDOWN_VALUE_SEPARATOR),
'disable': disable});

poolStr.push(poolName + (projectsStr.length ?
' (' + projectsStr.join(', ') + ')' : ''));
Expand Down Expand Up @@ -325,7 +326,7 @@ define([

for(var i = 0; i < len; i++) {
var ipam = ipamObjs[i];
var ipamFQN = ipamObjs[i].to.join(":");
var ipamFQN = ipamObjs[i].to.join(cowc.DROPDOWN_VALUE_SEPARATOR);
var field = 'ipam_subnets';
var subnetLen = ipam['attr'][field].length;

Expand Down Expand Up @@ -669,7 +670,10 @@ define([
$.each(projResponse, function (i, obj) {
var flatName = obj.fq_name[0] + ':' +
obj.fq_name[1];
projList.push({id: flatName + '~' + obj.uuid, text: flatName});
projList.push({
id: obj.uuid,
text: flatName
});
});

return projList;
Expand Down Expand Up @@ -730,10 +734,16 @@ define([
if (vCenter) {
if (domain == obj.fq_name[0] &&
project == obj.fq_name[1]) {
ipamList.push({id: obj.fq_name.join(':'), text: flatName});
ipamList.push({
id: obj.fq_name.join(cowc.DROPDOWN_VALUE_SEPARATOR),
text: flatName
});
}
} else {
ipamList.push({id: obj.fq_name.join(':'), text: flatName});
ipamList.push({
id: obj.fq_name.join(cowc.DROPDOWN_VALUE_SEPARATOR),
text: flatName
});
}
});

Expand Down
20 changes: 8 additions & 12 deletions webroot/config/networking/policy/ui/js/models/policyModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ define([
for (var i = 0; i < policeyRuleLen; i++){
var SI = policeyRule[i].service_instance();
if (SI != null) {
var SIArr = SI.split(",");
var SIArr = SI.split(cowc.DROPDOWN_VALUE_SEPARATOR);
SIArr = this.getApplyService(SIArr, SIDataSource);
policeyRule[i].service_instance(SIArr);
}
Expand Down Expand Up @@ -162,13 +162,12 @@ define([
newPoliceyRule[i].dst_addresses[0]["virtual_network"] = null;
newPoliceyRule[i].dst_addresses[0]["subnet"] = null;
newPoliceyRule[i].dst_addresses[0]["network_policy"] = null;
var desArr = policeyRule[i].dst_address().split("~");
//var desArr = policeyRule[i].dst_customValue().value.split("~");
var desArr = policeyRule[i].dst_address().split(cowc.DROPDOWN_VALUE_SEPARATOR);
if (desArr.length == 2 && desArr[1] !== 'subnet') {
newPoliceyRule[i].dst_addresses[0][desArr[1]] =
self.getPostAddressFormat(desArr[0], selectedDomain,
selectedProject);
} else {
} else if(desArr.length == 2) {
newPoliceyRule[i].dst_addresses[0]["subnet"] = {};
var subnet = desArr[0].split("/");
newPoliceyRule[i].dst_addresses[0]["subnet"]["ip_prefix"]
Expand All @@ -182,13 +181,12 @@ define([
newPoliceyRule[i].src_addresses[0]["virtual_network"] = null;
newPoliceyRule[i].src_addresses[0]["subnet"] = null;
newPoliceyRule[i].src_addresses[0]["network_policy"] = null;
var srcArr = policeyRule[i].src_address().split("~");
//var srcArr = policeyRule[i].src_customValue().value.split("~");
var srcArr = policeyRule[i].src_address().split(cowc.DROPDOWN_VALUE_SEPARATOR);
if (srcArr.length == 2 && srcArr[1] != 'subnet') {
newPoliceyRule[i].src_addresses[0][srcArr[1]] =
self.getPostAddressFormat(srcArr[0], selectedDomain,
selectedProject);
} else {
} else if(srcArr.length == 2) {
newPoliceyRule[i].src_addresses[0]["subnet"] = {};
var subnet = srcArr[0].split("/");
newPoliceyRule[i].src_addresses[0]["subnet"]["ip_prefix"]
Expand Down Expand Up @@ -218,15 +216,13 @@ define([
newPoliceyRule[i].action_list.apply_service = null;
} else {
if (policeyRule[i].service_instance() == "" ||
policeyRule[i].service_instance().trim() == "" ||
policeyRule[i].service_instance() == null) {
newPoliceyRule[i].action_list.apply_service = null;
} else {
newPoliceyRule[i].action_list.apply_service = [];
var SIVal = policeyRule[i].service_instance().split(",");
var SIValLen = SIVal.length;
for (var m = 0; m < SIValLen; m++) {
SIVal[m] = SIVal[m].split(" ")[0];
}
var SIVal = policeyRule[i].service_instance().
split(cowc.DROPDOWN_VALUE_SEPARATOR);
newPoliceyRule[i].action_list.apply_service = SIVal;
}
}
Expand Down

0 comments on commit 59b927d

Please sign in to comment.