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
28
api/src/com/cloud/api/commands/AddHostCmd.java
Normal file → Executable file
28
api/src/com/cloud/api/commands/AddHostCmd.java
Normal file → Executable file
@ -68,18 +68,6 @@ public class AddHostCmd extends BaseCmd {
|
|||||||
@Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, required=true, description="hypervisor type of the host")
|
@Parameter(name=ApiConstants.HYPERVISOR, type=CommandType.STRING, required=true, description="hypervisor type of the host")
|
||||||
private String hypervisor;
|
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")
|
@Parameter(name=ApiConstants.ALLOCATION_STATE, type=CommandType.STRING, description="Allocation state of this Host for allocation of new resources")
|
||||||
private String allocationState;
|
private String allocationState;
|
||||||
|
|
||||||
@ -126,22 +114,6 @@ public class AddHostCmd extends BaseCmd {
|
|||||||
return hostTags;
|
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() {
|
public String getAllocationState() {
|
||||||
return allocationState;
|
return allocationState;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,7 +124,7 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,
|
|||||||
@Override
|
@Override
|
||||||
public Map<? extends ServerResource, Map<String, String>> find(long dcId,
|
public Map<? extends ServerResource, Map<String, String>> find(long dcId,
|
||||||
Long podId, Long clusterId, URI uri, String username,
|
Long podId, Long clusterId, URI uri, String username,
|
||||||
String password) throws DiscoveryException {
|
String password, List<String> hostTags) throws DiscoveryException {
|
||||||
|
|
||||||
ClusterVO cluster = _clusterDao.findById(clusterId);
|
ClusterVO cluster = _clusterDao.findById(clusterId);
|
||||||
if(cluster == null || cluster.getHypervisorType() != HypervisorType.KVM) {
|
if(cluster == null || cluster.getHypervisorType() != HypervisorType.KVM) {
|
||||||
|
|||||||
@ -111,7 +111,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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>>();
|
Map<CitrixResourceBase, Map<String, String>> resources = new HashMap<CitrixResourceBase, Map<String, String>>();
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
if (!url.getScheme().equals("http")) {
|
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
|
* @param password
|
||||||
* @return ServerResource
|
* @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;
|
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;
|
private String _name;
|
||||||
|
|
||||||
@Override
|
@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")) {
|
if (!url.getScheme().equals("dummy")) {
|
||||||
return null;
|
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>();
|
List<HostVO> hosts = new ArrayList<HostVO>();
|
||||||
Map<? extends ServerResource, Map<String, String>> resources = null;
|
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) {
|
if (resources != null) {
|
||||||
for (Map.Entry<? extends ServerResource, Map<String, String>> entry : resources.entrySet()) {
|
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 url = cmd.getUrl();
|
||||||
String username = cmd.getUsername();
|
String username = cmd.getUsername();
|
||||||
String password = cmd.getPassword();
|
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();
|
List<String> hostTags = cmd.getHostTags();
|
||||||
Map<String, String> bareMetalParams = new HashMap<String, String>();
|
|
||||||
|
|
||||||
dcId = _accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), dcId);
|
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();
|
String allocationState = cmd.getAllocationState();
|
||||||
if (allocationState == null) {
|
if (allocationState == null) {
|
||||||
allocationState = Host.HostAllocationState.Enabled.toString();
|
allocationState = Host.HostAllocationState.Enabled.toString();
|
||||||
@ -480,7 +453,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||||||
Map<? extends ServerResource, Map<String, String>> resources = null;
|
Map<? extends ServerResource, Map<String, String>> resources = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resources = discoverer.find(dcId, podId, clusterId, uri, username, password);
|
resources = discoverer.find(dcId, podId, clusterId, uri, username, password, hostTags);
|
||||||
} catch(DiscoveryException e) {
|
} catch(DiscoveryException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception 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
|
@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")
|
if (!uri.getScheme().equalsIgnoreCase("nfs") && !uri.getScheme().equalsIgnoreCase("file")
|
||||||
&& !uri.getScheme().equalsIgnoreCase("iso") && !uri.getScheme().equalsIgnoreCase("dummy")) {
|
&& !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());
|
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