FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

NSX: Add appropriate error message when icmp type is set to -1 for NSX by Pearl1594 · Pull Request #8504 · apache/cloudstack · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (1) .json  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import javax.inject.Inject;

import com.cloud.dc.DataCenter;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.dao.NsxProviderDao;
import com.cloud.network.element.NsxProviderVO;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.user.network.CreateNetworkACLCmd;
Expand Down Expand Up @@ -99,6 +103,8 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
private VpcDao _vpcDao;
@Inject
private VpcService _vpcSvc;
@Inject
private NsxProviderDao nsxProviderDao;

private String supportedProtocolsForAclRules = "tcp,udp,icmp,all";

Expand Down Expand Up @@ -338,6 +344,7 @@ public NetworkACLItem createNetworkACLItem(CreateNetworkACLCmd createNetworkACLC
if (isGlobalAcl(acl.getVpcId()) && !Account.Type.ADMIN.equals(caller.getType())) {
throw new PermissionDeniedException("Only Root Admins can create rules for a global ACL.");
}
validateNsxConstraints(acl.getVpcId(), icmpType);
validateAclRuleNumber(createNetworkACLCmd, acl);

NetworkACLItem.Action ruleAction = validateAndCreateNetworkAclRuleAction(action);
Expand Down Expand Up @@ -428,6 +435,20 @@ protected void validateNetworkAcl(NetworkACL acl) {
}
}

private void validateNsxConstraints(Long vpcId, Integer icpmType) {
VpcVO vpc = _vpcDao.findById(vpcId);
final DataCenter dc = _entityMgr.findById(DataCenter.class, vpc.getZoneId());
final NsxProviderVO nsxProvider = nsxProviderDao.findByZoneId(dc.getId());
if (Objects.isNull(nsxProvider)) {
return;
}
if (icpmType == -1) {
String errorMsg = "Passing -1 for ICMP type is not supported for NSX enabled zones";
s_logger.error(errorMsg);
throw new InvalidParameterValueException(errorMsg);
}
}

/**
* This methods will simply return the ACL rule list ID if it has been provided by the parameter 'createNetworkACLCmd'.
* If no ACL rule List ID has been provided the method behave as follows:
Expand Down Expand Up @@ -817,7 +838,7 @@ public NetworkACLItem updateNetworkACLItem(UpdateNetworkACLItemCmd updateNetwork

NetworkACL acl = _networkAclMgr.getNetworkACL(networkACLItemVo.getAclId());
validateNetworkAcl(acl);

validateNsxConstraints(acl.getVpcId(), networkACLItemVo.getIcmpType());
Account account = CallContext.current().getCallingAccount();
validateGlobalAclPermissionAndAclAssociatedToVpc(acl, account, "Only Root Admins can update global ACLs.");

Expand Down
4 changes: 2 additions & 2 deletions ui/public/locales/en.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"error.release.dedicate.zone": "Failed to release dedicated zone.",
"error.unable.to.proceed": "Unable to proceed. Please contact your administrator.",
"firewall.close": "Firewall",
"icmp.code.desc": "Please specify -1 if you want to allow all ICMP codes.",
"icmp.type.desc": "Please specify -1 if you want to allow all ICMP types.",
"icmp.code.desc": "Please specify -1 if you want to allow all ICMP codes (except NSX zones).",
"icmp.type.desc": "Please specify -1 if you want to allow all ICMP types (except NSX zones).",
"inline": "Inline",
"label.about": "About",
"label.about.app": "About CloudStack",
Expand Down

Back | FazBrowse Home | New Git URL