@RequestMapping(value=NfsPrimaryStorageKVMBackend.UNMOUNT_PRIMARY_STORAGE_PATH, method=RequestMethod.POST) public @ResponseBody String nfsUnmount(@RequestBody String body) { if (config.unmountException) { throw new CloudRuntimeException("unmount exception on purpose"); } UnmountCmd cmd = JSONObjectUtil.toObject(body, UnmountCmd.class); AgentResponse rsp = new AgentResponse(); if (config.unmountSuccess) { rsp.setSuccess(true); config.unmountCmds.add(cmd); logger.debug(String.format("Unmount %s", cmd.getMountPath())); } else { rsp.setSuccess(false); rsp.setError("Fail umount on purpose"); } return JSONObjectUtil.toJsonString(rsp); }
private void unmount(PrimaryStorageInventory inv, String hostUuid) { UnmountCmd cmd = new UnmountCmd(); cmd.setUuid(inv.getUuid()); cmd.setMountPath(inv.getMountPath()); cmd.setUrl(inv.getUrl()); KVMHostSyncHttpCallMsg msg = new KVMHostSyncHttpCallMsg(); msg.setCommand(cmd); msg.setPath(UNMOUNT_PRIMARY_STORAGE_PATH); msg.setHostUuid(hostUuid); bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID, hostUuid); MessageReply reply = bus.call(msg); if (!reply.isSuccess()) { throw new OperationFailureException(reply.getError()); } AgentResponse rsp = ((KVMHostSyncHttpCallReply) reply).toResponse(AgentResponse.class); if (!rsp.isSuccess()) { String err = String.format("Unable to unmount nfs primary storage[uuid:%s] on kvm host[uuid:%s], because %s", inv.getUuid(), hostUuid, rsp.getError()); logger.warn(err); } else { String info = String.format("Successfully unmount nfs primary storage[uuid:%s] on kvm host[uuid:%s]", inv.getUuid(), hostUuid); logger.debug(info); nfsFactory.updateNfsHostStatus(inv.getUuid(), hostUuid, PrimaryStorageHostStatus.Disconnected); } }
@RequestMapping(value=KVMConstant.KVM_HARDEN_CONSOLE_PATH, method=RequestMethod.POST) public @ResponseBody String hardenVmConsole(HttpServletRequest req) { HttpEntity<String> entity = restf.httpServletRequestToHttpEntity(req); HardenVmConsoleCmd cmd = JSONObjectUtil.toObject(entity.getBody(), HardenVmConsoleCmd.class); config.hardenVmConsoleCmds.add(cmd); replyer.reply(entity, new AgentResponse()); return null; }
@RequestMapping(value = FlatUserdataBackend.BATCH_APPLY_USER_DATA, method = RequestMethod.POST) public @ResponseBody String batchApplyUserdata(HttpEntity<String> entity) { BatchApplyUserdataCmd cmd = JSONObjectUtil.toObject(entity.getBody(), BatchApplyUserdataCmd.class); config.batchApplyUserdataCmds.add(cmd); AgentResponse rsp = new AgentResponse(); reply(entity, rsp); return null; }
public @ResponseBody String createKvmSecret(HttpEntity<String> entity) { CreateKvmSecretCmd cmd = JSONObjectUtil.toObject(entity.getBody(), CreateKvmSecretCmd.class); config.createKvmSecretCmds.add(cmd); reply(entity, new KVMAgentCommands.AgentResponse()); return null; }
@RequestMapping(value= CephPrimaryStorageBase.KVM_CREATE_SECRET_PATH, method= RequestMethod.POST) public @ResponseBody String createKvmSecret(HttpEntity<String> entity) { CreateKvmSecretCmd cmd = JSONObjectUtil.toObject(entity.getBody(), CreateKvmSecretCmd.class); config.createKvmSecretCmds.add(cmd); reply(entity, new KVMAgentCommands.AgentResponse()); return null; }
@RequestMapping(value=KVMConstant.KVM_DELETE_CONSOLE_FIREWALL_PATH, method=RequestMethod.POST) public @ResponseBody String deleteVmConsole(HttpServletRequest req) { HttpEntity<String> entity = restf.httpServletRequestToHttpEntity(req); DeleteVmConsoleFirewallCmd cmd = JSONObjectUtil.toObject(entity.getBody(), DeleteVmConsoleFirewallCmd.class); config.deleteVmConsoleFirewallCmds.add(cmd); replyer.reply(entity, new AgentResponse()); return null; }