sudo87 commented on code in PR #12013:
URL: https://github.com/apache/cloudstack/pull/12013#discussion_r2591298598
##########
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:
As per the discussion on original issue, user can create new ACL and import
the csv and assign it to network. Allowing overwriting rules will lead to loss
of simplicity.
--
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]