bug 8208: Added first addHost dialog to take into account baremetal requirements in the resource page.

- Standardized the addHost optional parameters for baremetal.
This commit is contained in:
will 2011-03-17 16:29:31 -07:00
parent eb2a3d6f8e
commit ae549ed4d1
4 changed files with 79 additions and 19 deletions

View File

@ -67,13 +67,13 @@ public class AddHostCmd extends BaseCmd {
@Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, required=true, description="hypervisor type of the host")
private String hypervisor;
@Parameter(name=ApiConstants.HOST_CPU_CAPACITY, type=CommandType.LONG, description="Only for hypervisor is BareMetal, HZ per CPU of host")
private Long cpuCapacity;
@Parameter(name=ApiConstants.CPU_SPEED, type=CommandType.LONG, description="Only for hypervisor is BareMetal, HZ per CPU of host")
private Long cpuSpeed;
@Parameter(name=ApiConstants.HOST_CPU_NUM, type=CommandType.LONG, description="Only for hypervisor is BareMetal, number of CPU on host")
@Parameter(name=ApiConstants.CPU_NUMBER, type=CommandType.LONG, description="Only for hypervisor is BareMetal, number of CPU on host")
private Long cpuNum;
@Parameter(name=ApiConstants.HOST_MEM_CAPACITY, type=CommandType.LONG, description="Only for hypervisor is BareMetal, memory capacity of host(in MB)")
@Parameter(name=ApiConstants.MEMORY, type=CommandType.LONG, description="Only for hypervisor is BareMetal, memory capacity of host(in MB)")
private Long memCapacity;
@Parameter(name=ApiConstants.HOST_MAC, type=CommandType.STRING, description="Only for hypervisor is BareMetal, Mac of PXE nic")
@ -127,8 +127,8 @@ public class AddHostCmd extends BaseCmd {
return hostTags;
}
public Long getCpuCapacity() {
return cpuCapacity;
public Long getCpuSpeed() {
return cpuSpeed;
}
public Long getCpuNum() {

View File

@ -753,7 +753,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
String username = cmd.getUsername();
String password = cmd.getPassword();
Long memCapacity = cmd.getMemCapacity();
Long cpuCapacity = cmd.getCpuCapacity();
Long cpuSpeed = cmd.getCpuSpeed();
Long cpuNum = cmd.getCpuNum();
String mac = cmd.getMac();
String hostTag = cmd.getHostTag();
@ -768,8 +768,8 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
if (memCapacity == null) {
memCapacity = Long.valueOf(0);
}
if (cpuCapacity == null) {
cpuCapacity = Long.valueOf(0);
if (cpuSpeed == null) {
cpuSpeed = Long.valueOf(0);
}
if (cpuNum == null) {
cpuNum = Long.valueOf(0);
@ -779,7 +779,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
}
bareMetalParams.put("cpuNum", cpuNum.toString());
bareMetalParams.put("cpuCapacity", cpuCapacity.toString());
bareMetalParams.put("cpuCapacity", cpuSpeed.toString());
bareMetalParams.put("memCapacity", memCapacity.toString());
bareMetalParams.put("mac", mac);
if (hostTag != null) {

View File

@ -866,7 +866,7 @@
<ol>
<li>
<label>
<fmt:message key="label.adding"/>:</label>
<fmt:message key="label.zone"/>:</label>
<select class="select" id="zone_dropdown">
</select>
<div id="zone_dropdown_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
@ -943,7 +943,42 @@
<input class="text" type="text" name="host_vcenter_host" id="host_vcenter_host" />
<div id="host_vcenter_host_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
</li>
<li input_group="baremetal" style="display: none;">
<label for="host_baremetal_cpucores">
# of CPU Cores:</label>
<input class="text" type="text" name="host_baremetal_cpucores" id="host_baremetal_cpucores" />
<div id="host_baremetal_cpucores_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li input_group="baremetal" style="display: none;">
<label for="host_baremetal_cpu">
CPU (in MHz):</label>
<input class="text" type="text" name="host_baremetal_cpu" id="host_baremetal_cpu" />
<div id="host_baremetal_cpu_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li input_group="baremetal" style="display: none;">
<label for="host_baremetal_memory">
Memory (in MB):</label>
<input class="text" type="text" name="host_baremetal_memory" id="host_baremetal_memory" />
<div id="host_baremetal_memory_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li input_group="baremetal" style="display: none;">
<label for="host_baremetal_mac">
Host MAC:</label>
<input class="text" type="text" name="host_baremetal_mac" id="host_baremetal_mac" />
<div id="host_baremetal_mac_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li>
<label input_group="general">
Tags:</label>
<input class="text" type="text" name="host_baremetal_tags" id="host_baremetal_tags" />
<div id="host_baremetal_tags_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
</ol>
</form>
</div>

View File

@ -838,10 +838,16 @@ function initAddHostShortcut() {
if(clusterObj.hypervisortype == "VMware") {
$('li[input_group="vmware"]', $dialogAddHost).show();
$('li[input_group="general"]', $dialogAddHost).hide();
} else {
$('li[input_group="baremetal"]', $dialogAddHost).hide();
} else if (clusterObj.hypervisortype == "BareMetal") {
$('li[input_group="vmware"]', $dialogAddHost).hide();
$('li[input_group="general"]', $dialogAddHost).show();
$('li[input_group="baremetal"]', $dialogAddHost).show();
} else {
$('li[input_group="vmware"]', $dialogAddHost).hide();
$('li[input_group="general"]', $dialogAddHost).show();
}
$('li[input_group="baremetal"]', $dialogAddHost).hide();
}
});
$("#add_host_shortcut").unbind("click").bind("click", function(event) {
@ -871,11 +877,17 @@ function initAddHostShortcut() {
isValid &= validateString("vCenter Password", $thisDialog.find("#host_vcenter_password"), $thisDialog.find("#host_vcenter_password_errormsg"));
isValid &= validateString("vCenter Datacenter", $thisDialog.find("#host_vcenter_dc"), $thisDialog.find("#host_vcenter_dc_errormsg"));
isValid &= validateString("vCenter Host", $thisDialog.find("#host_vcenter_host"), $thisDialog.find("#host_vcenter_host_errormsg"));
} else {
isValid &= validateString("Host name", $thisDialog.find("#host_hostname"), $thisDialog.find("#host_hostname_errormsg"));
isValid &= validateString("User name", $thisDialog.find("#host_username"), $thisDialog.find("#host_username_errormsg"));
isValid &= validateString("Password", $thisDialog.find("#host_password"), $thisDialog.find("#host_password_errormsg"));
}
} else {
if (hypervisor == "BareMetal") {
isValid &= validateString("CPU Cores", $thisDialog.find("#host_baremetal_cpucores"), $thisDialog.find("#host_baremetal_cpucores_errormsg"));
isValid &= validateString("CPU", $thisDialog.find("#host_baremetal_cpu"), $thisDialog.find("#host_baremetal_cpu_errormsg"));
isValid &= validateString("Memory", $thisDialog.find("#host_baremetal_memory"), $thisDialog.find("#host_baremetal_memory_errormsg"));
isValid &= validateString("MAC", $thisDialog.find("#host_baremetal_mac"), $thisDialog.find("#host_baremetal_mac_errormsg"));
}
isValid &= validateString("Host name", $thisDialog.find("#host_hostname"), $thisDialog.find("#host_hostname_errormsg"));
isValid &= validateString("User name", $thisDialog.find("#host_username"), $thisDialog.find("#host_username_errormsg"));
isValid &= validateString("Password", $thisDialog.find("#host_password"), $thisDialog.find("#host_password_errormsg"));
}
}
if (!isValid)
return;
@ -921,6 +933,19 @@ function initAddHostShortcut() {
array1.push("&url="+todb(url));
} else {
if (hypervisor == "BareMetal") {
var cpuCores = trim($thisDialog.find("#host_baremetal_cpucores").val());
array1.push("&cpunumber="+todb(cpuCores));
var cpuSpeed = trim($thisDialog.find("#host_baremetal_cpu").val());
array1.push("&cpuspeeed="+todb(cpuSpeed));
var memory = trim($thisDialog.find("#host_baremetal_memory").val());
array1.push("&memory="+todb(memory));
var mac = trim($thisDialog.find("#host_baremetal_mac").val());
array1.push("&hostmac="+todb(mac));
}
var username = trim($thisDialog.find("#host_username").val());
array1.push("&username="+todb(username));