use of com.cloud.agent.api.baremetal.IpmISetBootDevCommand in project cloudstack by apache.
the class BareMetalPingServiceImpl method prepare.
@Override
public boolean prepare(VirtualMachineProfile profile, NicProfile pxeNic, Network network, DeployDestination dest, ReservationContext context) {
QueryBuilder<BaremetalPxeVO> sc = QueryBuilder.create(BaremetalPxeVO.class);
sc.and(sc.entity().getDeviceType(), Op.EQ, BaremetalPxeType.PING.toString());
sc.and(sc.entity().getPodId(), Op.EQ, dest.getPod().getId());
BaremetalPxeVO pxeVo = sc.find();
if (pxeVo == null) {
throw new CloudRuntimeException("No PING PXE server found in pod: " + dest.getPod().getId() + ", you need to add it before starting VM");
}
long pxeServerId = pxeVo.getHostId();
String mac = pxeNic.getMacAddress();
String ip = pxeNic.getIPv4Address();
String gateway = pxeNic.getIPv4Gateway();
String mask = pxeNic.getIPv4Netmask();
String dns = pxeNic.getIPv4Dns1();
if (dns == null) {
dns = pxeNic.getIPv4Dns2();
}
try {
String tpl = profile.getTemplate().getUrl();
assert tpl != null : "How can a null template get here!!!";
PreparePxeServerCommand cmd = new PreparePxeServerCommand(ip, mac, mask, gateway, dns, tpl, profile.getVirtualMachine().getInstanceName(), dest.getHost().getName());
PreparePxeServerAnswer ans = (PreparePxeServerAnswer) _agentMgr.send(pxeServerId, cmd);
if (!ans.getResult()) {
s_logger.warn("Unable tot program PXE server: " + pxeVo.getId() + " because " + ans.getDetails());
return false;
}
IpmISetBootDevCommand bootCmd = new IpmISetBootDevCommand(BootDev.pxe);
Answer anw = _agentMgr.send(dest.getHost().getId(), bootCmd);
if (!anw.getResult()) {
s_logger.warn("Unable to set host: " + dest.getHost().getId() + " to PXE boot because " + anw.getDetails());
}
return anw.getResult();
} catch (Exception e) {
s_logger.warn("Cannot prepare PXE server", e);
return false;
}
}
use of com.cloud.agent.api.baremetal.IpmISetBootDevCommand in project cloudstack by apache.
the class BaremetalKickStartServiceImpl method prepare.
@Override
public boolean prepare(VirtualMachineProfile profile, NicProfile nic, Network network, DeployDestination dest, ReservationContext context) {
try {
if (DataCenter.NetworkType.Basic.equals(dest.getDataCenter().getNetworkType())) {
if (!preparePxeInBasicZone(profile, nic, dest, context)) {
return false;
}
} else {
if (!preparePxeInAdvancedZone(profile, nic, network, dest, context)) {
return false;
}
}
IpmISetBootDevCommand bootCmd = new IpmISetBootDevCommand(BootDev.pxe);
Answer aws = _agentMgr.send(dest.getHost().getId(), bootCmd);
if (!aws.getResult()) {
s_logger.warn("Unable to set host: " + dest.getHost().getId() + " to PXE boot because " + aws.getDetails());
}
return aws.getResult();
} catch (Exception e) {
s_logger.warn("Cannot prepare PXE server", e);
return false;
}
}
Aggregations