use of com.cloud.network.router.VirtualRouter in project CloudStack-archive by CloudStack-extras.
the class StopRouterCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
UserContext.current().setEventDetails("Router Id: " + getId());
VirtualRouter result = _routerService.stopRouter(getId(), isForced());
if (result != null) {
DomainRouterResponse response = _responseGenerator.createDomainRouterResponse(result);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to stop router");
}
}
use of com.cloud.network.router.VirtualRouter in project cosmic by MissionCriticalCloud.
the class StartRouterCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
CallContext.current().setEventDetails("Router Id: " + getId());
VirtualRouter result = null;
final 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) {
final 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 cosmic by MissionCriticalCloud.
the class StopRouterCmd method execute.
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException {
CallContext.current().setEventDetails("Router Id: " + getId());
VirtualRouter result = null;
final 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) {
final 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 cosmic by MissionCriticalCloud.
the class UpgradeRouterCmd method execute.
@Override
public void execute() {
final VirtualRouter router = _routerService.upgradeRouter(this);
if (router != null) {
final 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 cosmic by MissionCriticalCloud.
the class VpcVirtualRouterElement method destroy.
@Override
public boolean destroy(final Network config, final ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
final Long vpcId = config.getVpcId();
if (vpcId == null) {
s_logger.debug("Network " + config + " doesn't belong to any vpc, so skipping unplug nic part");
return true;
}
boolean success = true;
final List<? extends VirtualRouter> routers = _routerDao.listByVpcId(vpcId);
for (final VirtualRouter router : routers) {
// 1) Check if router is already a part of the network
if (!_networkMdl.isVmPartOfNetwork(router.getId(), config.getId())) {
s_logger.debug("Router " + router + " is not a part the network " + config);
continue;
}
// 2) Call unplugNics in the network service
success = success && _vpcRouterMgr.removeVpcRouterFromGuestNetwork(router, config);
if (!success) {
s_logger.warn("Failed to unplug nic in network " + config + " for virtual router " + router);
} else {
s_logger.debug("Successfully unplugged nic in network " + config + " for virtual router " + router);
}
}
return success;
}
Aggregations