mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
Bug 8208 - bare metal provisioning
Able to add cluster and host
This commit is contained in:
parent
b313b7c852
commit
828f8c9493
@ -191,6 +191,8 @@ public class ApiConstants {
|
||||
public static final String AVAILABILITY = "availability";
|
||||
public static final String NETWORKRATE = "networkrate";
|
||||
public static final String HOST_CPU_CAPACITY = "hostcpucapacity";
|
||||
public static final String HOST_MEM_CAPACITY = "hostmemcapacity";
|
||||
public static final String HOST_CPU_NUM = "hostcpunum";
|
||||
public static final String HOST_MEM_CAPACITY = "hostmemcapacity";
|
||||
public static final String HOST_MAC = "hostmac";
|
||||
}
|
||||
|
||||
|
||||
@ -66,12 +66,18 @@ 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="CPU capacity of host")
|
||||
@Parameter(name=ApiConstants.HOST_CPU_CAPACITY, type=CommandType.LONG, description="HZ per CPU of host")
|
||||
private Long cpuCapacity;
|
||||
|
||||
@Parameter(name=ApiConstants.HOST_CPU_NUM, type=CommandType.LONG, description="number of CPU on host")
|
||||
private Long cpuNum;
|
||||
|
||||
@Parameter(name=ApiConstants.HOST_MEM_CAPACITY, type=CommandType.LONG, description="memory capacity of host")
|
||||
private Long memCapacity;
|
||||
|
||||
@Parameter(name=ApiConstants.HOST_MAC, type=CommandType.STRING, required=true, description="Mac of PXE nic")
|
||||
private String mac;
|
||||
|
||||
|
||||
|
||||
|
||||
@ -115,10 +121,18 @@ public class AddHostCmd extends BaseCmd {
|
||||
return cpuCapacity;
|
||||
}
|
||||
|
||||
public Long getCpuNum() {
|
||||
return cpuNum;
|
||||
}
|
||||
|
||||
public Long getMemCapacity() {
|
||||
return memCapacity;
|
||||
}
|
||||
|
||||
public String getMac() {
|
||||
return mac;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -751,6 +751,8 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
|
||||
String password = cmd.getPassword();
|
||||
Long memCapacity = cmd.getMemCapacity();
|
||||
Long cpuCapacity = cmd.getCpuCapacity();
|
||||
Long cpuNum = cmd.getCpuNum();
|
||||
String mac = cmd.getMac();
|
||||
Map<String, String>bareMetalParams = new HashMap<String, String>();
|
||||
|
||||
// this is for standalone option
|
||||
@ -765,9 +767,17 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
|
||||
if (cpuCapacity == null) {
|
||||
cpuCapacity = Long.valueOf(0);
|
||||
}
|
||||
if (cpuNum == null) {
|
||||
cpuNum = Long.valueOf(0);
|
||||
}
|
||||
if (mac == null) {
|
||||
mac = "unknown";
|
||||
}
|
||||
|
||||
bareMetalParams.put("cpuNum", cpuNum.toString());
|
||||
bareMetalParams.put("cpuCapacity", cpuCapacity.toString());
|
||||
bareMetalParams.put("memCapacity", memCapacity.toString());
|
||||
bareMetalParams.put("mac", mac);
|
||||
}
|
||||
|
||||
|
||||
@ -891,7 +901,9 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
|
||||
boolean isHypervisorTypeSupported = false;
|
||||
while (en.hasMoreElements()) {
|
||||
Discoverer discoverer = en.nextElement();
|
||||
discoverer.putParam(params);
|
||||
if (params != null) {
|
||||
discoverer.putParam(params);
|
||||
}
|
||||
|
||||
if (!discoverer.matchHypervisor(hypervisorType)) {
|
||||
continue;
|
||||
@ -2684,7 +2696,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
|
||||
// If this command is from a KVM agent, or from an agent that has a
|
||||
// null hypervisor type, don't do the CIDR check
|
||||
if (hypervisorType == null || hypervisorType == HypervisorType.KVM
|
||||
|| hypervisorType == HypervisorType.VMware) {
|
||||
|| hypervisorType == HypervisorType.VMware || hypervisorType == HypervisorType.BareMetal) {
|
||||
doCidrCheck = false;
|
||||
}
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
package com.cloud.resource;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
@ -47,6 +48,9 @@ public abstract class DiscovererBase implements Discoverer {
|
||||
|
||||
@Override
|
||||
public void putParam(Map<String, String> params) {
|
||||
if (_params == null) {
|
||||
_params = new HashMap<String, String>();
|
||||
}
|
||||
_params.putAll(params);
|
||||
}
|
||||
|
||||
|
||||
@ -103,5 +103,11 @@ public class DummyHostDiscoverer implements Discoverer {
|
||||
@Override
|
||||
public void postDiscovery(List<HostVO> hosts, long msId) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putParam(Map<String, String> params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -441,7 +441,11 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
|
||||
|
||||
List<VMTemplateVO> tmplts = listBy(sc);
|
||||
Collections.shuffle(tmplts);
|
||||
return tmplts.get(0);
|
||||
if (tmplts.size() > 0) {
|
||||
return tmplts.get(0);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user