@Override public Long getInstanceId() { return getId(); } }
@Override public Long getInstanceId() { return getSecurityGroupId(); } }
@Override public Long getInstanceId() { return getId(); } }
@Override @DB @SuppressWarnings("rawtypes") @ActionEvent(eventType = EventTypes.EVENT_SECURITY_GROUP_AUTHORIZE_INGRESS, eventDescription = "Adding Ingress Rule ", async = true) public List<SecurityGroupRuleVO> authorizeSecurityGroupIngress(AuthorizeSecurityGroupIngressCmd cmd) { Long securityGroupId = cmd.getSecurityGroupId(); String protocol = cmd.getProtocol(); Integer startPort = cmd.getStartPort(); Integer endPort = cmd.getEndPort(); Integer icmpType = cmd.getIcmpType(); Integer icmpCode = cmd.getIcmpCode(); List<String> cidrList = cmd.getCidrList(); Map groupList = cmd.getUserSecurityGroupList(); return authorizeSecurityGroupRule(securityGroupId, protocol, startPort, endPort, icmpType, icmpCode, cidrList, groupList, SecurityRuleType.IngressRule); }
@Override @DB @SuppressWarnings("rawtypes") @ActionEvent(eventType = EventTypes.EVENT_SECURITY_GROUP_AUTHORIZE_EGRESS, eventDescription = "Adding Egress Rule ", async = true) public List<SecurityGroupRuleVO> authorizeSecurityGroupEgress(AuthorizeSecurityGroupEgressCmd cmd) { Long securityGroupId = cmd.getSecurityGroupId(); String protocol = cmd.getProtocol(); Integer startPort = cmd.getStartPort(); Integer endPort = cmd.getEndPort(); Integer icmpType = cmd.getIcmpType(); Integer icmpCode = cmd.getIcmpCode(); List<String> cidrList = cmd.getCidrList(); Map groupList = cmd.getUserSecurityGroupList(); return authorizeSecurityGroupRule(securityGroupId, protocol, startPort, endPort, icmpType, icmpCode, cidrList, groupList, SecurityRuleType.EgressRule); }
@Override public Long getInstanceId() { return getSecurityGroupId(); } }
@Override public void execute() { ListResponse<SecurityGroupResponse> response = _queryService.searchForSecurityGroups(this); response.setResponseName(getCommandName()); setResponseObject(response); }
@Override public void execute() { boolean result = _securityGroupService.revokeSecurityGroupEgress(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to revoke security group egress rule"); } }
@Override public void execute() { boolean result = _securityGroupService.revokeSecurityGroupIngress(this); if (result) { SuccessResponse response = new SuccessResponse(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to revoke security group ingress rule"); } }
@Override public void execute() { SecurityGroup group = _securityGroupService.createSecurityGroup(this); if (group != null) { SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponse(group); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create security group"); } } }
public Long getId() { if (id != null && name != null) { throw new InvalidParameterValueException("name and id parameters are mutually exclusive"); } if (name != null) { id = _responseGenerator.getSecurityGroupId(name, getEntityOwnerId()); if (id == null) { throw new InvalidParameterValueException("Unable to find security group by name " + name + " for the account id=" + getEntityOwnerId()); } } if (id == null) { throw new InvalidParameterValueException("Either id or name parameter is requred by deleteSecurityGroup command"); } return id; }
public Long getSecurityGroupId() { if (securityGroupId != null && securityGroupName != null) { throw new InvalidParameterValueException("securityGroupId and securityGroupName parameters are mutually exclusive"); } if (securityGroupName != null) { securityGroupId = _responseGenerator.getSecurityGroupId(securityGroupName, getEntityOwnerId()); if (securityGroupId == null) { throw new InvalidParameterValueException("Unable to find security group " + securityGroupName + " for account id=" + getEntityOwnerId()); } securityGroupName = null; } if (securityGroupId == null) { throw new InvalidParameterValueException("Either securityGroupId or securityGroupName is required by authorizeSecurityGroupIngress command"); } return securityGroupId; }
public Long getSecurityGroupId() { if (securityGroupId != null && securityGroupName != null) { throw new InvalidParameterValueException("securityGroupId and securityGroupName parameters are mutually exclusive"); } if (securityGroupName != null) { securityGroupId = _responseGenerator.getSecurityGroupId(securityGroupName, getEntityOwnerId()); if (securityGroupId == null) { throw new InvalidParameterValueException("Unable to find security group " + securityGroupName + " for account id=" + getEntityOwnerId()); } securityGroupName = null; } if (securityGroupId == null) { throw new InvalidParameterValueException("Either securityGroupId or securityGroupName is required by authorizeSecurityGroupIngress command"); } return securityGroupId; }
@Override public void execute() { List<? extends SecurityRule> ingressRules = _securityGroupService.authorizeSecurityGroupIngress(this); if (ingressRules != null && !ingressRules.isEmpty()) { SecurityGroupResponse response = _responseGenerator.createSecurityGroupResponseFromSecurityGroupRule(ingressRules); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to authorize security group ingress rule(s)"); } }
@Override public String getEventDescription() { return "revoking egress rule id: " + getId(); }
@Override public String getEventDescription() { return "revoking ingress rule id: " + getId(); }
@Override @DB @ActionEvent(eventType = EventTypes.EVENT_SECURITY_GROUP_REVOKE_EGRESS, eventDescription = "Revoking Egress Rule ", async = true) public boolean revokeSecurityGroupEgress(RevokeSecurityGroupEgressCmd cmd) { Long id = cmd.getId(); return revokeSecurityGroupRule(id, SecurityRuleType.EgressRule); }
@Override @DB @ActionEvent(eventType = EventTypes.EVENT_SECURITY_GROUP_REVOKE_INGRESS, eventDescription = "Revoking Ingress Rule ", async = true) public boolean revokeSecurityGroupIngress(RevokeSecurityGroupIngressCmd cmd) { Long id = cmd.getId(); return revokeSecurityGroupRule(id, SecurityRuleType.IngressRule); }
@Override public long getEntityOwnerId() { SecurityRule rule = _entityMgr.findById(SecurityRule.class, getId()); if (rule != null) { SecurityGroup group = _entityMgr.findById(SecurityGroup.class, rule.getSecurityGroupId()); if (group != null) { return group.getAccountId(); } } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }
@Override public long getEntityOwnerId() { SecurityRule rule = _entityMgr.findById(SecurityRule.class, getId()); if (rule != null) { SecurityGroup group = _entityMgr.findById(SecurityGroup.class, rule.getSecurityGroupId()); if (group != null) { return group.getAccountId(); } } return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked }