Search in sources :

Example 1 with UcsManagerResponse

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;
    }
}
Also used : UcsManagerVO(com.cloud.ucs.database.UcsManagerVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) UcsManagerResponse(org.apache.cloudstack.api.response.UcsManagerResponse) DB(com.cloud.utils.db.DB)

Example 2 with UcsManagerResponse

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;
}
Also used : UcsManagerVO(com.cloud.ucs.database.UcsManagerVO) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) UcsManagerResponse(org.apache.cloudstack.api.response.UcsManagerResponse)

Example 3 with UcsManagerResponse

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());
    }
}
Also used : UcsManagerResponse(org.apache.cloudstack.api.response.UcsManagerResponse) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) NetworkRuleConflictException(com.cloud.exception.NetworkRuleConflictException) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException)

Aggregations

UcsManagerResponse (org.apache.cloudstack.api.response.UcsManagerResponse)3 UcsManagerVO (com.cloud.ucs.database.UcsManagerVO)2 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)1 NetworkRuleConflictException (com.cloud.exception.NetworkRuleConflictException)1 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 DB (com.cloud.utils.db.DB)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 ArrayList (java.util.ArrayList)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1