Search in sources :

Example 1 with RebootRouterCmd

use of org.apache.cloudstack.api.command.admin.router.RebootRouterCmd in project cloudstack by apache.

the class VirtualNetworkApplianceManagerImpl method rebootRouters.

private List<Long> rebootRouters(final List<DomainRouterVO> routers) {
    final List<Long> jobIds = new ArrayList<Long>();
    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<String, String>();
            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(org.apache.cloudstack.api.command.admin.router.RebootRouterCmd) DomainRouterVO(com.cloud.vm.DomainRouterVO) AsyncJobVO(org.apache.cloudstack.framework.jobs.impl.AsyncJobVO)

Aggregations

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