CloudStack CLOUDSTACK-1365

UI support for baremetal PXE server

CloudStack CLOUDSTACK-1364
UI support for baremetal DHCP server

Conflicts:

	plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java
	plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
	plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java
This commit is contained in:
frank 2013-08-22 16:30:49 -07:00 committed by root
parent 0fdaef8e3d
commit b37e6c14c1
16 changed files with 100 additions and 149 deletions

View File

@ -609,7 +609,7 @@ addBaremetalPxeKickStartServer=1
addBaremetalPxePingServer=1 addBaremetalPxePingServer=1
addBaremetalDhcp=1 addBaremetalDhcp=1
listBaremetalDhcp=1 listBaremetalDhcp=1
listBaremetalPxePingServer=1 listBaremetalPxeServers=1
#### UCS commands #### UCS commands
addUcsManager=1 addUcsManager=1
@ -617,7 +617,7 @@ listUcsManagers=1
listUcsProfiles=1 listUcsProfiles=1
listUcsBlades=1 listUcsBlades=1
associateUcsProfileToBlade=1 associateUcsProfileToBlade=1
deleteUcsManager=1 removedeleteUcsManager=1
#### New Load Balancer commands #### New Load Balancer commands
createLoadBalancer=15 createLoadBalancer=15

View File

