bug 11307: Add Bumped field for domain_router

Only used for redundant virtual router.
This commit is contained in:
Sheng Yang 2011-09-14 02:58:43 -07:00
parent 9cc1ecbce8
commit 59eb1b0ba1
5 changed files with 28 additions and 7 deletions

View File

@ -57,6 +57,9 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
@Column(name="priority")
int priority;
@Column(name="is_priority_bumpup")
boolean isPriorityBumpUp;
@Column(name="redundant_state")
@Enumerated(EnumType.STRING)
private RedundantState redundantState;
@ -76,13 +79,14 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
long networkId,
boolean isRedundantRouter,
int priority,
RedundantState redundantState,
boolean haEnabled) {
boolean isPriorityBumpUp,
RedundantState redundantState, boolean haEnabled) {
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
this.networkId = networkId;
this.isRedundantRouter = isRedundantRouter;
this.priority = priority;
this.redundantState = redundantState;
this.isPriorityBumpUp = isPriorityBumpUp;
}
public DomainRouterVO(long id,
@ -96,14 +100,15 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
long networkId,
boolean isRedundantRouter,
int priority,
boolean isPriorityBumpUp,
RedundantState redundantState,
boolean haEnabled,
VirtualMachine.Type vmType) {
boolean haEnabled, VirtualMachine.Type vmType) {
super(id, serviceOfferingId, name, name, vmType, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
this.networkId = networkId;
this.isRedundantRouter = isRedundantRouter;
this.priority = priority;
this.redundantState = redundantState;
this.isPriorityBumpUp = isPriorityBumpUp;
}
public void setPublicIpAddress(String publicIpAddress) {
@ -195,4 +200,13 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter {
public void setServiceOfferingId(long serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
public boolean getIsPriorityBumpUp() {
return this.isPriorityBumpUp;
}
public void setIsPriorityBumpUp(boolean isPriorityBumpUp) {
this.isPriorityBumpUp = isPriorityBumpUp;
}
}

View File

@ -504,7 +504,7 @@ public class ElasticLoadBalancerManagerImpl implements
elbVm = new DomainRouterVO(id, _elasticLbVmOffering.getId(), VirtualMachineName.getSystemVmName(id, _instance, _elbVmNamePrefix), template.getId(), template.getHypervisorType(), template.getGuestOSId(),
owner.getDomainId(), owner.getId(), guestNetwork.getId(), false, 0, RedundantState.UNKNOWN, _elasticLbVmOffering.getOfferHA(), VirtualMachine.Type.ElasticLoadBalancerVm);
owner.getDomainId(), owner.getId(), guestNetwork.getId(), false, 0, false, RedundantState.UNKNOWN, _elasticLbVmOffering.getOfferHA(), VirtualMachine.Type.ElasticLoadBalancerVm);
elbVm.setRole(Role.LB);
elbVm = _itMgr.allocate(elbVm, template, _elasticLbVmOffering, networks, plan, null, owner);
//TODO: create usage stats

View File

@ -797,11 +797,14 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
command.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
command.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
final CheckRouterAnswer answer = (CheckRouterAnswer) _agentMgr.easySend(router.getHostId(), command);
boolean isBumped = false;
RedundantState state = RedundantState.UNKNOWN;
if (answer != null && answer.getResult()) {
state = answer.getState();
isBumped = answer.isBumped();
}
router.setRedundantState(state);
router.setIsPriorityBumpUp(isBumped);
updated = true;
}
}
@ -960,7 +963,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
priority = 100 - routers.size() * 20;
}
router = new DomainRouterVO(id, _offering.getId(), VirtualMachineName.getRouterName(id, _instance), template.getId(), template.getHypervisorType(), template.getGuestOSId(),
owner.getDomainId(), owner.getId(), guestNetwork.getId(), isRedundant, priority, RedundantState.UNKNOWN, _offering.getOfferHA());
owner.getDomainId(), owner.getId(), guestNetwork.getId(), isRedundant, priority, false, RedundantState.UNKNOWN, _offering.getOfferHA());
router = _itMgr.allocate(router, template, _offering, networks, plan, null, owner);
// Creating stats entry for router
UserStatisticsVO stats = _userStatsDao.findBy(owner.getId(), dcId, router.getNetworkId(), null, router.getId(), router.getType().toString());
@ -1145,7 +1148,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
VMTemplateVO template = _templateDao.findRoutingTemplate(dest.getCluster().getHypervisorType());
router = new DomainRouterVO(id, _offering.getId(), VirtualMachineName.getRouterName(id, _instance), template.getId(), template.getHypervisorType(), template.getGuestOSId(),
owner.getDomainId(), owner.getId(), guestNetwork.getId(), false, 0, RedundantState.UNKNOWN, _offering.getOfferHA());
owner.getDomainId(), owner.getId(), guestNetwork.getId(), false, 0, false, RedundantState.UNKNOWN, _offering.getOfferHA());
router.setRole(Role.DHCP_USERDATA);
router = _itMgr.allocate(router, template, _offering, networks, plan, null, owner);
routers.add(router);

View File

@ -936,6 +936,7 @@ CREATE TABLE `cloud`.`domain_router` (
`network_id` bigint unsigned NOT NULL COMMENT 'network configuration that this domain router belongs to',
`is_redundant_router` int(1) unsigned NOT NULL COMMENT 'if in redundant router mode',
`priority` int(4) unsigned COMMENT 'priority of router in the redundant router mode',
`is_priority_bumpup` int(1) unsigned NOT NULL COMMENT 'if the priority has been bumped up',
`redundant_state` varchar(64) NOT NULL COMMENT 'the state of redundant virtual router',
`role` varchar(64) NOT NULL COMMENT 'type of role played by this router',
PRIMARY KEY (`id`),

View File

@ -12,6 +12,9 @@ INSERT IGNORE INTO configuration VALUES ('Premium', 'DEFAULT', 'management-serve
ALTER IGNORE TABLE `cloud`.`user_vm_details` DROP FOREIGN KEY `fk_user_vm_details__vm_id`;
ALTER TABLE `cloud`.`user_vm_details` ADD CONSTRAINT `fk_user_vm_details__vm_id` FOREIGN KEY `fk_user_vm_details__vm_id`(`vm_id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`domain_router` ADD COLUMN `is_priority_bumpup` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'if the priority has been bumped up';
DELETE FROM `cloud`.`configuration` where name='vmware.guest.nic.device.type';
INSERT IGNORE INTO configuration VALUES ('Advanced', 'DEFAULT', 'management-server', 'agent.lb.enabled', 'true', 'If agent load balancing enabled in cluster setup');