Fixed DB upgrade script - vm_type field can be NULL

Conflicts:

	server/src/com/cloud/network/NetworkManagerImpl.java
This commit is contained in:
alena 2011-03-05 10:37:57 -08:00
parent bda3264a77
commit 94fb0612f2
4 changed files with 7 additions and 21 deletions

View File

@ -39,11 +39,6 @@ public interface Nic {
OperationFailed,
}
public enum VmType {
System,
User;
}
public enum State implements FiniteState<State, Event> {
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();
}

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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');