mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-3307
UCS:DB: Same UCS manager can be added multiple times fixed resolved
This commit is contained in:
parent
33faf44b39
commit
7ff74caf8e
|
|
@ -132,7 +132,14 @@ public class UcsManagerImpl implements UcsManager {
|
|||
|
||||
@Override
|
||||
@DB
|
||||
public UcsManagerResponse addUcsManager(AddUcsManagerCmd cmd) {
|
||||
public UcsManagerResponse addUcsManager(AddUcsManagerCmd cmd) {
|
||||
SearchCriteriaService<UcsManagerVO, UcsManagerVO> q = SearchCriteria2.create(UcsManagerVO.class);
|
||||
q.addAnd(q.getEntity().getUrl(), Op.EQ, cmd.getUrl());
|
||||
UcsManagerVO mgrvo = q.find();
|
||||
if (mgrvo != null) {
|
||||
throw new IllegalArgumentException(String.format("duplicate UCS manager. url[%s] is used by another UCS manager already", cmd.getUrl()));
|
||||
}
|
||||
|
||||
UcsManagerVO vo = new UcsManagerVO();
|
||||
vo.setUuid(UUID.randomUUID().toString());
|
||||
vo.setPassword(cmd.getPassword());
|
||||
|
|
@ -141,6 +148,7 @@ public class UcsManagerImpl implements UcsManager {
|
|||
vo.setZoneId(cmd.getZoneId());
|
||||
vo.setName(cmd.getName());
|
||||
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
ucsDao.persist(vo);
|
||||
|
|
|
|||
Loading…
Reference in New Issue