From 94fb0612f2ad123c878878e91c0a8d9c29eaab53 Mon Sep 17 00:00:00 2001 From: alena Date: Sat, 5 Mar 2011 10:37:57 -0800 Subject: [PATCH] Fixed DB upgrade script - vm_type field can be NULL Conflicts: server/src/com/cloud/network/NetworkManagerImpl.java --- api/src/com/cloud/vm/Nic.java | 7 +------ .../src/com/cloud/network/NetworkManagerImpl.java | 13 ++----------- server/src/com/cloud/vm/NicVO.java | 6 +++--- setup/db/221to222.sql | 2 +- 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/api/src/com/cloud/vm/Nic.java b/api/src/com/cloud/vm/Nic.java index 16209e50021..4921dbc9c44 100644 --- a/api/src/com/cloud/vm/Nic.java +++ b/api/src/com/cloud/vm/Nic.java @@ -39,11 +39,6 @@ public interface Nic { OperationFailed, } - public enum VmType { - System, - User; - } - public enum State implements FiniteState { Allocated("Resource is allocated but not reserved"), Reserving("Resource is being reserved right now"), @@ -157,5 +152,5 @@ public interface Nic { URI getBroadcastUri(); - VmType getVmType(); + VirtualMachine.Type getVmType(); } diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 0fb5ebf0a26..b67a90da019 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -126,7 +126,6 @@ import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.Ip; import com.cloud.utils.net.NetUtils; import com.cloud.vm.Nic; -import com.cloud.vm.Nic.VmType; import com.cloud.vm.NicProfile; import com.cloud.vm.NicVO; import com.cloud.vm.ReservationContext; @@ -935,15 +934,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag continue; } - VmType vmType = null; - - if (vm.getType() == Type.User) { - vmType = Nic.VmType.User; - } else { - vmType = Nic.VmType.System; - } - - NicVO vo = new NicVO(guru.getName(), vm.getId(), config.getId(), vmType); + NicVO vo = new NicVO(guru.getName(), vm.getId(), config.getId(), vm.getType()); while (deviceIds[deviceId] && deviceId < deviceIds.length) { deviceId++; @@ -1149,7 +1140,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag txn.start(); _nicDao.update(nic.getId(), nic); - if (nic.getVmType() == VmType.User) { + if (nic.getVmType() == VirtualMachine.Type.User) { _networksDao.changeActiveNicsBy(networkId, count); } txn.commit(); diff --git a/server/src/com/cloud/vm/NicVO.java b/server/src/com/cloud/vm/NicVO.java index 71dfd2f9929..3d615340de6 100644 --- a/server/src/com/cloud/vm/NicVO.java +++ b/server/src/com/cloud/vm/NicVO.java @@ -103,7 +103,7 @@ public class NicVO implements Nic { @Enumerated(value=EnumType.STRING) @Column(name="vm_type") - VmType vmType; + VirtualMachine.Type vmType; @Column(name=GenericDao.REMOVED_COLUMN) Date removed; @@ -111,7 +111,7 @@ public class NicVO implements Nic { @Column(name=GenericDao.CREATED_COLUMN) Date created; - public NicVO(String reserver, Long instanceId, long configurationId, VmType vmType) { + public NicVO(String reserver, Long instanceId, long configurationId, VirtualMachine.Type vmType) { this.reserver = reserver; this.instanceId = instanceId; this.networkId = configurationId; @@ -307,7 +307,7 @@ public class NicVO implements Nic { } @Override - public VmType getVmType() { + public VirtualMachine.Type getVmType() { return vmType; } } diff --git a/setup/db/221to222.sql b/setup/db/221to222.sql index 2413314fd67..a9802e37f2a 100644 --- a/setup/db/221to222.sql +++ b/setup/db/221to222.sql @@ -5,7 +5,7 @@ update network_offerings set system_only=1 where name='System-Guest-Network'; update network_offerings set dns_service=1,userdata_service=1,dhcp_service=1 where system_only=0; update network_offerings set firewall_service=1, lb_service=1,vpn_service=1,gateway_service=1 where traffic_type='guest' and system_only=0; alter table domain add column `state` char(32) NOT NULL default 'Active' COMMENT 'state of the domain'; -alter table nics add column `vm_type` char(32) NOT NULL; +alter table nics add column `vm_type` char(32); update nics set vm_type=(select type from vm_instance where vm_instance.id=nics.instance_id); delete from configuration where name='router.cleanup'; INSERT INTO configuration (`category`, `instance`, `component`, `name`, `value`, `description`) VALUES ('Network','DEFAULT','none','network.guest.cidr.limit','22','size limit for guest cidr; cant be less than this value');