mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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:
parent
0fdaef8e3d
commit
b37e6c14c1
@ -609,7 +609,7 @@ addBaremetalPxeKickStartServer=1
|
||||
addBaremetalPxePingServer=1
|
||||
addBaremetalDhcp=1
|
||||
listBaremetalDhcp=1
|
||||
listBaremetalPxePingServer=1
|
||||
listBaremetalPxeServers=1
|
||||
|
||||
#### UCS commands
|
||||
addUcsManager=1
|
||||
@ -617,7 +617,7 @@ listUcsManagers=1
|
||||
listUcsProfiles=1
|
||||
listUcsBlades=1
|
||||
associateUcsProfileToBlade=1
|
||||
deleteUcsManager=1
|
||||
removedeleteUcsManager=1
|
||||
|
||||
#### New Load Balancer commands
|
||||
createLoadBalancer=15
|
||||
|
||||
2
engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
Normal file → Executable file
2
engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
Normal file → Executable 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.executeUpdate();
|
||||
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 = 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();
|
||||
|
||||
@ -35,7 +35,8 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.AddBaremetalPxeCmd;
|
||||
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.baremetal.IpmISetBootDevCommand;
|
||||
@ -271,34 +272,13 @@ public class BareMetalPingServiceImpl extends BareMetalPxeServiceBase implements
|
||||
|
||||
@Override
|
||||
public BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo) {
|
||||
BaremetalPxePingResponse response = new BaremetalPxePingResponse();
|
||||
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;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxePingServersCmd cmd) {
|
||||
SearchCriteriaService<BaremetalPxeVO, BaremetalPxeVO> sc = SearchCriteria2.create(BaremetalPxeVO.class);
|
||||
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;
|
||||
public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxeServersCmd cmd) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
HostPodVO pod = _podDao.findById(cmd.getPodId());
|
||||
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);
|
||||
List<HostVO> dhcps = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.BaremetalDhcp, null, null, zoneId);
|
||||
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;
|
||||
@ -242,16 +237,17 @@ public class BaremetalDhcpManagerImpl extends ManagerBase implements BaremetalDh
|
||||
}
|
||||
|
||||
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>();
|
||||
params.put("type", cmd.getDhcpType());
|
||||
params.put("zone", Long.toString(zoneId));
|
||||
params.put("pod", cmd.getPodId().toString());
|
||||
params.put("ip", ipAddress);
|
||||
params.put("username", cmd.getUsername());
|
||||
params.put("password", cmd.getPassword());
|
||||
params.put("guid", guid);
|
||||
params.put("gateway", pod.getGateway());
|
||||
String dns = zone.getDns1();
|
||||
if (dns == null) {
|
||||
dns = zone.getDns2();
|
||||
@ -284,7 +280,6 @@ public class BaremetalDhcpManagerImpl extends ManagerBase implements BaremetalDh
|
||||
vo.setHostId(dhcpServer.getId());
|
||||
vo.setNetworkServiceProviderId(ntwkSvcProvider.getId());
|
||||
vo.setPhysicalNetworkId(cmd.getPhysicalNetworkId());
|
||||
vo.setPodId(cmd.getPodId());
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
_extDhcpDao.persist(vo);
|
||||
@ -296,26 +291,32 @@ public class BaremetalDhcpManagerImpl extends ManagerBase implements BaremetalDh
|
||||
public BaremetalDhcpResponse generateApiResponse(BaremetalDhcpVO vo) {
|
||||
BaremetalDhcpResponse response = new BaremetalDhcpResponse();
|
||||
response.setDeviceType(vo.getDeviceType());
|
||||
response.setId(String.valueOf(vo.getId()));
|
||||
response.setPhysicalNetworkId(String.valueOf(vo.getPhysicalNetworkId()));
|
||||
response.setProviderId(String.valueOf(vo.getNetworkServiceProviderId()));
|
||||
response.setId(vo.getUuid());
|
||||
HostVO host = _hostDao.findById(vo.getHostId());
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
if (cmd.getDeviceType() != null) {
|
||||
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<BaremetalDhcpResponse> responses = new ArrayList<BaremetalDhcpResponse>(vos.size());
|
||||
for (BaremetalDhcpVO vo : vos) {
|
||||
responses.add(generateApiResponse(vo));
|
||||
}
|
||||
|
||||
13
plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpResourceBase.java
Normal file → Executable file
13
plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDhcpResourceBase.java
Normal file → Executable file
@ -55,8 +55,6 @@ public class BaremetalDhcpResourceBase extends ManagerBase implements ServerReso
|
||||
String _password;
|
||||
String _ip;
|
||||
String _zoneId;
|
||||
String _podId;
|
||||
String _gateway;
|
||||
String _dns;
|
||||
|
||||
@Override
|
||||
@ -67,8 +65,6 @@ public class BaremetalDhcpResourceBase extends ManagerBase implements ServerReso
|
||||
_username = (String)params.get("username");
|
||||
_password = (String)params.get("password");
|
||||
_zoneId = (String)params.get("zone");
|
||||
_podId = (String)params.get("pod");
|
||||
_gateway = (String)params.get("gateway");
|
||||
_dns = (String)params.get("dns");
|
||||
|
||||
if (_guid == null) {
|
||||
@ -79,10 +75,6 @@ public class BaremetalDhcpResourceBase extends ManagerBase implements ServerReso
|
||||
throw new ConfigurationException("No Zone specified");
|
||||
}
|
||||
|
||||
if (_podId == null) {
|
||||
throw new ConfigurationException("No Pod specified");
|
||||
}
|
||||
|
||||
if (_ip == null) {
|
||||
throw new ConfigurationException("No IP specified");
|
||||
}
|
||||
@ -95,10 +87,6 @@ public class BaremetalDhcpResourceBase extends ManagerBase implements ServerReso
|
||||
throw new ConfigurationException("No password specified");
|
||||
}
|
||||
|
||||
if (_gateway == null) {
|
||||
throw new ConfigurationException("No gateway specified");
|
||||
}
|
||||
|
||||
if (_dns == null) {
|
||||
throw new ConfigurationException("No dns specified");
|
||||
}
|
||||
@ -131,7 +119,6 @@ public class BaremetalDhcpResourceBase extends ManagerBase implements ServerReso
|
||||
StartupExternalDhcpCommand cmd = new StartupExternalDhcpCommand();
|
||||
cmd.setName(_name);
|
||||
cmd.setDataCenter(_zoneId);
|
||||
cmd.setPod(_podId);
|
||||
cmd.setPrivateIpAddress(_ip);
|
||||
cmd.setStorageIpAddress("");
|
||||
cmd.setVersion("");
|
||||
|
||||
@ -41,6 +41,9 @@ public class BaremetalDhcpResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.DHCP_SERVER_TYPE) @Param(description="name of the provider")
|
||||
private String deviceType;
|
||||
|
||||
@SerializedName(ApiConstants.URL) @Param(description="url")
|
||||
private String url;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -72,4 +75,12 @@ public class BaremetalDhcpResponse extends BaseResponse {
|
||||
public void setDeviceType(String deviceType) {
|
||||
this.deviceType = deviceType;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
|
||||
4
plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDnsmasqResource.java
Normal file → Executable file
4
plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalDnsmasqResource.java
Normal file → Executable file
@ -73,11 +73,13 @@ public class BaremetalDnsmasqResource extends BaremetalDhcpResourceBase {
|
||||
throw new ConfigurationException("Can not find script prepare_dnsmasq.sh at " + prepareDnsmasq);
|
||||
}
|
||||
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);
|
||||
if (!SSHCmdHelper.sshExecuteCmd(sshConnection, prepareCmd)) {
|
||||
throw new ConfigurationException("prepare dnsmasq at " + _ip + " failed");
|
||||
}
|
||||
*/
|
||||
|
||||
s_logger.debug("Dnsmasq resource configure successfully");
|
||||
return true;
|
||||
|
||||
@ -31,7 +31,8 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.AddBaremetalKickStartPxeCmd;
|
||||
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.baremetal.IpmISetBootDevCommand;
|
||||
@ -199,6 +200,9 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase imple
|
||||
throw new IllegalArgumentException(e.getMessage());
|
||||
}
|
||||
String ipAddress = uri.getHost();
|
||||
if (ipAddress == null) {
|
||||
ipAddress = cmd.getUrl();
|
||||
}
|
||||
|
||||
String guid = getPxeServerGuid(Long.toString(zoneId), BaremetalPxeType.KICK_START.toString(), ipAddress);
|
||||
|
||||
@ -236,27 +240,28 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase imple
|
||||
|
||||
@Override
|
||||
public BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo) {
|
||||
BaremetalPxeKickStartResponse response = new BaremetalPxeKickStartResponse();
|
||||
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.setTftpDir(details.get(BaremetalPxeService.PXE_PARAM_TFTP_DIR));
|
||||
BaremetalPxeResponse response = new BaremetalPxeResponse();
|
||||
response.setId(vo.getUuid());
|
||||
HostVO host = _hostDao.findById(vo.getHostId());
|
||||
response.setUrl(host.getPrivateIpAddress());
|
||||
PhysicalNetworkServiceProviderVO providerVO = _physicalNetworkServiceProviderDao.findById(vo.getNetworkServiceProviderId());
|
||||
response.setPhysicalNetworkId(providerVO.getUuid());
|
||||
PhysicalNetworkVO nwVO = _physicalNetworkDao.findById(vo.getPhysicalNetworkId());
|
||||
response.setPhysicalNetworkId(nwVO.getUuid());
|
||||
response.setObjectName("baremetalpxeserver");
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxePingServersCmd cmd) {
|
||||
SearchCriteriaService<BaremetalPxeVO, BaremetalPxeVO> sc = SearchCriteria2.create(BaremetalPxeVO.class);
|
||||
sc.addAnd(sc.getEntity().getDeviceType(), Op.EQ, BaremetalPxeType.KICK_START.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());
|
||||
}
|
||||
public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxeServersCmd cmd) {
|
||||
List<BaremetalPxeResponse> responses = new ArrayList<BaremetalPxeResponse>();
|
||||
if (cmd.getId() != null) {
|
||||
BaremetalPxeVO vo = _pxeDao.findById(cmd.getId());
|
||||
responses.add(getApiResponse(vo));
|
||||
return responses;
|
||||
}
|
||||
List<BaremetalPxeVO> vos = sc.list();
|
||||
List<BaremetalPxeResponse> responses = new ArrayList<BaremetalPxeResponse>(vos.size());
|
||||
|
||||
List<BaremetalPxeVO> vos = _pxeDao.listAll();
|
||||
for (BaremetalPxeVO vo : vos) {
|
||||
responses.add(getApiResponse(vo));
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ package com.cloud.baremetal.networkservice;
|
||||
import java.util.List;
|
||||
|
||||
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.deploy.DeployDestination;
|
||||
@ -55,7 +55,7 @@ public interface BaremetalPxeManager extends Manager, PluggableService {
|
||||
|
||||
BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo);
|
||||
|
||||
List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxePingServersCmd cmd);
|
||||
List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxeServersCmd cmd);
|
||||
|
||||
boolean addUserData(NicProfile nic, VirtualMachineProfile vm);
|
||||
|
||||
|
||||
@ -36,8 +36,9 @@ import org.apache.log4j.Logger;
|
||||
import org.apache.cloudstack.api.AddBaremetalKickStartPxeCmd;
|
||||
import org.apache.cloudstack.api.AddBaremetalPxeCmd;
|
||||
import org.apache.cloudstack.api.AddBaremetalPxePingServerCmd;
|
||||
import org.apache.cloudstack.api.ListBaremetalPxePingServersCmd;
|
||||
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.api.Answer;
|
||||
@ -179,8 +180,8 @@ public class BaremetalPxeManagerImpl extends ManagerBase implements BaremetalPxe
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxePingServersCmd cmd) {
|
||||
return getServiceByType(BaremetalPxeManager.BaremetalPxeType.PING.toString()).listPxeServers(cmd);
|
||||
public List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxeServersCmd cmd) {
|
||||
return getServiceByType(BaremetalPxeType.KICK_START.toString()).listPxeServers(cmd);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -247,7 +248,7 @@ public class BaremetalPxeManagerImpl extends ManagerBase implements BaremetalPxe
|
||||
List<Class<?>> cmds = new ArrayList<Class<?>>();
|
||||
cmds.add(AddBaremetalKickStartPxeCmd.class);
|
||||
cmds.add(AddBaremetalPxePingServerCmd.class);
|
||||
cmds.add(ListBaremetalPxePingServersCmd.class);
|
||||
cmds.add(ListBaremetalPxeServersCmd.class);
|
||||
return cmds;
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,9 +33,9 @@ public class BaremetalPxeResponse extends BaseResponse {
|
||||
|
||||
@SerializedName(ApiConstants.PROVIDER) @Param(description="name of the provider")
|
||||
private String providerId;
|
||||
|
||||
@SerializedName(ApiConstants.POD_ID) @Param(description="pod id where the device is in")
|
||||
private String podId;
|
||||
|
||||
@SerializedName(ApiConstants.URL) @Param(description="url")
|
||||
private String url;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
@ -61,11 +61,11 @@ public class BaremetalPxeResponse extends BaseResponse {
|
||||
this.providerId = providerId;
|
||||
}
|
||||
|
||||
public String getPodId() {
|
||||
return podId;
|
||||
}
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setPodId(String podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ package com.cloud.baremetal.networkservice;
|
||||
import java.util.List;
|
||||
|
||||
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.deploy.DeployDestination;
|
||||
@ -45,7 +45,7 @@ public interface BaremetalPxeService extends Adapter {
|
||||
|
||||
BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo);
|
||||
|
||||
List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxePingServersCmd cmd);
|
||||
List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxeServersCmd cmd);
|
||||
|
||||
String getPxeServiceType();
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
@APICommand(name="addBaremetalDhcp", description="adds a baremetal dhcp server", responseObject = BaremetalDhcpResponse.class)
|
||||
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);
|
||||
|
||||
@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")
|
||||
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")
|
||||
private String dhcpType;
|
||||
|
||||
@ -106,14 +103,6 @@ public class AddBaremetalDhcpCmd extends BaseAsyncCmd {
|
||||
return CallContext.current().getCallingAccount().getId();
|
||||
}
|
||||
|
||||
public Long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public void setPodId(Long podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
public String getDhcpType() {
|
||||
return dhcpType;
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ package org.apache.cloudstack.api;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.baremetal.networkservice.BaremetalPxeResponse;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
@ -43,7 +44,7 @@ import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
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);
|
||||
|
||||
@Inject BaremetalPxeManager pxeMgr;
|
||||
@ -83,6 +84,10 @@ public class AddBaremetalPxeCmd extends BaseAsyncCmd {
|
||||
ResourceAllocationException, NetworkRuleConflictException {
|
||||
try {
|
||||
BaremetalPxeVO vo = pxeMgr.addPxeServer(this);
|
||||
BaremetalPxeResponse rsp = pxeMgr.getApiResponse(vo);
|
||||
rsp.setObjectName(s_name);
|
||||
rsp.setResponseName(getCommandName());
|
||||
this.setResponseObject(rsp);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to add external pxe server with url: " + getUrl(), e);
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
|
||||
|
||||
@ -43,7 +43,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
||||
@APICommand(name="listBaremetalDhcp", description="list baremetal dhcp servers", responseObject = BaremetalDhcpResponse.class)
|
||||
public class ListBaremetalDhcpCmd extends BaseListCmd {
|
||||
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;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
@ -52,9 +52,6 @@ public class ListBaremetalDhcpCmd extends BaseListCmd {
|
||||
@Parameter(name = ApiConstants.ID, type = CommandType.LONG, description = "DHCP server device 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")
|
||||
private String deviceType;
|
||||
|
||||
@ -66,14 +63,6 @@ public class ListBaremetalDhcpCmd extends BaseListCmd {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public void setPodId(Long podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
public String getDeviceType() {
|
||||
return deviceType;
|
||||
}
|
||||
@ -90,6 +79,7 @@ public class ListBaremetalDhcpCmd extends BaseListCmd {
|
||||
List<BaremetalDhcpResponse> dhcpResponses = _dhcpMgr.listBaremetalDhcps(this);
|
||||
response.setResponses(dhcpResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
response.setObjectName("baremetaldhcps");
|
||||
this.setResponseObject(response);
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Exception happend while executing ListBaremetalDhcpCmd");
|
||||
|
||||
@ -22,15 +22,8 @@ import java.util.List;
|
||||
|
||||
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.PhysicalNetworkResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.baremetal.networkservice.BaremetalPxeManager;
|
||||
@ -41,10 +34,10 @@ import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
@APICommand(name="listBaremetalPxePingServer", description="list baremetal ping pxe server", responseObject = BaremetalPxePingResponse.class)
|
||||
public class ListBaremetalPxePingServersCmd extends BaseListCmd {
|
||||
private static final Logger s_logger = Logger.getLogger(ListBaremetalPxePingServersCmd.class);
|
||||
private static final String s_name = "listpingpxeserverresponse";
|
||||
@APICommand(name="listBaremetalPxeServers", description="list baremetal pxe server", responseObject = BaremetalPxeResponse.class)
|
||||
public class ListBaremetalPxeServersCmd extends BaseListCmd {
|
||||
private static final Logger s_logger = Logger.getLogger(ListBaremetalPxeServersCmd.class);
|
||||
private static final String s_name = "listbaremetalpxeserversresponse";
|
||||
|
||||
@Inject
|
||||
BaremetalPxeManager _pxeMgr;
|
||||
@ -52,11 +45,8 @@ public class ListBaremetalPxePingServersCmd extends BaseListCmd {
|
||||
// ////////////// 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;
|
||||
|
||||
@Parameter(name = ApiConstants.POD_ID, type = CommandType.LONG, description = "Pod ID where pxe server is in")
|
||||
private Long podId;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@ -66,14 +56,6 @@ public class ListBaremetalPxePingServersCmd extends BaseListCmd {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getPodId() {
|
||||
return podId;
|
||||
}
|
||||
|
||||
public void setPodId(Long podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException, NetworkRuleConflictException {
|
||||
@ -82,9 +64,10 @@ public class ListBaremetalPxePingServersCmd extends BaseListCmd {
|
||||
List<BaremetalPxeResponse> pxeResponses = _pxeMgr.listPxeServers(this);
|
||||
response.setResponses(pxeResponses);
|
||||
response.setResponseName(getCommandName());
|
||||
response.setObjectName("baremetalpxeservers");
|
||||
this.setResponseObject(response);
|
||||
} 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());
|
||||
}
|
||||
}
|
||||
@ -93,5 +76,4 @@ public class ListBaremetalPxePingServersCmd extends BaseListCmd {
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user