Add management IP/tenant IP/hostname customization
Change-Id: Ifc7486f8eec840239d0988b564470e45ae870a7e
This commit is contained in:
parent
56fe97ac8a
commit
4bb020fe4e
@ -16,3 +16,17 @@
|
|||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
box-shadow: 0 0 5px 0 rgba(215, 211, 207, 0.75) inset;
|
box-shadow: 0 0 5px 0 rgba(215, 211, 207, 0.75) inset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#customize-panel {
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#autofill-panel {
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.radioText {
|
||||||
|
color: #5964A1;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight:bold;
|
||||||
|
}
|
||||||
|
@ -33,25 +33,54 @@ steal(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("input:radio[name='fillType']").change(function() {
|
||||||
|
var fillType = $("input:radio[name='fillType']:checked").val();
|
||||||
|
if(fillType == "autofill") {
|
||||||
|
$("#autofill-panel").show(500);
|
||||||
|
$("#customize-panel").hide(500);
|
||||||
|
} else {
|
||||||
|
$("#autofill-panel").hide(500);
|
||||||
|
$("#customize-panel").show(500);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$("#dialog-confirm").dialog({
|
$("#dialog-confirm").dialog({
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
height: 200,
|
height: 350,
|
||||||
width: 500,
|
width: 550,
|
||||||
modal: true,
|
modal: true,
|
||||||
buttons: {
|
buttons: {
|
||||||
"Fill values": function() {
|
"Fill values": function() {
|
||||||
var pattern = $("#pattern").val();
|
var fillType = $("input:radio[name='fillType']:checked").val();
|
||||||
if (pattern == "Switch IP") {
|
|
||||||
|
if(fillType == "autofill") {
|
||||||
|
var management_auto = $("#management-auto").val();
|
||||||
|
var tenant_auto = $("#tenant-auto").val();
|
||||||
|
var hostname_auto = $("#hostname-auto").val();
|
||||||
|
|
||||||
|
if (hostname_auto == "Switch IP") {
|
||||||
self.fillHostnameBySwitchIp();
|
self.fillHostnameBySwitchIp();
|
||||||
} else if (pattern == "Switch alias") {
|
} else if (hostname_auto == "Switch alias") {
|
||||||
self.fillHostnameBySwitchAlias();
|
self.fillHostnameBySwitchAlias();
|
||||||
} else if (pattern == "Host") {
|
} else if (hostname_auto == "Host") {
|
||||||
self.fillHostnameByServer();
|
self.fillHostnameByServer();
|
||||||
} else if (pattern == "Custom") {
|
|
||||||
self.fillHostnameByCustomStr();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.fillMgtIpBySequence(parseInt(management_auto));
|
||||||
|
self.fillTntIpBySequence(parseInt(tenant_auto));
|
||||||
|
} else { //customize
|
||||||
|
var management_cust = $("#management-customize").val();
|
||||||
|
var tenant_cust = $("#tenant-customize").val();
|
||||||
|
var hostname_cust = $("#hostname-customize").val();
|
||||||
|
|
||||||
|
|
||||||
|
self.fillMgtIpByCustomStr(management_cust);
|
||||||
|
self.fillTntIpByCustomStr(tenant_cust);
|
||||||
|
self.fillHostnameByCustomStr(hostname_cust);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.tabSelected($(".tab_nav_active"));
|
||||||
$(this).dialog("close");
|
$(this).dialog("close");
|
||||||
},
|
},
|
||||||
Cancel: function() {
|
Cancel: function() {
|
||||||
@ -133,7 +162,6 @@ steal(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.options.odsState.servers_config = serverData;
|
this.options.odsState.servers_config = serverData;
|
||||||
this.tabSelected($(".tab_nav_active"));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
fillHostnameBySwitchAlias: function() {
|
fillHostnameBySwitchAlias: function() {
|
||||||
@ -147,7 +175,6 @@ steal(
|
|||||||
key_index++;
|
key_index++;
|
||||||
}
|
}
|
||||||
this.options.odsState.servers_config = serverData;
|
this.options.odsState.servers_config = serverData;
|
||||||
this.tabSelected($(".tab_nav_active"));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
fillHostnameByServer: function() {
|
fillHostnameByServer: function() {
|
||||||
@ -161,108 +188,279 @@ steal(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.options.odsState.servers_config = serverData;
|
this.options.odsState.servers_config = serverData;
|
||||||
this.tabSelected($(".tab_nav_active"));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
fillHostnameByCustomStr: function() {
|
fillHostnameByCustomStr: function(customStr) {
|
||||||
var preDefinedPatterns = ["{switchIp}", "{port}",
|
var preDefinedPatterns = ["{swIpPart1}", "{swIpPart2}", "{swIpPart3}", "{swIpPart4}", "{port}",
|
||||||
"{d.1}", "{d.2}", "{d.3}", "{d.4}",
|
|
||||||
"{mgtIpPart1}", "{mgtIpPart2}", "{mgtIpPart3}", "{mgtIpPart4}",
|
"{mgtIpPart1}", "{mgtIpPart2}", "{mgtIpPart3}", "{mgtIpPart4}",
|
||||||
"{tntIpPart1}", "{tntIpPart2}", "{tntIpPart3}", "{tntIpPart4}"
|
"{tntIpPart1}", "{tntIpPart2}", "{tntIpPart3}", "{tntIpPart4}"
|
||||||
];
|
];
|
||||||
var customStr = $("#custom-pattern").val();
|
var swIpPart1 = 0,
|
||||||
var serverData = this.options.odsState.servers_config;
|
swIpPart2 = 0,
|
||||||
var server_index = 1;
|
swIpPart3 = 0,
|
||||||
var customHostname = "";
|
swIpPart4 = 0,
|
||||||
|
port = 0,
|
||||||
|
mgtIpPart1 = 0,
|
||||||
|
mgtIpPart2 = 0,
|
||||||
|
mgtIpPart3 = 0,
|
||||||
|
mgtIpPart4 = 0,
|
||||||
|
tntIpPart1 = 0,
|
||||||
|
tntIpPart2 = 0,
|
||||||
|
tntIpPart3 = 0,
|
||||||
|
tntIpPart4 = 0;
|
||||||
|
digitNum = 0,
|
||||||
|
customCalculation = 0;
|
||||||
|
|
||||||
|
var regExp = /\[([^)]+\].(\d+))/;
|
||||||
|
var originalCustomStr = customStr;
|
||||||
|
var replaceStr = "";
|
||||||
|
|
||||||
|
customCalculation = regExp.exec(customStr);
|
||||||
|
if (customCalculation) {
|
||||||
|
replaceStr = customCalculation[0];
|
||||||
|
digitNum = parseInt(customCalculation[2]);
|
||||||
|
customCalculation = customCalculation[1].split("].")[0];
|
||||||
|
} else {
|
||||||
|
regExp = /\[([^)]+)\]/;
|
||||||
|
customCalculation = regExp.exec(customStr);
|
||||||
|
if(customCalculation) {
|
||||||
|
replaceStr = customCalculation[0];
|
||||||
|
customCalculation = customCalculation[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!customCalculation) {
|
||||||
|
alert("Invalid host name customization");
|
||||||
|
} else {
|
||||||
|
customCalculation = customCalculation.replace(preDefinedPatterns[0], "swIpPart1");
|
||||||
|
customCalculation = customCalculation.replace(preDefinedPatterns[1], "swIpPart2");
|
||||||
|
customCalculation = customCalculation.replace(preDefinedPatterns[2], "swIpPart3");
|
||||||
|
customCalculation = customCalculation.replace(preDefinedPatterns[3], "swIpPart4");
|
||||||
|
customCalculation = customCalculation.replace(preDefinedPatterns[4], "port");
|
||||||
|
customCalculation = customCalculation.replace(preDefinedPatterns[5], "mgtIpPart1");
|
||||||
|
customCalculation = customCalculation.replace(preDefinedPatterns[6], "mgtIpPart2");
|
||||||
|
customCalculation = customCalculation.replace(preDefinedPatterns[7], "mgtIpPart3");
|
||||||
|
customCalculation = customCalculation.replace(preDefinedPatterns[8], "mgtIpPart4");
|
||||||
|
customCalculation = customCalculation.replace(preDefinedPatterns[9], "tntIpPart1");
|
||||||
|
customCalculation = customCalculation.replace(preDefinedPatterns[10], "tntIpPart2");
|
||||||
|
customCalculation = customCalculation.replace(preDefinedPatterns[11], "tntIpPartt3");
|
||||||
|
customCalculation = customCalculation.replace(preDefinedPatterns[12], "tntIpPart4");
|
||||||
|
|
||||||
|
var serverData = this.options.odsState.servers_config;
|
||||||
|
var originalCustomCalculation = customCalculation;
|
||||||
for (var key in serverData) {
|
for (var key in serverData) {
|
||||||
|
var swIpParts = key.split(".");
|
||||||
|
swIpPart1 = swIpParts[0];
|
||||||
|
swIpPart2 = swIpParts[1];
|
||||||
|
swIpPart3 = swIpParts[2];
|
||||||
|
swIpPart4 = swIpParts[3];
|
||||||
|
|
||||||
var servers = serverData[key];
|
var servers = serverData[key];
|
||||||
for (var i = 0; i < servers.length; i++) {
|
for (var i = 0; i < servers.length; i++) {
|
||||||
customStr = $("#custom-pattern").val();
|
port = servers[i].port;
|
||||||
for (var patternIndex = 0; patternIndex < preDefinedPatterns.length; patternIndex++) {
|
var mgtIpParts = servers[i].management_ip.split(".");
|
||||||
if (customStr.indexOf(preDefinedPatterns[patternIndex]) != -1) {
|
mgtIpPart1 = mgtIpParts[0];
|
||||||
switch (patternIndex) {
|
mgtIpPart2 = mgtIpParts[1];
|
||||||
case 0: //{switchIp}
|
mgtIpPart3 = mgtIpParts[2];
|
||||||
customHostname = customStr.replace("{switchIp}", key.replace(/\./g, "-"));
|
mgtIpPart4 = mgtIpParts[3];
|
||||||
break;
|
var tntIpParts = servers[i].tenant_ip.split(".");
|
||||||
case 1: //{port}
|
tntIpPart1 = tntIpParts[0];
|
||||||
customHostname = customStr.replace("{port}", servers[i].port);
|
tntIpPart2 = tntIpParts[1];
|
||||||
break;
|
tntIpPart3 = tntIpParts[2];
|
||||||
case 2: //{d.1}
|
tntIpPart4 = tntIpParts[3];
|
||||||
customHostname = customStr.replace("{d.1}", server_index);
|
|
||||||
break;
|
try {
|
||||||
case 3: //{d.2}
|
customCalculation = eval(customCalculation);
|
||||||
if (server_index < 10) {
|
if(digitNum > 1) {
|
||||||
customHostname = customStr.replace("{d.2}", "0" + server_index);
|
customCalculation = this.leftPad(customCalculation, digitNum);
|
||||||
} else {
|
|
||||||
customHostname = customStr.replace("{d.2}", server_index);
|
|
||||||
}
|
}
|
||||||
break;
|
serverData[key][i]['hostname'] = originalCustomStr.replace(replaceStr, customCalculation);
|
||||||
case 4: //{d.3}
|
} catch (err) {
|
||||||
if (server_index < 10) {
|
serverData[key][i]['hostname'] = "";
|
||||||
customHostname = customStr.replace("{d.3}", "00" + server_index);
|
|
||||||
} else if (server_index < 100) {
|
|
||||||
customHostname = customStr.replace("{d.3}", "0" + server_index);
|
|
||||||
} else {
|
|
||||||
customHostname = customStr.replace("{d.3}", server_index);
|
|
||||||
}
|
}
|
||||||
break;
|
customCalculation = originalCustomCalculation;
|
||||||
case 5: //{d.4}
|
|
||||||
if (server_index < 10) {
|
|
||||||
customHostname = customStr.replace("{d.4}", "000" + server_index);
|
|
||||||
} else if (server_index < 100) {
|
|
||||||
customHostname = customStr.replace("{d.4}", "00" + server_index);
|
|
||||||
} else if (server_index < 1000) {
|
|
||||||
customHostname = customStr.replace("{d.4}", "0" + server_index);
|
|
||||||
} else {
|
|
||||||
customHostname = customStr.replace("{d.4}", server_index);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 6: //{mgtIpPart1}
|
|
||||||
var mgtIpPart1 = servers[i].management_ip.split(".")[0];
|
|
||||||
customHostname = customStr.replace("{mgtIpPart1}", mgtIpPart1);
|
|
||||||
break;
|
|
||||||
case 7: //{mgtIpPart2}
|
|
||||||
var mgtIpPart2 = servers[i].management_ip.split(".")[1];
|
|
||||||
customHostname = customStr.replace("{mgtIpPart2}", mgtIpPart2);
|
|
||||||
break;
|
|
||||||
case 8: //{mgtIpPart3}
|
|
||||||
var mgtIpPart3 = servers[i].management_ip.split(".")[2];
|
|
||||||
customHostname = customStr.replace("{mgtIpPart3}", mgtIpPart3);
|
|
||||||
break;
|
|
||||||
case 9: //{mgtIpPart4}
|
|
||||||
var mgtIpPart4 = servers[i].management_ip.split(".")[3];
|
|
||||||
customHostname = customStr.replace("{mgtIpPart4}", mgtIpPart4);
|
|
||||||
break;
|
|
||||||
case 10: //{tntIpPart1}
|
|
||||||
var tntIpPart1 = servers[i].tenant_ip.split(".")[0];
|
|
||||||
customHostname = customStr.replace("{tntIpPart1}", tntIpPart1);
|
|
||||||
break;
|
|
||||||
case 11: //{tntIpPart2}
|
|
||||||
var tntIpPart2 = servers[i].tenant_ip.split(".")[1];
|
|
||||||
customHostname = customStr.replace("{tntIpPart2}", tntIpPart2);
|
|
||||||
break;
|
|
||||||
case 12: //{tntIpPart3}
|
|
||||||
var tntIpPart3 = servers[i].tenant_ip.split(".")[2];
|
|
||||||
customHostname = customStr.replace("{tntIpPart3}", tntIpPart3);
|
|
||||||
break;
|
|
||||||
case 13: //{tntIpPart4}
|
|
||||||
var tntIpPart4 = servers[i].tenant_ip.split(".")[3];
|
|
||||||
customHostname = customStr.replace("{tntIpPart4}", tntIpPart4);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
customHostname = "";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
customStr = customHostname;
|
|
||||||
} // end of if
|
|
||||||
} //end of preDefinedPatterns for loop
|
|
||||||
servers[i]['hostname'] = customHostname;
|
|
||||||
server_index++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.options.odsState.servers_config = serverData;
|
this.options.odsState.servers_config = serverData;
|
||||||
this.tabSelected($(".tab_nav_active"));
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
leftPad: function(number, targetLength) {
|
||||||
|
var output = number + '';
|
||||||
|
while (output.length < targetLength) {
|
||||||
|
output = '0' + output;
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
},
|
||||||
|
|
||||||
|
fillMgtIpBySequence: function(interval) {
|
||||||
|
var mgtIpStart = this.options.odsState.networking.interfaces.management.ip_start;
|
||||||
|
var mgtIpEnd = this.options.odsState.networking.interfaces.management.ip_end;
|
||||||
|
|
||||||
|
var mgtIpStartParts = mgtIpStart.split(".");
|
||||||
|
var mgtIpEndParts = mgtIpEnd.split(".");
|
||||||
|
|
||||||
|
var mgtIpParts = [parseInt(mgtIpStartParts[0]), parseInt(mgtIpStartParts[1]), parseInt(mgtIpStartParts[2]), parseInt(mgtIpStartParts[3])];
|
||||||
|
|
||||||
|
var serverData = this.options.odsState.servers_config;
|
||||||
|
for (var key in serverData) {
|
||||||
|
var servers = serverData[key];
|
||||||
|
for (var i = 0; i < servers.length; i++) {
|
||||||
|
if (mgtIpParts[3] > 255) {
|
||||||
|
mgtIpParts[3] = mgtIpParts[3] - 256;
|
||||||
|
mgtIpParts[2]++;
|
||||||
|
}
|
||||||
|
if (mgtIpParts[2] > 255) {
|
||||||
|
mgtIpParts[2] = mgtIpParts[2] - 256;
|
||||||
|
mgtIpParts[1]++;
|
||||||
|
}
|
||||||
|
if (mgtIpParts[1] > 255) {
|
||||||
|
mgtIpParts[1] = mgtIpParts[1] - 256;
|
||||||
|
mgtIpParts[0]++;
|
||||||
|
}
|
||||||
|
if (mgtIpParts[0] > 255) {
|
||||||
|
alert("Management IP range is not enough. Please update management IP start and end on Networking page.");
|
||||||
|
serverData[key][i]['management_ip'] = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
serverData[key][i]['management_ip'] = mgtIpParts[0] + "." + mgtIpParts[1] + "." + mgtIpParts[2] + "." + mgtIpParts[3];
|
||||||
|
mgtIpParts[3] = mgtIpParts[3] + interval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.options.odsState.servers_config = serverData;
|
||||||
|
},
|
||||||
|
|
||||||
|
fillTntIpBySequence: function(interval) {
|
||||||
|
var tntIpStart = this.options.odsState.networking.interfaces.tenant.ip_start;
|
||||||
|
var tntIpEnd = this.options.odsState.networking.interfaces.tenant.ip_end;
|
||||||
|
|
||||||
|
var tntIpStartParts = tntIpStart.split(".");
|
||||||
|
var tntIpEndParts = tntIpEnd.split(".");
|
||||||
|
|
||||||
|
var tntIpParts = [parseInt(tntIpStartParts[0]), parseInt(tntIpStartParts[1]), parseInt(tntIpStartParts[2]), parseInt(tntIpStartParts[3])];
|
||||||
|
|
||||||
|
var serverData = this.options.odsState.servers_config;
|
||||||
|
for (var key in serverData) {
|
||||||
|
var servers = serverData[key];
|
||||||
|
for (var i = 0; i < servers.length; i++) {
|
||||||
|
if (tntIpParts[3] > 255) {
|
||||||
|
tntIpParts[3] = tntIpParts[3] - 256;
|
||||||
|
tntIpParts[2]++;
|
||||||
|
}
|
||||||
|
if (tntIpParts[2] > 255) {
|
||||||
|
tntIpParts[2] = tntIpParts[2] - 256;
|
||||||
|
tntIpParts[1]++;
|
||||||
|
}
|
||||||
|
if (tntIpParts[1] > 255) {
|
||||||
|
tntIpParts[1] = tntIpParts[1] - 256;
|
||||||
|
tntIpParts[0]++;
|
||||||
|
}
|
||||||
|
if (tntIpParts[0] > 255) {
|
||||||
|
alert("Tenent IP range is not enough. Please update tenant IP start and end on Networking page.");
|
||||||
|
serverData[key][i]['management_ip'] = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
serverData[key][i]['tenant_ip'] = tntIpParts[0] + "." + tntIpParts[1] + "." + tntIpParts[2] + "." + tntIpParts[3];
|
||||||
|
tntIpParts[3] = tntIpParts[3] + interval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.options.odsState.servers_config = serverData;
|
||||||
|
},
|
||||||
|
|
||||||
|
fillMgtIpByCustomStr: function(customStr) {
|
||||||
|
var preDefinedPatterns = ["{swIpPart1}", "{swIpPart2}", "{swIpPart3}", "{swIpPart4}", "{port}"];
|
||||||
|
var swIpPart1 = 0,
|
||||||
|
swIpPart2 = 0,
|
||||||
|
swIpPart3 = 0,
|
||||||
|
swIpPart4 = 0,
|
||||||
|
port = 0;
|
||||||
|
var regExp = /\[([^)]+)\]/;
|
||||||
|
customStr = regExp.exec(customStr);
|
||||||
|
if (!customStr) {
|
||||||
|
alert("Invalid management IP customization");
|
||||||
|
} else {
|
||||||
|
customStr = customStr[1];
|
||||||
|
customStr = customStr.replace(preDefinedPatterns[0], "swIpPart1");
|
||||||
|
customStr = customStr.replace(preDefinedPatterns[1], "swIpPart2");
|
||||||
|
customStr = customStr.replace(preDefinedPatterns[2], "swIpPart3");
|
||||||
|
customStr = customStr.replace(preDefinedPatterns[3], "swIpPart4");
|
||||||
|
customStr = customStr.replace(preDefinedPatterns[4], "port");
|
||||||
|
|
||||||
|
var mgtIpStart = this.options.odsState.networking.interfaces.management.ip_start;
|
||||||
|
var mgtIpEnd = this.options.odsState.networking.interfaces.management.ip_end;
|
||||||
|
var mgtIpStartParts = mgtIpStart.split(".");
|
||||||
|
var mgtIpEndParts = mgtIpEnd.split(".");
|
||||||
|
var mgtIpParts = [parseInt(mgtIpStartParts[0]), parseInt(mgtIpStartParts[1]), parseInt(mgtIpStartParts[2]), parseInt(mgtIpStartParts[3])];
|
||||||
|
|
||||||
|
var serverData = this.options.odsState.servers_config;
|
||||||
|
for (var key in serverData) {
|
||||||
|
var swIpParts = key.split(".");
|
||||||
|
swIpPart1 = swIpParts[0];
|
||||||
|
swIpPart2 = swIpParts[1];
|
||||||
|
swIpPart3 = swIpParts[2];
|
||||||
|
swIpPart4 = swIpParts[3];
|
||||||
|
|
||||||
|
var servers = serverData[key];
|
||||||
|
for (var i = 0; i < servers.length; i++) {
|
||||||
|
port = servers[i].port;
|
||||||
|
try {
|
||||||
|
mgtIpParts[3] = eval(customStr);
|
||||||
|
serverData[key][i]['management_ip'] = mgtIpParts[0] + "." + mgtIpParts[1] + "." + mgtIpParts[2] + "." + mgtIpParts[3];
|
||||||
|
} catch (err) {
|
||||||
|
serverData[key][i]['management_ip'] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.options.odsState.servers_config = serverData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
fillTntIpByCustomStr: function(customStr) {
|
||||||
|
var preDefinedPatterns = ["{swIpPart1}", "{swIpPart2}", "{swIpPart3}", "{swIpPart4}", "{port}"];
|
||||||
|
var swIpPart1 = 0,
|
||||||
|
swIpPart2 = 0,
|
||||||
|
swIpPart3 = 0,
|
||||||
|
swIpPart4 = 0,
|
||||||
|
port = 0;
|
||||||
|
var regExp = /\[([^)]+)\]/;
|
||||||
|
customStr = regExp.exec(customStr);
|
||||||
|
if (!customStr) {
|
||||||
|
alert("Invalid tenant IP customization");
|
||||||
|
} else {
|
||||||
|
customStr = customStr[1];
|
||||||
|
customStr = customStr.replace(preDefinedPatterns[0], "swIpPart1");
|
||||||
|
customStr = customStr.replace(preDefinedPatterns[1], "swIpPart2");
|
||||||
|
customStr = customStr.replace(preDefinedPatterns[2], "swIpPart3");
|
||||||
|
customStr = customStr.replace(preDefinedPatterns[3], "swIpPart4");
|
||||||
|
customStr = customStr.replace(preDefinedPatterns[4], "port");
|
||||||
|
|
||||||
|
var tntIpStart = this.options.odsState.networking.interfaces.tenant.ip_start;
|
||||||
|
var tntIpEnd = this.options.odsState.networking.interfaces.tenant.ip_end;
|
||||||
|
var tntIpStartParts = tntIpStart.split(".");
|
||||||
|
var tntIpEndParts = tntIpEnd.split(".");
|
||||||
|
var tntIpParts = [parseInt(tntIpStartParts[0]), parseInt(tntIpStartParts[1]), parseInt(tntIpStartParts[2]), parseInt(tntIpStartParts[3])];
|
||||||
|
|
||||||
|
var serverData = this.options.odsState.servers_config;
|
||||||
|
for (var key in serverData) {
|
||||||
|
var swIpParts = key.split(".");
|
||||||
|
swIpPart1 = swIpParts[0];
|
||||||
|
swIpPart2 = swIpParts[1];
|
||||||
|
swIpPart3 = swIpParts[2];
|
||||||
|
swIpPart4 = swIpParts[3];
|
||||||
|
|
||||||
|
var servers = serverData[key];
|
||||||
|
for (var i = 0; i < servers.length; i++) {
|
||||||
|
port = servers[i].port;
|
||||||
|
try {
|
||||||
|
tntIpParts[3] = eval(customStr);
|
||||||
|
serverData[key][i]['tenant_ip'] = tntIpParts[0] + "." + tntIpParts[1] + "." + tntIpParts[2] + "." + tntIpParts[3];
|
||||||
|
} catch (err) {
|
||||||
|
serverData[key][i]['tenant_ip'] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.options.odsState.servers_config = serverData;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
filloutTabs: function() {
|
filloutTabs: function() {
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
id: 10,
|
id: 10,
|
||||||
mac: "28:6e:31:47:c8:6c",
|
mac: "28:6e:31:47:c8:6c",
|
||||||
port: "1",
|
port: "1",
|
||||||
management_ip: "10.2.172.9",
|
management_ip: "",
|
||||||
tenant_ip: "192.168.100.100",
|
tenant_ip: "",
|
||||||
switch_ip: "172.29.8.40",
|
switch_ip: "172.29.8.40",
|
||||||
vlan: "1",
|
vlan: "1",
|
||||||
roles: []
|
roles: []
|
||||||
@ -39,8 +39,8 @@
|
|||||||
id: 10,
|
id: 10,
|
||||||
mac: "28:6e:31:34:fd:28",
|
mac: "28:6e:31:34:fd:28",
|
||||||
port: "2",
|
port: "2",
|
||||||
management_ip: "10.2.172.10",
|
management_ip: "",
|
||||||
tenant_ip: "192.168.100.101",
|
tenant_ip: "",
|
||||||
switch_ip: "172.29.8.40",
|
switch_ip: "172.29.8.40",
|
||||||
vlan: "2",
|
vlan: "2",
|
||||||
roles: []
|
roles: []
|
||||||
@ -72,6 +72,42 @@
|
|||||||
|
|
||||||
state.servers_config = config;
|
state.servers_config = config;
|
||||||
state.cluster_id = 1;
|
state.cluster_id = 1;
|
||||||
|
state.networking = {
|
||||||
|
"interfaces": {
|
||||||
|
"management": {
|
||||||
|
"ip_start": "255.255.250.1",
|
||||||
|
"ip_end": "10.10.10.255",
|
||||||
|
"netmask": "255.255.255.0",
|
||||||
|
"gateway": "10.10.10.1",
|
||||||
|
"nic": "eth0",
|
||||||
|
"promisc": 0
|
||||||
|
},
|
||||||
|
"tenant": {
|
||||||
|
"ip_start": "192.168.100.100",
|
||||||
|
"ip_end": "192.168.100.200",
|
||||||
|
"netmask": "255.255.255.0",
|
||||||
|
"gateway": "192.168.100.1",
|
||||||
|
"nic": "eth0",
|
||||||
|
"promisc": 0
|
||||||
|
},
|
||||||
|
"public": {
|
||||||
|
"ip_start": "172.29.3.100",
|
||||||
|
"ip_end": "172.29.3.200",
|
||||||
|
"netmask": "255.255.255.0",
|
||||||
|
"gateway": "172.29.3.1",
|
||||||
|
"nic": "eth1",
|
||||||
|
"promisc": 1
|
||||||
|
},
|
||||||
|
"storage": {
|
||||||
|
"ip_start": "172.16.128.10",
|
||||||
|
"ip_end": "172.16.128.200",
|
||||||
|
"netmask": "255.255.255.0",
|
||||||
|
"gateway": "172.16.128.1",
|
||||||
|
"nic": "eth0",
|
||||||
|
"promisc": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$('#host_config-test').ods_ui_host_config({ "odsState" : state });
|
$('#host_config-test').ods_ui_host_config({ "odsState" : state });
|
||||||
|
|
||||||
|
@ -5,26 +5,73 @@
|
|||||||
<div class="rounded" style="padding-top: 10; padding-bottom: 5px">
|
<div class="rounded" style="padding-top: 10; padding-bottom: 5px">
|
||||||
<div class="float_left">Switch IP</div>
|
<div class="float_left">Switch IP</div>
|
||||||
<div class="float_right">
|
<div class="float_right">
|
||||||
<a href="javascript: void(0)" id="auto_fill" style="padding-right:20px">Auto-fill values</a>
|
<a href="javascript: void(0)" id="auto_fill" style="padding-right:20px">Fill values</a>
|
||||||
<a id="clear-hostconfig" href="javascript: void(0)">Clear</a>
|
<a id="clear-hostconfig" href="javascript: void(0)">Clear</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="clear"> </div>
|
<div class="clear"> </div>
|
||||||
<div id="dialog-confirm" title="Auto fill values">
|
<div id="dialog-confirm" title="Fill values">
|
||||||
<p>
|
|
||||||
<div class="float_left" id="test">Host name pattern:</div>
|
<div>
|
||||||
|
<input type="radio" name="fillType" value="autofill" checked> <span class="radioText">Auto fill</span>
|
||||||
|
<div id="autofill-panel">
|
||||||
<div class="float_left">
|
<div class="float_left">
|
||||||
<select id="pattern">
|
<p>Management IP</p>
|
||||||
|
<p>Tenant IP</p>
|
||||||
|
<p>Host name</p>
|
||||||
|
</div>
|
||||||
|
<div class="float_left" style="padding-left:10px">
|
||||||
|
<p>
|
||||||
|
<select id="management-auto">
|
||||||
|
<option value="1">Increase by 1</option>
|
||||||
|
<option value="2">Increase by 2</option>
|
||||||
|
<option value="3">Increase by 3</option>
|
||||||
|
<option value="4">Increase by 4</option>
|
||||||
|
<option value="5">Increase by 5</option>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<select id="tenant-auto">
|
||||||
|
<option value="1">Increase by 1</option>
|
||||||
|
<option value="2">Increase by 2</option>
|
||||||
|
<option value="3">Increase by 3</option>
|
||||||
|
<option value="4">Increase by 4</option>
|
||||||
|
<option value="5">Increase by 5</option>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<select id="hostname-auto">
|
||||||
<option value="Host">Host</option>
|
<option value="Host">Host</option>
|
||||||
<option value="Switch IP">Switch IP</option>
|
<option value="Switch IP">Switch IP</option>
|
||||||
<option value="Switch alias">Switch alias</option>
|
<option value="Switch alias">Switch alias</option>
|
||||||
<option value="Custom">Custom</option>
|
</select>
|
||||||
</select><br>
|
|
||||||
<input id="custom-pattern" class="rounded non-empty-value" style="display:none; margin-top:10px; width:255px">
|
|
||||||
</div>
|
|
||||||
<span class="pattern-tip ui-icon ui-icon-info" style="float: right; margin: 6px 19px 4px 7px;" data-geo="info-ico">
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="">
|
</div>
|
||||||
|
<div class="clear"></div>
|
||||||
|
<input type="radio" name="fillType" value="customize"> <span class="radioText">Customize</span>
|
||||||
|
<div id="customize-panel" style="display:none">
|
||||||
|
<div class="float_left">
|
||||||
|
<p>Management IP</p>
|
||||||
|
<p>Tenant IP</p>
|
||||||
|
<p>Host name</p>
|
||||||
|
</div>
|
||||||
|
<div class="float_left" style="padding-left:10px">
|
||||||
|
<p>
|
||||||
|
<input id="management-customize" class="rounded" value="[{port}*2]" placeholder="eg: [{port}*2]">
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<input id="tenant-customize" class="rounded" value="[{port}*2+1]" placeholder="eg: [{port}*2+1]">
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<input id="hostname-customize" class="rounded" value="sv-[{mgtIpPart4}*2+3].3" placeholder="eg: sv-[{mgtIpPart4}*2+3].3">
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--<span class="pattern-tip ui-icon ui-icon-info" style="float: right; margin: 6px 19px 4px 7px;" data-geo="info-ico">-->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
<div class="float_left switch-navs" style="padding-top: 20px;">
|
<div class="float_left switch-navs" style="padding-top: 20px;">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -139,7 +139,7 @@ steal(
|
|||||||
if (!$(".ipaddress").hasClass("error") && this.nicErr == 0) {
|
if (!$(".ipaddress").hasClass("error") && this.nicErr == 0) {
|
||||||
var mgtIpRangeValid = this.verifyIpRange(mgt_ipstart, mgt_ipend, this.options.odsState.servers.length);
|
var mgtIpRangeValid = this.verifyIpRange(mgt_ipstart, mgt_ipend, this.options.odsState.servers.length);
|
||||||
var tenantIpRangeValid = this.verifyIpRange(tenant_ipstart, tenant_ipend, this.options.odsState.servers.length);
|
var tenantIpRangeValid = this.verifyIpRange(tenant_ipstart, tenant_ipend, this.options.odsState.servers.length);
|
||||||
|
/*
|
||||||
var mindex = mgt_ipstart.lastIndexOf('.') + 1;
|
var mindex = mgt_ipstart.lastIndexOf('.') + 1;
|
||||||
var mgtIpPrefix = mgt_ipstart.substring(0, mindex);
|
var mgtIpPrefix = mgt_ipstart.substring(0, mindex);
|
||||||
var mgtIpStartLastDigit = mgt_ipstart.substring(mindex);
|
var mgtIpStartLastDigit = mgt_ipstart.substring(mindex);
|
||||||
@ -149,7 +149,7 @@ steal(
|
|||||||
var tenantIpPrefix = tenant_ipstart.substring(0, tindex);
|
var tenantIpPrefix = tenant_ipstart.substring(0, tindex);
|
||||||
var tenantIpStartLastDigit = tenant_ipstart.substring(tindex);
|
var tenantIpStartLastDigit = tenant_ipstart.substring(tindex);
|
||||||
var tenantIpEndLastDigit = tenant_ipend.substring(tindex);
|
var tenantIpEndLastDigit = tenant_ipend.substring(tindex);
|
||||||
|
*/
|
||||||
|
|
||||||
if (!mgtIpRangeValid) {
|
if (!mgtIpRangeValid) {
|
||||||
alert("The management IP range is not valid.");
|
alert("The management IP range is not valid.");
|
||||||
@ -178,6 +178,8 @@ steal(
|
|||||||
if (!isConfiged) {
|
if (!isConfiged) {
|
||||||
server['hostname'] = '';
|
server['hostname'] = '';
|
||||||
server['roles'] = [];
|
server['roles'] = [];
|
||||||
|
server['management_ip'] = '';
|
||||||
|
server['tenant_ip'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
//server['server_ip'] = this.startPrefix + (parseInt(this.startLastDigit) + i);
|
//server['server_ip'] = this.startPrefix + (parseInt(this.startLastDigit) + i);
|
||||||
@ -190,7 +192,7 @@ steal(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.options.odsState.servers_config = this.serverData;
|
this.options.odsState.servers_config = this.serverData;
|
||||||
|
/*
|
||||||
var j = 0;
|
var j = 0;
|
||||||
var serverData = this.options.odsState.servers_config;
|
var serverData = this.options.odsState.servers_config;
|
||||||
for (var key in serverData) {
|
for (var key in serverData) {
|
||||||
@ -201,7 +203,7 @@ steal(
|
|||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
var networkingData = {
|
var networkingData = {
|
||||||
"networking": {
|
"networking": {
|
||||||
"interfaces": {
|
"interfaces": {
|
||||||
|
Loading…
Reference in New Issue
Block a user