use of com.cloud.host.DetailVO in project cloudstack by apache.
the class NuageVspManagerImpl method findMatchingNuageVspDevice.
private NuageVspDeviceVO findMatchingNuageVspDevice(NuageVspDeviceVO nuageVspDevice) {
DetailVO nuageVspDeviceHost = _hostDetailsDao.findDetail(nuageVspDevice.getHostId(), "hostname");
String nuageVspDeviceHostName = (nuageVspDeviceHost != null) ? nuageVspDeviceHost.getValue() : null;
List<NuageVspDeviceVO> otherNuageVspDevices = _nuageVspDao.listAll();
for (NuageVspDeviceVO otherNuageVspDevice : otherNuageVspDevices) {
if (otherNuageVspDevice.getId() == nuageVspDevice.getId())
continue;
DetailVO otherNuageVspDeviceHostName = _hostDetailsDao.findDetail(otherNuageVspDevice.getHostId(), "hostname");
if (otherNuageVspDeviceHostName != null && nuageVspDeviceHostName.equals(otherNuageVspDeviceHostName.getValue())) {
return otherNuageVspDevice;
}
}
return null;
}
use of com.cloud.host.DetailVO in project cosmic by MissionCriticalCloud.
the class HostDetailsDaoImpl method deleteDetails.
@Override
public void deleteDetails(final long hostId) {
final SearchCriteria sc = HostSearch.create();
sc.setParameters("hostId", hostId);
final List<DetailVO> results = search(sc, null);
for (final DetailVO result : results) {
remove(result.getId());
}
}
use of com.cloud.host.DetailVO in project cosmic by MissionCriticalCloud.
the class HostDetailsDaoImpl method findDetail.
@Override
public DetailVO findDetail(final long hostId, final String name) {
final SearchCriteria<DetailVO> sc = DetailSearch.create();
sc.setParameters("hostId", hostId);
sc.setParameters("name", name);
final DetailVO detail = findOneIncludingRemovedBy(sc);
if ("password".equals(name) && detail != null) {
detail.setValue(DBEncryptionUtil.decrypt(detail.getValue()));
}
return detail;
}
use of com.cloud.host.DetailVO in project cosmic by MissionCriticalCloud.
the class ResourceManagerImpl method doUpdateHostPassword.
private boolean doUpdateHostPassword(final long hostId) {
if (!_agentMgr.isAgentAttached(hostId)) {
return false;
}
DetailVO nv = _hostDetailsDao.findDetail(hostId, ApiConstants.USERNAME);
final String username = nv.getValue();
nv = _hostDetailsDao.findDetail(hostId, ApiConstants.PASSWORD);
final String password = nv.getValue();
final HostVO host = _hostDao.findById(hostId);
final String hostIpAddress = host.getPrivateIpAddress();
final UpdateHostPasswordCommand cmd = new UpdateHostPasswordCommand(username, password, hostIpAddress);
final Answer answer = _agentMgr.easySend(hostId, cmd);
s_logger.info("Result returned from update host password ==> " + answer.getDetails());
return answer.getResult();
}
use of com.cloud.host.DetailVO in project cosmic by MissionCriticalCloud.
the class ManagementServerImpl method updateHostsInCluster.
private boolean updateHostsInCluster(final UpdateHostPasswordCmd command) {
// get all the hosts in this cluster
final List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(command.getClusterId());
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(final TransactionStatus status) {
for (final HostVO h : hosts) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Changing password for host name = " + h.getName());
}
// update password for this host
final DetailVO nv = _detailsDao.findDetail(h.getId(), ApiConstants.USERNAME);
if (nv.getValue().equals(command.getUsername())) {
final DetailVO nvp = _detailsDao.findDetail(h.getId(), ApiConstants.PASSWORD);
nvp.setValue(DBEncryptionUtil.encrypt(command.getPassword()));
_detailsDao.persist(nvp);
} else {
// rollback to maintain consistency
throw new InvalidParameterValueException("The username is not same for all hosts, please modify passwords for individual hosts.");
}
}
}
});
return true;
}
Aggregations