@AsyncThread private void doApplySecurityGroupRules(HttpEntity<String> entity) { ApplySecurityGroupRuleCmd cmd = JSONObjectUtil.toObject(entity.getBody(), ApplySecurityGroupRuleCmd.class); ApplySecurityGroupRuleResponse rsp = new ApplySecurityGroupRuleResponse(); if (!config.securityGroupSuccess) { rsp.setError("fail to apply security group rules on purpose"); rsp.setSuccess(false); } else { for (SecurityGroupRuleTO rto : cmd.getRuleTOs()) { config.securityGroups.put(rto.getVmNicInternalName(), rto); logger.debug(String.format("succesfully applied security group rules for vm nic[%s], %s", rto.getVmNicInternalName(), rto)); } } reply(entity, rsp); }
@Override public void run(MessageReply reply) { if (!reply.isSuccess()) { complete.fail(reply.getError()); return; } KVMHostAsyncHttpCallReply hreply = reply.castReply(); ApplySecurityGroupRuleResponse rsp = hreply.toResponse(ApplySecurityGroupRuleResponse.class); if (!rsp.isSuccess()) { ErrorCode err = operr("failed to apply rules of security group rules to kvm host[uuid:%s], because %s", hto.getHostUuid(), rsp.getError()); complete.fail(err); return; } String info = String.format("successfully applied rules of security group rules to kvm host[uuid:%s]", hto.getHostUuid()); logger.debug(info); complete.success(); } });
@Override public void run(MessageReply reply) { if (!reply.isSuccess()) { complete.fail(reply.getError()); return; } KVMHostAsyncHttpCallReply hreply = reply.castReply(); ApplySecurityGroupRuleResponse rsp = hreply.toResponse(ApplySecurityGroupRuleResponse.class); if (!rsp.isSuccess()) { ErrorCode err = operr("failed to apply rules of security group rules to kvm host[uuid:%s], because %s", hto.getHostUuid(), rsp.getError()); complete.fail(err); return; } String info = String.format("successfully applied rules of security group rules to kvm host[uuid:%s]", hto.getHostUuid()); logger.debug(info); complete.success(); } });