mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 7389: made ip optinal for list pf rules, all rules for the account will be listed when ip is not available
status 7389: resolved fixed
This commit is contained in:
parent
6dbf6fe67a
commit
02ae55cc96
@ -40,7 +40,7 @@ public class ListPortForwardingRulesCmd extends BaseListCmd {
|
|||||||
//////////////// API parameters /////////////////////
|
//////////////// API parameters /////////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, required=true, description="the IP address of the port forwarding services")
|
@Parameter(name=ApiConstants.IP_ADDRESS, type=CommandType.STRING, description="the IP address of the port forwarding services")
|
||||||
private String ipAddress;
|
private String ipAddress;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
|
|||||||
@ -345,17 +345,22 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends PortForwardingRule> listPortForwardingRules(ListPortForwardingRulesCmd cmd) {
|
public List<? extends PortForwardingRule> listPortForwardingRules(ListPortForwardingRulesCmd cmd) {
|
||||||
Ip ipAddress = new Ip(cmd.getIpAddress());
|
|
||||||
Account caller = UserContext.current().getCaller();
|
Account caller = UserContext.current().getCaller();
|
||||||
|
|
||||||
|
List<PortForwardingRuleVO> rules = null;
|
||||||
|
|
||||||
|
if(cmd.getIpAddress() != null){
|
||||||
|
Ip ipAddress = new Ip(cmd.getIpAddress());
|
||||||
IPAddressVO ipAddressVO = _ipAddressDao.findById(ipAddress);
|
IPAddressVO ipAddressVO = _ipAddressDao.findById(ipAddress);
|
||||||
if (ipAddressVO == null || !ipAddressVO.readyToUse()) {
|
if (ipAddressVO == null || !ipAddressVO.readyToUse()) {
|
||||||
throw new InvalidParameterValueException("Ip address not ready for port forwarding rules yet: " + ipAddress);
|
throw new InvalidParameterValueException("Ip address not ready for port forwarding rules yet: " + ipAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PortForwardingRuleVO> rules = _forwardingDao.listByIp(ipAddress);
|
rules = _forwardingDao.listByIp(ipAddress);
|
||||||
_accountMgr.checkAccess(caller, rules.toArray(new PortForwardingRuleVO[rules.size()]));
|
_accountMgr.checkAccess(caller, rules.toArray(new PortForwardingRuleVO[rules.size()]));
|
||||||
|
} else {
|
||||||
|
rules = _forwardingDao.listByAccount(caller.getAccountId());
|
||||||
|
}
|
||||||
return rules;
|
return rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,4 +41,6 @@ public interface PortForwardingRulesDao extends GenericDao<PortForwardingRuleVO,
|
|||||||
List<PortForwardingRuleVO> listByVm(Long vmId);
|
List<PortForwardingRuleVO> listByVm(Long vmId);
|
||||||
|
|
||||||
List<PortForwardingRuleVO> listByNetworkId(long networkId);
|
List<PortForwardingRuleVO> listByNetworkId(long networkId);
|
||||||
|
|
||||||
|
List<PortForwardingRuleVO> listByAccount(long accountId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,6 +38,7 @@ public class PortForwardingRulesDaoImpl extends GenericDaoBase<PortForwardingRul
|
|||||||
protected final SearchBuilder<PortForwardingRuleVO> ApplicationSearch;
|
protected final SearchBuilder<PortForwardingRuleVO> ApplicationSearch;
|
||||||
protected final SearchBuilder<PortForwardingRuleVO> ActiveRulesSearch;
|
protected final SearchBuilder<PortForwardingRuleVO> ActiveRulesSearch;
|
||||||
protected final SearchBuilder<PortForwardingRuleVO> AllRulesSearchByVM;
|
protected final SearchBuilder<PortForwardingRuleVO> AllRulesSearchByVM;
|
||||||
|
protected final SearchBuilder<PortForwardingRuleVO> ActiveRulesSearchByAccount;
|
||||||
|
|
||||||
protected PortForwardingRulesDaoImpl() {
|
protected PortForwardingRulesDaoImpl() {
|
||||||
super();
|
super();
|
||||||
@ -61,6 +62,11 @@ public class PortForwardingRulesDaoImpl extends GenericDaoBase<PortForwardingRul
|
|||||||
AllRulesSearchByVM = createSearchBuilder();
|
AllRulesSearchByVM = createSearchBuilder();
|
||||||
AllRulesSearchByVM.and("vmId", AllRulesSearchByVM.entity().getVirtualMachineId(), Op.EQ);
|
AllRulesSearchByVM.and("vmId", AllRulesSearchByVM.entity().getVirtualMachineId(), Op.EQ);
|
||||||
AllRulesSearchByVM.done();
|
AllRulesSearchByVM.done();
|
||||||
|
|
||||||
|
ActiveRulesSearchByAccount = createSearchBuilder();
|
||||||
|
ActiveRulesSearchByAccount.and("accountId", ActiveRulesSearchByAccount.entity().getAccountId(), Op.EQ);
|
||||||
|
ActiveRulesSearchByAccount.and("state", ActiveRulesSearchByAccount.entity().getState(), Op.NEQ);
|
||||||
|
ActiveRulesSearchByAccount.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -118,4 +124,12 @@ public class PortForwardingRulesDaoImpl extends GenericDaoBase<PortForwardingRul
|
|||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PortForwardingRuleVO> listByAccount(long accountId) {
|
||||||
|
SearchCriteria<PortForwardingRuleVO> sc = ActiveRulesSearchByAccount.create();
|
||||||
|
sc.setParameters("accountId", accountId);
|
||||||
|
sc.setParameters("state", State.Revoke);
|
||||||
|
return listBy(sc);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user