mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-16 18:43:26 +01:00
Bug 8208 - bare metal provisioning
Add LinMin username, password, apid fields in AddPxeServerCmd
This commit is contained in:
parent
35b7c26689
commit
ec7a6e6863
@ -195,6 +195,9 @@ public class ApiConstants {
|
||||
public static final String HOST_MEM_CAPACITY = "hostmemcapacity";
|
||||
public static final String HOST_MAC = "hostmac";
|
||||
public static final String PXE_SERVER_TYPE = "pxeservertype";
|
||||
public static final String LINMIN_USERNAME = "linminusername";
|
||||
public static final String LINMIN_PASSWORD = "linminpassword";
|
||||
public static final String LINMIN_APID = "linminapid";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -47,6 +47,15 @@ public class AddPxeServerCmd extends BaseCmd {
|
||||
|
||||
@Parameter(name=ApiConstants.PXE_SERVER_TYPE, type=CommandType.STRING, required = true, description="Type of PXE server. Current values are LinMin, DMCD")
|
||||
private String type;
|
||||
|
||||
@Parameter(name=ApiConstants.LINMIN_USERNAME, type=CommandType.STRING, required = false, description="Optional, username uses to access LinMin API")
|
||||
private String linminUsername;
|
||||
|
||||
@Parameter(name=ApiConstants.LINMIN_PASSWORD, type=CommandType.STRING, required = false, description="Optional, password uses to access LinMin API")
|
||||
private String linminPassword;
|
||||
|
||||
@Parameter(name=ApiConstants.LINMIN_APID, type=CommandType.STRING, required = false, description="Optional, APID uses to access LinMin API")
|
||||
private String linminApid;
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
@ -75,6 +84,18 @@ public class AddPxeServerCmd extends BaseCmd {
|
||||
public Long getPod() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public String getLinMinUsername() {
|
||||
return linminUsername;
|
||||
}
|
||||
|
||||
public String getLinMinPassword() {
|
||||
return linminPassword;
|
||||
}
|
||||
|
||||
public String getLinMinApid() {
|
||||
return linminApid;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
||||
@ -38,6 +38,9 @@ public class LinMinPxeServerManagerImpl extends PxeServerManagerImpl implements
|
||||
public Host addPxeServer(AddPxeServerCmd cmd) throws InvalidParameterValueException, CloudRuntimeException {
|
||||
long zoneId = cmd.getZoneId();
|
||||
Long podId = cmd.getPod();
|
||||
String apiUsername;
|
||||
String apiPassword;
|
||||
String apid;
|
||||
|
||||
DataCenterVO zone = _dcDao.findById(zoneId);
|
||||
if (zone == null) {
|
||||
@ -57,6 +60,21 @@ public class LinMinPxeServerManagerImpl extends PxeServerManagerImpl implements
|
||||
throw new InvalidParameterValueException(e.getMessage());
|
||||
}
|
||||
|
||||
apiUsername = cmd.getLinMinUsername();
|
||||
apiPassword = cmd.getLinMinPassword();
|
||||
apid = cmd.getLinMinApid();
|
||||
if (apiUsername == null) {
|
||||
throw new InvalidParameterValueException("No LinMin username specified, without it I can user LinMin API");
|
||||
}
|
||||
|
||||
if (apiPassword == null) {
|
||||
throw new InvalidParameterValueException("No LinMin password specified, without it I can user LinMin API");
|
||||
}
|
||||
|
||||
if (apid == null) {
|
||||
throw new InvalidParameterValueException("No LinMin apid specified, without it I can user LinMin API");
|
||||
}
|
||||
|
||||
String ipAddress = uri.getHost();
|
||||
String username = cmd.getUsername();
|
||||
String password = cmd.getPassword();
|
||||
@ -69,6 +87,9 @@ public class LinMinPxeServerManagerImpl extends PxeServerManagerImpl implements
|
||||
params.put("password", password);
|
||||
params.put("guid", guid);
|
||||
params.put("pod", Long.toString(cmd.getPod()));
|
||||
params.put("apiUsername", apiUsername);
|
||||
params.put("apiPassword", apiPassword);
|
||||
params.put("apid", apid);
|
||||
|
||||
ServerResource resource = null;
|
||||
try {
|
||||
|
||||
@ -49,6 +49,9 @@ public class LinMinPxeServerResource implements ServerResource {
|
||||
String _ip;
|
||||
String _zoneId;
|
||||
String _podId;
|
||||
String _apiUsername;
|
||||
String _apiPassword;
|
||||
String _apid;
|
||||
|
||||
class XmlReturn {
|
||||
NodeList nList;
|
||||
@ -88,6 +91,9 @@ public class LinMinPxeServerResource implements ServerResource {
|
||||
_password = (String)params.get("password");
|
||||
_zoneId = (String)params.get("zone");
|
||||
_podId = (String)params.get("pod");
|
||||
_apiUsername = (String)params.get("apiUsername");
|
||||
_apiPassword = (String)params.get("apiPassword");
|
||||
_apid = (String)params.get("apid");
|
||||
|
||||
if (_guid == null) {
|
||||
throw new ConfigurationException("No Guid specified");
|
||||
@ -113,6 +119,18 @@ public class LinMinPxeServerResource implements ServerResource {
|
||||
throw new ConfigurationException("No password specified");
|
||||
}
|
||||
|
||||
if (_apiUsername == null) {
|
||||
throw new ConfigurationException("No API username specified");
|
||||
}
|
||||
|
||||
if (_apiPassword == null) {
|
||||
throw new ConfigurationException("No API password specified");
|
||||
}
|
||||
|
||||
if (_apid == null) {
|
||||
throw new ConfigurationException("No A specified");
|
||||
}
|
||||
|
||||
com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22);
|
||||
|
||||
s_logger.debug(String.format("Trying to connect to LinMin PXE server(IP=%1$s, username=%2$s, password=%3$s", _ip, _username, _password));
|
||||
@ -212,19 +230,16 @@ public class LinMinPxeServerResource implements ServerResource {
|
||||
|
||||
|
||||
protected PrepareLinMinPxeServerAnswer execute(PrepareLinMinPxeServerCommand cmd) {
|
||||
String apiUserName = "root";
|
||||
String apiPassword = "password";
|
||||
String apid = "2ad644fb479871a0f5543dd6d29fe9ed";
|
||||
StringBuffer askApid = new StringBuffer();
|
||||
|
||||
askApid.append("http://");
|
||||
askApid.append(_ip);
|
||||
askApid.append("/tftpboot/www/lbmp-API.php?actiontype=provision&apid=");
|
||||
askApid.append(apid);
|
||||
askApid.append(_apid);
|
||||
askApid.append("&auth_user=");
|
||||
askApid.append(apiUserName);
|
||||
askApid.append(_apiUsername);
|
||||
askApid.append("&auth_user_pw=");
|
||||
askApid.append(apiPassword);
|
||||
askApid.append(_apiPassword);
|
||||
askApid.append("&rtn_format=XML&action=authorize");
|
||||
InputSource s = httpCall(askApid.toString());
|
||||
if (s == null) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user