Skip to content

Commit

Permalink
In Edit case of a Parent port, subinterface ref is getting set to emp…
Browse files Browse the repository at this point in the history
…ty - Fixed it

* In case of edit a parent port vmiRef was set to empty array because of
that the reference to the subInterface was removed - Fixed it.
* Added The name along with the UUID in the landing page grid.
* In landing page grid row It shows (N more) after 3 data exist In other place
it is followed as 2 so, Changed to 2.
* Not showing the sub-interface if it is a parent port.
* dropdownAutoWidth : false, is added for the drop down's to avoid the drop down
growing beyond the view area.
* Sub-interface cannot be removed In UI the checkbox is disabled
* In Delete case, If it is a parent port We show a message saying even the
subinterface will be delete do you want to conform then sending all the UUID of
children so that the children will be removed first and then the parent will be
removed.

Service Health Check is added in UI.
Closes-Bug: #1549112

API FIX
* The sub-interface remove is not supported in delete we are trying to update the
parent port so it was throwing some error - Fixed it.
* vm ref in subinterface was added for DNS resolution and stats.
Now it is not required
* The subinterface are removed and then the parentport is removed.
* The delete is handled in both delete and delete all

Removed the reference of that VM from the created/edited Sub-interface.
Closes-Bug: #1540789

The flow was like attach of VM will happen first and then the IP was created
because of that the ip was not setting to VM To avoid that
The interface IP is added first and then the compute is getting attachecd.

Removel of VM ref from the subinterface also solves the issue
Instance name is replaced by '-' under monitor-instance tab
Closes-Bug: #1538531

Port page not able to load sometimes
Issue:
TypeError: self.deviceOwner is not a function
- Placed the function return as inline.
So it will be not be looking for that variable.
Closes-Bug: #1542295

Change-Id: I0e198219f85904f30b2420ecac79ce332c1b29bc
Closes-Bug: #1543632
  • Loading branch information
balamurugang committed Feb 24, 2016
1 parent 51d0344 commit 7decc64
Show file tree
Hide file tree
Showing 6 changed files with 590 additions and 257 deletions.
342 changes: 224 additions & 118 deletions webroot/config/networking/port/api/portsconfig.api.js

Large diffs are not rendered by default.

