cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject [48/91] [abbrv] [partial] Moved most of the VOs and DAOs from server package into engine-schema as well
Date Thu, 09 May 2013 00:20:59 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/cluster/dao/ManagementServerHostPeerDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/cluster/dao/ManagementServerHostPeerDaoImpl.java b/engine/schema/src/com/cloud/cluster/dao/ManagementServerHostPeerDaoImpl.java
new file mode 100644
index 0000000..8ad02cd
--- /dev/null
+++ b/engine/schema/src/com/cloud/cluster/dao/ManagementServerHostPeerDaoImpl.java
@@ -0,0 +1,108 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.cluster.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.cluster.ManagementServerHost;
+import com.cloud.cluster.ManagementServerHostPeerVO;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.Transaction;
+
+@Component
+@Local(value={ManagementServerHostPeerDao.class})
+public class ManagementServerHostPeerDaoImpl extends GenericDaoBase<ManagementServerHostPeerVO, Long> implements ManagementServerHostPeerDao {
+    private static final Logger s_logger = Logger.getLogger(ManagementServerHostPeerDaoImpl.class);
+    
+    private final SearchBuilder<ManagementServerHostPeerVO> ClearPeerSearch;
+    private final SearchBuilder<ManagementServerHostPeerVO> FindForUpdateSearch;
+    private final SearchBuilder<ManagementServerHostPeerVO> CountSearch;
+
+    public ManagementServerHostPeerDaoImpl() {
+        ClearPeerSearch = createSearchBuilder();
+        ClearPeerSearch.and("ownerMshost", ClearPeerSearch.entity().getOwnerMshost(), SearchCriteria.Op.EQ);
+        ClearPeerSearch.done();
+        
+        FindForUpdateSearch = createSearchBuilder();
+        FindForUpdateSearch.and("ownerMshost", FindForUpdateSearch.entity().getOwnerMshost(), SearchCriteria.Op.EQ);
+        FindForUpdateSearch.and("peerMshost", FindForUpdateSearch.entity().getPeerMshost(), SearchCriteria.Op.EQ);
+        FindForUpdateSearch.and("peerRunid", FindForUpdateSearch.entity().getPeerRunid(), SearchCriteria.Op.EQ);
+        FindForUpdateSearch.done();
+        
+        CountSearch = createSearchBuilder();
+        CountSearch.and("peerMshost", CountSearch.entity().getPeerMshost(), SearchCriteria.Op.EQ);
+        CountSearch.and("peerRunid", CountSearch.entity().getPeerRunid(), SearchCriteria.Op.EQ);
+        CountSearch.and("peerState", CountSearch.entity().getPeerState(), SearchCriteria.Op.EQ);
+        CountSearch.done();
+    }
+    
+    @Override
+    @DB
+    public void clearPeerInfo(long ownerMshost) {
+        SearchCriteria<ManagementServerHostPeerVO>  sc = ClearPeerSearch.create();
+        sc.setParameters("ownerMshost", ownerMshost);
+        
+        expunge(sc);
+    }
+    
+    @Override
+    @DB
+    public void updatePeerInfo(long ownerMshost, long peerMshost, long peerRunid, ManagementServerHost.State peerState) {
+        Transaction txn = Transaction.currentTxn();
+        try {
+            txn.start();
+        
+            SearchCriteria<ManagementServerHostPeerVO> sc = FindForUpdateSearch.create();
+            sc.setParameters("ownerMshost", ownerMshost);
+            sc.setParameters("peerMshost", peerMshost);
+            sc.setParameters("peerRunid", peerRunid);
+            List<ManagementServerHostPeerVO> l = listBy(sc);
+            if(l.size() == 1) {
+                ManagementServerHostPeerVO peer = l.get(0);
+                peer.setPeerState(peerState);
+                update(peer.getId(), peer);
+            } else {
+                ManagementServerHostPeerVO peer = new ManagementServerHostPeerVO(ownerMshost, peerMshost, peerRunid, peerState);
+                persist(peer);
+            }
+            txn.commit();
+        } catch(Exception e) {
+            s_logger.warn("Unexpected exception, ", e);
+            txn.rollback();
+        }
+    }
+    
+    @Override
+    @DB
+    public int countStateSeenInPeers(long mshost, long runid, ManagementServerHost.State state) {
+        SearchCriteria<ManagementServerHostPeerVO> sc = CountSearch.create();
+        sc.setParameters("peerMshost", mshost);
+        sc.setParameters("peerRunid", runid);
+        sc.setParameters("peerState", state);
+        
+        List<ManagementServerHostPeerVO> l = listBy(sc);
+        return l.size();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/configuration/dao/ConfigurationDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/configuration/dao/ConfigurationDao.java b/engine/schema/src/com/cloud/configuration/dao/ConfigurationDao.java
new file mode 100644
index 0000000..2b09901
--- /dev/null
+++ b/engine/schema/src/com/cloud/configuration/dao/ConfigurationDao.java
@@ -0,0 +1,69 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.configuration.dao;
+
+import java.util.Map;
+import java.util.List;
+
+import com.cloud.configuration.ConfigurationVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface ConfigurationDao extends GenericDao<ConfigurationVO, String> {
+	
+	/**
+	 * 
+	 *    1. params passed in.
+	 *    2. configuration for the instance.
+	 *    3. configuration for the DEFAULT instance.
+	 * 
+	 * @param params parameters from the components.xml which will override the database values.
+	 * @return a consolidated look at the configuration parameters.
+	 */
+    public Map<String, String> getConfiguration(String instance, Map<String, ? extends Object> params);
+    
+    public Map<String, String> getConfiguration(Map<String, ? extends Object> params);
+    
+    public Map<String, String> getConfiguration();
+    
+    /**
+     * Updates a configuration value
+     * @param value the new value
+     * @return true if success, false if failure
+     */
+    public boolean update(String name, String value);
+    
+    /**
+     * Gets the value for the specified configuration name
+     * @return value
+     */
+    public String getValue(String name);
+    
+    public String getValueAndInitIfNotExist(String name, String category, String initValue);
+    
+
+    /**
+     * returns whether or not this is a premium configuration
+     * @return true if premium configuration, false otherwise
+     */
+    boolean isPremium();
+    
+    ConfigurationVO findByName(String name);
+
+	boolean update(String name, String category, String value);
+	
+	void invalidateCache();
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/configuration/dao/ConfigurationDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/configuration/dao/ConfigurationDaoImpl.java b/engine/schema/src/com/cloud/configuration/dao/ConfigurationDaoImpl.java
new file mode 100644
index 0000000..fe5f5ae
--- /dev/null
+++ b/engine/schema/src/com/cloud/configuration/dao/ConfigurationDaoImpl.java
@@ -0,0 +1,225 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.configuration.dao;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.Local;
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.configuration.ConfigurationVO;
+import com.cloud.utils.component.ComponentLifecycle;
+import com.cloud.utils.crypt.DBEncryptionUtil;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.Transaction;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Component
+@Local(value={ConfigurationDao.class})
+public class ConfigurationDaoImpl extends GenericDaoBase<ConfigurationVO, String> implements ConfigurationDao {
+    private static final Logger s_logger = Logger.getLogger(ConfigurationDaoImpl.class);
+    private Map<String, String> _configs = null;
+    private boolean _premium;
+
+    final SearchBuilder<ConfigurationVO> InstanceSearch;
+    final SearchBuilder<ConfigurationVO> NameSearch;
+    
+    public static final String UPDATE_CONFIGURATION_SQL = "UPDATE configuration SET value = ? WHERE name = ?";
+
+    public ConfigurationDaoImpl () {
+        InstanceSearch = createSearchBuilder();
+        InstanceSearch.and("instance", InstanceSearch.entity().getInstance(), SearchCriteria.Op.EQ);
+        
+        NameSearch = createSearchBuilder();
+        NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
+        setRunLevel(ComponentLifecycle.RUN_LEVEL_SYSTEM_BOOTSTRAP);
+    }
+
+    @Override
+    public boolean isPremium() {
+        return _premium;
+    }
+    
+    @Override
+    public void invalidateCache() {
+    	_configs = null;
+    }
+
+    @Override
+    public Map<String, String> getConfiguration(String instance, Map<String, ? extends Object> params) {
+        if (_configs == null) {
+            _configs = new HashMap<String, String>();
+
+            SearchCriteria<ConfigurationVO> sc = InstanceSearch.create();
+            sc.setParameters("instance", "DEFAULT");
+
+            List<ConfigurationVO> configurations = listIncludingRemovedBy(sc);
+
+            for (ConfigurationVO config : configurations) {
+            	if (config.getValue() != null)
+            		_configs.put(config.getName(), config.getValue());
+            }
+
+            if(!"DEFAULT".equals(instance)){
+            	//Default instance params are already added, need not add again 
+            	sc = InstanceSearch.create();
+            	sc.setParameters("instance", instance);
+
+            	configurations = listIncludingRemovedBy(sc);
+
+            	for (ConfigurationVO config : configurations) {
+            		if (config.getValue() != null)
+            			_configs.put(config.getName(), config.getValue());
+            	}
+            }
+
+        }
+
+        mergeConfigs(_configs, params);
+        return _configs;
+    }
+
+    @Override
+    public Map<String, String> getConfiguration(Map<String, ? extends Object> params) {
+        return getConfiguration("DEFAULT", params);
+    }
+    
+    @Override
+    public Map<String, String> getConfiguration() {
+        return getConfiguration("DEFAULT", new HashMap<String, Object>());
+    }
+    
+    protected void mergeConfigs(Map<String, String> dbParams, Map<String, ? extends Object> xmlParams) {
+        for (Map.Entry<String, ? extends Object> param : xmlParams.entrySet()) {
+            dbParams.put(param.getKey(), (String)param.getValue());
+        }
+    }
+
+    @Override
+	public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+    	super.configure(name, params);
+
+    	Object premium = params.get("premium");
+        _premium = (premium != null) && ((String) premium).equals("true");
+
+        return true;
+    }
+
+    //Use update method with category instead
+    @Override @Deprecated
+    public boolean update(String name, String value) {
+    	Transaction txn = Transaction.currentTxn();
+		try {
+			PreparedStatement stmt = txn.prepareStatement(UPDATE_CONFIGURATION_SQL);
+			stmt.setString(1, value);
+			stmt.setString(2, name);
+			stmt.executeUpdate();
+			return true;
+		} catch (Exception e) {
+			s_logger.warn("Unable to update Configuration Value", e);
+		}
+		return false;
+    }
+
+    @Override
+    public boolean update(String name, String category, String value) {
+    	Transaction txn = Transaction.currentTxn();
+		try {
+			value = ("Hidden".equals(category) || "Secure".equals(category)) ? DBEncryptionUtil.encrypt(value) : value;
+			PreparedStatement stmt = txn.prepareStatement(UPDATE_CONFIGURATION_SQL);
+			stmt.setString(1, value);
+			stmt.setString(2, name);
+			stmt.executeUpdate();
+			return true;
+		} catch (Exception e) {
+			s_logger.warn("Unable to update Configuration Value", e);
+		}
+		return false;
+    }
+    
+    @Override
+    public String getValue(String name) {
+    	ConfigurationVO config =  findByName(name);
+        return (config == null) ? null : config.getValue();
+    }
+    
+    @Override
+    @DB
+    public String getValueAndInitIfNotExist(String name, String category, String initValue) {
+    	Transaction txn = Transaction.currentTxn();
+    	PreparedStatement stmt = null;
+    	PreparedStatement stmtInsert = null;
+    	String returnValue = initValue;
+		try {
+			txn.start();
+			stmt = txn.prepareAutoCloseStatement("SELECT value FROM configuration WHERE name=?");
+			stmt.setString(1, name);
+			ResultSet rs = stmt.executeQuery();
+			if(rs != null && rs.next()) {
+				returnValue =  rs.getString(1);
+				if(returnValue != null) {
+					txn.commit();
+					if("Hidden".equals(category) || "Secure".equals(category)){
+						return DBEncryptionUtil.decrypt(returnValue);
+					} else {
+						return returnValue;
+					}
+				} else {
+					// restore init value
+					returnValue = initValue;
+				}
+			}
+			stmt.close();
+
+			if("Hidden".equals(category) || "Secure".equals(category)){
+				initValue = DBEncryptionUtil.encrypt(initValue);
+			}
+			stmtInsert = txn.prepareAutoCloseStatement(
+				"INSERT INTO configuration(instance, name, value, description) VALUES('DEFAULT', ?, ?, '') ON DUPLICATE KEY UPDATE value=?");
+			stmtInsert.setString(1, name);
+			stmtInsert.setString(2, initValue);
+			stmtInsert.setString(3, initValue);
+			if(stmtInsert.executeUpdate() < 1) {
+				throw new CloudRuntimeException("Unable to init configuration variable: " + name); 
+			}
+			txn.commit();
+			return returnValue;
+		} catch (Exception e) {
+			s_logger.warn("Unable to update Configuration Value", e);
+			throw new CloudRuntimeException("Unable to init configuration variable: " + name); 
+		}
+    }
+    
+    @Override
+    public ConfigurationVO findByName(String name) {
+        SearchCriteria<ConfigurationVO> sc = NameSearch.create();
+        sc.setParameters("name", name);
+        return findOneIncludingRemovedBy(sc);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/configuration/dao/ResourceCountDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/configuration/dao/ResourceCountDao.java b/engine/schema/src/com/cloud/configuration/dao/ResourceCountDao.java
new file mode 100644
index 0000000..111bcb1
--- /dev/null
+++ b/engine/schema/src/com/cloud/configuration/dao/ResourceCountDao.java
@@ -0,0 +1,58 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.configuration.dao;
+
+import java.util.List;
+import java.util.Set;
+
+import com.cloud.configuration.Resource.ResourceOwnerType;
+import com.cloud.configuration.Resource.ResourceType;
+import com.cloud.configuration.ResourceCountVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface ResourceCountDao extends GenericDao<ResourceCountVO, Long> {
+	/**
+     * @param domainId the id of the domain to get the resource count
+     * @param type the type of resource (e.g. user_vm, public_ip, volume)
+     * @return the count of resources in use for the given type and domain
+     */
+	long getResourceCount(long ownerId, ResourceOwnerType ownerType, ResourceType type);
+
+    /**
+     * @param domainId the id of the domain to set the resource count
+     * @param type the type of resource (e.g. user_vm, public_ip, volume)
+     * @param the count of resources in use for the given type and domain
+     */
+	void setResourceCount(long ownerId, ResourceOwnerType ownerType, ResourceType type, long count);
+	
+	@Deprecated 
+	void updateDomainCount(long domainId, ResourceType type, boolean increment, long delta);
+
+    boolean updateById(long id, boolean increment, long delta);
+
+    void createResourceCounts(long ownerId, ResourceOwnerType ownerType);
+    
+    List<ResourceCountVO> listByOwnerId(long ownerId, ResourceOwnerType ownerType);
+    
+    ResourceCountVO findByOwnerAndType(long ownerId, ResourceOwnerType ownerType, ResourceType type);
+    
+    List<ResourceCountVO> listResourceCountByOwnerType(ResourceOwnerType ownerType);
+    
+    Set<Long> listAllRowsToUpdate(long ownerId, ResourceOwnerType ownerType, ResourceType type);
+
+    Set<Long> listRowsToUpdateForDomain(long domainId, ResourceType type);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java b/engine/schema/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java
new file mode 100644
index 0000000..52bc746
--- /dev/null
+++ b/engine/schema/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java
@@ -0,0 +1,222 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.configuration.dao;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.configuration.Resource;
+import com.cloud.configuration.Resource.ResourceOwnerType;
+import com.cloud.configuration.Resource.ResourceType;
+import com.cloud.configuration.ResourceCountVO;
+import com.cloud.configuration.ResourceLimit;
+import com.cloud.domain.dao.DomainDao;
+import com.cloud.domain.dao.DomainDaoImpl;
+import com.cloud.exception.UnsupportedServiceException;
+import com.cloud.user.dao.AccountDao;
+import com.cloud.user.dao.AccountDaoImpl;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.Transaction;
+
+@Component
+@Local(value={ResourceCountDao.class})
+public class ResourceCountDaoImpl extends GenericDaoBase<ResourceCountVO, Long> implements ResourceCountDao {
+    private final SearchBuilder<ResourceCountVO> TypeSearch;
+
+    private final SearchBuilder<ResourceCountVO> AccountSearch;
+    private final SearchBuilder<ResourceCountVO> DomainSearch;
+
+    @Inject protected DomainDao _domainDao;
+    @Inject protected AccountDao _accountDao;
+
+    public ResourceCountDaoImpl() {
+        TypeSearch = createSearchBuilder();
+        TypeSearch.and("type", TypeSearch.entity().getType(), SearchCriteria.Op.EQ);
+        TypeSearch.and("accountId", TypeSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
+        TypeSearch.and("domainId", TypeSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
+        TypeSearch.done();
+
+        AccountSearch = createSearchBuilder();
+        AccountSearch.and("accountId", AccountSearch.entity().getAccountId(), SearchCriteria.Op.NNULL);
+        AccountSearch.done();
+
+        DomainSearch = createSearchBuilder();
+        DomainSearch.and("domainId", DomainSearch.entity().getDomainId(), SearchCriteria.Op.NNULL);
+        DomainSearch.done();
+    }
+
+    @Override 
+    public ResourceCountVO findByOwnerAndType(long ownerId, ResourceOwnerType ownerType, ResourceType type) {
+        SearchCriteria<ResourceCountVO> sc = TypeSearch.create();
+        sc.setParameters("type", type);
+
+        if (ownerType == ResourceOwnerType.Account) {
+            sc.setParameters("accountId", ownerId);
+            return findOneIncludingRemovedBy(sc);
+        } else if (ownerType == ResourceOwnerType.Domain) {
+            sc.setParameters("domainId", ownerId);
+            return findOneIncludingRemovedBy(sc);
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public long getResourceCount(long ownerId, ResourceOwnerType ownerType, ResourceType type) {
+        ResourceCountVO vo = findByOwnerAndType(ownerId, ownerType, type);
+        if (vo != null) {
+            return vo.getCount();
+        } else {
+            return 0;
+        }
+    }
+
+    @Override 
+    public void setResourceCount(long ownerId, ResourceOwnerType ownerType, ResourceType type, long count) {
+        ResourceCountVO resourceCountVO = findByOwnerAndType(ownerId, ownerType, type);
+        if (count != resourceCountVO.getCount()) {
+            resourceCountVO.setCount(count);
+            update(resourceCountVO.getId(), resourceCountVO);
+        }
+    }
+
+    @Override @Deprecated
+    public void updateDomainCount(long domainId, ResourceType type, boolean increment, long delta) {
+        delta = increment ? delta : delta * -1;
+
+        ResourceCountVO resourceCountVO = findByOwnerAndType(domainId, ResourceOwnerType.Domain, type);
+        resourceCountVO.setCount(resourceCountVO.getCount() + delta);
+        update(resourceCountVO.getId(), resourceCountVO);	
+    }
+
+    @Override
+    public boolean updateById(long id, boolean increment, long delta) {
+        delta = increment ? delta : delta * -1;
+
+        ResourceCountVO resourceCountVO = findById(id);
+        resourceCountVO.setCount(resourceCountVO.getCount() + delta);
+        return update(resourceCountVO.getId(), resourceCountVO);
+    }
+
+    @Override
+    public Set<Long> listRowsToUpdateForDomain(long domainId, ResourceType type) {
+        Set<Long> rowIds = new HashSet<Long>();
+        Set<Long> domainIdsToUpdate = _domainDao.getDomainParentIds(domainId);
+        for (Long domainIdToUpdate : domainIdsToUpdate) {
+            ResourceCountVO domainCountRecord = findByOwnerAndType(domainIdToUpdate, ResourceOwnerType.Domain, type);
+            if (domainCountRecord != null) {
+                rowIds.add(domainCountRecord.getId());
+            }
+        }
+        return rowIds;
+    }
+
+    @Override
+    public Set<Long> listAllRowsToUpdate(long ownerId, ResourceOwnerType ownerType, ResourceType type) {
+        Set<Long> rowIds = new HashSet<Long>();
+
+        if (ownerType == ResourceOwnerType.Account) {
+            //get records for account
+            ResourceCountVO accountCountRecord = findByOwnerAndType(ownerId, ResourceOwnerType.Account, type);
+            if (accountCountRecord != null) {
+                rowIds.add(accountCountRecord.getId());
+            }
+
+            //get records for account's domain and all its parent domains
+            rowIds.addAll(listRowsToUpdateForDomain(_accountDao.findByIdIncludingRemoved(ownerId).getDomainId(),type));
+        } else if (ownerType == ResourceOwnerType.Domain) {
+            return listRowsToUpdateForDomain(ownerId, type);
+        } 
+
+        return rowIds;
+    }
+
+    @Override @DB
+    public void createResourceCounts(long ownerId, ResourceLimit.ResourceOwnerType ownerType){
+
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+
+        ResourceType[] resourceTypes = Resource.ResourceType.values();
+        for (ResourceType resourceType : resourceTypes) {
+            if (!resourceType.supportsOwner(ownerType)) {
+                continue;
+            }
+            ResourceCountVO resourceCountVO = new ResourceCountVO(resourceType, 0, ownerId, ownerType);
+            persist(resourceCountVO);
+        }
+
+        txn.commit();
+    }
+
+    private List<ResourceCountVO> listByDomainId(long domainId) {
+        SearchCriteria<ResourceCountVO> sc = TypeSearch.create();
+        sc.setParameters("domainId", domainId);
+
+        return listBy(sc);
+    }
+
+    private List<ResourceCountVO> listByAccountId(long accountId) {
+        SearchCriteria<ResourceCountVO> sc = TypeSearch.create();
+        sc.setParameters("accountId", accountId);
+
+        return listBy(sc);
+    }
+
+    @Override
+    public List<ResourceCountVO> listByOwnerId(long ownerId, ResourceOwnerType ownerType) {
+        if (ownerType == ResourceOwnerType.Account) {
+            return listByAccountId(ownerId);
+        } else if (ownerType == ResourceOwnerType.Domain) {
+            return listByDomainId(ownerId);
+        } else {
+            return new ArrayList<ResourceCountVO>();
+        }
+    }
+
+    @Override
+    public List<ResourceCountVO> listResourceCountByOwnerType(ResourceOwnerType ownerType) {
+        if (ownerType == ResourceOwnerType.Account) {
+            return listBy(AccountSearch.create());
+        } else if (ownerType == ResourceOwnerType.Domain) {
+            return listBy(DomainSearch.create());
+        } else {
+            return new ArrayList<ResourceCountVO>();
+        }
+    }
+
+    @Override
+    public ResourceCountVO persist(ResourceCountVO resourceCountVO){
+        ResourceOwnerType ownerType = resourceCountVO.getResourceOwnerType();
+        ResourceType resourceType = resourceCountVO.getType();
+        if (!resourceType.supportsOwner(ownerType)) {
+            throw new UnsupportedServiceException("Resource type " + resourceType + " is not supported for owner of type " + ownerType.getName());
+        }
+
+        return super.persist(resourceCountVO);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDao.java b/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDao.java
new file mode 100644
index 0000000..5fd79b3
--- /dev/null
+++ b/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDao.java
@@ -0,0 +1,35 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.configuration.dao;
+
+import java.util.List;
+
+import com.cloud.configuration.Resource.ResourceOwnerType;
+import com.cloud.configuration.ResourceCount;
+import com.cloud.configuration.ResourceLimitVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface ResourceLimitDao extends GenericDao<ResourceLimitVO, Long> {
+
+    List<ResourceLimitVO> listByOwner(Long ownerId, ResourceOwnerType ownerType);
+
+    boolean update(Long id, Long max);
+
+    ResourceCount.ResourceType getLimitType(String type);
+
+    ResourceLimitVO findByOwnerIdAndType(long ownerId, ResourceOwnerType ownerType, ResourceCount.ResourceType type);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDaoImpl.java b/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDaoImpl.java
new file mode 100644
index 0000000..d337070
--- /dev/null
+++ b/engine/schema/src/com/cloud/configuration/dao/ResourceLimitDaoImpl.java
@@ -0,0 +1,100 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.configuration.dao;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.configuration.Resource;
+import com.cloud.configuration.Resource.ResourceOwnerType;
+import com.cloud.configuration.Resource.ResourceType;
+import com.cloud.configuration.ResourceCount;
+import com.cloud.configuration.ResourceLimitVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Component
+@Local(value = { ResourceLimitDao.class })
+public class ResourceLimitDaoImpl extends GenericDaoBase<ResourceLimitVO, Long> implements ResourceLimitDao {
+    private SearchBuilder<ResourceLimitVO> IdTypeSearch;
+
+    public ResourceLimitDaoImpl() {
+        IdTypeSearch = createSearchBuilder();
+        IdTypeSearch.and("type", IdTypeSearch.entity().getType(), SearchCriteria.Op.EQ);
+        IdTypeSearch.and("domainId", IdTypeSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
+        IdTypeSearch.and("accountId", IdTypeSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
+        IdTypeSearch.done();
+    }
+
+    @Override
+    public List<ResourceLimitVO> listByOwner(Long ownerId, ResourceOwnerType ownerType) {
+        SearchCriteria<ResourceLimitVO> sc = IdTypeSearch.create();
+
+        if (ownerType == ResourceOwnerType.Account) {
+            sc.setParameters("accountId", ownerId);
+            return listBy(sc);
+        } else if (ownerType == ResourceOwnerType.Domain) {
+            sc.setParameters("domainId", ownerId);
+            return listBy(sc);
+        } else {
+            return new ArrayList<ResourceLimitVO>();
+        }
+    }
+
+    @Override
+    public boolean update(Long id, Long max) {
+        ResourceLimitVO limit = findById(id);
+        if (max != null)
+            limit.setMax(max);
+        else
+            limit.setMax(new Long(-1));
+        return update(id, limit);
+    }
+
+    @Override
+    public ResourceCount.ResourceType getLimitType(String type) {
+        ResourceType[] validTypes = Resource.ResourceType.values();
+
+        for (ResourceType validType : validTypes) {
+            if (validType.getName().equals(type)) {
+                return validType;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public ResourceLimitVO findByOwnerIdAndType(long ownerId, ResourceOwnerType ownerType, ResourceCount.ResourceType type) {
+        SearchCriteria<ResourceLimitVO> sc = IdTypeSearch.create();
+        sc.setParameters("type", type);
+
+        if (ownerType == ResourceOwnerType.Account) {
+            sc.setParameters("accountId", ownerId);
+            return findOneBy(sc);
+        } else if (ownerType == ResourceOwnerType.Domain) {
+            sc.setParameters("domainId", ownerId);
+            return findOneBy(sc);
+        } else {
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/dc/AccountVlanMapVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/AccountVlanMapVO.java b/engine/schema/src/com/cloud/dc/AccountVlanMapVO.java
new file mode 100644
index 0000000..b1bf919
--- /dev/null
+++ b/engine/schema/src/com/cloud/dc/AccountVlanMapVO.java
@@ -0,0 +1,65 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.dc;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.user.OwnedBy;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="account_vlan_map")
+public class AccountVlanMapVO implements OwnedBy, InternalIdentity {
+	    
+	@Id
+	@GeneratedValue(strategy=GenerationType.IDENTITY)
+	@Column(name="id")
+	private long id;
+	
+	@Column(name="account_id")
+	private long accountId;
+	
+	@Column(name="vlan_db_id")
+	private long vlanDbId;
+	
+	public AccountVlanMapVO(long accountId, long vlanDbId) {
+		this.accountId = accountId;
+		this.vlanDbId = vlanDbId;
+	}
+	
+	public AccountVlanMapVO() {
+		
+	}
+	
+	public long getId() {
+		return id;
+	}
+
+	@Override
+	public long getAccountId() {
+		return accountId;
+	}
+	
+	public long getVlanDbId() {
+		return vlanDbId;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/dc/ClusterDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/ClusterDetailsDao.java b/engine/schema/src/com/cloud/dc/ClusterDetailsDao.java
new file mode 100644
index 0000000..2c7e241
--- /dev/null
+++ b/engine/schema/src/com/cloud/dc/ClusterDetailsDao.java
@@ -0,0 +1,32 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.dc;
+
+import java.util.Map;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface ClusterDetailsDao extends GenericDao<ClusterDetailsVO, Long> {
+    Map<String, String> findDetails(long clusterId);
+    
+    void persist(long clusterId, Map<String, String> details);
+    void persist(long clusterId, String name, String value);
+    
+    ClusterDetailsVO findDetail(long clusterId, String name);
+
+	void deleteDetails(long clusterId);
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/dc/ClusterDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/ClusterDetailsDaoImpl.java b/engine/schema/src/com/cloud/dc/ClusterDetailsDaoImpl.java
new file mode 100755
index 0000000..d14e0e4
--- /dev/null
+++ b/engine/schema/src/com/cloud/dc/ClusterDetailsDaoImpl.java
@@ -0,0 +1,133 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.dc;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.crypt.DBEncryptionUtil;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.Transaction;
+
+@Component
+@Local(value=ClusterDetailsDao.class)
+public class ClusterDetailsDaoImpl extends GenericDaoBase<ClusterDetailsVO, Long> implements ClusterDetailsDao {
+    protected final SearchBuilder<ClusterDetailsVO> ClusterSearch;
+    protected final SearchBuilder<ClusterDetailsVO> DetailSearch;
+
+    protected ClusterDetailsDaoImpl() {
+        ClusterSearch = createSearchBuilder();
+        ClusterSearch.and("clusterId", ClusterSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
+        ClusterSearch.done();
+
+        DetailSearch = createSearchBuilder();
+        DetailSearch.and("clusterId", DetailSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
+        DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ);
+        DetailSearch.done();
+    }
+
+    @Override
+    public ClusterDetailsVO findDetail(long clusterId, String name) {
+        SearchCriteria<ClusterDetailsVO> sc = DetailSearch.create();
+        // This is temporary fix to support list/update configuration api for cpu and memory overprovisioning ratios
+        if(name.equalsIgnoreCase("cpu.overprovisioning.factor")) {
+            name = "cpuOvercommitRatio";
+        }
+        if (name.equalsIgnoreCase("mem.overprovisioning.factor")) {
+            name = "memoryOvercommitRatio";
+        }
+        sc.setParameters("clusterId", clusterId);
+        sc.setParameters("name", name);
+
+
+        ClusterDetailsVO detail = findOneIncludingRemovedBy(sc);
+        if("password".equals(name) && detail != null){
+            detail.setValue(DBEncryptionUtil.decrypt(detail.getValue()));
+        }
+        return detail;
+    }
+
+
+    @Override
+    public Map<String, String> findDetails(long clusterId) {
+        SearchCriteria<ClusterDetailsVO> sc = ClusterSearch.create();
+        sc.setParameters("clusterId", clusterId);
+
+        List<ClusterDetailsVO> results = search(sc, null);
+        Map<String, String> details = new HashMap<String, String>(results.size());
+        for (ClusterDetailsVO result : results) {
+            if("password".equals(result.getName())){
+                details.put(result.getName(), DBEncryptionUtil.decrypt(result.getValue()));
+            } else {
+                details.put(result.getName(), result.getValue());
+            }
+        }
+        return details;
+    }
+
+    @Override
+    public void deleteDetails(long clusterId) {
+        SearchCriteria sc = ClusterSearch.create();
+        sc.setParameters("clusterId", clusterId);
+
+        List<ClusterDetailsVO> results = search(sc, null);
+        for (ClusterDetailsVO result : results) {
+            remove(result.getId());
+        }
+    }
+
+    @Override
+    public void persist(long clusterId, Map<String, String> details) {
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        SearchCriteria<ClusterDetailsVO> sc = ClusterSearch.create();
+        sc.setParameters("clusterId", clusterId);
+        expunge(sc);
+
+        for (Map.Entry<String, String> detail : details.entrySet()) {
+            String value = detail.getValue();
+            if("password".equals(detail.getKey())){
+                value = DBEncryptionUtil.encrypt(value);
+            }
+            ClusterDetailsVO vo = new ClusterDetailsVO(clusterId, detail.getKey(), value);
+            persist(vo);
+        }
+        txn.commit();
+    }
+
+    @Override
+    public void persist(long clusterId, String name, String value) {
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        SearchCriteria<ClusterDetailsVO> sc = DetailSearch.create();
+        sc.setParameters("clusterId", clusterId);
+        sc.setParameters("name", name);
+        expunge(sc);
+
+        ClusterDetailsVO vo = new ClusterDetailsVO(clusterId, name, value);
+        persist(vo);
+        txn.commit();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/dc/ClusterDetailsVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/ClusterDetailsVO.java b/engine/schema/src/com/cloud/dc/ClusterDetailsVO.java
new file mode 100644
index 0000000..11a5525
--- /dev/null
+++ b/engine/schema/src/com/cloud/dc/ClusterDetailsVO.java
@@ -0,0 +1,74 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.dc;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="cluster_details")
+public class ClusterDetailsVO implements InternalIdentity {
+
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+    
+    @Column(name="cluster_id")
+    private long clusterId;
+    
+    @Column(name="name")
+    private String name;
+    
+    @Column(name="value")
+    private String value;
+    
+    protected ClusterDetailsVO() {
+    }
+    
+    public ClusterDetailsVO(long clusterId, String name, String value) {
+        this.clusterId = clusterId;
+        this.name = name;
+        this.value = value;
+    }
+
+    public long getClusterId() {
+        return clusterId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public long getId() {
+        return id;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/dc/ClusterVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/ClusterVO.java b/engine/schema/src/com/cloud/dc/ClusterVO.java
new file mode 100644
index 0000000..4195b74
--- /dev/null
+++ b/engine/schema/src/com/cloud/dc/ClusterVO.java
@@ -0,0 +1,189 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.dc;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.Identity;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.org.Cluster;
+import com.cloud.org.Managed.ManagedState;
+import com.cloud.org.Grouping;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="cluster")
+public class ClusterVO implements Cluster {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name="id")
+    long id;
+
+    @Column(name="name")
+    String name;
+
+    @Column(name="guid")
+    String guid;
+
+    @Column(name="data_center_id")
+    long dataCenterId;
+
+    @Column(name="pod_id")
+    long podId;
+
+    @Column(name="hypervisor_type")
+    String hypervisorType;
+
+    @Column(name="cluster_type")
+    @Enumerated(value=EnumType.STRING)
+    Cluster.ClusterType clusterType;
+
+    @Column(name="allocation_state")
+    @Enumerated(value=EnumType.STRING)
+    AllocationState allocationState;
+
+    @Column(name="managed_state")
+    @Enumerated(value=EnumType.STRING)
+    ManagedState managedState;
+
+    @Column(name=GenericDao.REMOVED_COLUMN)
+    private Date removed;
+
+    @Column(name="uuid")
+    String uuid;
+
+    public ClusterVO() {
+    	clusterType = Cluster.ClusterType.CloudManaged;
+    	allocationState = Grouping.AllocationState.Enabled;
+
+    	this.uuid = UUID.randomUUID().toString();
+    }
+
+    public ClusterVO(long dataCenterId, long podId, String name) {
+        this.dataCenterId = dataCenterId;
+        this.podId = podId;
+        this.name = name;
+    	this.clusterType = Cluster.ClusterType.CloudManaged;
+    	this.allocationState = Grouping.AllocationState.Enabled;
+    	this.managedState = ManagedState.Managed;
+    	this.uuid = UUID.randomUUID().toString();
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public long getDataCenterId() {
+        return dataCenterId;
+    }
+
+    public long getPodId() {
+        return podId;
+    }
+
+    public Cluster.ClusterType getClusterType() {
+    	return clusterType;
+    }
+
+    public void setClusterType(Cluster.ClusterType clusterType) {
+    	this.clusterType = clusterType;
+    }
+
+    public AllocationState getAllocationState() {
+    	return allocationState;
+    }
+
+    public void setAllocationState(AllocationState allocationState) {
+		this.allocationState = allocationState;
+    }
+
+    public ManagedState getManagedState() {
+        return managedState;
+    }
+
+    public void setManagedState(ManagedState managedState) {
+        this.managedState = managedState;
+    }
+
+    public ClusterVO(long clusterId) {
+        this.id = clusterId;
+    }
+
+    @Override
+    public int hashCode() {
+        return NumbersUtil.hash(id);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof ClusterVO)) {
+            return false;
+        }
+        ClusterVO that = (ClusterVO)obj;
+        return this.id == that.id;
+    }
+
+    public HypervisorType getHypervisorType() {
+    	return HypervisorType.getType(hypervisorType);
+    }
+
+	public void setHypervisorType(String hy) {
+    	hypervisorType = hy;
+    }
+
+    public String getGuid() {
+        return guid;
+    }
+
+    public void setGuid(String guid) {
+        this.guid = guid;
+    }
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public String getUuid() {
+    	return this.uuid;
+    }
+
+    public void setUuid(String uuid) {
+    	this.uuid = uuid;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/dc/ClusterVSMMapVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/ClusterVSMMapVO.java b/engine/schema/src/com/cloud/dc/ClusterVSMMapVO.java
new file mode 100644
index 0000000..a7fe748
--- /dev/null
+++ b/engine/schema/src/com/cloud/dc/ClusterVSMMapVO.java
@@ -0,0 +1,62 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.dc;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+
+
+// NOTE: This particular table is totally internal to the CS MS.
+// Do not ever include a uuid/guid field in this table. We just
+// need it map cluster Ids with Cisco Nexus VSM Ids.
+
+@Entity
+@Table(name="cluster_vsm_map")
+public class ClusterVSMMapVO {
+
+    @Column(name="cluster_id")
+    long clusterId;
+    
+    @Column(name="vsm_id")
+    long vsmId;
+    
+    public ClusterVSMMapVO(long clusterId, long vsmId) {
+        this.clusterId = clusterId;
+        this.vsmId = vsmId;
+    }
+    
+    public ClusterVSMMapVO() {
+    	// Do nothing.
+    }  
+
+    public long getClusterId() {
+        return clusterId;
+    }
+
+    public long getVsmId() {
+        return vsmId;
+    }
+    
+    public void setClusterId(long clusterId) {
+        this.clusterId = clusterId;
+    }
+
+    public void setVsmId(long vsmId) {
+        this.vsmId = vsmId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/dc/DataCenterIpAddressVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/DataCenterIpAddressVO.java b/engine/schema/src/com/cloud/dc/DataCenterIpAddressVO.java
new file mode 100755
index 0000000..d92227f
--- /dev/null
+++ b/engine/schema/src/com/cloud/dc/DataCenterIpAddressVO.java
@@ -0,0 +1,115 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.dc;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+@Table(name="op_dc_ip_address_alloc")
+public class DataCenterIpAddressVO implements InternalIdentity {
+
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    long id;
+    
+    @Column(name="ip_address", updatable=false, nullable=false)
+    String ipAddress;
+    
+    @Column(name="taken")
+    @Temporal(value=TemporalType.TIMESTAMP)
+    private Date takenAt;
+    
+    @Column(name="data_center_id", updatable=false, nullable=false)
+    private long dataCenterId;
+    
+    @Column(name="pod_id", updatable=false, nullable=false)
+    private long podId;
+    
+    @Column(name="reservation_id")
+    String reservationId;
+    
+    @Column(name="nic_id")
+    private Long instanceId;
+    
+    @Column(name="mac_address")
+    long macAddress;
+    
+    protected DataCenterIpAddressVO() {
+    }
+    
+    public String getReservationId() {
+        return reservationId;
+    }
+
+    public void setReservationId(String reservationId) {
+        this.reservationId = reservationId;
+    }
+
+	public DataCenterIpAddressVO(String ipAddress, long dataCenterId, long podId) {
+        this.ipAddress = ipAddress;
+        this.dataCenterId = dataCenterId;
+        this.podId = podId;
+    }
+    
+    public long getId() {
+        return id;
+    }
+    
+    public Long getInstanceId() {
+    	return instanceId;
+    }
+    
+    public void setInstanceId(Long instanceId) {
+    	this.instanceId = instanceId;
+    }
+
+    public long getPodId() {
+        return podId;
+    }
+
+    public void setTakenAt(Date takenDate) {
+        this.takenAt = takenDate;
+    }
+
+    public String getIpAddress() {
+        return ipAddress;
+    }
+    
+    public long getDataCenterId() {
+        return dataCenterId;
+    }
+
+    public Date getTakenAt() {
+        return takenAt;
+    }
+    
+    public long getMacAddress() {
+        return macAddress;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/dc/DataCenterLinkLocalIpAddressVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/DataCenterLinkLocalIpAddressVO.java b/engine/schema/src/com/cloud/dc/DataCenterLinkLocalIpAddressVO.java
new file mode 100644
index 0000000..ffa7549
--- /dev/null
+++ b/engine/schema/src/com/cloud/dc/DataCenterLinkLocalIpAddressVO.java
@@ -0,0 +1,108 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.dc;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+@Table(name="op_dc_link_local_ip_address_alloc")
+public class DataCenterLinkLocalIpAddressVO implements InternalIdentity {
+
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    long id;
+    
+    @Column(name="ip_address", updatable=false, nullable=false)
+    String ipAddress;
+    
+    @Column(name="taken")
+    @Temporal(value=TemporalType.TIMESTAMP)
+    private Date takenAt;
+    
+    @Column(name="data_center_id", updatable=false, nullable=false)
+    private long dataCenterId;
+    
+    @Column(name="pod_id", updatable=false, nullable=false)
+    private long podId;
+    
+    @Column(name="nic_id")
+    private Long instanceId;
+    
+    @Column(name="reservation_id")
+    private String reservationId;
+    
+    protected DataCenterLinkLocalIpAddressVO() {
+    }
+    
+    public DataCenterLinkLocalIpAddressVO(String ipAddress, long dataCenterId, long podId) {
+        this.ipAddress = ipAddress;
+        this.dataCenterId = dataCenterId;
+        this.podId = podId;
+    }
+    
+    public long getId() {
+        return id;
+    }
+    
+    public Long getInstanceId() {
+    	return instanceId;
+    }
+    
+    public void setInstanceId(Long instanceId) {
+    	this.instanceId = instanceId;
+    }
+
+    public long getPodId() {
+        return podId;
+    }
+
+    public void setTakenAt(Date takenDate) {
+        this.takenAt = takenDate;
+    }
+    
+    public void setReservationId(String reservationId) {
+        this.reservationId = reservationId;
+    }
+    
+    public String getReservationId() {
+        return reservationId;
+    }
+
+    public String getIpAddress() {
+        return ipAddress;
+    }
+    
+    public long getDataCenterId() {
+        return dataCenterId;
+    }
+
+    public Date getTakenAt() {
+        return takenAt;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/dc/DataCenterVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/DataCenterVO.java b/engine/schema/src/com/cloud/dc/DataCenterVO.java
new file mode 100644
index 0000000..6da13e7
--- /dev/null
+++ b/engine/schema/src/com/cloud/dc/DataCenterVO.java
@@ -0,0 +1,460 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.dc;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import javax.persistence.Transient;
+
+import org.apache.cloudstack.api.Identity;
+import com.cloud.network.Network.Provider;
+import com.cloud.org.Grouping;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name="data_center")
+public class DataCenterVO implements DataCenter {
+
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+	@Column(name="name")
+	private String name = null;
+
+    @Column(name="description")
+    private String description = null;
+
+    @Column(name="dns1")
+    private String dns1 = null;
+
+    @Column(name="dns2")
+    private String dns2 = null;
+
+    @Column(name="ip6_dns1")
+    private String ip6Dns1 = null;
+
+    @Column(name="ip6_dns2")
+    private String ip6Dns2 = null;
+
+    @Column(name="internal_dns1")
+    private String internalDns1 = null;
+
+    @Column(name="internal_dns2")
+    private String internalDns2 = null;
+
+    @Column(name="router_mac_address", updatable = false, nullable=false)
+    private String routerMacAddress = "02:00:00:00:00:01";
+
+    @Column(name="guest_network_cidr")
+    private String guestNetworkCidr = null;
+
+    @Column(name="domain_id")
+    private Long domainId = null;
+
+    @Column(name="domain")
+    private String domain;
+
+    @Column(name="networktype")
+    @Enumerated(EnumType.STRING)
+    NetworkType networkType;
+
+    @Column(name="dns_provider")
+    private String dnsProvider;
+
+    @Column(name="dhcp_provider")
+    private String dhcpProvider;
+
+    @Column(name="gateway_provider")
+    private String gatewayProvider;
+
+    @Column(name="vpn_provider")
+    private String vpnProvider;
+
+    @Column(name="userdata_provider")
+    private String userDataProvider;
+
+    @Column(name="lb_provider")
+    private String loadBalancerProvider;
+
+    @Column(name="firewall_provider")
+    private String firewallProvider;
+
+    @Column(name="mac_address", nullable=false)
+    @TableGenerator(name="mac_address_sq", table="data_center", pkColumnName="id", valueColumnName="mac_address", allocationSize=1)
+    private long macAddress = 1;
+
+	@Column(name="zone_token")
+	private String zoneToken;
+
+    @Column(name=GenericDao.REMOVED_COLUMN)
+    private Date removed;
+
+    // This is a delayed load value.  If the value is null,
+    // then this field has not been loaded yet.
+    // Call the dao to load it.
+    @Transient
+    Map<String, String> details;
+
+    @Column(name="allocation_state")
+    @Enumerated(value=EnumType.STRING)
+    AllocationState allocationState;
+
+	@Column(name="uuid")
+	private String uuid;
+
+    @Column(name="is_security_group_enabled")
+    boolean securityGroupEnabled;
+
+    @Column(name="is_local_storage_enabled")
+    boolean localStorageEnabled;
+
+    @Override
+    public String getDnsProvider() {
+        return dnsProvider;
+    }
+
+    public void setDnsProvider(String dnsProvider) {
+        this.dnsProvider = dnsProvider;
+    }
+
+    @Override
+    public String getDhcpProvider() {
+        return dhcpProvider;
+    }
+
+    public void setDhcpProvider(String dhcpProvider) {
+        this.dhcpProvider = dhcpProvider;
+    }
+
+    @Override
+    public String getGatewayProvider() {
+        return gatewayProvider;
+    }
+
+    public void setGatewayProvider(String gatewayProvider) {
+        this.gatewayProvider = gatewayProvider;
+    }
+
+    @Override
+    public String getLoadBalancerProvider() {
+        return loadBalancerProvider;
+    }
+
+    public void setLoadBalancerProvider(String loadBalancerProvider) {
+        this.loadBalancerProvider = loadBalancerProvider;
+    }
+
+    @Override
+    public String getFirewallProvider() {
+        return firewallProvider;
+    }
+
+    public void setFirewallProvider(String firewallProvider) {
+        this.firewallProvider = firewallProvider;
+    }
+
+    public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix) {
+        this(name, description, dns1, dns2, dns3, dns4, guestCidr, domain, domainId, zoneType, zoneToken, domainSuffix, false, false, null, null);
+        this.id = id;
+        this.allocationState = Grouping.AllocationState.Enabled;
+        this.uuid = UUID.randomUUID().toString();
+	}
+
+    public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String guestCidr, String domain, Long domainId, NetworkType zoneType, String zoneToken, String domainSuffix, boolean securityGroupEnabled, boolean localStorageEnabled, String ip6Dns1, String ip6Dns2) {
+        this.name = name;
+        this.description = description;
+        this.dns1 = dns1;
+        this.dns2 = dns2;
+        this.ip6Dns1 = ip6Dns1;
+        this.ip6Dns2 = ip6Dns2;
+        this.internalDns1 = dns3;
+        this.internalDns2 = dns4;
+        this.guestNetworkCidr = guestCidr;
+        this.domain = domain;
+        this.domainId = domainId;
+        this.networkType = zoneType;
+        this.allocationState = Grouping.AllocationState.Enabled;
+        this.securityGroupEnabled = securityGroupEnabled;
+        this.localStorageEnabled = localStorageEnabled;
+
+        if (zoneType == NetworkType.Advanced) {
+            loadBalancerProvider = Provider.VirtualRouter.getName();
+            firewallProvider = Provider.VirtualRouter.getName();
+            dhcpProvider = Provider.VirtualRouter.getName();
+            dnsProvider = Provider.VirtualRouter.getName();
+            gatewayProvider = Provider.VirtualRouter.getName();
+            vpnProvider = Provider.VirtualRouter.getName();
+            userDataProvider = Provider.VirtualRouter.getName();
+        } else if (zoneType == NetworkType.Basic){
+            dhcpProvider = Provider.VirtualRouter.getName();
+            dnsProvider = Provider.VirtualRouter.getName();
+            userDataProvider = Provider.VirtualRouter.getName();
+            loadBalancerProvider = Provider.ElasticLoadBalancerVm.getName();
+        }
+
+        this.zoneToken = zoneToken;
+        this.domain = domainSuffix;
+        this.uuid = UUID.randomUUID().toString();
+    }
+
+    @Override
+    public String getVpnProvider() {
+        return vpnProvider;
+    }
+
+    public void setVpnProvider(String vpnProvider) {
+        this.vpnProvider = vpnProvider;
+    }
+
+    @Override
+    public String getUserDataProvider() {
+        return userDataProvider;
+    }
+
+    public void setUserDataProvider(String userDataProvider) {
+        this.userDataProvider = userDataProvider;
+    }
+
+    @Override
+    public String getGuestNetworkCidr()
+    {
+    	return guestNetworkCidr;
+    }
+
+    public void setGuestNetworkCidr(String guestNetworkCidr)
+    {
+    	this.guestNetworkCidr = guestNetworkCidr;
+    }
+
+    @Override
+    public Long getDomainId() {
+		return domainId;
+	}
+
+	public void setDomainId(Long domainId) {
+		this.domainId = domainId;
+	}
+
+    @Override
+    public String getDescription() {
+        return description;
+    }
+
+    public String getRouterMacAddress() {
+        return routerMacAddress;
+    }
+
+    @Override
+    public String getDns1() {
+        return dns1;
+    }
+
+    @Override
+    public String getDns2() {
+        return dns2;
+    }
+
+    @Override
+    public String getInternalDns1() {
+        return internalDns1;
+    }
+
+    @Override
+    public String getInternalDns2() {
+        return internalDns2;
+    }
+
+	protected DataCenterVO() {
+    }
+
+	@Override
+    public long getId() {
+		return id;
+	}
+
+	@Override
+    public String getName() {
+	    return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public void setDns1(String dns1) {
+		this.dns1 = dns1;
+	}
+
+	public void setDns2(String dns2) {
+		this.dns2 = dns2;
+	}
+
+	public void setInternalDns1(String dns3) {
+		this.internalDns1 = dns3;
+	}
+
+	public void setInternalDns2(String dns4) {
+		this.internalDns2 = dns4;
+	}
+
+    public void setRouterMacAddress(String routerMacAddress) {
+        this.routerMacAddress = routerMacAddress;
+    }
+
+    @Override
+    public String getDomain() {
+        return domain;
+    }
+
+    public void setDomain(String domain) {
+        this.domain = domain;
+    }
+
+    public void setNetworkType(NetworkType zoneNetworkType) {
+        this.networkType = zoneNetworkType;
+    }
+
+    @Override
+    public NetworkType getNetworkType() {
+        return networkType;
+    }
+
+    @Override
+    public boolean isSecurityGroupEnabled() {
+        return securityGroupEnabled;
+    }
+
+    public void setSecurityGroupEnabled(boolean enabled) {
+        this.securityGroupEnabled = enabled;
+    }
+
+    @Override
+    public boolean isLocalStorageEnabled() {
+        return localStorageEnabled;
+    }
+
+    public void setLocalStorageEnabled(boolean enabled) {
+        this.localStorageEnabled = enabled;
+    }
+
+    @Override
+    public Map<String, String> getDetails() {
+        return details;
+    }
+
+    @Override
+    public void setDetails(Map<String, String> details2) {
+        details = details2;
+    }
+
+    public String getDetail(String name) {
+        assert (details != null) : "Did you forget to load the details?";
+
+        return details != null ? details.get(name) : null;
+    }
+
+    public void setDetail(String name, String value) {
+        assert (details != null) : "Did you forget to load the details?";
+
+        details.put(name, value);
+    }
+
+    public AllocationState getAllocationState() {
+    	return allocationState;
+    }
+
+    public void setAllocationState(AllocationState allocationState) {
+		this.allocationState = allocationState;
+    }
+
+    @Override
+    public int hashCode() {
+        return NumbersUtil.hash(id);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof DataCenterVO)) {
+            return false;
+        }
+        DataCenterVO that = (DataCenterVO)obj;
+        return this.id == that.id;
+    }
+
+    @Override
+    public String getZoneToken() {
+ 	    return zoneToken;
+ 	}
+
+ 	public void setZoneToken(String zoneToken) {
+ 		this.zoneToken = zoneToken;
+ 	}
+
+ 	public Date getRemoved() {
+ 	    return removed;
+ 	}
+
+ 	@Override
+ 	public String getUuid() {
+ 		return this.uuid;
+ 	}
+
+ 	public void setUuid(String uuid) {
+ 		this.uuid = uuid;
+ 	}
+
+    public long getMacAddress() {
+        return macAddress;
+    }
+
+    public void setMacAddress(long macAddress) {
+        this.macAddress = macAddress;
+    }
+
+ 	@Override
+	public String getIp6Dns1() {
+		return ip6Dns1;
+	}
+
+	public void setIp6Dns1(String ip6Dns1) {
+		this.ip6Dns1 = ip6Dns1;
+	}
+
+ 	@Override
+	public String getIp6Dns2() {
+		return ip6Dns2;
+	}
+
+	public void setIp6Dns2(String ip6Dns2) {
+		this.ip6Dns2 = ip6Dns2;
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/dc/DataCenterVnetVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/DataCenterVnetVO.java b/engine/schema/src/com/cloud/dc/DataCenterVnetVO.java
new file mode 100755
index 0000000..9bae132
--- /dev/null
+++ b/engine/schema/src/com/cloud/dc/DataCenterVnetVO.java
@@ -0,0 +1,120 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.dc;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+@Table(name="op_dc_vnet_alloc")
+public class DataCenterVnetVO implements InternalIdentity {
+    
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    long id;
+    
+    @Column(name="taken", nullable=true)
+    @Temporal(value=TemporalType.TIMESTAMP)
+    Date takenAt;
+
+    @Column(name="vnet", updatable=false, nullable=false)
+    protected String vnet;
+
+    @Column(name="physical_network_id", updatable=false, nullable=false)
+    protected long physicalNetworkId;
+
+    @Column(name="data_center_id", updatable=false, nullable=false)
+    protected long dataCenterId;
+
+    @Column(name="account_id")
+    protected Long accountId;
+    
+    @Column(name="reservation_id")
+    protected String reservationId;
+
+    @Column(name="account_vnet_map_id")
+    protected Long accountGuestVlanMapId;
+    
+    public Date getTakenAt() {
+        return takenAt;
+    }
+
+    public void setTakenAt(Date taken) {
+        this.takenAt = taken;
+    }
+
+    public DataCenterVnetVO(String vnet, long dcId, long physicalNetworkId) {
+        this.vnet = vnet;
+        this.dataCenterId = dcId;
+        this.physicalNetworkId = physicalNetworkId;
+        this.takenAt = null;
+    }
+    
+    public long getId() {
+        return id;
+    }
+    
+    public String getVnet() {
+        return vnet;
+    }
+    
+    public String getReservationId() {
+        return reservationId;
+    }
+    
+    public void setReservationId(String reservationId) {
+        this.reservationId = reservationId;
+    }
+    
+    public Long getAccountId() {
+    	return accountId;
+    }
+    
+    public void setAccountId(Long accountId) {
+    	this.accountId = accountId;
+    }
+    
+    public long getDataCenterId() {
+        return dataCenterId;
+    }
+
+    public long getPhysicalNetworkId() {
+        return physicalNetworkId;
+    }
+
+    public void setAccountGuestVlanMapId(Long accountGuestVlanMapId) {
+        this.accountGuestVlanMapId = accountGuestVlanMapId;
+    }
+
+    public Long getAccountGuestVlanMapId() {
+        return accountGuestVlanMapId;
+    }
+    
+    protected DataCenterVnetVO() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/dc/DcDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/DcDetailVO.java b/engine/schema/src/com/cloud/dc/DcDetailVO.java
new file mode 100644
index 0000000..15bfacb
--- /dev/null
+++ b/engine/schema/src/com/cloud/dc/DcDetailVO.java
@@ -0,0 +1,73 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.dc;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="data_center_details")
+public class DcDetailVO implements InternalIdentity {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+    
+    @Column(name="dc_id")
+    private long dcId;
+    
+    @Column(name="name")
+    private String name;
+    
+    @Column(name="value")
+    private String value;
+    
+    protected DcDetailVO() {
+    }
+    
+    public DcDetailVO(long dcId, String name, String value) {
+        this.dcId = dcId;
+        this.name = name;
+        this.value = value;
+    }
+
+    public long getDcId() {
+        return dcId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public long getId() {
+        return id;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/dc/HostPodVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/HostPodVO.java b/engine/schema/src/com/cloud/dc/HostPodVO.java
new file mode 100644
index 0000000..e4ba9d0
--- /dev/null
+++ b/engine/schema/src/com/cloud/dc/HostPodVO.java
@@ -0,0 +1,197 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.dc;
+
+import java.util.Date;
+import java.util.UUID;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import org.apache.cloudstack.api.Identity;
+import com.cloud.org.Grouping;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.db.GenericDao;
+import org.apache.cloudstack.api.InternalIdentity;
+
+@Entity
+@Table(name = "host_pod_ref")
+public class HostPodVO implements Pod {
+	@Id
+	@GeneratedValue(strategy = GenerationType.IDENTITY)
+	long id;
+
+	@Column(name = "name")
+	private String name = null;
+
+	@Column(name = "data_center_id")
+	private long dataCenterId;
+
+	@Column(name = "gateway")
+	private String gateway;
+
+	@Column(name = "cidr_address")
+	private String cidrAddress;
+
+	@Column(name = "cidr_size")
+	private int cidrSize;
+
+	@Column(name = "description")
+	private String description;
+
+    @Column(name="allocation_state")
+    @Enumerated(value=EnumType.STRING)
+    AllocationState allocationState;
+
+	@Column(name = "external_dhcp")
+	private Boolean externalDhcp;
+
+    @Column(name=GenericDao.REMOVED_COLUMN)
+    private Date removed;
+
+	@Column(name = "uuid")
+	private String uuid;
+
+	public HostPodVO(String name, long dcId, String gateway, String cidrAddress, int cidrSize, String description) {
+		this.name = name;
+		this.dataCenterId = dcId;
+		this.gateway = gateway;
+		this.cidrAddress = cidrAddress;
+		this.cidrSize = cidrSize;
+		this.description = description;
+		this.allocationState = Grouping.AllocationState.Enabled;
+		this.externalDhcp = false;
+		this.uuid = UUID.randomUUID().toString();
+	}
+
+	/*
+	 * public HostPodVO(String name, long dcId) { this(null, name, dcId); }
+	 */
+	protected HostPodVO() {
+		this.uuid = UUID.randomUUID().toString();
+	}
+
+	@Override
+    public long getId() {
+		return id;
+	}
+
+	public long getDataCenterId() {
+		return dataCenterId;
+	}
+
+	public void setDataCenterId(long dataCenterId) {
+		this.dataCenterId = dataCenterId;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	@Override
+    public String getCidrAddress() {
+		return cidrAddress;
+	}
+
+	public void setCidrAddress(String cidrAddress) {
+		this.cidrAddress = cidrAddress;
+	}
+
+	@Override
+    public int getCidrSize() {
+		return cidrSize;
+	}
+
+	public void setCidrSize(int cidrSize) {
+		this.cidrSize = cidrSize;
+	}
+
+	@Override
+    public String getGateway() {
+		return gateway;
+	}
+
+	public void setGateway(String gateway) {
+		this.gateway = gateway;
+	}
+
+	public String getDescription() {
+		return description;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+    public AllocationState getAllocationState() {
+    	return allocationState;
+    }
+
+    public void setAllocationState(AllocationState allocationState) {
+		this.allocationState = allocationState;
+    }
+
+	// Use for comparisons only.
+	public HostPodVO(Long id) {
+	    this.id = id;
+	}
+
+	@Override
+    public int hashCode() {
+	    return  NumbersUtil.hash(id);
+	}
+
+	public boolean getExternalDhcp() {
+		return externalDhcp;
+	}
+
+	public void setExternalDhcp(boolean use) {
+		externalDhcp = use;
+	}
+
+	@Override
+    public boolean equals(Object obj) {
+	    if (obj instanceof HostPodVO) {
+	        return id == ((HostPodVO)obj).id;
+	    } else {
+	        return false;
+	    }
+	}
+
+    public Date getRemoved() {
+        return removed;
+    }
+
+    @Override
+    public String getUuid() {
+    	return this.uuid;
+    }
+
+    public void setUuid(String uuid) {
+    	this.uuid = uuid;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/572e71e5/engine/schema/src/com/cloud/dc/PodCluster.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/PodCluster.java b/engine/schema/src/com/cloud/dc/PodCluster.java
new file mode 100644
index 0000000..acffe4d
--- /dev/null
+++ b/engine/schema/src/com/cloud/dc/PodCluster.java
@@ -0,0 +1,67 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.dc;
+
+public class PodCluster {
+    HostPodVO _pod;
+    ClusterVO _cluster;
+    
+    protected PodCluster() {
+        super();
+    }
+    
+    public PodCluster(HostPodVO pod, ClusterVO cluster) {
+        _pod = pod;
+        _cluster = cluster;
+    }
+    
+    public HostPodVO getPod() {
+        return _pod;
+    }
+    
+    public ClusterVO getCluster() {
+        return _cluster;
+    }
+    
+    
+    @Override
+    public int hashCode() {
+        return _pod.hashCode() ^ (_cluster != null ? _cluster.hashCode() : 0);
+    }
+    
+    @Override
+    public boolean equals(Object obj) {
+        if (!(obj instanceof PodCluster)) {
+            return false;
+        }
+        
+        PodCluster that = (PodCluster)obj;
+        if (!this._pod.equals(that._pod)) {
+            return false;
+        }
+        
+        if (this._cluster == null && that._cluster == null) {
+            return true;
+        }
+        
+        if (this._cluster == null || that._cluster == null) {
+            return false;
+        }
+        
+        return this._cluster.equals(that._cluster);
+    }
+}


Mime
View raw message