use of org.apache.cloudstack.api.response.UcsManagerResponse in project cloudstack by apache.
the class UcsManagerImpl method addUcsManager.
@Override
@DB
public UcsManagerResponse addUcsManager(AddUcsManagerCmd cmd) {
QueryBuilder<UcsManagerVO> q = QueryBuilder.create(UcsManagerVO.class);
q.and(q.entity().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()));
}
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) {
ucsDao.remove(mgrvo.getId());
}
throw e;
}
}
use of org.apache.cloudstack.api.response.UcsManagerResponse in project cloudstack by apache.
the class UcsManagerImpl method listUcsManager.
@Override
public ListResponse<UcsManagerResponse> listUcsManager(ListUcsManagerCmd cmd) {
List<UcsManagerResponse> rsps = new ArrayList<UcsManagerResponse>();
ListResponse<UcsManagerResponse> response = new ListResponse<UcsManagerResponse>();
if (cmd.getId() != null) {
UcsManagerVO vo = ucsDao.findById(cmd.getId());
UcsManagerResponse rsp = new UcsManagerResponse();
rsp.setObjectName("ucsmanager");
rsp.setId(vo.getUuid());
rsp.setName(vo.getName());
rsp.setUrl(vo.getUrl());
rsp.setZoneId(zoneIdToUuid(vo.getZoneId()));
rsps.add(rsp);
response.setResponses(rsps);
return response;
}
QueryBuilder<UcsManagerVO> serv = QueryBuilder.create(UcsManagerVO.class);
serv.and(serv.entity().getZoneId(), Op.EQ, cmd.getZoneId());
List<UcsManagerVO> vos = serv.list();
for (UcsManagerVO vo : vos) {
UcsManagerResponse rsp = new UcsManagerResponse();
rsp.setObjectName("ucsmanager");
rsp.setId(vo.getUuid());
rsp.setName(vo.getName());
rsp.setUrl(vo.getUrl());
rsp.setZoneId(zoneIdToUuid(vo.getZoneId()));
rsps.add(rsp);
}
response.setResponses(rsps);
return response;
}
use of org.apache.cloudstack.api.response.UcsManagerResponse in project cloudstack by apache.
the class AddUcsManagerCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
try {
UcsManagerResponse rsp = mgr.addUcsManager(this);
rsp.setObjectName("ucsmanager");
rsp.setResponseName(getCommandName());
this.setResponseObject(rsp);
} catch (Exception e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
Aggregations