From 59eb1b0ba1cedc16b6f867a0a6b5f80c70bc1980 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Wed, 14 Sep 2011 02:58:43 -0700 Subject: [PATCH] bug 11307: Add Bumped field for domain_router Only used for redundant virtual router. --- core/src/com/cloud/vm/DomainRouterVO.java | 22 +++++++++++++++---- .../lb/ElasticLoadBalancerManagerImpl.java | 2 +- .../VirtualNetworkApplianceManagerImpl.java | 7 ++++-- setup/db/create-schema.sql | 1 + setup/db/db/schema-2211to2212.sql | 3 +++ 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/core/src/com/cloud/vm/DomainRouterVO.java b/core/src/com/cloud/vm/DomainRouterVO.java index eca325e9313..db37f37c725 100755 --- a/core/src/com/cloud/vm/DomainRouterVO.java +++ b/core/src/com/cloud/vm/DomainRouterVO.java @@ -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; + } + } diff --git a/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java b/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java index ee19eaed45c..a260e8c0849 100644 --- a/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java +++ b/server/src/com/cloud/network/lb/ElasticLoadBalancerManagerImpl.java @@ -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 diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 00aa0ee0c3d..22146b586fd 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -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); diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index c3a13b17e37..2351a2f583d 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -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`), diff --git a/setup/db/db/schema-2211to2212.sql b/setup/db/db/schema-2211to2212.sql index 35631aff68d..4fe91dc4943 100644 --- a/setup/db/db/schema-2211to2212.sql +++ b/setup/db/db/schema-2211to2212.sql @@ -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');