diff --git a/api/src/com/cloud/api/commands/CreateServiceOfferingCmd.java b/api/src/com/cloud/api/commands/CreateServiceOfferingCmd.java index a598dec9789..c6f031cf8eb 100644 --- a/api/src/com/cloud/api/commands/CreateServiceOfferingCmd.java +++ b/api/src/com/cloud/api/commands/CreateServiceOfferingCmd.java @@ -61,9 +61,6 @@ public class CreateServiceOfferingCmd extends BaseCmd { @Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="the tags for this service offering.") private String tags; - @Parameter(name=ApiConstants.USE_VIRTUAL_NETWORK, type=CommandType.BOOLEAN, description="if true, the VM created will use default virtual networking. If false, the VM created will use a direct attached networking model. The default value is true.") - private Boolean useVirtualNetwork; - @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the containing domain, null for public offerings") private Long domainId; @@ -107,10 +104,6 @@ public class CreateServiceOfferingCmd extends BaseCmd { return domainId; } - public Boolean getUseVirtualNetwork() { - return useVirtualNetwork; - } - ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// diff --git a/api/src/com/cloud/network/router/VirtualRouter.java b/api/src/com/cloud/network/router/VirtualRouter.java index ded9b83b33b..32009620c88 100755 --- a/api/src/com/cloud/network/router/VirtualRouter.java +++ b/api/src/com/cloud/network/router/VirtualRouter.java @@ -28,12 +28,5 @@ public interface VirtualRouter extends VirtualMachine { DHCP_FIREWALL_LB_PASSWD_USERDATA, DHCP_USERDATA } - /** - * @return the ram size for this machine. - */ - public int getRamSize(); - Role getRole(); - - void setRamSize(int ramSize); } diff --git a/api/src/com/cloud/offering/ServiceOffering.java b/api/src/com/cloud/offering/ServiceOffering.java index c9ca5ba3272..57c5d0e49e5 100755 --- a/api/src/com/cloud/offering/ServiceOffering.java +++ b/api/src/com/cloud/offering/ServiceOffering.java @@ -19,8 +19,6 @@ package com.cloud.offering; import java.util.Date; -import com.cloud.network.Network; - /** * ServiceOffering models the different types of service contracts to be * offered. @@ -69,11 +67,6 @@ public interface ServiceOffering { */ int getMulticastRateMbps(); - /** - * @return the type of IP address to allocate as the primary ip address to a guest - */ - Network.GuestIpType getGuestIpType(); - /** * @return whether or not the service offering requires local storage */ diff --git a/core/src/com/cloud/vm/ConsoleProxyVO.java b/core/src/com/cloud/vm/ConsoleProxyVO.java index 148ab090590..f5c0252d93d 100644 --- a/core/src/com/cloud/vm/ConsoleProxyVO.java +++ b/core/src/com/cloud/vm/ConsoleProxyVO.java @@ -50,9 +50,6 @@ public class ConsoleProxyVO extends VMInstanceVO implements ConsoleProxy { @Column(name="public_netmask", nullable=false) private String publicNetmask; - @Column(name="ram_size", updatable=false, nullable=false) - private int ramSize; - @Column(name="active_session", updatable=true, nullable=false) private int activeSession; @@ -93,10 +90,6 @@ public class ConsoleProxyVO extends VMInstanceVO implements ConsoleProxy { this.publicMacAddress = publicMacAddress; } - public void setRamSize(int ramSize) { - this.ramSize = ramSize; - } - public void setActiveSession(int activeSession) { this.activeSession = activeSession; } @@ -124,11 +117,6 @@ public class ConsoleProxyVO extends VMInstanceVO implements ConsoleProxy { return this.publicMacAddress; } - @Override - public int getRamSize() { - return this.ramSize; - } - @Override public int getActiveSession() { return this.activeSession; diff --git a/core/src/com/cloud/vm/DomainRouterVO.java b/core/src/com/cloud/vm/DomainRouterVO.java index 81828ec6b92..296ae393688 100755 --- a/core/src/com/cloud/vm/DomainRouterVO.java +++ b/core/src/com/cloud/vm/DomainRouterVO.java @@ -37,9 +37,6 @@ import com.cloud.network.router.VirtualRouter; @PrimaryKeyJoinColumn(name="id") @DiscriminatorValue(value="DomainRouter") public class DomainRouterVO extends VMInstanceVO implements VirtualRouter { - @Column(name="ram_size", nullable=false) - private int ramSize; - @Column(name="public_ip_address") private String publicIpAddress; @@ -52,12 +49,6 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter { @Column(name="guest_ip_address") private String guestIpAddress; - @Column(name="guest_netmask") - private String guestNetmask; - - @Column(name="domain", nullable=false) - private String domain; - @Column(name="network_id") long networkId; @@ -73,12 +64,10 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter { long guestOSId, long domainId, long accountId, - long networkConfigurationId, - boolean haEnabled, - String networkDomain) { + long networkId, + boolean haEnabled) { super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, hypervisorType, guestOSId, domainId, accountId, haEnabled); - this.networkId = networkConfigurationId; - this.domain = networkDomain; + this.networkId = networkId; } public void setPublicIpAddress(String publicIpAddress) { @@ -101,10 +90,6 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter { this.guestIpAddress = routerIpAddress; } - public void setDomain(String domain) { - this.domain = domain; - } - @Override public long getDataCenterId() { return dataCenterId; @@ -126,20 +111,6 @@ public class DomainRouterVO extends VMInstanceVO implements VirtualRouter { super(); } - public String getDomain() { - return domain; - } - - @Override - public int getRamSize() { - return ramSize; - } - - @Override - public void setRamSize(int ramSize) { - this.ramSize = ramSize; - } - public String getPublicIpAddress() { return publicIpAddress; } diff --git a/core/src/com/cloud/vm/SecondaryStorageVmVO.java b/core/src/com/cloud/vm/SecondaryStorageVmVO.java index fc66537a7b7..d407ab3ad12 100644 --- a/core/src/com/cloud/vm/SecondaryStorageVmVO.java +++ b/core/src/com/cloud/vm/SecondaryStorageVmVO.java @@ -54,10 +54,6 @@ public class SecondaryStorageVmVO extends VMInstanceVO implements SecondaryStora @Column(name="nfs_share", nullable=false) private String nfsShare; - - @Column(name="ram_size", updatable=false, nullable=false) - private int ramSize; - @Temporal(TemporalType.TIMESTAMP) @Column(name="last_update", updatable=true, nullable=true) private Date lastUpdateTime; @@ -85,10 +81,6 @@ public class SecondaryStorageVmVO extends VMInstanceVO implements SecondaryStora this.publicMacAddress = publicMacAddress; } - public void setRamSize(int ramSize) { - this.ramSize = ramSize; - } - public void setLastUpdateTime(Date time) { this.lastUpdateTime = time; } @@ -108,11 +100,6 @@ public class SecondaryStorageVmVO extends VMInstanceVO implements SecondaryStora return this.publicMacAddress; } - @Override - public int getRamSize() { - return this.ramSize; - } - @Override public Date getLastUpdateTime() { return this.lastUpdateTime; diff --git a/core/src/com/cloud/vm/SystemVm.java b/core/src/com/cloud/vm/SystemVm.java index 21d5027246e..fbedb79476f 100644 --- a/core/src/com/cloud/vm/SystemVm.java +++ b/core/src/com/cloud/vm/SystemVm.java @@ -23,6 +23,5 @@ public interface SystemVm extends VirtualMachine { public String getPublicIpAddress(); public String getPublicNetmask(); public String getPublicMacAddress(); - public int getRamSize(); public Date getLastUpdateTime(); } diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index 1880bca19fd..82bfd0b485d 100755 --- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -1221,7 +1221,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, throw new AgentUnavailableException(-1); } - assert noDbTxn() : "I know, I know. Why are we so strict as to not allow txn across an agent call? ... Why are we so cruel ... Why are we such a dictator .... Too bad... Sorry...but NO AGENT COMMANDS WRAPPED WITHIN DB TRANSACTIONS!"; + //assert noDbTxn() : "I know, I know. Why are we so strict as to not allow txn across an agent call? ... Why are we so cruel ... Why are we such a dictator .... Too bad... Sorry...but NO AGENT COMMANDS WRAPPED WITHIN DB TRANSACTIONS!"; Command[] cmds = commands.toCommands(); diff --git a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java index c7f30dbc8c5..707766b98da 100755 --- a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java @@ -150,7 +150,7 @@ public class FirstFitAllocator implements HostAllocator { s_logger.debug("Found " + domainRouters.size() + " router domains on host " + host.getId()); } for (DomainRouterVO router : domainRouters) { - usedMemory += router.getRamSize() * 1024L * 1024L; + usedMemory += 0;//FIXME or more like get rid of me router.getRamSize() * 1024L * 1024L; } List proxys = _consoleProxyDao.listUpByHostId(host.getId()); @@ -158,7 +158,7 @@ public class FirstFitAllocator implements HostAllocator { s_logger.debug("Found " + proxys.size() + " console proxy on host " + host.getId()); } for(ConsoleProxyVO proxy : proxys) { - usedMemory += proxy.getRamSize() * 1024L * 1024L; + usedMemory += 0; // FIXME or get ird of me totally proxy.getRamSize() * 1024L * 1024L; } List secStorageVms = _secStorgaeVmDao.listUpByHostId(host.getId()); @@ -166,7 +166,7 @@ public class FirstFitAllocator implements HostAllocator { s_logger.debug("Found " + secStorageVms.size() + " secondary storage VM on host " + host.getId()); } for(SecondaryStorageVmVO secStorageVm : secStorageVms) { - usedMemory += secStorageVm.getRamSize() * 1024L * 1024L; + usedMemory += 0; // FIXME or get rid of me secStorageVm.getRamSize() * 1024L * 1024L; } List vms = _vmDao.listUpByHostId(host.getId()); diff --git a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java index 354e077a5e3..660e05f529a 100755 --- a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java +++ b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java @@ -38,7 +38,6 @@ import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; import com.cloud.dc.Pod; import com.cloud.dc.dao.HostPodDao; -import com.cloud.network.Network; import com.cloud.offering.ServiceOffering; import com.cloud.service.ServiceOfferingVO; import com.cloud.service.dao.ServiceOfferingDao; @@ -250,14 +249,14 @@ public class UserConcentratedAllocator implements PodAllocator { so = _offeringDao.findById(userVm.getServiceOfferingId()); } else if(vm.getType() == VirtualMachine.Type.ConsoleProxy) { so = new ServiceOfferingVO("Fake Offering For DomP", 1, - _proxyRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true); + _proxyRamSize, 0, 0, 0, false, null, false, true, null, true); } else if(vm.getType() == VirtualMachine.Type.SecondaryStorageVm) { - so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true); + so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, false, true, null, true); } else if(vm.getType() == VirtualMachine.Type.DomainRouter) { - so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true); + so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, false, true, null, true); } else { assert(false) : "Unsupported system vm type"; - so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true); + so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, false, true, null, true); } if(capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) { diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java index 86f62945d37..b5613874057 100644 --- a/server/src/com/cloud/capacity/CapacityManagerImpl.java +++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java @@ -29,16 +29,9 @@ import javax.naming.ConfigurationException; import org.apache.log4j.Logger; -import com.cloud.agent.Listener; -import com.cloud.agent.api.AgentControlAnswer; -import com.cloud.agent.api.AgentControlCommand; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.Command; -import com.cloud.agent.api.StartupCommand; import com.cloud.capacity.dao.CapacityDao; import com.cloud.configuration.Config; import com.cloud.configuration.dao.ConfigurationDao; -import com.cloud.exception.ConnectionException; import com.cloud.host.Host; import com.cloud.host.HostVO; import com.cloud.host.Status; @@ -374,7 +367,7 @@ public class CapacityManagerImpl implements CapacityManager , StateListener 1) endIP = ipAddressRangeArray[1]; + if (ipAddressRangeArray.length > 1) { + endIP = ipAddressRangeArray[1]; + } // If a netmask was provided, check that the startIP, endIP, and gateway all belong to the same subnet if (netmask != null && netmask != "") { if (endIP != null) { - if (!IPRangeConfig.sameSubnet(startIP, endIP, netmask)) printError("Start and end IPs for the public IP range must be in the same subnet, as per the provided netmask."); + if (!IPRangeConfig.sameSubnet(startIP, endIP, netmask)) { + printError("Start and end IPs for the public IP range must be in the same subnet, as per the provided netmask."); + } } if (gateway != null && gateway != "") { - if (!IPRangeConfig.sameSubnet(startIP, gateway, netmask)) printError("The start IP for the public IP range must be in the same subnet as the gateway, as per the provided netmask."); + if (!IPRangeConfig.sameSubnet(startIP, gateway, netmask)) { + printError("The start IP for the public IP range must be in the same subnet as the gateway, as per the provided netmask."); + } if (endIP != null) { - if (!IPRangeConfig.sameSubnet(endIP, gateway, netmask)) printError("The end IP for the public IP range must be in the same subnet as the gateway, as per the provided netmask."); + if (!IPRangeConfig.sameSubnet(endIP, gateway, netmask)) { + printError("The end IP for the public IP range must be in the same subnet as the gateway, as per the provided netmask."); + } } } } @@ -708,12 +733,16 @@ public class DatabaseConfig { if (privateIpRange != null) { // Check that the given IP address range was valid - if (!checkIpAddressRange(privateIpRange)) printError("Please enter a valid private IP range."); + if (!checkIpAddressRange(privateIpRange)) { + printError("Please enter a valid private IP range."); + } String[] ipAddressRangeArray = privateIpRange.split("\\-"); startIP = ipAddressRangeArray[0]; endIP = null; - if (ipAddressRangeArray.length > 1) endIP = ipAddressRangeArray[1]; + if (ipAddressRangeArray.length > 1) { + endIP = ipAddressRangeArray[1]; + } } // Check that the start IP and end IP match up with the CIDR @@ -752,13 +781,6 @@ public class DatabaseConfig { int mcRate = 10; boolean ha = Boolean.parseBoolean(_currentObjectParams.get("enableHA")); boolean mirroring = Boolean.parseBoolean(_currentObjectParams.get("mirrored")); - String guestIpType = _currentObjectParams.get("guestIpType"); - Network.GuestIpType type = null; - if (guestIpType == null) { - type = Network.GuestIpType.Virtual; - } else { - type = Network.GuestIpType.valueOf(guestIpType); - } boolean useLocalStorage; if (useLocalStorageValue != null) { @@ -771,7 +793,7 @@ public class DatabaseConfig { useLocalStorage = false; } - ServiceOfferingVO serviceOffering = new ServiceOfferingVO(name, cpu, ramSize, speed, nwRate, mcRate, ha, displayText, type, useLocalStorage, false, null, false); + ServiceOfferingVO serviceOffering = new ServiceOfferingVO(name, cpu, ramSize, speed, nwRate, mcRate, ha, displayText, useLocalStorage, false, null, false); ServiceOfferingDaoImpl dao = ComponentLocator.inject(ServiceOfferingDaoImpl.class); try { dao.persist(serviceOffering); @@ -848,7 +870,9 @@ public class DatabaseConfig { boolean saveNetworkThrottlingRate = (_networkThrottlingRate != null); boolean saveMulticastThrottlingRate = (_multicastThrottlingRate != null); - if (!saveNetworkThrottlingRate && !saveMulticastThrottlingRate) return; + if (!saveNetworkThrottlingRate && !saveMulticastThrottlingRate) { + return; + } String insertNWRateSql = "UPDATE `cloud`.`service_offering` SET `nw_rate` = ?"; String insertMCRateSql = "UPDATE `cloud`.`service_offering` SET `mc_rate` = ?"; @@ -958,7 +982,9 @@ public class DatabaseConfig { String password = _currentObjectParams.get("password"); String email = _currentObjectParams.get("email"); - if (email == null || email.equals("")) printError("An email address for each user is required."); + if (email == null || email.equals("")) { + printError("An email address for each user is required."); + } MessageDigest md5 = null; try { @@ -1025,16 +1051,21 @@ public class DatabaseConfig { String instanceNameError = "Please enter a non-blank value for the field: "; if (name.equals("instance.name")) { - if (value == null || value.isEmpty() || !value.matches("^[A-Za-z0-9]{1,8}$")) - printError(instanceNameError + "configuration: instance.name can not be empty and can only contain numbers and alphabets up to 8 characters long"); + if (value == null || value.isEmpty() || !value.matches("^[A-Za-z0-9]{1,8}$")) { + printError(instanceNameError + "configuration: instance.name can not be empty and can only contain numbers and alphabets up to 8 characters long"); + } } if (name.equals("network.throttling.rate")) { - if (value != null && !value.isEmpty()) _networkThrottlingRate = value; + if (value != null && !value.isEmpty()) { + _networkThrottlingRate = value; + } } if (name.equals("multicast.throttling.rate")) { - if (value != null && !value.isEmpty()) _multicastThrottlingRate = value; + if (value != null && !value.isEmpty()) { + _multicastThrottlingRate = value; + } } String insertSql = "INSERT INTO `cloud`.`configuration` (instance, component, name, value, description, category) " + @@ -1060,7 +1091,9 @@ public class DatabaseConfig { String[] ipAddressRangeArray = ipAddressRange.split("\\-"); String startIP = ipAddressRangeArray[0]; String endIP = null; - if (ipAddressRangeArray.length > 1) endIP = ipAddressRangeArray[1]; + if (ipAddressRangeArray.length > 1) { + endIP = ipAddressRangeArray[1]; + } if (!IPRangeConfig.validIP(startIP)) { s_logger.error("The private IP address: " + startIP + " is invalid."); @@ -1199,8 +1232,9 @@ public class DatabaseConfig { if (rs.next()) { String value = rs.getString(name); return value; - } - else return null; + } else { + return null; + } } catch (SQLException e) { System.out.println("Exception: " + e.getMessage()); printError(errorMsg); @@ -1217,8 +1251,11 @@ public class DatabaseConfig { try { stmt = txn.prepareAutoCloseStatement(selectSql); ResultSet rs = stmt.executeQuery(); - if (rs.next()) return rs.getLong(name); - else return -1; + if (rs.next()) { + return rs.getLong(name); + } else { + return -1; + } } catch (SQLException e) { System.out.println("Exception: " + e.getMessage()); printError(errorMsg); diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 7337a21d139..84da906dc4b 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2525,7 +2525,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager Object isAdmin = c.getCriteria(Criteria.ISADMIN); assert c.getCriteria(Criteria.IPADDRESS) == null : "We don't support search by ip address on VM any more. If you see this assert, it means we have to find a different way to search by the nic table."; Object groupId = c.getCriteria(Criteria.GROUPID); - Object useVirtualNetwork = c.getCriteria(Criteria.FOR_VIRTUAL_NETWORK); Object path = c.getCriteria(Criteria.PATH); Object networkId = c.getCriteria(Criteria.NETWORKID); Object hypervisor = c.getCriteria(Criteria.HYPERVISOR); @@ -2573,16 +2572,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager sb.join("nicSearch", nicSearch, sb.entity().getId(), nicSearch.entity().getInstanceId(), JoinBuilder.JoinType.INNER); } - if (useVirtualNetwork != null) { - SearchBuilder serviceSearch = _offeringDao.createSearchBuilder(); - if ((Boolean)useVirtualNetwork){ - serviceSearch.and("guestIpType", serviceSearch.entity().getGuestIpType(), SearchCriteria.Op.EQ); - } else { - serviceSearch.and("guestIpType", serviceSearch.entity().getGuestIpType(), SearchCriteria.Op.NEQ); - } - sb.join("serviceSearch", serviceSearch, sb.entity().getServiceOfferingId(), serviceSearch.entity().getId(), JoinBuilder.JoinType.INNER); - } - SearchBuilder accountRemoved = _accountDao.createSearchBuilder(); accountRemoved.and("accountremoved", accountRemoved.entity().getRemoved(), SearchCriteria.Op.NULL); sb.join("accountRemoved", accountRemoved, sb.entity().getAccountId(), accountRemoved.entity().getId(), JoinBuilder.JoinType.INNER); @@ -2596,10 +2585,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager sc.setJoinParameters("groupSearch", "groupId", groupId); } - if (useVirtualNetwork != null) { - sc.setJoinParameters("serviceSearch", "guestIpType", Network.GuestIpType.Virtual.toString()); - } - if (keyword != null) { SearchCriteria ssc = _vmDao.createSearchCriteria(); ssc.addOr("displayName", SearchCriteria.Op.LIKE, "%" + keyword + "%"); diff --git a/setup/db/create-index-fk.sql b/setup/db/create-index-fk.sql index 17861ececbc..5cc40dc0274 100755 --- a/setup/db/create-index-fk.sql +++ b/setup/db/create-index-fk.sql @@ -1,31 +1,14 @@ # This file is obsolete! Put what you need into create-schema.sql -ALTER TABLE `cloud`.`account_network_ref` ADD CONSTRAINT `fk_account_network_ref__account_id` FOREIGN KEY `fk_account_network_ref__account_id`(`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE; -ALTER TABLE `cloud`.`account_network_ref` ADD CONSTRAINT `fk_account_network_ref__networks_id` FOREIGN KEY `fk_account_network_ref__networks_id`(`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE; - ALTER TABLE `cloud`.`op_dc_ip_address_alloc` ADD INDEX `i_op_dc_ip_address_alloc__pod_id__data_center_id__taken` (`pod_id`, `data_center_id`, `taken`, `instance_id`); ALTER TABLE `cloud`.`op_dc_ip_address_alloc` ADD UNIQUE `i_op_dc_ip_address_alloc__ip_address__data_center_id`(`ip_address`, `data_center_id`); ALTER TABLE `cloud`.`op_dc_ip_address_alloc` ADD CONSTRAINT `fk_op_dc_ip_address_alloc__pod_id` FOREIGN KEY `fk_op_dc_ip_address_alloc__pod_id` (`pod_id`) REFERENCES `host_pod_ref` (`id`) ON DELETE CASCADE; ALTER TABLE `cloud`.`op_dc_ip_address_alloc` ADD INDEX `i_op_dc_ip_address_alloc__pod_id`(`pod_id`); -ALTER TABLE `cloud`.`host_pod_ref` ADD INDEX `i_host_pod_ref__data_center_id`(`data_center_id`); - ALTER TABLE `cloud`.`op_dc_vnet_alloc` ADD UNIQUE `i_op_dc_vnet_alloc__vnet__data_center_id__account_id`(`vnet`, `data_center_id`, `account_id`); ALTER TABLE `cloud`.`op_dc_vnet_alloc` ADD INDEX `i_op_dc_vnet_alloc__dc_taken`(`data_center_id`, `taken`); ALTER TABLE `cloud`.`op_dc_vnet_alloc` ADD UNIQUE `i_op_dc_vnet_alloc__vnet__data_center_id`(`vnet`, `data_center_id`); -ALTER TABLE `cloud`.`host` ADD INDEX `i_host__removed`(`removed`); -ALTER TABLE `cloud`.`host` ADD INDEX `i_host__last_ping`(`last_ping`); -ALTER TABLE `cloud`.`host` ADD INDEX `i_host__status`(`status`); -ALTER TABLE `cloud`.`host` ADD INDEX `i_host__data_center_id`(`data_center_id`); -ALTER TABLE `cloud`.`host` ADD CONSTRAINT `fk_host__pod_id` FOREIGN KEY `fk_host__pod_id` (`pod_id`) REFERENCES `host_pod_ref` (`id`) ON DELETE CASCADE; -ALTER TABLE `cloud`.`host` ADD INDEX `i_host__pod_id`(`pod_id`); -ALTER TABLE `cloud`.`host` ADD CONSTRAINT `fk_host__cluster_id` FOREIGN KEY `fk_host__cluster_id`(`cluster_id`) REFERENCES `cloud`.`cluster`(`id`); - -ALTER TABLE `cloud`.`op_host` ADD CONSTRAINT `fk_op_host__id` FOREIGN KEY `fk_op_host__id`(`id`) REFERENCES `host`(`id`) ON DELETE CASCADE; -ALTER TABLE `cloud`.`host_details` ADD CONSTRAINT `fk_host_details__host_id` FOREIGN KEY `fk_host_details__host_id`(`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE; -ALTER TABLE `cloud`.`host_tags` ADD CONSTRAINT `fk_host_tags__host_id` FOREIGN KEY `fk_host_tags__host_id`(`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE; - ALTER TABLE `cloud`.`storage_pool` ADD CONSTRAINT `fk_storage_pool__pod_id` FOREIGN KEY `fk_storage_pool__pod_id` (`pod_id`) REFERENCES `host_pod_ref` (`id`) ON DELETE CASCADE; ALTER TABLE `cloud`.`storage_pool` ADD INDEX `i_storage_pool__pod_id`(`pod_id`); ALTER TABLE `cloud`.`storage_pool` ADD CONSTRAINT `fk_storage_pool__cluster_id` FOREIGN KEY `fk_storage_pool__cluster_id`(`cluster_id`) REFERENCES `cloud`.`cluster`(`id`); @@ -57,12 +40,6 @@ ALTER TABLE `cloud`.`event` ADD INDEX `i_event__account_id` (`account_id`); ALTER TABLE `cloud`.`event` ADD INDEX `i_event__level_id`(`level`); ALTER TABLE `cloud`.`event` ADD INDEX `i_event__type_id`(`type`); -ALTER TABLE `cloud`.`cluster` ADD CONSTRAINT `fk_cluster__data_center_id` FOREIGN KEY `fk_cluster__data_center_id`(`data_center_id`) REFERENCES `cloud`.`data_center`(`id`); -ALTER TABLE `cloud`.`cluster` ADD CONSTRAINT `fk_cluster__pod_id` FOREIGN KEY `fd_cluster__pod_id`(`pod_id`) REFERENCES `cloud`.`host_pod_ref`(`id`); -ALTER TABLE `cloud`.`cluster` ADD UNIQUE `i_cluster__pod_id__name`(`pod_id`, `name`); - -ALTER TABLE `cloud`.`cluster_details` ADD CONSTRAINT `fk_cluster_details__cluster_id` FOREIGN KEY `fk_cluster_details__cluster_id`(`cluster_id`) REFERENCES `cluster`(`id`) ON DELETE CASCADE; - ALTER TABLE `cloud`.`vm_template` ADD INDEX `i_vm_template__removed`(`removed`); ALTER TABLE `cloud`.`vm_template` ADD INDEX `i_vm_template__public`(`public`); diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index a7679b2a2d3..5ed76e7b2e9 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -158,14 +158,14 @@ CREATE TABLE `cloud`.`networks` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - CREATE TABLE `cloud`.`account_network_ref` ( `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id', `account_id` bigint unsigned NOT NULL COMMENT 'account id', `network_id` bigint unsigned NOT NULL COMMENT 'network id', `is_owner` smallint(1) NOT NULL COMMENT 'is the owner of the network', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + CONSTRAINT `fk_account_network_ref__account_id` FOREIGN KEY (`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE, + CONSTRAINT `fk_account_network_ref__networks_id` FOREIGN KEY (`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`certificate` ( @@ -195,7 +195,7 @@ CREATE TABLE `cloud`.`nics` ( `device_id` int(10) COMMENT 'device id for the network when plugged into the virtual machine', `update_time` timestamp NOT NULL COMMENT 'time the state was changed', `isolation_uri` varchar(255) COMMENT 'id for isolation', - `ip6_address` varchar(32) COMMENT 'ip6 address', + `ip6_address` char(40) COMMENT 'ip6 address', `default_nic` tinyint NOT NULL COMMENT "None", `created` datetime NOT NULL COMMENT 'date created', `removed` datetime COMMENT 'date removed if not null', @@ -238,7 +238,10 @@ CREATE TABLE `cloud`.`cluster` ( `data_center_id` bigint unsigned NOT NULL COMMENT 'data center id', `hypervisor_type` varchar(32), `cluster_type` varchar(64) DEFAULT 'CloudManaged', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + CONSTRAINT `fk_cluster__data_center_id` FOREIGN KEY (`data_center_id`) REFERENCES `cloud`.`data_center`(`id`), + CONSTRAINT `fk_cluster__pod_id` FOREIGN KEY (`pod_id`) REFERENCES `cloud`.`host_pod_ref`(`id`), + UNIQUE `i_cluster__pod_id__name`(`pod_id`, `name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`cluster_details` ( @@ -246,7 +249,8 @@ CREATE TABLE `cloud`.`cluster_details` ( `cluster_id` bigint unsigned NOT NULL COMMENT 'cluster id', `name` varchar(255) NOT NULL, `value` varchar(255) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + CONSTRAINT `fk_cluster_details__cluster_id` FOREIGN KEY (`cluster_id`) REFERENCES `cluster`(`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`op_host_upgrade` ( @@ -464,7 +468,8 @@ CREATE TABLE `cloud`.`host_pod_ref` ( `description` varchar(255) COMMENT 'store private ip range in startIP-endIP format', `enabled` tinyint NOT NULL DEFAULT 1 COMMENT 'Is this Pod enabled for activity', PRIMARY KEY (`id`), - UNIQUE KEY (`name`, `data_center_id`) + UNIQUE KEY (`name`, `data_center_id`), + INDEX `i_host_pod_ref__data_center_id`(`data_center_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`op_dc_vnet_alloc` ( @@ -530,7 +535,6 @@ CREATE TABLE `cloud`.`port_forwarding_rules` ( CONSTRAINT `fk_port_forwarding_rules__id` FOREIGN KEY(`id`) REFERENCES `firewall_rules`(`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - CREATE TABLE `cloud`.`host` ( `id` bigint unsigned NOT NULL auto_increment, `name` varchar(255) NOT NULL, @@ -572,13 +576,21 @@ CREATE TABLE `cloud`.`host` ( `disconnected` datetime COMMENT 'Time this was disconnected', `created` datetime COMMENT 'date the host first signed on', `removed` datetime COMMENT 'date removed if not null', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + INDEX `i_host__removed`(`removed`), + INDEX `i_host__last_ping`(`last_ping`), + INDEX `i_host__status`(`status`), + INDEX `i_host__data_center_id`(`data_center_id`), + CONSTRAINT `fk_host__pod_id` FOREIGN KEY (`pod_id`) REFERENCES `host_pod_ref` (`id`) ON DELETE CASCADE, + INDEX `i_host__pod_id`(`pod_id`), + CONSTRAINT `fk_host__cluster_id` FOREIGN KEY (`cluster_id`) REFERENCES `cloud`.`cluster`(`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`op_host` ( `id` bigint unsigned NOT NULL UNIQUE COMMENT 'host id', `sequence` bigint unsigned DEFAULT 1 NOT NULL COMMENT 'sequence for the host communication', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + CONSTRAINT `fk_op_host__id` FOREIGN KEY (`id`) REFERENCES `host`(`id`) ON DELETE CASCADE ) ENGINE = InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`host_details` ( @@ -586,7 +598,8 @@ CREATE TABLE `cloud`.`host_details` ( `host_id` bigint unsigned NOT NULL COMMENT 'host id', `name` varchar(255) NOT NULL, `value` varchar(255) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + CONSTRAINT `fk_host_details__host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`mshost` ( @@ -606,7 +619,8 @@ CREATE TABLE `cloud`.`host_tags` ( `id` bigint unsigned NOT NULL auto_increment, `host_id` bigint unsigned NOT NULL COMMENT 'host id', `tag` varchar(255) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + CONSTRAINT `fk_host_tags__host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `cloud`.`user` ( @@ -779,12 +793,9 @@ CREATE TABLE `cloud`.`user_vm_details` ( CREATE TABLE `cloud`.`domain_router` ( `id` bigint unsigned UNIQUE NOT NULL COMMENT 'Primary Key', - `ram_size` int(10) unsigned NOT NULL DEFAULT 128 COMMENT 'memory to use in mb', - `domain` varchar(255) COMMENT 'domain', `public_mac_address` varchar(17) COMMENT 'mac address of the public facing network card', `public_ip_address` varchar(15) COMMENT 'public ip address used for source net', `public_netmask` varchar(15) COMMENT 'netmask used for the domR', - `guest_mac_address` varchar(17) COMMENT 'mac address of the pod facing network card', `guest_netmask` varchar(15) COMMENT 'netmask used for the guest network', `guest_ip_address` varchar(15) COMMENT ' ip address in the guest network', `network_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'network configuration that this domain router belongs to', @@ -1030,7 +1041,6 @@ CREATE TABLE `cloud`.`service_offering` ( `nw_rate` smallint unsigned default 200 COMMENT 'network rate throttle mbits/s', `mc_rate` smallint unsigned default 10 COMMENT 'mcast rate throttle mbits/s', `ha_enabled` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Enable HA', - `guest_ip_type` varchar(255) NOT NULL DEFAULT 'Virtualized' COMMENT 'Type of guest network -- direct or virtualized', `host_tag` varchar(255) COMMENT 'host tag specified by the service_offering', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;