Skip to content

Commit b7181bb

Browse files
author
Jessica Wang
committed
CLOUDSTACK-642: cloudstack UI - Add Host step in zone wizard, Add Host diaog in hosts listView - call addHost API by type POST instead of type GET, remove parameters from URL.
1 parent 859412c commit b7181bb

2 files changed

Lines changed: 72 additions & 50 deletions

File tree

‎ui/scripts/system.js‎

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8250,54 +8250,69 @@
82508250
},
82518251

82528252
action: function(args) {
8253-
var array1 = [];
8254-
array1.push("&zoneid=" + args.data.zoneid);
8255-
array1.push("&podid=" + args.data.podId);
8256-
array1.push("&clusterid=" + args.data.clusterId);
8257-
array1.push("&hypervisor=" + todb(selectedClusterObj.hypervisortype));
8258-
var clustertype = selectedClusterObj.clustertype;
8259-
array1.push("&clustertype=" + todb(clustertype));
8260-
array1.push("&hosttags=" + todb(args.data.hosttags));
8253+
var data = {
8254+
zoneid: args.data.zoneid,
8255+
podid: args.data.podId,
8256+
clusterid: args.data.clusterId,
8257+
hypervisor: selectedClusterObj.hypervisortype,
8258+
clustertype: selectedClusterObj.clustertype,
8259+
hosttags: args.data.hosttags
8260+
};
82618261

82628262
if(selectedClusterObj.hypervisortype == "VMware") {
8263-
array1.push("&username=");
8264-
array1.push("&password=");
8263+
$.extend(data,{
8264+
username: '',
8265+
password: ''
8266+
});
8267+
82658268
var hostname = args.data.vcenterHost;
82668269
var url;
82678270
if(hostname.indexOf("http://")==-1)
82688271
url = "http://" + hostname;
82698272
else
82708273
url = hostname;
8271-
array1.push("&url=" + todb(url));
8274+
8275+
$.extend(data, {
8276+
url: url
8277+
});
82728278
}
82738279
else {
8274-
array1.push("&username=" + todb(args.data.username));
8275-
array1.push("&password=" + todb(args.data.password));
8276-
8280+
$.extend(data, {
8281+
username: args.data.username,
8282+
password: args.data.password
8283+
});
8284+
82778285
var hostname = args.data.hostname;
8278-
82798286
var url;
82808287
if(hostname.indexOf("http://")==-1)
82818288
url = "http://" + hostname;
82828289
else
82838290
url = hostname;
8284-
array1.push("&url="+todb(url));
8285-
8291+
8292+
$.extend(data, {
8293+
url: url
8294+
});
8295+
82868296
if (selectedClusterObj.hypervisortype == "BareMetal") {
8287-
array1.push("&cpunumber=" + todb(args.data.baremetalCpuCores));
8288-
array1.push("&cpuspeed=" + todb(args.data.baremetalCpu));
8289-
array1.push("&memory=" + todb(args.data.baremetalMemory));
8290-
array1.push("&hostmac=" + todb(args.data.baremetalMAC));
8297+
$.extend(data, {
8298+
cpunumber: args.data.baremetalCpuCores,
8299+
cpuspeed: args.data.baremetalCpu,
8300+
memory: args.data.baremetalMemory,
8301+
hostmac: args.data.baremetalMAC
8302+
});
82918303
}
82928304
else if(selectedClusterObj.hypervisortype == "Ovm") {
8293-
array1.push("&agentusername=" + todb(args.data.agentUsername));
8294-
array1.push("&agentpassword=" + todb(args.data.agentPassword));
8305+
$.extend(data, {
8306+
agentusername: args.data.agentUsername,
8307+
agentpassword: args.data.agentPassword
8308+
});
82958309
}
82968310
}
82978311

82988312
$.ajax({
8299-
url: createURL("addHost" + array1.join("")),
8300-
dataType: "json",
8313+
url: createURL("addHost"),
8314+
type: "POST",
8315+
data: data,
83018316
success: function(json) {
83028317
var item = json.addhostresponse.host[0];
83038318
args.response.success({

‎ui/scripts/zoneWizard.js‎

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2896,41 +2896,48 @@
28962896
addHost: function(args) {
28972897
message(dictionary['message.adding.host']);
28982898

2899-
var array1 = [];
2900-
array1.push("&zoneid=" + args.data.returnedZone.id);
2901-
array1.push("&podid=" + args.data.returnedPod.id);
2902-
array1.push("&clusterid=" + args.data.returnedCluster.id);
2903-
array1.push("&hypervisor=" + todb(args.data.returnedCluster.hypervisortype));
2904-
var clustertype = args.data.returnedCluster.clustertype;
2905-
array1.push("&clustertype=" + todb(clustertype));
2906-
array1.push("&hosttags=" + todb(args.data.host.hosttags));
2907-
array1.push("&username=" + todb(args.data.host.username));
2908-
array1.push("&password=" + todb(args.data.host.password));
2899+
var data = {
2900+
zoneid: args.data.returnedZone.id,
2901+
podid: args.data.returnedPod.id,
2902+
clusterid: args.data.returnedCluster.id,
2903+
hypervisor: args.data.returnedCluster.hypervisortype,
2904+
clustertype: args.data.returnedCluster.clustertype,
2905+
hosttags: args.data.host.hosttags,
2906+
username: args.data.host.username,
2907+
password: args.data.host.password
2908+
};
29092909

29102910
var hostname = args.data.host.hostname;
2911-
29122911
var url;
2913-
if(hostname.indexOf("http://")==-1)
2912+
if(hostname.indexOf("http://")==-1) {
29142913
url = "http://" + hostname;
2915-
else
2916-
url = hostname;
2917-
array1.push("&url="+todb(url));
2918-
2914+
}
2915+
else {
2916+
url = hostname;
2917+
}
2918+
$.extend(data,{
2919+
url: url
2920+
});
2921+
29192922
if (args.data.cluster.hypervisor == "BareMetal") {
2920-
array1.push("&cpunumber=" + todb(args.data.host.baremetalCpuCores));
2921-
array1.push("&cpuspeed=" + todb(args.data.host.baremetalCpu));
2922-
array1.push("&memory=" + todb(args.data.host.baremetalMemory));
2923-
array1.push("&hostmac=" + todb(args.data.host.baremetalMAC));
2923+
$.extend(data, {
2924+
cpunumber: args.data.host.baremetalCpuCores,
2925+
cpuspeed: args.data.host.baremetalCpu,
2926+
memory: args.data.host.baremetalMemory,
2927+
hostmac: args.data.host.baremetalMAC
2928+
});
29242929
}
29252930
else if(args.data.cluster.hypervisor == "Ovm") {
2926-
array1.push("&agentusername=" + todb(args.data.host.agentUsername));
2927-
array1.push("&agentpassword=" + todb(args.data.host.agentPassword));
2931+
$.extend(data, {
2932+
agentusername: args.data.host.agentUsername,
2933+
agentpassword: args.data.host.agentPassword
2934+
});
29282935
}
29292936

2930-
29312937
$.ajax({
2932-
url: createURL("addHost" + array1.join("")),
2933-
dataType: "json",
2938+
url: createURL("addHost"),
2939+
type: "POST",
2940+
data: data,
29342941
success: function(json) {
29352942
stepFns.addPrimaryStorage({
29362943
data: $.extend(args.data, {

0 commit comments

Comments
 (0)