fix security group rule which not get updated into db, and simulator agents reports the wrong security group to mgt server

This commit is contained in:
Edison Su 2011-09-12 19:09:11 -07:00
parent ae64c56c12
commit d461cfbf1b
5 changed files with 19 additions and 18 deletions

View File

@ -20,6 +20,7 @@ import com.cloud.agent.api.MigrateCommand;
import com.cloud.agent.api.NetworkUsageAnswer; import com.cloud.agent.api.NetworkUsageAnswer;
import com.cloud.agent.api.NetworkUsageCommand; import com.cloud.agent.api.NetworkUsageCommand;
import com.cloud.agent.api.RebootCommand; import com.cloud.agent.api.RebootCommand;
import com.cloud.agent.api.SecurityIngressRuleAnswer;
import com.cloud.agent.api.SecurityIngressRulesCmd; import com.cloud.agent.api.SecurityIngressRulesCmd;
import com.cloud.agent.api.StartCommand; import com.cloud.agent.api.StartCommand;
import com.cloud.agent.api.StopCommand; import com.cloud.agent.api.StopCommand;
@ -79,8 +80,8 @@ public interface MockVmManager extends Manager {
Answer CheckConsoleProxyLoad(CheckConsoleProxyLoadCommand cmd); Answer CheckConsoleProxyLoad(CheckConsoleProxyLoadCommand cmd);
Answer WatchConsoleProxyLoad(WatchConsoleProxyLoadCommand cmd); Answer WatchConsoleProxyLoad(WatchConsoleProxyLoadCommand cmd);
Answer AddSecurityIngressRules(SecurityIngressRulesCmd cmd);
Answer SavePassword(SavePasswordCommand cmd); Answer SavePassword(SavePasswordCommand cmd);
HashMap<String, Pair<Long, Long>> syncNetworkGroups(String hostGuid); HashMap<String, Pair<Long, Long>> syncNetworkGroups(String hostGuid);
SecurityIngressRuleAnswer AddSecurityIngressRules(SecurityIngressRulesCmd cmd, String hostGuid);
} }

View File

