1) Updated schema for data_center - provider fields can have NULL values.

2) Fixed deletePortForwarding/deleteIpForwardingRule commands to return false when delete rule fails.
This commit is contained in:
alena 2010-12-28 16:21:42 -08:00
parent 383f524725
commit 085824d524
6 changed files with 18 additions and 22 deletions

View File

@ -66,8 +66,9 @@ public class DeleteIpForwardingRuleCmd extends BaseAsyncCmd {
@Override @Override
public void execute(){ public void execute(){
PortForwardingRule rule = _rulesService.revokePortForwardingRule(id, true); boolean result = _rulesService.revokePortForwardingRule(id, true);
if (rule != null) {
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName()); SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response); this.setResponseObject(response);
} else { } else {

View File

@ -81,8 +81,9 @@ public class DeletePortForwardingRuleCmd extends BaseAsyncCmd {
@Override @Override
public void execute() throws ResourceUnavailableException { public void execute() throws ResourceUnavailableException {
PortForwardingRule result = _rulesService.revokePortForwardingRule(id, true); boolean result = _rulesService.revokePortForwardingRule(id, true);
if (result != null) {
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName()); SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response); this.setResponseObject(response);
} else { } else {

View File

@ -44,7 +44,7 @@ public interface RulesService {
* @param caller * @param caller
* @return * @return
*/ */
PortForwardingRule revokePortForwardingRule(long ruleId, boolean apply); boolean revokePortForwardingRule(long ruleId, boolean apply);
/** /**
* List port forwarding rules assigned to an ip address * List port forwarding rules assigned to an ip address
* @param cmd the command object holding the criteria for listing port forwarding rules (the ipAddress) * @param cmd the command object holding the criteria for listing port forwarding rules (the ipAddress)

View File

@ -33,7 +33,6 @@ import com.cloud.utils.net.Ip;
* Rules Manager manages the network rules created for different networks. * Rules Manager manages the network rules created for different networks.
*/ */
public interface RulesManager extends RulesService { public interface RulesManager extends RulesService {
PortForwardingRule revokePortForwardingRule(String ruleId, Account caller);
boolean applyPortForwardingRules(Ip ip, boolean continueOnError); boolean applyPortForwardingRules(Ip ip, boolean continueOnError);

View File

@ -301,7 +301,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
} }
@Override @Override
public PortForwardingRule revokePortForwardingRule(long ruleId, boolean apply) { public boolean revokePortForwardingRule(long ruleId, boolean apply) {
UserContext ctx = UserContext.current(); UserContext ctx = UserContext.current();
Account caller = ctx.getAccount(); Account caller = ctx.getAccount();
@ -314,15 +314,10 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
revokeRule(rule, caller, ctx.getUserId()); revokeRule(rule, caller, ctx.getUserId());
if (apply) { if (apply) {
applyPortForwardingRules(rule.getSourceIpAddress(), true); return applyPortForwardingRules(rule.getSourceIpAddress(), true);
} else {
return true;
} }
return rule;
}
@Override
public PortForwardingRule revokePortForwardingRule(String ruleId, Account caller) {
// FIXME: Not working yet.
return null;
} }
@Override @Override

View File

@ -407,13 +407,13 @@ CREATE TABLE `cloud`.`data_center` (
`domain` varchar(100) COMMENT 'Network domain name of the Vms of the zone', `domain` varchar(100) COMMENT 'Network domain name of the Vms of the zone',
`domain_id` bigint unsigned COMMENT 'domain id for the parent domain to this zone (null signifies public zone)', `domain_id` bigint unsigned COMMENT 'domain id for the parent domain to this zone (null signifies public zone)',
`networktype` varchar(255) NOT NULL DEFAULT 'Basic' COMMENT 'Network type of the zone', `networktype` varchar(255) NOT NULL DEFAULT 'Basic' COMMENT 'Network type of the zone',
`dns_provider` char(64) NOT NULL DEFAULT 'VirtualRouter', `dns_provider` char(64) DEFAULT 'VirtualRouter',
`gateway_provider` char(64) NOT NULL DEFAULT 'VirtualRouter', `gateway_provider` char(64) DEFAULT 'VirtualRouter',
`firewall_provider` char(64) NOT NULL DEFAULT 'VirtualRouter', `firewall_provider` char(64) DEFAULT 'VirtualRouter',
`dhcp_provider` char(64) NOT NULL DEFAULT 'VirtualRouter', `dhcp_provider` char(64) DEFAULT 'VirtualRouter',
`lb_provider` char(64) NOT NULL DEFAULT 'VirtualRouter', `lb_provider` char(64) DEFAULT 'VirtualRouter',
`vpn_provider` char(64) NOT NULL DEFAULT 'VirtualRouter', `vpn_provider` char(64) DEFAULT 'VirtualRouter',
`userdata_provider` char(64) NOT NULL DEFAULT 'VirtualRouter', `userdata_provider` char(64) DEFAULT 'VirtualRouter',
`enable` tinyint NOT NULL DEFAULT 1 COMMENT 'Is this data center enabled for activities', `enable` tinyint NOT NULL DEFAULT 1 COMMENT 'Is this data center enabled for activities',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;