mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Remove baremetal specific parameters from AddHostCmd
This commit is contained in:
parent
ac7d73172c
commit
e8c2fa4e8e
30
api/src/com/cloud/api/commands/AddHostCmd.java
Normal file → Executable file
30
api/src/com/cloud/api/commands/AddHostCmd.java
Normal file → Executable file
@ -67,19 +67,7 @@ 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.CPU_SPEED, type=CommandType.LONG, description="Only for hypervisor is BareMetal, HZ per CPU of host")
|
||||
private Long cpuSpeed;
|
||||
|
||||
@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.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")
|
||||
private String mac;
|
||||
|
||||
|
||||
@Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="Allocation state of this Host for allocation of new resources")
|
||||
private String allocationState;
|
||||
|
||||
@ -125,22 +113,6 @@ public class AddHostCmd extends BaseCmd {
|
||||
public List<String> getHostTags() {
|
||||
return hostTags;
|
||||
}
|
||||
|
||||
public Long getCpuSpeed() {
|
||||
return cpuSpeed;
|
||||
}
|
||||
|
||||
public Long getCpuNum() {
|
||||
return cpuNum;
|
||||
}
|
||||
|
||||
public Long getMemCapacity() {
|
||||
return memCapacity;
|
||||
}
|
||||
|
||||
public String getMac() {
|
||||
return mac;
|
||||
}
|
||||
|
||||
public String getAllocationState() {
|
||||
return allocationState;
|
||||
|
||||
@ -124,7 +124,7 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,
|
||||
@Override
|
||||
public Map<? extends ServerResource, Map<String, String>> find(long dcId,
|
||||
Long podId, Long clusterId, URI uri, String username,
|
||||
String password) throws DiscoveryException {
|
||||
String password, List<String> hostTags) throws DiscoveryException {
|
||||
|
||||
ClusterVO cluster = _clusterDao.findById(clusterId);
|
||||
if(cluster == null || cluster.getHypervisorType() != HypervisorType.KVM) {
|
||||
|
||||
@ -111,7 +111,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url, String username, String password) throws DiscoveryException {
|
||||
public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags) throws DiscoveryException {
|
||||
Map<CitrixResourceBase, Map<String, String>> resources = new HashMap<CitrixResourceBase, Map<String, String>>();
|
||||
Connection conn = null;
|
||||
if (!url.getScheme().equals("http")) {
|
||||
|
||||
2
server/src/com/cloud/resource/Discoverer.java
Normal file → Executable file
2
server/src/com/cloud/resource/Discoverer.java
Normal file → Executable file
@ -39,7 +39,7 @@ public interface Discoverer extends Adapter {
|
||||
* @param password
|
||||
* @return ServerResource
|
||||
*/
|
||||
Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI uri, String username, String password) throws DiscoveryException;
|
||||
Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI uri, String username, String password, List<String> hostTags) throws DiscoveryException;
|
||||
|
||||
void postDiscovery(List<HostVO> hosts, long msId) throws DiscoveryException;
|
||||
|
||||
|
||||
2
server/src/com/cloud/resource/DummyHostDiscoverer.java
Normal file → Executable file
2
server/src/com/cloud/resource/DummyHostDiscoverer.java
Normal file → Executable file
@ -39,7 +39,7 @@ public class DummyHostDiscoverer implements Discoverer {
|
||||
private String _name;
|
||||
|
||||
@Override
|
||||
public Map<ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url, String username, String password) {
|
||||
public Map<ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags) {
|
||||
if (!url.getScheme().equals("dummy")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
31
server/src/com/cloud/resource/ResourceManagerImpl.java
Normal file → Executable file
31
server/src/com/cloud/resource/ResourceManagerImpl.java
Normal file → Executable file
@ -254,7 +254,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
||||
|
||||
List<HostVO> hosts = new ArrayList<HostVO>();
|
||||
Map<? extends ServerResource, Map<String, String>> resources = null;
|
||||
resources = discoverer.find(dcId, podId, clusterId, uri, username, password);
|
||||
resources = discoverer.find(dcId, podId, clusterId, uri, username, password, null);
|
||||
|
||||
if (resources != null) {
|
||||
for (Map.Entry<? extends ServerResource, Map<String, String>> entry : resources.entrySet()) {
|
||||
@ -306,12 +306,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
||||
String url = cmd.getUrl();
|
||||
String username = cmd.getUsername();
|
||||
String password = cmd.getPassword();
|
||||
Long memCapacity = cmd.getMemCapacity();
|
||||
Long cpuSpeed = cmd.getCpuSpeed();
|
||||
Long cpuNum = cmd.getCpuNum();
|
||||
String mac = cmd.getMac();
|
||||
List<String> hostTags = cmd.getHostTags();
|
||||
Map<String, String> bareMetalParams = new HashMap<String, String>();
|
||||
|
||||
dcId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), dcId);
|
||||
|
||||
@ -334,28 +329,6 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd.getHypervisor().equalsIgnoreCase(Hypervisor.HypervisorType.BareMetal.toString())) {
|
||||
if (memCapacity == null) {
|
||||
memCapacity = Long.valueOf(0);
|
||||
}
|
||||
if (cpuSpeed == null) {
|
||||
cpuSpeed = Long.valueOf(0);
|
||||
}
|
||||
if (cpuNum == null) {
|
||||
cpuNum = Long.valueOf(0);
|
||||
}
|
||||
if (mac == null) {
|
||||
mac = "unknown";
|
||||
}
|
||||
|
||||
bareMetalParams.put("cpuNum", cpuNum.toString());
|
||||
bareMetalParams.put("cpuCapacity", cpuSpeed.toString());
|
||||
bareMetalParams.put("memCapacity", memCapacity.toString());
|
||||
bareMetalParams.put("mac", mac);
|
||||
if (hostTags != null && hostTags.size() > 0) {
|
||||
bareMetalParams.put("hostTag", hostTags.get(0));
|
||||
}
|
||||
}
|
||||
String allocationState = cmd.getAllocationState();
|
||||
if (allocationState == null) {
|
||||
allocationState = Host.HostAllocationState.Enabled.toString();
|
||||
@ -480,7 +453,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
||||
Map<? extends ServerResource, Map<String, String>> resources = null;
|
||||
|
||||
try {
|
||||
resources = discoverer.find(dcId, podId, clusterId, uri, username, password);
|
||||
resources = discoverer.find(dcId, podId, clusterId, uri, username, password, hostTags);
|
||||
} catch(DiscoveryException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
|
||||
2
server/src/com/cloud/storage/secondary/SecondaryStorageDiscoverer.java
Normal file → Executable file
2
server/src/com/cloud/storage/secondary/SecondaryStorageDiscoverer.java
Normal file → Executable file
@ -83,7 +83,7 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI uri, String username, String password) {
|
||||
public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI uri, String username, String password, List<String> hostTags) {
|
||||
if (!uri.getScheme().equalsIgnoreCase("nfs") && !uri.getScheme().equalsIgnoreCase("file")
|
||||
&& !uri.getScheme().equalsIgnoreCase("iso") && !uri.getScheme().equalsIgnoreCase("dummy")) {
|
||||
s_logger.debug("It's not NFS or file or ISO, so not a secondary storage server: " + uri.toString());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user