@Override
@DB
public UcsManagerResponse addUcsManager(AddUcsManagerCmd cmd) {
SearchCriteria<UcsManagerVO> q = ucsDao.createSearchCriteria();
q.addAnd("url", Op.EQ, cmd.getUrl());
UcsManagerVO mgrvo = ucsDao.findOneBy(q);
if (mgrvo != null) {
throw new IllegalArgumentException(String.format("duplicate UCS manager. url[%s] is used by another UCS manager already", cmd.getUrl()));
}
try {
UcsManagerVO vo = new UcsManagerVO();
vo.setUuid(UUID.randomUUID().toString());
vo.setPassword(cmd.getPassword());
vo.setUrl(cmd.getUrl());
vo.setUsername(cmd.getUsername());
vo.setZoneId(cmd.getZoneId());
vo.setName(cmd.getName());
mgrvo = ucsDao.persist(vo);
UcsManagerResponse rsp = new UcsManagerResponse();
rsp.setId(String.valueOf(vo.getId()));
rsp.setName(vo.getName());
rsp.setUrl(vo.getUrl());
rsp.setZoneId(String.valueOf(vo.getZoneId()));
discoverBlades(vo);
return rsp;
} catch (CloudRuntimeException e) {
if (mgrvo != null) {