Search in sources :

Example 6 with HostTagVO

use of com.cloud.host.HostTagVO in project cloudstack by apache.

the class HostTagsDaoImpl method persist.

@Override
public void persist(long hostId, List<String> hostTags) {
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    SearchCriteria<HostTagVO> sc = HostSearch.create();
    sc.setParameters("hostId", hostId);
    expunge(sc);
    for (String tag : hostTags) {
        tag = tag.trim();
        if (tag.length() > 0) {
            HostTagVO vo = new HostTagVO(hostId, tag);
            persist(vo);
        }
    }
    txn.commit();
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) HostTagVO(com.cloud.host.HostTagVO)

Example 7 with HostTagVO

use of com.cloud.host.HostTagVO in project cloudstack by apache.

the class HostTagsDaoImpl method persist.

@Override
public void persist(long hostId, List<String> hostTags) {
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    SearchCriteria<HostTagVO> sc = HostSearch.create();
    sc.setParameters("hostId", hostId);
    expunge(sc);
    for (String tag : hostTags) {
        tag = tag.trim();
        if (tag.length() > 0) {
            HostTagVO vo = new HostTagVO(hostId, tag);
            persist(vo);
        }
    }
    txn.commit();
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) HostTagVO(com.cloud.host.HostTagVO)

Example 8 with HostTagVO

use of com.cloud.host.HostTagVO in project cloudstack by apache.

the class HostTagsDaoImpl method gethostTags.

@Override
public List<String> gethostTags(long hostId) {
    SearchCriteria<HostTagVO> sc = HostSearch.create();
    sc.setParameters("hostId", hostId);
    List<HostTagVO> results = search(sc, null);
    List<String> hostTags = new ArrayList<String>(results.size());
    for (HostTagVO result : results) {
        hostTags.add(result.getTag());
    }
    return hostTags;
}
Also used : HostTagVO(com.cloud.host.HostTagVO) ArrayList(java.util.ArrayList)

Aggregations

HostTagVO (com.cloud.host.HostTagVO)8 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)3 HostVO (com.cloud.host.HostVO)2 ArrayList (java.util.ArrayList)2 Filter (com.cloud.utils.db.Filter)1 EngineHostVO (org.apache.cloudstack.engine.datacenter.entity.api.db.EngineHostVO)1