Search in sources :

Example 16 with DetailVO

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;
}
Also used : NuageVspDeviceVO(com.cloud.network.NuageVspDeviceVO) DetailVO(com.cloud.host.DetailVO)

Example 17 with DetailVO

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());
    }
}
Also used : DetailVO(com.cloud.host.DetailVO) SearchCriteria(com.cloud.utils.db.SearchCriteria)

Example 18 with DetailVO

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;
}
Also used : DetailVO(com.cloud.host.DetailVO)

Example 19 with DetailVO

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();
}
Also used : UnsupportedAnswer(com.cloud.agent.api.UnsupportedAnswer) GetGPUStatsAnswer(com.cloud.agent.api.GetGPUStatsAnswer) MaintainAnswer(com.cloud.agent.api.MaintainAnswer) GetHostStatsAnswer(com.cloud.agent.api.GetHostStatsAnswer) Answer(com.cloud.agent.api.Answer) DetailVO(com.cloud.host.DetailVO) UpdateHostPasswordCommand(com.cloud.agent.api.UpdateHostPasswordCommand) StoragePoolHostVO(com.cloud.storage.StoragePoolHostVO) HostVO(com.cloud.host.HostVO)

Example 20 with DetailVO

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;
}
Also used : DetailVO(com.cloud.host.DetailVO) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) TransactionStatus(com.cloud.utils.db.TransactionStatus) TransactionCallbackNoReturn(com.cloud.utils.db.TransactionCallbackNoReturn) HostVO(com.cloud.host.HostVO)

Aggregations

DetailVO (com.cloud.host.DetailVO)38 HostVO (com.cloud.host.HostVO)15 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)13 TransactionStatus (com.cloud.utils.db.TransactionStatus)13 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)13 ConfigurationException (javax.naming.ConfigurationException)13 HashMap (java.util.HashMap)12 Host (com.cloud.host.Host)9 DB (com.cloud.utils.db.DB)9 PhysicalNetworkServiceProviderVO (com.cloud.network.dao.PhysicalNetworkServiceProviderVO)8 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)8 StoragePoolHostVO (com.cloud.storage.StoragePoolHostVO)7 NetworkDevice (org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice)6 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)5 InsufficientNetworkCapacityException (com.cloud.exception.InsufficientNetworkCapacityException)5 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)5 ServerResource (com.cloud.resource.ServerResource)5 UnableDeleteHostException (com.cloud.resource.UnableDeleteHostException)5 GuestOSCategoryVO (com.cloud.storage.GuestOSCategoryVO)4 TransactionCallbackNoReturn (com.cloud.utils.db.TransactionCallbackNoReturn)4