use of com.cloud.agent.api.ReadyAnswer in project cloudstack by apache.
the class CitrixReadyCommandWrapper method execute.
@Override
public Answer execute(final ReadyCommand command, final CitrixResourceBase citrixResourceBase) {
final Connection conn = citrixResourceBase.getConnection();
final Long dcId = command.getDataCenterId();
// Ignore the result of the callHostPlugin. Even if unmounting the
// snapshots dir fails, let Ready command
// succeed.
citrixResourceBase.umountSnapshotDir(conn, dcId);
citrixResourceBase.setupLinkLocalNetwork(conn);
// try to destroy CD-ROM device for all system VMs on this host
try {
final Host host = Host.getByUuid(conn, citrixResourceBase.getHost().getUuid());
final Set<VM> vms = host.getResidentVMs(conn);
for (final VM vm : vms) {
citrixResourceBase.destroyPatchVbd(conn, vm.getNameLabel(conn));
}
} catch (final Exception e) {
}
try {
final boolean result = citrixResourceBase.cleanupHaltedVms(conn);
if (!result) {
return new ReadyAnswer(command, "Unable to cleanup halted vms");
}
} catch (final XenAPIException e) {
s_logger.warn("Unable to cleanup halted vms", e);
return new ReadyAnswer(command, "Unable to cleanup halted vms");
} catch (final XmlRpcException e) {
s_logger.warn("Unable to cleanup halted vms", e);
return new ReadyAnswer(command, "Unable to cleanup halted vms");
}
return new ReadyAnswer(command);
}
use of com.cloud.agent.api.ReadyAnswer in project cloudstack by apache.
the class VmwareResource method execute.
protected Answer execute(ReadyCommand cmd) {
if (s_logger.isInfoEnabled()) {
s_logger.info("Executing resource ReadyCommand: " + _gson.toJson(cmd));
}
try {
VmwareContext context = getServiceContext();
VmwareHypervisorHost hyperHost = getHyperHost(context);
if (hyperHost.isHyperHostConnected()) {
return new ReadyAnswer(cmd);
} else {
return new ReadyAnswer(cmd, "Host is not in connect state");
}
} catch (Exception e) {
s_logger.error("Unexpected exception: ", e);
return new ReadyAnswer(cmd, VmwareHelper.getExceptionMessage(e));
}
}
use of com.cloud.agent.api.ReadyAnswer in project cloudstack by apache.
the class Ovm3HypervisorSupport method execute.
/* Check if the host is in ready state for CS */
public ReadyAnswer execute(ReadyCommand cmd) {
try {
Linux host = new Linux(c);
Pool pool = new Pool(c);
/* only interesting when doing cluster */
if (!host.getIsMaster() && config.getAgentInOvm3Cluster()) {
if (pool.getPoolMasterVip().equalsIgnoreCase(c.getIp())) {
/* check pool state here */
return new ReadyAnswer(cmd);
} else {
LOGGER.debug("Master IP changes to " + pool.getPoolMasterVip() + ", it should be " + c.getIp());
return new ReadyAnswer(cmd, "I am not the master server");
}
} else if (host.getIsMaster()) {
LOGGER.debug("Master, not clustered " + config.getAgentHostname());
return new ReadyAnswer(cmd);
} else {
LOGGER.debug("No master, not clustered " + config.getAgentHostname());
return new ReadyAnswer(cmd);
}
} catch (CloudRuntimeException | Ovm3ResourceException e) {
LOGGER.debug("XML RPC Exception" + e.getMessage(), e);
throw new CloudRuntimeException("XML RPC Exception" + e.getMessage(), e);
}
}
Aggregations