@ -352,7 +352,7 @@ public class MockVmManagerImpl implements MockVmManager {
} }
@Override @Override
public SecurityIngressRuleAnswer AddSecurityIngressRules(SecurityIngressRulesCmd cmd) { public SecurityIngressRuleAnswer AddSecurityIngressRules(SecurityIngressRulesCmd cmd, String hostGuid) {
MockVMVO vm = _mockVmDao.findByVmName(cmd.getVmName()); MockVMVO vm = _mockVmDao.findByVmName(cmd.getVmName());
if (vm == null) { if (vm == null) {
return new SecurityIngressRuleAnswer(cmd, false, "cant' find the vm: " + cmd.getVmName()); return new SecurityIngressRuleAnswer(cmd, false, "cant' find the vm: " + cmd.getVmName());
@ -364,8 +364,8 @@ public class MockVmManagerImpl implements MockVmManager {
rules.setRuleSet(cmd.stringifyRules()); rules.setRuleSet(cmd.stringifyRules());
rules.setSeqNum(cmd.getSeqNum()); rules.setSeqNum(cmd.getSeqNum());
rules.setSignature(cmd.getSignature()); rules.setSignature(cmd.getSignature());
rules.setVmId(vm.getId()); rules.setVmId(cmd.getVmId());
rules.setHostId(vm.getHostId()); rules.setHostId(hostGuid);
_mockSecurityDao.persist(rules); _mockSecurityDao.persist(rules);
} else if (update){ } else if (update){
@ -373,7 +373,7 @@ public class MockVmManagerImpl implements MockVmManager {
rules.setSignature(cmd.getSignature()); rules.setSignature(cmd.getSignature());
rules.setRuleSet(cmd.stringifyRules()); rules.setRuleSet(cmd.stringifyRules());
rules.setVmId(cmd.getVmId()); rules.setVmId(cmd.getVmId());
rules.setHostId(vm.getHostId()); rules.setHostId(hostGuid);
_mockSecurityDao.update(rules.getId(), rules); _mockSecurityDao.update(rules.getId(), rules);
} }

View File

@ -90,7 +90,7 @@ public class SimulatorManagerImpl implements SimulatorManager {
try { try {
Connection conn = Transaction.getStandaloneConnectionWithException(); Connection conn = Transaction.getStandaloneConnectionWithException();
conn.setAutoCommit(true); conn.setAutoCommit(true);
_concierge = new ConnectionConcierge("AgentMonitor", conn, false); _concierge = new ConnectionConcierge("SimulatorConnection", conn, true);
} catch (SQLException e) { } catch (SQLException e) {
throw new CloudRuntimeException("Unable to get a db connection", e); throw new CloudRuntimeException("Unable to get a db connection", e);
} }
@ -186,7 +186,7 @@ public class SimulatorManagerImpl implements SimulatorManager {
} else if (cmd instanceof WatchConsoleProxyLoadCommand) { } else if (cmd instanceof WatchConsoleProxyLoadCommand) {
return _mockVmMgr.WatchConsoleProxyLoad((WatchConsoleProxyLoadCommand)cmd); return _mockVmMgr.WatchConsoleProxyLoad((WatchConsoleProxyLoadCommand)cmd);
} else if (cmd instanceof SecurityIngressRulesCmd) { } else if (cmd instanceof SecurityIngressRulesCmd) {
return _mockVmMgr.AddSecurityIngressRules((SecurityIngressRulesCmd)cmd); return _mockVmMgr.AddSecurityIngressRules((SecurityIngressRulesCmd)cmd, hostGuid);
} else if (cmd instanceof SavePasswordCommand) { } else if (cmd instanceof SavePasswordCommand) {
return _mockVmMgr.SavePassword((SavePasswordCommand)cmd); return _mockVmMgr.SavePassword((SavePasswordCommand)cmd);
} else if (cmd instanceof PrimaryStorageDownloadCommand) { } else if (cmd instanceof PrimaryStorageDownloadCommand) {

View File

@ -23,13 +23,13 @@ public class MockSecurityRulesVO {
private String signature; private String signature;
@Column(name="seqnum") @Column(name="seqnum")
private Long seqnum; private Long seqNum;
@Column(name="ruleset") @Column(name="ruleset")
private String ruleset; private String ruleSet;
@Column(name="hostid") @Column(name="hostid")
private Long hostId; private String hostId;
@Column(name="vmname") @Column(name="vmname")
public String vmName; public String vmName;
@ -42,11 +42,11 @@ public class MockSecurityRulesVO {
this.vmName = vmName; this.vmName = vmName;
} }
public Long getHostId() { public String getHostId() {
return this.hostId; return this.hostId;
} }
public void setHostId(Long hostId) { public void setHostId(String hostId) {
this.hostId = hostId; this.hostId = hostId;
} }
@ -71,18 +71,18 @@ public class MockSecurityRulesVO {
} }
public Long getSeqNum() { public Long getSeqNum() {
return this.seqnum; return this.seqNum;
} }
public void setSeqNum(Long seqNum) { public void setSeqNum(Long seqNum) {
this.seqnum = seqNum; this.seqNum = seqNum;
} }
public String getRuleSet() { public String getRuleSet() {
return this.ruleset; return this.ruleSet;
} }
public void setRuleSet(String ruleset) { public void setRuleSet(String ruleset) {
this.ruleset = ruleset; this.ruleSet = ruleset;
} }
} }

View File

@ -96,10 +96,10 @@ CREATE TABLE `cloud`.`mocksecurityrules` (
`vmid` bigint unsigned, `vmid` bigint unsigned,
`signature` varchar(255), `signature` varchar(255),
`ruleset` varchar(4095), `ruleset` varchar(4095),
`hostid` bigint unsigned, `hostid` varchar(255),
`seqnum` bigint unsigned, `seqnum` bigint unsigned,
`vmname` varchar(255), `vmname` varchar(255),
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
INDEX `i_mocksecurityrules__vmid`(`vmid`), INDEX `i_mocksecurityrules__vmid`(`vmid`),
INDEX `i_mocksecurityrules__hostid`(`hostid`) INDEX `i_mocksecurityrules__hostid`(`hostid`)
) ENGINE=Memory DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;