@ -283,8 +283,6 @@ public class Upgrade410to420 implements DbUpgrade {
pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE"); pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE");
pstmt.executeUpdate(); pstmt.executeUpdate();
pstmt.close(); pstmt.close();
pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_pod_id` FOREIGN KEY (`pod_id`) REFERENCES `host_pod_ref`(`id`) ON DELETE CASCADE");
pstmt.executeUpdate();
pstmt.close(); pstmt.close();
pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE"); pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE");
pstmt.executeUpdate(); pstmt.executeUpdate();

View File

@ -35,7 +35,8 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.api.AddBaremetalPxeCmd; import org.apache.cloudstack.api.AddBaremetalPxeCmd;
import org.apache.cloudstack.api.AddBaremetalPxePingServerCmd; import org.apache.cloudstack.api.AddBaremetalPxePingServerCmd;
import org.apache.cloudstack.api.ListBaremetalPxePingServersCmd; import org.apache.cloudstack.api.ListBaremetalPxeServersCmd;
import org.apache.log4j.Logger;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
import com.cloud.agent.api.baremetal.IpmISetBootDevCommand; import com.cloud.agent.api.baremetal.IpmISetBootDevCommand;
@ -271,34 +272,13 @@ public class BareMetalPingServiceImpl extends BareMetalPxeServiceBase implements
@Override @Override
public BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo) { public BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo) {
BaremetalPxePingResponse response = new BaremetalPxePingResponse(); return null;
response.setId(String.valueOf(vo.getId()));
response.setPhysicalNetworkId(String.valueOf(vo.getPhysicalNetworkId()));
response.setPodId(String.valueOf(vo.getPodId()));
Map<String, String> details = _hostDetailsDao.findDetails(vo.getHostId());
response.setPingStorageServerIp(details.get(BaremetalPxeService.PXE_PARAM_PING_STORAGE_SERVER_IP));
response.setPingDir(details.get(BaremetalPxeService.PXE_PARAM_PING_ROOT_DIR));
response.setTftpDir(details.get(BaremetalPxeService.PXE_PARAM_TFTP_DIR));
return response;
} }
@Override @Override
public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxePingServersCmd cmd) { public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxeServersCmd cmd) {
SearchCriteriaService<BaremetalPxeVO, BaremetalPxeVO> sc = SearchCriteria2.create(BaremetalPxeVO.class); return null;
sc.addAnd(sc.getEntity().getDeviceType(), Op.EQ, BaremetalPxeType.PING.toString());
if (cmd.getPodId() != null) {
sc.addAnd(sc.getEntity().getPodId(), Op.EQ, cmd.getPodId());
if (cmd.getId() != null) {
sc.addAnd(sc.getEntity().getId(), Op.EQ, cmd.getId());
}
}
List<BaremetalPxeVO> vos = sc.list();
List<BaremetalPxeResponse> responses = new ArrayList<BaremetalPxeResponse>(vos.size());
for (BaremetalPxeVO vo : vos) {
responses.add(getApiResponse(vo));
}
return responses;
} }

View File

@ -223,14 +223,9 @@ public class BaremetalDhcpManagerImpl extends ManagerBase implements BaremetalDh
+ " is in shutdown state in the physical network: " + cmd.getPhysicalNetworkId() + "to add this device"); + " is in shutdown state in the physical network: " + cmd.getPhysicalNetworkId() + "to add this device");
} }
HostPodVO pod = _podDao.findById(cmd.getPodId()); List<HostVO> dhcps = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.BaremetalDhcp, null, null, zoneId);
if (pod == null) {
throw new IllegalArgumentException("Could not find pod with ID: " + cmd.getPodId());
}
List<HostVO> dhcps = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.BaremetalDhcp, null, cmd.getPodId(), zoneId);
if (dhcps.size() != 0) { if (dhcps.size() != 0) {
throw new IllegalArgumentException("Already had a DHCP server in Pod: " + cmd.getPodId() + " zone: " + zoneId); throw new IllegalArgumentException("Already had a DHCP server in zone: " + zoneId);
} }
URI uri; URI uri;
@ -242,16 +237,17 @@ public class BaremetalDhcpManagerImpl extends ManagerBase implements BaremetalDh
} }
String ipAddress = uri.getHost(); String ipAddress = uri.getHost();
String guid = getDhcpServerGuid(Long.toString(zoneId) + "-" + Long.toString(cmd.getPodId()), "ExternalDhcp", ipAddress); if (ipAddress == null) {
ipAddress = cmd.getUrl(); // the url is raw ip. For backforward compatibility, we have to support http://ip format as well
}
String guid = getDhcpServerGuid(Long.toString(zoneId), "ExternalDhcp", ipAddress);
Map params = new HashMap<String, String>(); Map params = new HashMap<String, String>();
params.put("type", cmd.getDhcpType()); params.put("type", cmd.getDhcpType());
params.put("zone", Long.toString(zoneId)); params.put("zone", Long.toString(zoneId));
params.put("pod", cmd.getPodId().toString());
params.put("ip", ipAddress); params.put("ip", ipAddress);
params.put("username", cmd.getUsername()); params.put("username", cmd.getUsername());
params.put("password", cmd.getPassword()); params.put("password", cmd.getPassword());
params.put("guid", guid); params.put("guid", guid);
params.put("gateway", pod.getGateway());
String dns = zone.getDns1(); String dns = zone.getDns1();
if (dns == null) { if (dns == null) {
dns = zone.getDns2(); dns = zone.getDns2();
@ -284,7 +280,6 @@ public class BaremetalDhcpManagerImpl extends ManagerBase implements BaremetalDh
vo.setHostId(dhcpServer.getId()); vo.setHostId(dhcpServer.getId());
vo.setNetworkServiceProviderId(ntwkSvcProvider.getId()); vo.setNetworkServiceProviderId(ntwkSvcProvider.getId());
vo.setPhysicalNetworkId(cmd.getPhysicalNetworkId()); vo.setPhysicalNetworkId(cmd.getPhysicalNetworkId());
vo.setPodId(cmd.getPodId());
Transaction txn = Transaction.currentTxn(); Transaction txn = Transaction.currentTxn();
txn.start(); txn.start();
_extDhcpDao.persist(vo); _extDhcpDao.persist(vo);
@ -296,26 +291,32 @@ public class BaremetalDhcpManagerImpl extends ManagerBase implements BaremetalDh
public BaremetalDhcpResponse generateApiResponse(BaremetalDhcpVO vo) { public BaremetalDhcpResponse generateApiResponse(BaremetalDhcpVO vo) {
BaremetalDhcpResponse response = new BaremetalDhcpResponse(); BaremetalDhcpResponse response = new BaremetalDhcpResponse();
response.setDeviceType(vo.getDeviceType()); response.setDeviceType(vo.getDeviceType());
response.setId(String.valueOf(vo.getId())); response.setId(vo.getUuid());
response.setPhysicalNetworkId(String.valueOf(vo.getPhysicalNetworkId())); HostVO host = _hostDao.findById(vo.getHostId());
response.setProviderId(String.valueOf(vo.getNetworkServiceProviderId())); response.setUrl(host.getPrivateIpAddress());
PhysicalNetworkVO nwVO = _physicalNetworkDao.findById(vo.getPhysicalNetworkId());
response.setPhysicalNetworkId(nwVO.getUuid());
PhysicalNetworkServiceProviderVO providerVO = _physicalNetworkServiceProviderDao.findById(vo.getNetworkServiceProviderId());
response.setProviderId(providerVO.getUuid());
response.setObjectName("baremetaldhcp");
return response; return response;
} }
@Override @Override
public List<BaremetalDhcpResponse> listBaremetalDhcps(ListBaremetalDhcpCmd cmd) { public List<BaremetalDhcpResponse> listBaremetalDhcps(ListBaremetalDhcpCmd cmd) {
List<BaremetalDhcpResponse> responses = new ArrayList<BaremetalDhcpResponse>();
if (cmd.getId() != null) {
BaremetalDhcpVO vo = _extDhcpDao.findById(cmd.getId());
responses.add(generateApiResponse(vo));
return responses;
}
SearchCriteriaService<BaremetalDhcpVO, BaremetalDhcpVO> sc = SearchCriteria2.create(BaremetalDhcpVO.class); SearchCriteriaService<BaremetalDhcpVO, BaremetalDhcpVO> sc = SearchCriteria2.create(BaremetalDhcpVO.class);
if (cmd.getDeviceType() != null) { if (cmd.getDeviceType() != null) {
sc.addAnd(sc.getEntity().getDeviceType(), Op.EQ, cmd.getDeviceType()); sc.addAnd(sc.getEntity().getDeviceType(), Op.EQ, cmd.getDeviceType());
} }
if (cmd.getPodId() != null) {
sc.addAnd(sc.getEntity().getPodId(), Op.EQ, cmd.getPodId());
if (cmd.getId() != null) {
sc.addAnd(sc.getEntity().getId(), Op.EQ, cmd.getId());
}
}
List<BaremetalDhcpVO> vos = sc.list(); List<BaremetalDhcpVO> vos = sc.list();
List<BaremetalDhcpResponse> responses = new ArrayList<BaremetalDhcpResponse>(vos.size());
for (BaremetalDhcpVO vo : vos) { for (BaremetalDhcpVO vo : vos) {
responses.add(generateApiResponse(vo)); responses.add(generateApiResponse(vo));
} }

View File

@ -55,8 +55,6 @@ public class BaremetalDhcpResourceBase extends ManagerBase implements ServerReso
String _password; String _password;
String _ip; String _ip;
String _zoneId; String _zoneId;
String _podId;
String _gateway;
String _dns; String _dns;
@Override @Override
@ -67,8 +65,6 @@ public class BaremetalDhcpResourceBase extends ManagerBase implements ServerReso
_username = (String)params.get("username"); _username = (String)params.get("username");
_password = (String)params.get("password"); _password = (String)params.get("password");
_zoneId = (String)params.get("zone"); _zoneId = (String)params.get("zone");
_podId = (String)params.get("pod");
_gateway = (String)params.get("gateway");
_dns = (String)params.get("dns"); _dns = (String)params.get("dns");
if (_guid == null) { if (_guid == null) {
@ -79,10 +75,6 @@ public class BaremetalDhcpResourceBase extends ManagerBase implements ServerReso
throw new ConfigurationException("No Zone specified"); throw new ConfigurationException("No Zone specified");
} }
if (_podId == null) {
throw new ConfigurationException("No Pod specified");
}
if (_ip == null) { if (_ip == null) {
throw new ConfigurationException("No IP specified"); throw new ConfigurationException("No IP specified");
} }
@ -95,10 +87,6 @@ public class BaremetalDhcpResourceBase extends ManagerBase implements ServerReso
throw new ConfigurationException("No password specified"); throw new ConfigurationException("No password specified");
} }
if (_gateway == null) {
throw new ConfigurationException("No gateway specified");
}
if (_dns == null) { if (_dns == null) {
throw new ConfigurationException("No dns specified"); throw new ConfigurationException("No dns specified");
} }
@ -131,7 +119,6 @@ public class BaremetalDhcpResourceBase extends ManagerBase implements ServerReso
StartupExternalDhcpCommand cmd = new StartupExternalDhcpCommand(); StartupExternalDhcpCommand cmd = new StartupExternalDhcpCommand();
cmd.setName(_name); cmd.setName(_name);
cmd.setDataCenter(_zoneId); cmd.setDataCenter(_zoneId);
cmd.setPod(_podId);
cmd.setPrivateIpAddress(_ip); cmd.setPrivateIpAddress(_ip);
cmd.setStorageIpAddress(""); cmd.setStorageIpAddress("");
cmd.setVersion(""); cmd.setVersion("");

View File

@ -41,6 +41,9 @@ public class BaremetalDhcpResponse extends BaseResponse {
@SerializedName(ApiConstants.DHCP_SERVER_TYPE) @Param(description="name of the provider") @SerializedName(ApiConstants.DHCP_SERVER_TYPE) @Param(description="name of the provider")
private String deviceType; private String deviceType;
@SerializedName(ApiConstants.URL) @Param(description="url")
private String url;
public String getId() { public String getId() {
return id; return id;
} }
@ -72,4 +75,12 @@ public class BaremetalDhcpResponse extends BaseResponse {
public void setDeviceType(String deviceType) { public void setDeviceType(String deviceType) {
this.deviceType = deviceType; this.deviceType = deviceType;
} }
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
} }

View File

@ -73,11 +73,13 @@ public class BaremetalDnsmasqResource extends BaremetalDhcpResourceBase {
throw new ConfigurationException("Can not find script prepare_dnsmasq.sh at " + prepareDnsmasq); throw new ConfigurationException("Can not find script prepare_dnsmasq.sh at " + prepareDnsmasq);
} }
scp.put(prepareDnsmasqPath, "/usr/bin/", "0755"); scp.put(prepareDnsmasqPath, "/usr/bin/", "0755");
/*
String prepareCmd = String.format("sh /usr/bin/prepare_dnsmasq.sh %1$s %2$s %3$s", _gateway, _dns, _ip); String prepareCmd = String.format("sh /usr/bin/prepare_dnsmasq.sh %1$s %2$s %3$s", _gateway, _dns, _ip);
if (!SSHCmdHelper.sshExecuteCmd(sshConnection, prepareCmd)) { if (!SSHCmdHelper.sshExecuteCmd(sshConnection, prepareCmd)) {
throw new ConfigurationException("prepare dnsmasq at " + _ip + " failed"); throw new ConfigurationException("prepare dnsmasq at " + _ip + " failed");
} }
*/
s_logger.debug("Dnsmasq resource configure successfully"); s_logger.debug("Dnsmasq resource configure successfully");
return true; return true;

View File

@ -31,7 +31,8 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.api.AddBaremetalKickStartPxeCmd; import org.apache.cloudstack.api.AddBaremetalKickStartPxeCmd;
import org.apache.cloudstack.api.AddBaremetalPxeCmd; import org.apache.cloudstack.api.AddBaremetalPxeCmd;
import org.apache.cloudstack.api.ListBaremetalPxePingServersCmd; import org.apache.cloudstack.api.ListBaremetalPxeServersCmd;
import org.apache.log4j.Logger;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
import com.cloud.agent.api.baremetal.IpmISetBootDevCommand; import com.cloud.agent.api.baremetal.IpmISetBootDevCommand;
@ -199,6 +200,9 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase imple
throw new IllegalArgumentException(e.getMessage()); throw new IllegalArgumentException(e.getMessage());
} }
String ipAddress = uri.getHost(); String ipAddress = uri.getHost();
if (ipAddress == null) {
ipAddress = cmd.getUrl();
}
String guid = getPxeServerGuid(Long.toString(zoneId), BaremetalPxeType.KICK_START.toString(), ipAddress); String guid = getPxeServerGuid(Long.toString(zoneId), BaremetalPxeType.KICK_START.toString(), ipAddress);
@ -236,27 +240,28 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase imple
@Override @Override
public BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo) { public BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo) {
BaremetalPxeKickStartResponse response = new BaremetalPxeKickStartResponse(); BaremetalPxeResponse response = new BaremetalPxeResponse();
response.setId(String.valueOf(vo.getId())); response.setId(vo.getUuid());
response.setPhysicalNetworkId(String.valueOf(vo.getPhysicalNetworkId())); HostVO host = _hostDao.findById(vo.getHostId());
response.setPodId(String.valueOf(vo.getPodId())); response.setUrl(host.getPrivateIpAddress());
Map<String, String> details = _hostDetailsDao.findDetails(vo.getHostId()); PhysicalNetworkServiceProviderVO providerVO = _physicalNetworkServiceProviderDao.findById(vo.getNetworkServiceProviderId());
response.setTftpDir(details.get(BaremetalPxeService.PXE_PARAM_TFTP_DIR)); response.setPhysicalNetworkId(providerVO.getUuid());
PhysicalNetworkVO nwVO = _physicalNetworkDao.findById(vo.getPhysicalNetworkId());
response.setPhysicalNetworkId(nwVO.getUuid());
response.setObjectName("baremetalpxeserver");
return response; return response;
} }
@Override @Override
public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxePingServersCmd cmd) { public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxeServersCmd cmd) {
SearchCriteriaService<BaremetalPxeVO, BaremetalPxeVO> sc = SearchCriteria2.create(BaremetalPxeVO.class); List<BaremetalPxeResponse> responses = new ArrayList<BaremetalPxeResponse>();
sc.addAnd(sc.getEntity().getDeviceType(), Op.EQ, BaremetalPxeType.KICK_START.toString()); if (cmd.getId() != null) {
if (cmd.getPodId() != null) { BaremetalPxeVO vo = _pxeDao.findById(cmd.getId());
sc.addAnd(sc.getEntity().getPodId(), Op.EQ, cmd.getPodId()); responses.add(getApiResponse(vo));
if (cmd.getId() != null) { return responses;
sc.addAnd(sc.getEntity().getId(), Op.EQ, cmd.getId());
}
} }
List<BaremetalPxeVO> vos = sc.list();
List<BaremetalPxeResponse> responses = new ArrayList<BaremetalPxeResponse>(vos.size()); List<BaremetalPxeVO> vos = _pxeDao.listAll();
for (BaremetalPxeVO vo : vos) { for (BaremetalPxeVO vo : vos) {
responses.add(getApiResponse(vo)); responses.add(getApiResponse(vo));
} }

View File

@ -25,7 +25,7 @@ package com.cloud.baremetal.networkservice;
import java.util.List; import java.util.List;
import org.apache.cloudstack.api.AddBaremetalPxeCmd; import org.apache.cloudstack.api.AddBaremetalPxeCmd;
import org.apache.cloudstack.api.ListBaremetalPxePingServersCmd; import org.apache.cloudstack.api.ListBaremetalPxeServersCmd;
import com.cloud.baremetal.database.BaremetalPxeVO; import com.cloud.baremetal.database.BaremetalPxeVO;
import com.cloud.deploy.DeployDestination; import com.cloud.deploy.DeployDestination;
@ -55,7 +55,7 @@ public interface BaremetalPxeManager extends Manager, PluggableService {
BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo); BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo);
List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxePingServersCmd cmd); List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxeServersCmd cmd);
boolean addUserData(NicProfile nic, VirtualMachineProfile vm); boolean addUserData(NicProfile nic, VirtualMachineProfile vm);

View File

@ -36,8 +36,9 @@ import org.apache.log4j.Logger;
import org.apache.cloudstack.api.AddBaremetalKickStartPxeCmd; import org.apache.cloudstack.api.AddBaremetalKickStartPxeCmd;
import org.apache.cloudstack.api.AddBaremetalPxeCmd; import org.apache.cloudstack.api.AddBaremetalPxeCmd;
import org.apache.cloudstack.api.AddBaremetalPxePingServerCmd; import org.apache.cloudstack.api.AddBaremetalPxePingServerCmd;
import org.apache.cloudstack.api.ListBaremetalPxePingServersCmd;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.api.ListBaremetalPxeServersCmd;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager; import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
@ -179,8 +180,8 @@ public class BaremetalPxeManagerImpl extends ManagerBase implements BaremetalPxe
} }
@Override @Override
public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxePingServersCmd cmd) { public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxeServersCmd cmd) {
return getServiceByType(BaremetalPxeManager.BaremetalPxeType.PING.toString()).listPxeServers(cmd); return getServiceByType(BaremetalPxeType.KICK_START.toString()).listPxeServers(cmd);
} }
@Override @Override
@ -247,7 +248,7 @@ public class BaremetalPxeManagerImpl extends ManagerBase implements BaremetalPxe
List<Class<?>> cmds = new ArrayList<Class<?>>(); List<Class<?>> cmds = new ArrayList<Class<?>>();
cmds.add(AddBaremetalKickStartPxeCmd.class); cmds.add(AddBaremetalKickStartPxeCmd.class);
cmds.add(AddBaremetalPxePingServerCmd.class); cmds.add(AddBaremetalPxePingServerCmd.class);
cmds.add(ListBaremetalPxePingServersCmd.class); cmds.add(ListBaremetalPxeServersCmd.class);
return cmds; return cmds;
} }
} }

View File

@ -33,9 +33,9 @@ public class BaremetalPxeResponse extends BaseResponse {
@SerializedName(ApiConstants.PROVIDER) @Param(description="name of the provider") @SerializedName(ApiConstants.PROVIDER) @Param(description="name of the provider")
private String providerId; private String providerId;
@SerializedName(ApiConstants.POD_ID) @Param(description="pod id where the device is in") @SerializedName(ApiConstants.URL) @Param(description="url")
private String podId; private String url;
public String getId() { public String getId() {
return id; return id;
@ -61,11 +61,11 @@ public class BaremetalPxeResponse extends BaseResponse {
this.providerId = providerId; this.providerId = providerId;
} }
public String getPodId() { public String getUrl() {
return podId; return url;
} }
public void setPodId(String podId) { public void setUrl(String url) {
this.podId = podId; this.url = url;
} }
} }

View File

@ -25,7 +25,7 @@ package com.cloud.baremetal.networkservice;
import java.util.List; import java.util.List;
import org.apache.cloudstack.api.AddBaremetalPxeCmd; import org.apache.cloudstack.api.AddBaremetalPxeCmd;
import org.apache.cloudstack.api.ListBaremetalPxePingServersCmd; import org.apache.cloudstack.api.ListBaremetalPxeServersCmd;
import com.cloud.baremetal.database.BaremetalPxeVO; import com.cloud.baremetal.database.BaremetalPxeVO;
import com.cloud.deploy.DeployDestination; import com.cloud.deploy.DeployDestination;
@ -45,7 +45,7 @@ public interface BaremetalPxeService extends Adapter {
BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo); BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo);
List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxePingServersCmd cmd); List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxeServersCmd cmd);
String getPxeServiceType(); String getPxeServiceType();

View File

@ -45,7 +45,7 @@ import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.ResourceUnavailableException;
@APICommand(name="addBaremetalDhcp", description="adds a baremetal dhcp server", responseObject = BaremetalDhcpResponse.class) @APICommand(name="addBaremetalDhcp", description="adds a baremetal dhcp server", responseObject = BaremetalDhcpResponse.class)
public class AddBaremetalDhcpCmd extends BaseAsyncCmd { public class AddBaremetalDhcpCmd extends BaseAsyncCmd {
private static final String s_name = "addexternaldhcpresponse"; private static final String s_name = "addbaremetaldhcpresponse";
public static final Logger s_logger = Logger.getLogger(AddBaremetalDhcpCmd.class); public static final Logger s_logger = Logger.getLogger(AddBaremetalDhcpCmd.class);
@Inject BaremetalDhcpManager mgr; @Inject BaremetalDhcpManager mgr;
@ -56,9 +56,6 @@ public class AddBaremetalDhcpCmd extends BaseAsyncCmd {
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID, entityType=PhysicalNetworkResponse.class, required=true, description="the Physical Network ID") @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID, entityType=PhysicalNetworkResponse.class, required=true, description="the Physical Network ID")
private Long physicalNetworkId; private Long physicalNetworkId;
@Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class, required = true, description="Pod Id")
private Long podId;
@Parameter(name=ApiConstants.DHCP_SERVER_TYPE, type=CommandType.STRING, required = true, description="Type of dhcp device") @Parameter(name=ApiConstants.DHCP_SERVER_TYPE, type=CommandType.STRING, required = true, description="Type of dhcp device")
private String dhcpType; private String dhcpType;
@ -106,14 +103,6 @@ public class AddBaremetalDhcpCmd extends BaseAsyncCmd {
return CallContext.current().getCallingAccount().getId(); return CallContext.current().getCallingAccount().getId();
} }
public Long getPodId() {
return podId;
}
public void setPodId(Long podId) {
this.podId = podId;
}
public String getDhcpType() { public String getDhcpType() {
return dhcpType; return dhcpType;
} }

View File

@ -20,6 +20,7 @@ package org.apache.cloudstack.api;
import javax.inject.Inject; import javax.inject.Inject;
import com.cloud.baremetal.networkservice.BaremetalPxeResponse;
import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode; import org.apache.cloudstack.api.ApiErrorCode;
@ -43,7 +44,7 @@ import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.ResourceUnavailableException;
public class AddBaremetalPxeCmd extends BaseAsyncCmd { public class AddBaremetalPxeCmd extends BaseAsyncCmd {
private static final String s_name = "addexternalpxeresponse"; private static final String s_name = "addbaremetalpxeresponse";
public static final Logger s_logger = Logger.getLogger(AddBaremetalPxeCmd.class); public static final Logger s_logger = Logger.getLogger(AddBaremetalPxeCmd.class);
@Inject BaremetalPxeManager pxeMgr; @Inject BaremetalPxeManager pxeMgr;
@ -83,6 +84,10 @@ public class AddBaremetalPxeCmd extends BaseAsyncCmd {
ResourceAllocationException, NetworkRuleConflictException { ResourceAllocationException, NetworkRuleConflictException {
try { try {
BaremetalPxeVO vo = pxeMgr.addPxeServer(this); BaremetalPxeVO vo = pxeMgr.addPxeServer(this);
BaremetalPxeResponse rsp = pxeMgr.getApiResponse(vo);
rsp.setObjectName(s_name);
rsp.setResponseName(getCommandName());
this.setResponseObject(rsp);
} catch (Exception e) { } catch (Exception e) {
s_logger.warn("Unable to add external pxe server with url: " + getUrl(), e); s_logger.warn("Unable to add external pxe server with url: " + getUrl(), e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());

View File

@ -43,7 +43,7 @@ import com.cloud.exception.ResourceUnavailableException;
@APICommand(name="listBaremetalDhcp", description="list baremetal dhcp servers", responseObject = BaremetalDhcpResponse.class) @APICommand(name="listBaremetalDhcp", description="list baremetal dhcp servers", responseObject = BaremetalDhcpResponse.class)
public class ListBaremetalDhcpCmd extends BaseListCmd { public class ListBaremetalDhcpCmd extends BaseListCmd {
private static final Logger s_logger = Logger.getLogger(ListBaremetalDhcpCmd.class); private static final Logger s_logger = Logger.getLogger(ListBaremetalDhcpCmd.class);
private static final String s_name = "listexternaldhcpresponse"; private static final String s_name = "listbaremetaldhcpresponse";
@Inject BaremetalDhcpManager _dhcpMgr; @Inject BaremetalDhcpManager _dhcpMgr;
// /////////////////////////////////////////////////// // ///////////////////////////////////////////////////
@ -52,9 +52,6 @@ public class ListBaremetalDhcpCmd extends BaseListCmd {
@Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "DHCP server device ID") @Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "DHCP server device ID")
private Long id; private Long id;
@Parameter(name = ApiConstants.POD_ID, type = CommandType.LONG, description = "Pod ID where pxe server is in")
private Long podId;
@Parameter(name = ApiConstants.DHCP_SERVER_TYPE, type = CommandType.STRING, description = "Type of DHCP device") @Parameter(name = ApiConstants.DHCP_SERVER_TYPE, type = CommandType.STRING, description = "Type of DHCP device")
private String deviceType; private String deviceType;
@ -66,14 +63,6 @@ public class ListBaremetalDhcpCmd extends BaseListCmd {
this.id = id; this.id = id;
} }
public Long getPodId() {
return podId;
}
public void setPodId(Long podId) {
this.podId = podId;
}
public String getDeviceType() { public String getDeviceType() {
return deviceType; return deviceType;
} }
@ -90,6 +79,7 @@ public class ListBaremetalDhcpCmd extends BaseListCmd {
List<BaremetalDhcpResponse> dhcpResponses = _dhcpMgr.listBaremetalDhcps(this); List<BaremetalDhcpResponse> dhcpResponses = _dhcpMgr.listBaremetalDhcps(this);
response.setResponses(dhcpResponses); response.setResponses(dhcpResponses);
response.setResponseName(getCommandName()); response.setResponseName(getCommandName());
response.setObjectName("baremetaldhcps");
this.setResponseObject(response); this.setResponseObject(response);
} catch (Exception e) { } catch (Exception e) {
s_logger.debug("Exception happend while executing ListBaremetalDhcpCmd"); s_logger.debug("Exception happend while executing ListBaremetalDhcpCmd");

View File

@ -22,15 +22,8 @@ import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.BaseCmd.CommandType;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.ListResponse; import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.cloud.baremetal.networkservice.BaremetalPxeManager; import com.cloud.baremetal.networkservice.BaremetalPxeManager;
@ -41,10 +34,10 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.NetworkRuleConflictException; import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.ResourceUnavailableException;
@APICommand(name="listBaremetalPxePingServer", description="list baremetal ping pxe server", responseObject = BaremetalPxePingResponse.class) @APICommand(name="listBaremetalPxeServers", description="list baremetal pxe server", responseObject = BaremetalPxeResponse.class)
public class ListBaremetalPxePingServersCmd extends BaseListCmd { public class ListBaremetalPxeServersCmd extends BaseListCmd {
private static final Logger s_logger = Logger.getLogger(ListBaremetalPxePingServersCmd.class); private static final Logger s_logger = Logger.getLogger(ListBaremetalPxeServersCmd.class);
private static final String s_name = "listpingpxeserverresponse"; private static final String s_name = "listbaremetalpxeserversresponse";
@Inject @Inject
BaremetalPxeManager _pxeMgr; BaremetalPxeManager _pxeMgr;
@ -52,11 +45,8 @@ public class ListBaremetalPxePingServersCmd extends BaseListCmd {
// ////////////// API parameters ///////////////////// // ////////////// API parameters /////////////////////
// /////////////////////////////////////////////////// // ///////////////////////////////////////////////////
@Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "Ping pxe server device ID") @Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "Pxe server device ID")
private Long id; private Long id;
@Parameter(name = ApiConstants.POD_ID, type = CommandType.LONG, description = "Pod ID where pxe server is in")
private Long podId;
public Long getId() { public Long getId() {
return id; return id;
@ -66,14 +56,6 @@ public class ListBaremetalPxePingServersCmd extends BaseListCmd {
this.id = id; this.id = id;
} }
public Long getPodId() {
return podId;
}
public void setPodId(Long podId) {
this.podId = podId;
}
@Override @Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
ResourceAllocationException, NetworkRuleConflictException { ResourceAllocationException, NetworkRuleConflictException {
@ -82,9 +64,10 @@ public class ListBaremetalPxePingServersCmd extends BaseListCmd {
List<BaremetalPxeResponse> pxeResponses = _pxeMgr.listPxeServers(this); List<BaremetalPxeResponse> pxeResponses = _pxeMgr.listPxeServers(this);
response.setResponses(pxeResponses); response.setResponses(pxeResponses);
response.setResponseName(getCommandName()); response.setResponseName(getCommandName());
response.setObjectName("baremetalpxeservers");
this.setResponseObject(response); this.setResponseObject(response);
} catch (Exception e) { } catch (Exception e) {
s_logger.debug("Exception happend while executing ListPingPxeServersCmd" ,e); s_logger.debug("Exception happened while executing ListPingPxeServersCmd" ,e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage()); throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
} }
} }
@ -93,5 +76,4 @@ public class ListBaremetalPxePingServersCmd extends BaseListCmd {
public String getCommandName() { public String getCommandName() {
return s_name; return s_name;
} }
} }