Expand Up @@ -48,7 +48,7 @@ define([
}
},
'mac': function(value, attr, finalObj) {
if(value != "" &&
if(value != "" && typeof value == "string" &&
isValidMACAddress(value) == false){
return "Enter valid MAC Address in Allowed address pairs";
}
Expand Down
156 changes: 125 additions & 31 deletions webroot/config/networking/port/ui/js/models/portModel.js
Expand Up @@ -44,6 +44,7 @@ define([
'logicalRouterValue':'',
'virtual_machine_refs':[],
'virtualMachineValue':'',
'service_health_check_refs':'',
'virtual_machine_interface_mac_addresses':
{
'mac_address':[]
Expand Down Expand Up @@ -90,6 +91,7 @@ define([
'templateGeneratorData': 'rawData',
'disable_sub_interface' : false,
'subnetGroupVisible': true,
'isParent' : false,
'ecmp_hashing_include_fields': {/*
'hashing_configured': false,
'source_ip': true,
Expand Down Expand Up @@ -168,7 +170,6 @@ define([
}
}
}

//Modal config default Fixed IP formatting
var fixedIPModels = [];
var fixedipList = modelConfig["instance_ip_back_refs"];
Expand Down Expand Up @@ -256,6 +257,17 @@ define([
modelConfig['staticRoute'].push(SRVal);
}
}
//Modal config default Health Check formatting
healthCheck = getValueByJsonPath(modelConfig, 'service_health_check_refs', []);
if (healthCheck.length > 0) {
var healthCheckTo = getValueByJsonPath(healthCheck[0], 'to', '');
var healthCheckuuid = getValueByJsonPath(healthCheck[0],
'uuid', '');
if (healthCheckTo != "" && healthCheckuuid != "") {
healthCheckVal = healthCheckTo.join(":") + " " + healthCheckuuid;
modelConfig['service_health_check_refs'] = healthCheckVal;
}
}

//Modal config default ECMP formatting
var ecmpHashIncFields = [];
Expand Down Expand Up @@ -322,6 +334,10 @@ define([

//Modal config default Port Binding formatting
var portBinding = [];
var devOwner = getValueByJsonPath(modelConfig, 'virtual_machine_interface_device_owner');
if ("compute" == devOwner.substring(0,7)) {
devOwner = "compute";
}
var portBindingList =
modelConfig["virtual_machine_interface_bindings"]["key_value_pair"];
if(portBindingList != null && portBindingList.length > 0) {
Expand All @@ -332,10 +348,11 @@ define([
port_binding_obj.value == "direct" ) {
port_binding_obj.key = "SR-IOV (vnic_type:direct)";
}
if(port_binding_obj.key == "SR-IOV (vnic_type:direct)" ||
if(devOwner == "compute" &&
(port_binding_obj.key == "SR-IOV (vnic_type:direct)" ||
port_binding_obj.key == "vnic_type" ||
port_binding_obj.key == "vif_type" ||
port_binding_obj.key == "vif_details") {
port_binding_obj.key == "vif_details")) {
port_binding_obj.disablePortBindKey = true;
}
var portBindingModel = new PortBindingModel(port_binding_obj);
Expand Down Expand Up @@ -412,6 +429,13 @@ define([
modelConfig["disable_sub_interface"] = true;
}
}
if(vlanTag == ""){
var vmiRefTo = getValueByJsonPath(modelConfig,
"virtual_machine_interface_refs",[]);
if (vmiRefTo.length > 0) {
modelConfig['isParent'] = true;
}
}
modelConfig['deviceOwnerValue'] = deviceOwnerValue;
return modelConfig;
},
Expand Down Expand Up @@ -483,6 +507,16 @@ define([
return "Device Owner UUID cannot be empty.";
}
},
'deviceOwnerValue': function(value, attr, finalObj) {
if (value == "router") {
if (finalObj.isParent == true) {
return "Router cannot be set to a parent port.";
}
if (finalObj.is_sub_interface == true) {
return "Router cannot be set to a Sub Interface.";
}
}
},
'portBindingCollection': function(value, attr, finalObj) {
if(value.length > 0) {
var portBindingLength = value.length;
Expand Down Expand Up @@ -822,7 +856,10 @@ define([
aapLocal[i] = {};
var prefix = 32;
var ip = aapCollection[i].ipPrefixVal();
aapLocal[i]["mac"] = aapCollection[i].mac();
//aapLocal[i]["mac"] = null;
if (aapCollection[i].mac() != "") {
aapLocal[i]["mac"] = aapCollection[i].mac();
}
if(ip != ""){
aapLocal[i]["ip"] = {};
if(ip.split("/").length == 2) {
Expand Down Expand Up @@ -946,6 +983,18 @@ define([
} else {
newPortData.interface_route_table_refs = [];
}
// Health Check
var healthCheck = getValueByJsonPath(newPortData,
"service_health_check_refs","");
if(healthCheck != "") {
var healthCheckArr = healthCheck.split(" ");
newPortData.service_health_check_refs = [];
newPortData.service_health_check_refs[0] = {};
newPortData.service_health_check_refs[0].to = healthCheckArr[0].split(":");
newPortData.service_health_check_refs[0].uuid = healthCheckArr[1];
} else {
newPortData.service_health_checks_refs = [];
}
/* ECMP Hashing */
var ecmpHashIncFields = this.getNonDefaultECMPHashingFields();
var count = 0;
Expand Down Expand Up @@ -1096,10 +1145,10 @@ define([
newPortData.virtual_machine_interface_refs[0].uuid = uuid;
newPortData.virtual_machine_interface_refs[0].to = to;
} else {
newPortData.virtual_machine_interface_refs = [];
//if(selectedParentVMIObject.length > 0) {
// newPortData["virtual_machine_interface_refs"] = selectedParentVMIObject;
//}
newPortData.virtual_machine_interface_properties.sub_interface_vlan_tag = null;
if (newPortData.isParent != true) {
newPortData.virtual_machine_interface_refs = [];
}
}
newPortData.virtual_machine_interface_properties.interface_mirror = {}
if (newPortData.is_mirror == true) {
Expand Down Expand Up @@ -1188,6 +1237,7 @@ define([
delete(newPortData.mirrorToAnalyzerIpAddress);
delete(newPortData.mirrorToRoutingInstance);
delete(newPortData.mirrorToUdpPort);
delete(newPortData.isParent);
if("parent_href" in newPortData) {
delete(newPortData.parent_href);
}
Expand Down Expand Up @@ -1250,30 +1300,74 @@ define([
deletePort: function(selectedGridData, callbackObj) {
var ajaxConfig = {}, returnFlag = false;
var delDataID = [];
for(var i=0;i<selectedGridData.length;i++) {
delDataID.push(selectedGridData[i]["uuid"]);
}
var sentData = [{"type": "virtual-machine-interface",
"deleteIDs": delDataID}];
ajaxConfig.async = false;
ajaxConfig.type = "POST";
ajaxConfig.data = JSON.stringify(sentData);
ajaxConfig.url = "/api/tenants/config/delete";
contrail.ajaxHandler(ajaxConfig, function () {
if (contrail.checkIfFunction(callbackObj.init)) {
callbackObj.init();
}
}, function (response) {
if (contrail.checkIfFunction(callbackObj.success)) {
callbackObj.success();
}
returnFlag = true;
}, function (error) {
if (contrail.checkIfFunction(callbackObj.error)) {
callbackObj.error(error);
var parentPort = [];
var isParentPortBool;
var sendData = [];
var subInterface = [];
var pushedUUIDForParent = [];
for (var i = 0; i < selectedGridData.length; i++) {
var vmiRelation = portFormatters.getVMIRelation(selectedGridData[i]);
switch (vmiRelation){
case "vmi": {
delDataID.push({"type": "virtual-machine-interface",
"deleteIDs": [selectedGridData[i]["uuid"]],
"userData" : null});
break;
}
case "subInterface": {
subInterface.push(selectedGridData[i]["uuid"]);
break;
}
case "primaryInterface": {
var chiledUUID = [];
var children = getValueByJsonPath(selectedGridData[i],
"virtual_machine_interface_refs",
[]);
var vmiChildlen = children.length;
for (var j = 0; j < vmiChildlen; j++) {
var tempUUID = getValueByJsonPath(
children[j], "uuid");
chiledUUID.push(tempUUID);
pushedUUIDForParent.push(tempUUID)
}
parentPort.push({"type": "virtual-machine-interface",
"deleteIDs": [selectedGridData[i]["uuid"]],
"userData" : chiledUUID});
break;
}
}
returnFlag = false;
});
}
for (var j = 0; j < subInterface.length; j++) {
if (!(_.contains(pushedUUIDForParent, subInterface[j]))) {
delDataID.push({"type": "virtual-machine-interface",
"deleteIDs": [subInterface[j]],
"userData" : null})
};
}
delDataID = delDataID.concat(parentPort);
delDataID = _.uniq(delDataID);
if (delDataID.length > 0) {
var sentData = delDataID;
ajaxConfig.async = false;
ajaxConfig.type = "POST";
ajaxConfig.data = JSON.stringify(sentData);
ajaxConfig.url = "/api/tenants/config/delete";
contrail.ajaxHandler(ajaxConfig, function () {
if (contrail.checkIfFunction(callbackObj.init)) {
callbackObj.init();
}
}, function (response) {
if (contrail.checkIfFunction(callbackObj.success)) {
callbackObj.success();
}
returnFlag = true;
}, function (error) {
if (contrail.checkIfFunction(callbackObj.error)) {
callbackObj.error(error);
}
returnFlag = false;
});
}
return returnFlag;
},
deleteAllPort: function(callbackObj) {
Expand Down

0 comments on commit 7decc64

Please sign in to comment.