DaanHoogland commented on code in PR #12013:
URL: https://github.com/apache/cloudstack/pull/12013#discussion_r2577162626
##########
server/src/main/java/com/cloud/network/vpc/NetworkACLServiceImpl.java:
##########
@@ -1061,6 +1064,111 @@ public NetworkACLItem
moveRuleToTheTopInACLList(NetworkACLItem ruleBeingMoved) {
return moveRuleToTheTop(ruleBeingMoved, allRules);
}
+ @Override
+ public List<NetworkACLItem> importNetworkACLRules(ImportNetworkACLCmd cmd)
throws ResourceUnavailableException {
+ long aclId = cmd.getAclId();
+ Map<Object, Object> rules = cmd.getRules();
+ List<NetworkACLItem> createdRules = new ArrayList<>();
+ List<String> errors = new ArrayList<>();
+ for (Map.Entry<Object, Object> entry : rules.entrySet()) {
+ try {
+ Map<String, Object> ruleMap = (Map<String, Object>)
entry.getValue();
+ NetworkACLItem item = createACLRuleFromMap(ruleMap, aclId);
+ createdRules.add(item);
+ } catch (Exception ex) {
+ String error = "Failed to import rule at index " +
entry.getKey() + ": " + ex.getMessage();
+ errors.add(error);
+ logger.error(error, ex);
+ }
+ }
+ // no rules got imported
+ if (createdRules.isEmpty() && !errors.isEmpty()) {
+ logger.error("Failed to import any ACL rules. Errors: {}",
String.join("; ", errors));
+ throw new CloudRuntimeException("Failed to import any ACL rules.");
Review Comment:
this is very confusing to a user. the reason is probably because a rule
already existed and it is counterintuitive to not allow it. We might add a flag
allowing overwriting it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]