mirror of https://github.com/apache/cloudstack.git
sg improvements
This commit is contained in:
parent
efaa63a428
commit
f150f68128
|
|
@ -29,8 +29,8 @@ import com.cloud.agent.api.AgentControlCommand;
|
|||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.CleanupNetworkRulesCmd;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.SecurityIngressRuleAnswer;
|
||||
import com.cloud.agent.api.PingRoutingWithNwGroupsCommand;
|
||||
import com.cloud.agent.api.SecurityIngressRuleAnswer;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.agent.manager.Commands;
|
||||
|
|
@ -47,62 +47,65 @@ import com.cloud.network.security.dao.SecurityGroupWorkDao;
|
|||
public class SecurityGroupListener implements Listener {
|
||||
public static final Logger s_logger = Logger.getLogger(SecurityGroupListener.class.getName());
|
||||
|
||||
SecurityGroupManagerImpl _securityGroupManager;
|
||||
SecurityGroupManagerImpl _securityGroupManager;
|
||||
AgentManager _agentMgr;
|
||||
SecurityGroupWorkDao _workDao;
|
||||
|
||||
|
||||
public SecurityGroupListener(SecurityGroupManagerImpl securityGroupManager,
|
||||
AgentManager agentMgr, SecurityGroupWorkDao workDao) {
|
||||
super();
|
||||
_securityGroupManager = securityGroupManager;
|
||||
_agentMgr = agentMgr;
|
||||
_workDao = workDao;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getTimeout() {
|
||||
return -1;
|
||||
}
|
||||
public SecurityGroupListener(SecurityGroupManagerImpl securityGroupManager,
|
||||
AgentManager agentMgr, SecurityGroupWorkDao workDao) {
|
||||
super();
|
||||
_securityGroupManager = securityGroupManager;
|
||||
_agentMgr = agentMgr;
|
||||
_workDao = workDao;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isRecurring() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public int getTimeout() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean processAnswers(long agentId, long seq, Answer[] answers) {
|
||||
Set<Long> affectedVms = new HashSet<Long>();
|
||||
int commandNum = 0;
|
||||
for (Answer ans: answers) {
|
||||
if (ans instanceof SecurityIngressRuleAnswer) {
|
||||
SecurityIngressRuleAnswer ruleAnswer = (SecurityIngressRuleAnswer) ans;
|
||||
if (ans.getResult()) {
|
||||
s_logger.debug("Successfully programmed rule " + ruleAnswer.toString() + " into host " + agentId);
|
||||
_workDao.updateStep(ruleAnswer.getVmId(), ruleAnswer.getLogSequenceNumber(), Step.Done);
|
||||
@Override
|
||||
public boolean isRecurring() {
|
||||
return true;
|
||||
}
|
||||
|
||||
} else {
|
||||
_workDao.updateStep(ruleAnswer.getVmId(), ruleAnswer.getLogSequenceNumber(), Step.Error);
|
||||
s_logger.debug("Failed to program rule " + ruleAnswer.toString() + " into host " + agentId);
|
||||
affectedVms.add(ruleAnswer.getVmId());
|
||||
}
|
||||
commandNum++;
|
||||
}
|
||||
}
|
||||
_securityGroupManager.scheduleRulesetUpdateToHosts(affectedVms, false, new Long(10*1000l));
|
||||
|
||||
@Override
|
||||
public boolean processAnswers(long agentId, long seq, Answer[] answers) {
|
||||
Set<Long> affectedVms = new HashSet<Long>();
|
||||
int commandNum = 0;
|
||||
for (Answer ans: answers) {
|
||||
if (ans instanceof SecurityIngressRuleAnswer) {
|
||||
SecurityIngressRuleAnswer ruleAnswer = (SecurityIngressRuleAnswer) ans;
|
||||
if (ans.getResult()) {
|
||||
s_logger.debug("Successfully programmed rule " + ruleAnswer.toString() + " into host " + agentId);
|
||||
_workDao.updateStep(ruleAnswer.getVmId(), ruleAnswer.getLogSequenceNumber(), Step.Done);
|
||||
|
||||
} else {
|
||||
_workDao.updateStep(ruleAnswer.getVmId(), ruleAnswer.getLogSequenceNumber(), Step.Error);
|
||||
s_logger.debug("Failed to program rule " + ruleAnswer.toString() + " into host " + agentId);
|
||||
affectedVms.add(ruleAnswer.getVmId());
|
||||
}
|
||||
commandNum++;
|
||||
}
|
||||
}
|
||||
|
||||
if (affectedVms.size() > 0) {
|
||||
_securityGroupManager.scheduleRulesetUpdateToHosts(affectedVms, false, new Long(10 * 1000l));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean processCommands(long agentId, long seq, Command[] commands) {
|
||||
boolean processed = false;
|
||||
@Override
|
||||
public boolean processCommands(long agentId, long seq, Command[] commands) {
|
||||
boolean processed = false;
|
||||
for (Command cmd : commands) {
|
||||
if (cmd instanceof PingRoutingWithNwGroupsCommand) {
|
||||
PingRoutingWithNwGroupsCommand ping = (PingRoutingWithNwGroupsCommand)cmd;
|
||||
PingRoutingWithNwGroupsCommand ping = (PingRoutingWithNwGroupsCommand)cmd;
|
||||
if (ping.getNewGroupStates().size() > 0) {
|
||||
_securityGroupManager.fullSync(agentId, ping.getNewGroupStates());
|
||||
}
|
||||
|
|
@ -110,46 +113,46 @@ public class SecurityGroupListener implements Listener {
|
|||
}
|
||||
}
|
||||
return processed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
@Override
|
||||
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Received a host startup notification");
|
||||
|
||||
if (cmd instanceof StartupRoutingCommand) {
|
||||
//if (Boolean.toString(true).equals(host.getDetail("can_bridge_firewall"))) {
|
||||
try {
|
||||
CleanupNetworkRulesCmd cleanupCmd = new CleanupNetworkRulesCmd();
|
||||
Commands c = new Commands(cleanupCmd);
|
||||
_agentMgr.send(host.getId(), c, this);
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Scheduled network rules cleanup, interval=" + cleanupCmd.getInterval());
|
||||
} catch (AgentUnavailableException e) {
|
||||
s_logger.warn("Unable to schedule network rules cleanup");
|
||||
}
|
||||
|
||||
}
|
||||
if (cmd instanceof StartupRoutingCommand) {
|
||||
//if (Boolean.toString(true).equals(host.getDetail("can_bridge_firewall"))) {
|
||||
try {
|
||||
CleanupNetworkRulesCmd cleanupCmd = new CleanupNetworkRulesCmd();
|
||||
Commands c = new Commands(cleanupCmd);
|
||||
_agentMgr.send(host.getId(), c, this);
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Scheduled network rules cleanup, interval=" + cleanupCmd.getInterval());
|
||||
} catch (AgentUnavailableException e) {
|
||||
s_logger.warn("Unable to schedule network rules cleanup");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AgentControlAnswer processControlCommand(long agentId,
|
||||
AgentControlCommand cmd) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public AgentControlAnswer processControlCommand(long agentId,
|
||||
AgentControlCommand cmd) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean processDisconnect(long agentId, Status state) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean processDisconnect(long agentId, Status state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean processTimeout(long agentId, long seq) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean processTimeout(long agentId, long seq) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1404,7 +1404,7 @@ CREATE TABLE `cloud`.`op_nwgrp_work` (
|
|||
INDEX `i_op_nwgrp_work__taken`(`taken`),
|
||||
INDEX `i_op_nwgrp_work__step`(`step`),
|
||||
INDEX `i_op_nwgrp_work__seq_no`(`seq_no`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
) ENGINE=MEMORY DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `cloud`.`op_vm_ruleset_log` (
|
||||
`id` bigint unsigned UNIQUE NOT NULL AUTO_INCREMENT COMMENT 'id',
|
||||
|
|
|
|||
Loading…
Reference in New Issue