Search in sources :

Example 11 with DomainRouterResponse

use of com.cloud.api.response.DomainRouterResponse in project cosmic by MissionCriticalCloud.

the class ViewResponseHelper method createDomainRouterResponse.

public static List<DomainRouterResponse> createDomainRouterResponse(final DomainRouterJoinVO... routers) {
    final Account caller = CallContext.current().getCallingAccount();
    final Hashtable<Long, DomainRouterResponse> vrDataList = new Hashtable<>();
    // Initialise the vrdatalist with the input data
    for (final DomainRouterJoinVO vr : routers) {
        DomainRouterResponse vrData = vrDataList.get(vr.getId());
        if (vrData == null) {
            // first time encountering this vm
            vrData = ApiDBUtils.newDomainRouterResponse(vr, caller);
        } else {
            // update nics for 1 to many mapping fields
            vrData = ApiDBUtils.fillRouterDetails(vrData, vr);
        }
        vrDataList.put(vr.getId(), vrData);
    }
    return new ArrayList<>(vrDataList.values());
}
Also used : Account(com.cloud.user.Account) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) DomainRouterResponse(com.cloud.api.response.DomainRouterResponse) DomainRouterJoinVO(com.cloud.api.query.vo.DomainRouterJoinVO)

Example 12 with DomainRouterResponse

use of com.cloud.api.response.DomainRouterResponse in project cosmic by MissionCriticalCloud.

the class DestroyRouterCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
    final CallContext ctx = CallContext.current();
    ctx.setEventDetails("Router Id: " + getId());
    final VirtualRouter result = _routerService.destroyRouter(getId(), ctx.getCallingAccount(), ctx.getCallingUserId());
    if (result != null) {
        final DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to destroy router");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) CallContext(com.cloud.context.CallContext) DomainRouterResponse(com.cloud.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Example 13 with DomainRouterResponse

use of com.cloud.api.response.DomainRouterResponse in project cosmic by MissionCriticalCloud.

the class RebootRouterCmd method execute.

@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
    CallContext.current().setEventDetails("Router Id: " + getId());
    final VirtualRouter result = _routerService.rebootRouter(getId(), true);
    if (result != null) {
        final DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
        response.setResponseName("router");
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reboot router");
    }
}
Also used : ServerApiException(com.cloud.api.ServerApiException) DomainRouterResponse(com.cloud.api.response.DomainRouterResponse) VirtualRouter(com.cloud.network.router.VirtualRouter)

Aggregations

DomainRouterResponse (com.cloud.api.response.DomainRouterResponse)13 VirtualRouter (com.cloud.network.router.VirtualRouter)11 ServerApiException (com.cloud.api.ServerApiException)10 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)2 ArrayList (java.util.ArrayList)2 DomainRouterJoinVO (com.cloud.api.query.vo.DomainRouterJoinVO)1 ListResponse (com.cloud.api.response.ListResponse)1 NicResponse (com.cloud.api.response.NicResponse)1 CallContext (com.cloud.context.CallContext)1 TrafficType (com.cloud.network.Networks.TrafficType)1 Account (com.cloud.user.Account)1 Hashtable (java.util.Hashtable)1