Search in sources :

Example 1 with RebootRouterCmd

use of com.cloud.api.command.admin.router.RebootRouterCmd in project cosmic by MissionCriticalCloud.

the class VirtualNetworkApplianceManagerImpl method rebootRouters.

private List<Long> rebootRouters(final List<DomainRouterVO> routers) {
    final List<Long> jobIds = new ArrayList<>();
    for (final DomainRouterVO router : routers) {
        if (!_nwHelper.checkRouterVersion(router)) {
            s_logger.debug("Upgrading template for router: " + router.getId());
            final Map<String, String> params = new HashMap<>();
            params.put("ctxUserId", "1");
            params.put("ctxAccountId", "" + router.getAccountId());
            final RebootRouterCmd cmd = new RebootRouterCmd();
            ComponentContext.inject(cmd);
            params.put("id", "" + router.getId());
            params.put("ctxStartEventId", "1");
            final AsyncJobVO job = new AsyncJobVO("", User.UID_SYSTEM, router.getAccountId(), RebootRouterCmd.class.getName(), ApiGsonHelper.getBuilder().create().toJson(params), router.getId(), cmd.getInstanceType() != null ? cmd.getInstanceType().toString() : null, null);
            job.setDispatcher(_asyncDispatcher.getName());
            final long jobId = _asyncMgr.submitAsyncJob(job);
            jobIds.add(jobId);
        } else {
            s_logger.debug("Router: " + router.getId() + " is already at the latest version. No upgrade required");
        }
    }
    return jobIds;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RebootRouterCmd(com.cloud.api.command.admin.router.RebootRouterCmd) DomainRouterVO(com.cloud.vm.DomainRouterVO) AsyncJobVO(com.cloud.framework.jobs.impl.AsyncJobVO)

Aggregations

RebootRouterCmd (com.cloud.api.command.admin.router.RebootRouterCmd)1 AsyncJobVO (com.cloud.framework.jobs.impl.AsyncJobVO)1 DomainRouterVO (com.cloud.vm.DomainRouterVO)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1