use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.
the class StartRouterCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
CallContext.current().setEventDetails("Router Id: " + this._uuidMgr.getUuid(VirtualMachine.class, getId()));
VirtualRouter result = null;
VirtualRouter router = _routerService.findRouter(getId());
if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {
throw new InvalidParameterValueException("Can't find router by id");
} else {
result = _routerService.startRouter(getId());
}
if (result != null) {
DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
routerResponse.setResponseName(getCommandName());
setResponseObject(routerResponse);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start router");
}
}
use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.
the class UpgradeRouterCmd method execute.
@Override
public void execute() {
VirtualRouter router = _routerService.upgradeRouter(this);
if (router != null) {
DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(router);
routerResponse.setResponseName(getCommandName());
setResponseObject(routerResponse);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade router");
}
}
use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.
the class StopRouterCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
CallContext.current().setEventDetails("Router Id: " + this._uuidMgr.getUuid(VirtualMachine.class, getId()));
VirtualRouter result = null;
VirtualRouter router = _routerService.findRouter(getId());
if (router == null || router.getRole() != Role.VIRTUAL_ROUTER) {
throw new InvalidParameterValueException("Can't find router by id");
} else {
result = _routerService.stopRouter(getId(), isForced());
}
if (result != null) {
DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
response.setResponseName(getCommandName());
setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop router");
}
}
use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.
the class StartInternalLBVMCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
CallContext.current().setEventDetails("Internal Lb Vm Id: " + getId());
VirtualRouter result = null;
VirtualRouter router = _routerService.findRouter(getId());
if (router == null || router.getRole() != Role.INTERNAL_LB_VM) {
throw new InvalidParameterValueException("Can't find internal lb vm by id");
} else {
result = _internalLbSvc.startInternalLbVm(getId(), CallContext.current().getCallingAccount(), CallContext.current().getCallingUserId());
}
if (result != null) {
DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
routerResponse.setResponseName(getCommandName());
setResponseObject(routerResponse);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start internal lb vm");
}
}
use of com.cloud.network.router.VirtualRouter in project cloudstack by apache.
the class InternalLoadBalancerElement method destroy.
@Override
public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
List<? extends VirtualRouter> internalLbVms = _routerDao.listByNetworkAndRole(network.getId(), Role.INTERNAL_LB_VM);
if (internalLbVms == null || internalLbVms.isEmpty()) {
return true;
}
boolean result = true;
for (VirtualRouter internalLbVm : internalLbVms) {
result = result && (_internalLbMgr.destroyInternalLbVm(internalLbVm.getId(), context.getAccount(), context.getCaller().getId()));
}
return result;
}
Aggregations