mirror of https://github.com/apache/cloudstack.git
Add ability to trigger ruleset updates from JMX
This commit is contained in:
parent
65414903b7
commit
549749a2d7
|
|
@ -360,7 +360,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
|||
return DigestUtils.md5Hex(ruleset);
|
||||
}
|
||||
|
||||
protected void handleVmStarted(VMInstanceVO vm) {
|
||||
public void handleVmStarted(VMInstanceVO vm) {
|
||||
if (vm.getType() != VirtualMachine.Type.User || !isVmSecurityGroupEnabled(vm.getId()))
|
||||
return;
|
||||
List<Long> affectedVms = getAffectedVmsForVmStart(vm);
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ public class SecurityGroupManagerImpl2 extends SecurityGroupManagerImpl{
|
|||
|
||||
}
|
||||
|
||||
protected void sendRulesetUpdates(SecurityGroupWork work){
|
||||
public void sendRulesetUpdates(SecurityGroupWork work){
|
||||
Long userVmId = work.getInstanceId();
|
||||
UserVm vm = _userVMDao.findById(userVmId);
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@ public interface SecurityGroupManagerMBean {
|
|||
int getQueueSize();
|
||||
|
||||
List<Long> getVmsInQueue();
|
||||
|
||||
|
||||
void scheduleRulesetUpdateForVm(Long vmId);
|
||||
|
||||
void tryRulesetUpdateForVmBypassSchedulerVeryDangerous(Long vmId, Long seqno);
|
||||
|
||||
void simulateVmStart(Long vmId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.cloud.network.security;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -8,6 +9,12 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
import javax.management.StandardMBean;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.security.LocalSecurityGroupWorkQueue.LocalSecurityGroupWork;
|
||||
import com.cloud.network.security.SecurityGroupWork.Step;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine.Type;
|
||||
|
||||
public class SecurityManagerMBeanImpl extends StandardMBean implements SecurityGroupManagerMBean, RuleUpdateLog {
|
||||
SecurityGroupManagerImpl2 _sgMgr;
|
||||
boolean _monitoringEnabled = false;
|
||||
|
|
@ -93,12 +100,32 @@ public class SecurityManagerMBeanImpl extends StandardMBean implements SecurityG
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void enableSchedulerForAllVms() {
|
||||
_sgMgr.enableAllVmsForScheduler();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void scheduleRulesetUpdateForVm(Long vmId) {
|
||||
List<Long> affectedVms = new ArrayList<Long>(1);
|
||||
affectedVms.add(vmId);
|
||||
_sgMgr.scheduleRulesetUpdateToHosts(affectedVms, true, null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tryRulesetUpdateForVmBypassSchedulerVeryDangerous(Long vmId, Long seqno) {
|
||||
LocalSecurityGroupWork work = new LocalSecurityGroupWorkQueue.LocalSecurityGroupWork(vmId, seqno, Step.Scheduled);
|
||||
_sgMgr.sendRulesetUpdates(work);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simulateVmStart(Long vmId) {
|
||||
//all we need is the vmId
|
||||
VMInstanceVO vm = new VMInstanceVO(vmId, 5, "foo", "foo", Type.User, null, HypervisorType.Any, 8, 1, 1, false, false);
|
||||
_sgMgr.handleVmStarted(vm);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue