Skip to content

Commit

Permalink
Related-Bug: #1548710
Browse files Browse the repository at this point in the history
1. Adding Instance IPs of VMIs in port tuple name.
2. Making v2 as default visible version while creating ST.
3. In VMI list, show the IP first and then uuid.

Change-Id: I6f01eb181a8f6e87da03442ce80c8ec3f6d9a855
  • Loading branch information
biswajit-mandal committed Feb 23, 2016
1 parent e93cc5e commit 8cf1b4a
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2102,8 +2102,8 @@ function deletePortTuplesAndSI (portTupleUUIDList, siID, appData, callback)
if ((null == portTupleUUIDList) || (!portTupleUUIDList.length)) {
configApiServer.apiDelete(siDelURL, appData, function(error, data) {
callback(error, data);
return;
});
return;
}

var portTuplesCnt = portTupleUUIDList.length;
Expand Down
54 changes: 16 additions & 38 deletions webroot/config/services/instances/ui/js/models/PortTupleModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ define([

defaultConfig: {
portTupleName: "",
portTupleDisplayName: "",
portTupleData: null,
intfTypes: [],
disable: false
Expand Down Expand Up @@ -42,28 +43,37 @@ define([
var vnVmis = modelConfig.parentIntfs;

var vmisCnt = vmis.length;
var vmiTypeToObjMap = {};
for (var i = 0; i < vmisCnt; i++) {
var intfType =
vmis[i]['virtual_machine_interface_properties']
['service_interface_type'];
vmiTypeToObjMap[intfType] = vmis[i];
}

var intfTypes = getValueByJsonPath(modelConfig, 'intfTypes', []);
var intfCnt = intfTypes.length;
for (var i = 0; i < intfCnt; i++) {
intfType = intfTypes[i];
var vmiObj = vmiTypeToObjMap[intfType];
if (null == vmiObj) {
continue;
}
var vnName = vnVmis[intfType];
var vmiList = [];
if (window.vnVmiMaps[vnName]) {
vmiList = window.vnVmiMaps[vnName];
}
var vmi = vmis[i]['fq_name'].join(':') + "~~" + vmis[i]['uuid'];
var vmi = vmiObj['fq_name'].join(':') + "~~" + vmiObj['uuid'];
var propModel =
new InterfaceTypesModel({interfaceType: intfType,
interface: vmis[i]['fq_name'].join(':') +
"~~" + vmis[i]['uuid'],
interface: vmiObj['fq_name'].join(':') +
"~~" + vmiObj['uuid'],
vmiListData: vmiList,
disable: modelConfig['disable']});
propModels.push(propModel);
}
if (!vmisCnt) {
var intfTypes = getValueByJsonPath(modelConfig, 'intfTypes',
[]);
var intfCnt = intfTypes.length;
var vmi = null;
for (var i = 0; i < intfCnt; i++) {
var vnName = vnVmis[intfTypes[i]];
Expand All @@ -83,38 +93,6 @@ define([
modelConfig['portTupleInterfaces'] = propCollectionModel;
return modelConfig;
},
addPortTupleInterface: function() {
var svcTmpl = $('#service_template_dropdown').val();
var svcTmpls = $(gridElId).data('svcInstTmplts');
var svcTmplFqn = getCookie('domain') + ":" +
svcTmpl.split(' - [')[0];
var svcTmplObj = svcTmpls[svcTmplFqn];
var intfTypes =
getValueByJsonPath(svcTmplObj,
'service_template_properties;interface_type',
[]);
var origList = [];
var intfCnt = intfTypes.length;
for (var i = 0; i < intfCnt; i++) {
origList.push(intfTypes[i]['service_interface_type']);
}
var props = this.model().attributes.model().get('portTupleInterfaces');
if (props.length >= intfTypes.length) {
return;
}
var count = props.length;
var vmi = window.vmiList.length > 0 ? window.vmiList[0].value : "";
var propsList = [];
for (var i = 0; i < count; i++) {
var model = props.at(i);
propsList.push(model.attributes.interfaceType());
}
var newIntf = _.difference(origList, propsList);
var newProp =
new InterfaceTypesModel({'interfaceType': newIntf[0],
'interface': vmi});
props.add([newProp]);
},
deletePortTuple: function() {
var portTupleCollection =this .model().collection;
var portTupleEntry = this.model();
Expand Down
104 changes: 102 additions & 2 deletions webroot/config/services/instances/ui/js/models/svcInstModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,13 @@ define([
var intfs =
this.getInterfaceTypeVNMap(modelConfig['interfaces'].toJSON());
for (var i = 0; i < portTuplesCnt; i++) {
var portTupleDispName =
this.getPortTupleDisplayName(portTupleList[i]['to'][3],
portTupleList[i], intfTypes);
var portTupleModel =
new PortTupleModel({portTupleName:
portTupleList[i]['to'][3],
portTupleDisplayName: portTupleDispName,
portTupleData:
portTupleList[i],
intfTypes: intfTypes,
Expand All @@ -649,6 +653,87 @@ define([

return modelConfig;
},
getPortTupleDisplayName: function(portTupleName, portTupleData,
intfTypes) {
var vmis = getValueByJsonPath(portTupleData,
'virtual-machine-interfaces', []);
var dispName = "port-tuple";
var splitArr = portTupleName.split('-port-tuple');
if (splitArr.length > 0) {
var newArr = splitArr[1].split('-');
if (newArr.length > 0) {
dispName += newArr[0];
}
}
var vmisCnt = vmis.length;
var vmiTypeToObjMap = {};
for (var i = 0; i < vmisCnt; i++) {
var vmiType =
getValueByJsonPath(vmis[i],
'virtual_machine_interface_properties;service_interface_type',
null);
if (null == vmiType) {
/* Weired */
console.error('service interface type is null');
continue;
}
vmiTypeToObjMap[vmiType] = vmis[i];
}
var intfTypesCnt = intfTypes.length;
for (var i = 0; i < intfTypesCnt; i++) {
var vmiObj = vmiTypeToObjMap[intfTypes[i]];
if (null == vmiObj) {
continue;
}
if (0 == i) {
dispName += ' : ';
}
var vmiId = vmiObj['uuid'];
var instIps = window.vmiToInstIpsMap[vmiId];
if ((null != instIps) && (instIps.length > 0)) {
dispName += instIps[0];
}
if (i < vmisCnt - 1) {
dispName += ', ';
}
}
return dispName;
},
setPortTupleName: function(model, portTupleEntry) {
var intfTypes = portTupleEntry.intfTypes();
var ctIntfType = model.get('interfaceType');
var intfIdx = intfTypes.indexOf(ctIntfType);
if (-1 == intfIdx) {
return;
}
var portTupleDispName = portTupleEntry.portTupleDisplayName();
var portTupleSplit = portTupleDispName.split(' : ');
var ips = [];
if (null != portTupleSplit[1]) {
ips = portTupleSplit[1].split(', ');
}
var intf = model.get('interface');
var vmiId = intf.split('~~')[1];
var intfCnt = intfTypes.length;
var dispStr = portTupleSplit[0] + ' : ';
for (var i = 0; i < intfCnt; i++) {
if (i == intfIdx) {
/* Set the IP here */
var instIps = window.vmiToInstIpsMap[vmiId];
if ((null != instIps) && (instIps.length > 0)) {
dispStr += instIps[0];
}
} else {
if (null != ips[i]) {
dispStr += ips[i];
}
}
if (i < intfCnt - 1) {
dispStr += ', ';
}
}
portTupleEntry['portTupleDisplayName'](dispStr);
},
deleteModelCollectionData: function(model, type) {
var collection = model.attributes[type];
var len = collection.length;
Expand Down Expand Up @@ -724,6 +809,7 @@ define([
},
addPortTuple: function() {
var svcInstName = this.model().get('display_name');
var self = this;
if ((null == svcInstName) || (!svcInstName.trim().length)) {
var model = this.model();
var attr = cowu.getAttributeFromPath('display_name');
Expand Down Expand Up @@ -784,15 +870,29 @@ define([
tmpPortTupleId.toString() + '-' + newUUID['hex'];
var intfs =
this.getInterfaceTypeVNMap(this.model().get('interfaces').toJSON());
var intfTypes = this.getIntfTypes(true);
var portTupleDispName =
this.getPortTupleDisplayName(portTupleName, null, intfTypes);
var newPortTupleEntry =
new PortTupleModel({portTupleName: portTupleName,
portTupleDisplayName: portTupleDispName,
portTupleData: {},
intfTypes: this.getIntfTypes(true),
intfTypes: intfTypes,
parentIntfs: intfs, disable: false});

kbValidation.bind(this.editView,
{collection:
newPortTupleEntry.model().attributes.portTupleInterfaces});
var portTupleIntfsColl =
newPortTupleEntry.model().attributes.portTupleInterfaces;
var portTupleIntfsCollLen = portTupleIntfsColl.length;
for (var i = 0; i < portTupleIntfsCollLen; i++) {
var model = portTupleIntfsColl.models[i]['attributes'].model();
self.newPortTupleEntry = newPortTupleEntry;
model.on('change:interface', function(model, newValue) {
self.setPortTupleName(model,
self.newPortTupleEntry);
});
}
portTupleCollection.add([newPortTupleEntry]);
},
getInterfaceTypeVNMap: function(intfData) {
Expand Down
23 changes: 15 additions & 8 deletions webroot/config/services/instances/ui/js/svcInst.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,30 @@ define([
if ((domain == domProj[0]) && (project == domProj[1])) {
text = vmi['uuid'];
if (instIpAddrs.length > 0) {
text = text + ' - (' + instIpAddrs.join(', ') + ')';
text = '(' + instIpAddrs.join(', ') + ') - ' + text;
}
return {text: text, id:
vmi['fq_name'].join(':') + "~~" + vmi['uuid']};
vmi['fq_name'].join(':') + "~~" + vmi['uuid'],
instIps: instIpAddrs};
} else {
var tmpFqn =
JSON.parse(JSON.stringify(vmi['fq_name']));
var domProj = tmpFqn.splice(0, 2);
text = vmi['uuid'] + " (" + domProj.join(':') + ")";
if (instIpAddrs.length > 0) {
text = text + ' - (' + instIpAddrs.join(', ') + ')';
text = '(' + instIpAddrs.join(', ') + ') - ' + text;
}
return {text: text +" (" + domProj.join(':')
+ ")",
id: vmi['fq_name'].join(':') +
"~~" + vmi['uuid']};
"~~" + vmi['uuid'],
instIps: instIpAddrs};
}
return {};
},
this.vmiListFormatter = function(vmis) {
var vnVmiMaps = {};
var vmiToInstIpsMap = {};
var vnList = [];
if ((null == vmis) || (!vmis.length)) {
return ({vnList:
Expand All @@ -85,6 +88,7 @@ define([
var vmisCnt = vmis.length;
var tmpVNIds = {};
window.allVMIList = [];
window.vmiToInstIpsMap = {};
for (var i = 0; i < vmisCnt; i++) {
var vmi =
getValueByJsonPath(vmis[i],
Expand All @@ -94,6 +98,9 @@ define([
}
var builtVMI = this.buildVMI(vmi);
window.allVMIList.push(builtVMI);
if (null != builtVMI.instIps) {
window.vmiToInstIpsMap[vmi.uuid] = builtVMI.instIps;
}
var vmRefs = getValueByJsonPath(vmi,
'virtual_machine_refs',
[]);
Expand Down Expand Up @@ -400,15 +407,15 @@ define([
iconClass: 'icon-minus'}
],
columns: [{
elementId: 'portTupleName',
elementId: 'portTupleDisplayName',
view: 'FormInputView',
class: "", width: "600",
name: 'Tuple Name',
name: 'Tuple',
viewConfig: {
disabled: true,
templateId: cowc.TMPL_EDITABLE_GRID_INPUT_VIEW,
path: 'portTupleName',
dataBindValue: 'portTupleName()'
path: 'portTupleDisplayName',
dataBindValue: 'portTupleDisplayName()'
}
}]
}
Expand Down
16 changes: 2 additions & 14 deletions webroot/config/services/instances/ui/js/views/svcInstListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,6 @@ define([
{
'type': 'route-aggregates',
},
{
'type': 'virtual-machine-interfaces',
/*
'parent_fq_name_str': getCookie('domain') + ':' +
getCookie('project'),
'parent_type': 'project'
*/
},
{
'type': 'virtual-networks',
'parent_fq_name_str': contrail.getCookie('domain') +
Expand All @@ -263,7 +255,6 @@ define([
window.interfaceRouteTableList = [];
window.routingPolicyList = [];
window.routeAggregateList = [];
window.vmiList = [];
window.allVNList = [];
if (null == response) {
return;
Expand All @@ -280,10 +271,7 @@ define([
window.routeAggregateList =
buildTextValueByConfigList(response[3],
'route-aggregates');
window.vmiList =
buildTextValueByConfigList(response[4],
'virtual-machine-interfaces');
window.allVNList = svcInstUtils.virtNwListFormatter(response[5]);
window.allVNList = svcInstUtils.virtNwListFormatter(response[4]);
if (window.allVNList.length > 0) {
window.allVNList.unshift({'text':"Auto Configured",
'id':"autoConfigured"});
Expand All @@ -294,7 +282,7 @@ define([
window.interfaceRouteTableList = [];
window.routingPolicyList = [];
window.routeAggregateList = [];
window.vmiList = [];
window.allVNList = [];
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ define([
'service_mode': 'transparent',
'service_type': 'firewall',
'flavor': null,
'version': 1,
'version': 2,
'service_scaling': false,
'vrouter_instance_type': null,
'ordered_interfaces': true,
'interface_type': []
},
'user_created_service_virtualization_type': 'virtual-machine',
'user_created_version': 1,
'user_created_version': 2,
'user_created_service_scaling': false,
'user_created_service_mode': 'transparent',
'user_created_service_type': 'firewall',
Expand Down

0 comments on commit 8cf1b4a

Please sign in to comment.