mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Moved the DB layer code into framework-db and change only the necessary projects to refer to it. Cut down on the dependencies introduced with all the code in utils.
This commit is contained in:
parent
81b121bbe0
commit
f5e5b39c9b
21
api/pom.xml
21
api/pom.xml
@ -36,10 +36,27 @@
|
|||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>${cs.gson.version}</version>
|
<version>${cs.gson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cloudstack</groupId>
|
||||||
|
<artifactId>cloud-framework-db</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>install</defaultGoal>
|
<defaultGoal>install</defaultGoal>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<plugins>
|
||||||
<testSourceDirectory>test</testSourceDirectory>
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>test-jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -18,7 +18,7 @@ package org.apache.cloudstack.api.response;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
import org.apache.cloudstack.api.ApiConstants;
|
||||||
import org.apache.cloudstack.api.BaseResponse;
|
import org.apache.cloudstack.api.BaseResponse;
|
||||||
@ -26,7 +26,6 @@ import org.apache.cloudstack.api.EntityReference;
|
|||||||
|
|
||||||
import com.cloud.offering.ServiceOffering;
|
import com.cloud.offering.ServiceOffering;
|
||||||
import com.cloud.serializer.Param;
|
import com.cloud.serializer.Param;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
@EntityReference(value = ServiceOffering.class)
|
@EntityReference(value = ServiceOffering.class)
|
||||||
public class ServiceOfferingResponse extends BaseResponse {
|
public class ServiceOfferingResponse extends BaseResponse {
|
||||||
@ -141,7 +140,7 @@ public class ServiceOfferingResponse extends BaseResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSystemVmType(String vmtype) {
|
public void setSystemVmType(String vmtype) {
|
||||||
this.vm_type = vmtype;
|
vm_type = vmtype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -16,19 +16,8 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package org.apache.cloudstack.usage;
|
package org.apache.cloudstack.usage;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.InternalIdentity;
|
|
||||||
|
|
||||||
import java.util.Date;
|
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;
|
|
||||||
|
|
||||||
public interface Usage {
|
public interface Usage {
|
||||||
|
|
||||||
public long getId();
|
public long getId();
|
||||||
@ -39,7 +28,7 @@ public interface Usage {
|
|||||||
|
|
||||||
public Long getDomainId();
|
public Long getDomainId();
|
||||||
|
|
||||||
public String getDescription();
|
public String getDescription();
|
||||||
|
|
||||||
public String getUsageDisplay();
|
public String getUsageDisplay();
|
||||||
|
|
||||||
|
|||||||
@ -289,6 +289,11 @@
|
|||||||
<artifactId>javassist</artifactId>
|
<artifactId>javassist</artifactId>
|
||||||
<version>3.9.0.GA</version>
|
<version>3.9.0.GA</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cloudstack</groupId>
|
||||||
|
<artifactId>cloud-framework-db</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
<resources>
|
||||||
|
|||||||
@ -25,6 +25,11 @@
|
|||||||
<artifactId>cloud-utils</artifactId>
|
<artifactId>cloud-utils</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cloudstack</groupId>
|
||||||
|
<artifactId>cloud-framework-db</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.cloudstack</groupId>
|
<groupId>org.apache.cloudstack</groupId>
|
||||||
<artifactId>cloud-api</artifactId>
|
<artifactId>cloud-api</artifactId>
|
||||||
|
|||||||
@ -43,6 +43,11 @@
|
|||||||
<artifactId>cloud-engine-components-api</artifactId>
|
<artifactId>cloud-engine-components-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cloudstack</groupId>
|
||||||
|
<artifactId>cloud-framework-db</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<defaultGoal>install</defaultGoal>
|
<defaultGoal>install</defaultGoal>
|
||||||
|
|||||||
@ -64,7 +64,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.cloudstack</groupId>
|
<groupId>org.apache.cloudstack</groupId>
|
||||||
<artifactId>cloud-utils</artifactId>
|
<artifactId>cloud-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
|
|||||||
@ -24,5 +24,10 @@
|
|||||||
<artifactId>cloud-utils</artifactId>
|
<artifactId>cloud-utils</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cloudstack</groupId>
|
||||||
|
<artifactId>cloud-framework-db</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -19,10 +19,34 @@
|
|||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.ejb</groupId>
|
||||||
|
<artifactId>ejb-api</artifactId>
|
||||||
|
<version>${cs.ejb.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.persistence</groupId>
|
||||||
|
<artifactId>javax.persistence</artifactId>
|
||||||
|
<version>${cs.jpa.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.cloudstack</groupId>
|
<groupId>org.apache.cloudstack</groupId>
|
||||||
<artifactId>cloud-utils</artifactId>
|
<artifactId>cloud-utils</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>com/cloud/utils/testcase/*TestCase*</exclude>
|
||||||
|
<exclude>com/cloud/utils/db/*Test*</exclude>
|
||||||
|
</excludes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -23,8 +23,6 @@ import java.util.Map;
|
|||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import net.sf.ehcache.Cache;
|
import net.sf.ehcache.Cache;
|
||||||
|
|
||||||
import com.cloud.utils.component.ManagerBase;
|
import com.cloud.utils.component.ManagerBase;
|
||||||
@ -35,7 +33,6 @@ import com.cloud.utils.db.GenericSearchBuilder;
|
|||||||
import com.cloud.utils.db.SearchBuilder;
|
import com.cloud.utils.db.SearchBuilder;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
|
|
||||||
@Component
|
|
||||||
@Local(value=EntityManager.class)
|
@Local(value=EntityManager.class)
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class EntityManagerImpl extends ManagerBase implements EntityManager {
|
public class EntityManagerImpl extends ManagerBase implements EntityManager {
|
||||||
@ -48,7 +45,6 @@ public class EntityManagerImpl extends ManagerBase implements EntityManager {
|
|||||||
return dao.findById(id);
|
return dao.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T, K extends Serializable> T findByIdIncludingRemoved(Class<T> entityType, K id) {
|
public <T, K extends Serializable> T findByIdIncludingRemoved(Class<T> entityType, K id) {
|
||||||
GenericDao<? extends T, K> dao = (GenericDao<? extends T, K>)GenericDaoBase.getDao(entityType);
|
GenericDao<? extends T, K> dao = (GenericDao<? extends T, K>)GenericDaoBase.getDao(entityType);
|
||||||
return dao.findByIdIncludingRemoved(id);
|
return dao.findByIdIncludingRemoved(id);
|
||||||
@ -61,7 +57,6 @@ public class EntityManagerImpl extends ManagerBase implements EntityManager {
|
|||||||
return dao.findByUuid(uuid);
|
return dao.findByUuid(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> T findByUuidIncludingRemoved(Class<T> entityType, String uuid) {
|
public <T> T findByUuidIncludingRemoved(Class<T> entityType, String uuid) {
|
||||||
// Finds and returns a unique VO using uuid, null if entity not found in db
|
// Finds and returns a unique VO using uuid, null if entity not found in db
|
||||||
GenericDao<? extends T, String> dao = (GenericDao<? extends T, String>)GenericDaoBase.getDao(entityType);
|
GenericDao<? extends T, String> dao = (GenericDao<? extends T, String>)GenericDaoBase.getDao(entityType);
|
||||||
@ -79,19 +74,16 @@ public class EntityManagerImpl extends ManagerBase implements EntityManager {
|
|||||||
return dao.listAll();
|
return dao.listAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> T persist(T t) {
|
public <T> T persist(T t) {
|
||||||
GenericDao<T, ? extends Serializable> dao = (GenericDao<T, ? extends Serializable>)GenericDaoBase.getDao((Class<T>)t.getClass());
|
GenericDao<T, ? extends Serializable> dao = (GenericDao<T, ? extends Serializable>)GenericDaoBase.getDao((Class<T>)t.getClass());
|
||||||
return dao.persist(t);
|
return dao.persist(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T> SearchBuilder<T> createSearchBuilder(Class<T> entityType) {
|
public <T> SearchBuilder<T> createSearchBuilder(Class<T> entityType) {
|
||||||
GenericDao<T, ? extends Serializable> dao = (GenericDao<T, ? extends Serializable>)GenericDaoBase.getDao(entityType);
|
GenericDao<T, ? extends Serializable> dao = (GenericDao<T, ? extends Serializable>)GenericDaoBase.getDao(entityType);
|
||||||
return dao.createSearchBuilder();
|
return dao.createSearchBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T, K> GenericSearchBuilder<T, K> createGenericSearchBuilder(Class<T> entityType, Class<K> resultType) {
|
public <T, K> GenericSearchBuilder<T, K> createGenericSearchBuilder(Class<T> entityType, Class<K> resultType) {
|
||||||
GenericDao<T, ? extends Serializable> dao = (GenericDao<T, ? extends Serializable>)GenericDaoBase.getDao(entityType);
|
GenericDao<T, ? extends Serializable> dao = (GenericDao<T, ? extends Serializable>)GenericDaoBase.getDao(entityType);
|
||||||
return dao.createSearchBuilder((Class<K>)resultType.getClass());
|
return dao.createSearchBuilder((Class<K>)resultType.getClass());
|
||||||
@ -100,22 +92,6 @@ public class EntityManagerImpl extends ManagerBase implements EntityManager {
|
|||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||||
_name = name;
|
_name = name;
|
||||||
/*
|
|
||||||
String threadId = Long.toString(Thread.currentThread().getId());
|
|
||||||
|
|
||||||
CacheManager cm = CacheManager.create();
|
|
||||||
|
|
||||||
_cache = cm.getCache(threadId);
|
|
||||||
|
|
||||||
if (_cache == null) {
|
|
||||||
int maxElements = NumbersUtil.parseInt((String)params.get("cache.size"), 100);
|
|
||||||
int live = NumbersUtil.parseInt((String)params.get("cache.time.to.live"), 300);
|
|
||||||
int idle = NumbersUtil.parseInt((String)params.get("cache.time.to.idle"), 300);
|
|
||||||
|
|
||||||
_cache = new Cache(threadId, maxElements, false, live == -1, live == -1 ? Integer.MAX_VALUE : live, idle);
|
|
||||||
cm.addCache(_cache);
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -135,7 +111,6 @@ public class EntityManagerImpl extends ManagerBase implements EntityManager {
|
|||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T, K> List<K> search(Class<T> entityType, SearchCriteria<K> sc) {
|
public <T, K> List<K> search(Class<T> entityType, SearchCriteria<K> sc) {
|
||||||
GenericDao<T, ? extends Serializable> dao = (GenericDao<T, ? extends Serializable>)GenericDaoBase.getDao(entityType);
|
GenericDao<T, ? extends Serializable> dao = (GenericDao<T, ? extends Serializable>)GenericDaoBase.getDao(entityType);
|
||||||
return dao.customSearch(sc, null);
|
return dao.customSearch(sc, null);
|
||||||
@ -215,7 +215,7 @@ public interface GenericDao<T, ID extends Serializable> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove based on the search criteria. This will delete if the VO object
|
* Remove based on the search criteria. This will delete if the VO object
|
||||||
* does not have a REMOVED column.
|
* does not have a REMOVED column.
|
||||||
* @param sc search criteria to match
|
* @param sc search criteria to match
|
||||||
* @return rows removed.
|
* @return rows removed.
|
||||||
*/
|
*/
|
||||||
@ -49,7 +49,7 @@ public class SearchCriteria2<T, K> implements SearchCriteriaService<T, K>, Metho
|
|||||||
protected SelectType _selectType;
|
protected SelectType _selectType;
|
||||||
protected Class<T> _entityBeanType;
|
protected Class<T> _entityBeanType;
|
||||||
|
|
||||||
protected SearchCriteria2(T entity, Class<K> resultType, final Map<String, Attribute> attrs, GenericDao<? extends Serializable, ? extends Serializable> dao) {
|
protected SearchCriteria2(T entity, Class<K> resultType, final Map<String, Attribute> attrs, GenericDao<? extends Serializable, ? extends Serializable> dao) {
|
||||||
_entityBeanType = (Class<T>)entity.getClass();
|
_entityBeanType = (Class<T>)entity.getClass();
|
||||||
_dao = dao;
|
_dao = dao;
|
||||||
_resultType = resultType;
|
_resultType = resultType;
|
||||||
@ -125,7 +125,7 @@ public class SearchCriteria2<T, K> implements SearchCriteriaService<T, K>, Metho
|
|||||||
if (isSelectAll()) {
|
if (isSelectAll()) {
|
||||||
return (List<K>)_dao.search(sc1, null);
|
return (List<K>)_dao.search(sc1, null);
|
||||||
} else {
|
} else {
|
||||||
return (List<K>)_dao.customSearch(sc1, null);
|
return _dao.customSearch(sc1, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ public class SearchCriteria2<T, K> implements SearchCriteriaService<T, K>, Metho
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T getEntity() {
|
public T getEntity() {
|
||||||
return (T) _entity;
|
return _entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SearchCriteria<K> createSearchCriteria() {
|
private SearchCriteria<K> createSearchCriteria() {
|
||||||
@ -22,10 +22,7 @@ import org.junit.runner.RunWith;
|
|||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
|
|
||||||
import com.cloud.utils.Profiler;
|
import com.cloud.utils.Profiler;
|
||||||
import com.cloud.utils.testcase.Log4jEnabledTestCase;
|
|
||||||
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ -42,6 +39,7 @@ public class GlobalLockTest {
|
|||||||
timeoutSeconds = timeout;
|
timeoutSeconds = timeout;
|
||||||
jobDuration = duration;
|
jobDuration = duration;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
boolean locked = false;
|
boolean locked = false;
|
||||||
try {
|
try {
|
||||||
@ -64,15 +64,5 @@
|
|||||||
<artifactId>wsdl4j</artifactId>
|
<artifactId>wsdl4j</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>4.10</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.mockito</groupId>
|
|
||||||
<artifactId>mockito-all</artifactId>
|
|
||||||
<version>1.9.5</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -77,7 +77,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.cloudstack</groupId>
|
<groupId>org.apache.cloudstack</groupId>
|
||||||
<artifactId>cloud-utils</artifactId>
|
<artifactId>cloud-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
|
|||||||
@ -92,7 +92,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.cloudstack</groupId>
|
<groupId>org.apache.cloudstack</groupId>
|
||||||
<artifactId>cloud-utils</artifactId>
|
<artifactId>cloud-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
|
|||||||
@ -352,7 +352,7 @@ public class ApiDispatcher {
|
|||||||
for (Class<?> entity : entities) {
|
for (Class<?> entity : entities) {
|
||||||
// For backward compatibility, we search within removed entities and let service layer deal
|
// For backward compatibility, we search within removed entities and let service layer deal
|
||||||
// with removed ones, return empty response or error
|
// with removed ones, return empty response or error
|
||||||
Object objVO = s_instance._entityMgr.findByUuidIncludingRemoved(entity, uuid);
|
Object objVO = s_instance._entityMgr.findByUuid(entity, uuid);
|
||||||
if (objVO == null) {
|
if (objVO == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,9 @@ import java.util.TimeZone;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import org.apache.cloudstack.acl.ControlledEntity;
|
import org.apache.cloudstack.acl.ControlledEntity;
|
||||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||||
import org.apache.cloudstack.affinity.AffinityGroup;
|
import org.apache.cloudstack.affinity.AffinityGroup;
|
||||||
@ -70,6 +73,7 @@ import org.apache.cloudstack.api.response.HostForMigrationResponse;
|
|||||||
import org.apache.cloudstack.api.response.HostResponse;
|
import org.apache.cloudstack.api.response.HostResponse;
|
||||||
import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
|
import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
|
||||||
import org.apache.cloudstack.api.response.IPAddressResponse;
|
import org.apache.cloudstack.api.response.IPAddressResponse;
|
||||||
|
import org.apache.cloudstack.api.response.ImageStoreResponse;
|
||||||
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
import org.apache.cloudstack.api.response.InstanceGroupResponse;
|
||||||
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
|
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
|
||||||
import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
|
import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
|
||||||
@ -86,7 +90,6 @@ import org.apache.cloudstack.api.response.NetworkOfferingResponse;
|
|||||||
import org.apache.cloudstack.api.response.NetworkResponse;
|
import org.apache.cloudstack.api.response.NetworkResponse;
|
||||||
import org.apache.cloudstack.api.response.NicResponse;
|
import org.apache.cloudstack.api.response.NicResponse;
|
||||||
import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
|
import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
|
||||||
import org.apache.cloudstack.api.response.ImageStoreResponse;
|
|
||||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
||||||
import org.apache.cloudstack.api.response.PodResponse;
|
import org.apache.cloudstack.api.response.PodResponse;
|
||||||
import org.apache.cloudstack.api.response.PortableIpRangeResponse;
|
import org.apache.cloudstack.api.response.PortableIpRangeResponse;
|
||||||
@ -144,9 +147,6 @@ import org.apache.cloudstack.usage.Usage;
|
|||||||
import org.apache.cloudstack.usage.UsageService;
|
import org.apache.cloudstack.usage.UsageService;
|
||||||
import org.apache.cloudstack.usage.UsageTypes;
|
import org.apache.cloudstack.usage.UsageTypes;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.cloud.api.query.ViewResponseHelper;
|
import com.cloud.api.query.ViewResponseHelper;
|
||||||
import com.cloud.api.query.vo.AccountJoinVO;
|
import com.cloud.api.query.vo.AccountJoinVO;
|
||||||
import com.cloud.api.query.vo.AsyncJobJoinVO;
|
import com.cloud.api.query.vo.AsyncJobJoinVO;
|
||||||
@ -301,9 +301,9 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
public final Logger s_logger = Logger.getLogger(ApiResponseHelper.class);
|
public final Logger s_logger = Logger.getLogger(ApiResponseHelper.class);
|
||||||
private static final DecimalFormat s_percentFormat = new DecimalFormat("##.##");
|
private static final DecimalFormat s_percentFormat = new DecimalFormat("##.##");
|
||||||
@Inject
|
@Inject
|
||||||
private EntityManager _entityMgr = null;
|
private final EntityManager _entityMgr = null;
|
||||||
@Inject
|
@Inject
|
||||||
private UsageService _usageSvc = null;
|
private final UsageService _usageSvc = null;
|
||||||
@Inject NetworkModel _ntwkModel;
|
@Inject NetworkModel _ntwkModel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -831,7 +831,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
capacityResponse.setCapacityType(capacity.getCapacityType());
|
capacityResponse.setCapacityType(capacity.getCapacityType());
|
||||||
capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
|
capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
|
||||||
if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU) {
|
if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU) {
|
||||||
capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity())));
|
capacityResponse.setCapacityTotal(new Long((capacity.getTotalCapacity())));
|
||||||
} else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
|
} else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
|
||||||
List<SummedCapacity> c = ApiDBUtils.findNonSharedStorageForClusterPodZone(null, pod.getId(), null);
|
List<SummedCapacity> c = ApiDBUtils.findNonSharedStorageForClusterPodZone(null, pod.getId(), null);
|
||||||
capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
|
capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
|
||||||
@ -1409,7 +1409,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
templateResponse.setOsTypeName("");
|
templateResponse.setOsTypeName("");
|
||||||
}
|
}
|
||||||
|
|
||||||
final Account account = ApiDBUtils.findAccountByIdIncludingRemoved(iso.getAccountId());
|
final Account account = ApiDBUtils.findAccountById(iso.getAccountId());
|
||||||
populateAccount(templateResponse, account.getId());
|
populateAccount(templateResponse, account.getId());
|
||||||
populateDomain(templateResponse, account.getDomainId());
|
populateDomain(templateResponse, account.getDomainId());
|
||||||
|
|
||||||
@ -1466,7 +1466,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
isoResponse.setOsTypeId("-1");
|
isoResponse.setOsTypeId("-1");
|
||||||
isoResponse.setOsTypeName("");
|
isoResponse.setOsTypeName("");
|
||||||
}
|
}
|
||||||
Account account = ApiDBUtils.findAccountByIdIncludingRemoved(iso.getAccountId());
|
Account account = ApiDBUtils.findAccountById(iso.getAccountId());
|
||||||
populateAccount(isoResponse, account.getId());
|
populateAccount(isoResponse, account.getId());
|
||||||
populateDomain(isoResponse, account.getDomainId());
|
populateDomain(isoResponse, account.getDomainId());
|
||||||
boolean isAdmin = false;
|
boolean isAdmin = false;
|
||||||
@ -1521,7 +1521,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
isoResponse.setOsTypeName("");
|
isoResponse.setOsTypeName("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Account account = ApiDBUtils.findAccountByIdIncludingRemoved(iso.getAccountId());
|
Account account = ApiDBUtils.findAccountById(iso.getAccountId());
|
||||||
populateAccount(isoResponse, account.getId());
|
populateAccount(isoResponse, account.getId());
|
||||||
populateDomain(isoResponse, account.getDomainId());
|
populateDomain(isoResponse, account.getDomainId());
|
||||||
|
|
||||||
@ -1578,7 +1578,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
isoResponses.add(isoResponse);
|
isoResponses.add(isoResponse);
|
||||||
return isoResponses;
|
return isoResponses;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityGroupResponse createSecurityGroupResponse(SecurityGroup group) {
|
public SecurityGroupResponse createSecurityGroupResponse(SecurityGroup group) {
|
||||||
@ -1909,7 +1909,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
regularAccounts.add(accountName);
|
regularAccounts.add(accountName);
|
||||||
} else {
|
} else {
|
||||||
// convert account to projectIds
|
// convert account to projectIds
|
||||||
Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getId());
|
Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
|
||||||
|
|
||||||
if (project.getUuid() != null && !project.getUuid().isEmpty())
|
if (project.getUuid() != null && !project.getUuid().isEmpty())
|
||||||
projectIds.add(project.getUuid());
|
projectIds.add(project.getUuid());
|
||||||
@ -2211,7 +2211,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// populate network offering information
|
// populate network offering information
|
||||||
NetworkOffering networkOffering = (NetworkOffering) ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
|
NetworkOffering networkOffering = ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
|
||||||
if (networkOffering != null) {
|
if (networkOffering != null) {
|
||||||
response.setNetworkOfferingId(networkOffering.getUuid());
|
response.setNetworkOfferingId(networkOffering.getUuid());
|
||||||
response.setNetworkOfferingName(networkOffering.getName());
|
response.setNetworkOfferingName(networkOffering.getName());
|
||||||
@ -2455,11 +2455,11 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
// ControlledEntity id to uuid conversion are all done.
|
// ControlledEntity id to uuid conversion are all done.
|
||||||
// currently code is scattered in
|
// currently code is scattered in
|
||||||
private void populateOwner(ControlledEntityResponse response, ControlledEntity object) {
|
private void populateOwner(ControlledEntityResponse response, ControlledEntity object) {
|
||||||
Account account = ApiDBUtils.findAccountByIdIncludingRemoved(object.getAccountId());
|
Account account = ApiDBUtils.findAccountById(object.getAccountId());
|
||||||
|
|
||||||
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
||||||
// find the project
|
// find the project
|
||||||
Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getId());
|
Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
|
||||||
response.setProjectId(project.getUuid());
|
response.setProjectId(project.getUuid());
|
||||||
response.setProjectName(project.getName());
|
response.setProjectName(project.getName());
|
||||||
} else {
|
} else {
|
||||||
@ -2485,10 +2485,10 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void populateAccount(ControlledEntityResponse response, long accountId) {
|
private void populateAccount(ControlledEntityResponse response, long accountId) {
|
||||||
Account account = ApiDBUtils.findAccountByIdIncludingRemoved(accountId);
|
Account account = ApiDBUtils.findAccountById(accountId);
|
||||||
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
||||||
// find the project
|
// find the project
|
||||||
Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getId());
|
Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
|
||||||
response.setProjectId(project.getUuid());
|
response.setProjectId(project.getUuid());
|
||||||
response.setProjectName(project.getName());
|
response.setProjectName(project.getName());
|
||||||
response.setAccountName(account.getAccountName());
|
response.setAccountName(account.getAccountName());
|
||||||
@ -3273,10 +3273,10 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
public UsageRecordResponse createUsageResponse(Usage usageRecord) {
|
public UsageRecordResponse createUsageResponse(Usage usageRecord) {
|
||||||
UsageRecordResponse usageRecResponse = new UsageRecordResponse();
|
UsageRecordResponse usageRecResponse = new UsageRecordResponse();
|
||||||
|
|
||||||
Account account = ApiDBUtils.findAccountByIdIncludingRemoved(usageRecord.getAccountId());
|
Account account = ApiDBUtils.findAccountById(usageRecord.getAccountId());
|
||||||
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
||||||
//find the project
|
//find the project
|
||||||
Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getId());
|
Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
|
||||||
usageRecResponse.setProjectId(project.getUuid());
|
usageRecResponse.setProjectId(project.getUuid());
|
||||||
usageRecResponse.setProjectName(project.getName());
|
usageRecResponse.setProjectName(project.getName());
|
||||||
} else {
|
} else {
|
||||||
@ -3299,7 +3299,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
usageRecResponse.setUsage(usageRecord.getUsageDisplay());
|
usageRecResponse.setUsage(usageRecord.getUsageDisplay());
|
||||||
usageRecResponse.setUsageType(usageRecord.getUsageType());
|
usageRecResponse.setUsageType(usageRecord.getUsageType());
|
||||||
if (usageRecord.getVmInstanceId() != null) {
|
if (usageRecord.getVmInstanceId() != null) {
|
||||||
VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getVmInstanceId());
|
VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getVmInstanceId());
|
||||||
usageRecResponse.setVirtualMachineId(vm.getUuid());
|
usageRecResponse.setVirtualMachineId(vm.getUuid());
|
||||||
}
|
}
|
||||||
usageRecResponse.setVmName(usageRecord.getVmName());
|
usageRecResponse.setVmName(usageRecord.getVmName());
|
||||||
@ -3311,11 +3311,11 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(usageRecord.getUsageType() == UsageTypes.RUNNING_VM || usageRecord.getUsageType() == UsageTypes.ALLOCATED_VM){
|
if(usageRecord.getUsageType() == UsageTypes.RUNNING_VM || usageRecord.getUsageType() == UsageTypes.ALLOCATED_VM){
|
||||||
ServiceOfferingVO svcOffering = _entityMgr.findByIdIncludingRemoved(ServiceOfferingVO.class, usageRecord.getOfferingId().toString());
|
ServiceOfferingVO svcOffering = _entityMgr.findById(ServiceOfferingVO.class, usageRecord.getOfferingId().toString());
|
||||||
//Service Offering Id
|
//Service Offering Id
|
||||||
usageRecResponse.setOfferingId(svcOffering.getUuid());
|
usageRecResponse.setOfferingId(svcOffering.getUuid());
|
||||||
//VM Instance ID
|
//VM Instance ID
|
||||||
VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getUsageId().toString());
|
VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getUsageId().toString());
|
||||||
usageRecResponse.setUsageId(vm.getUuid());
|
usageRecResponse.setUsageId(vm.getUuid());
|
||||||
//Hypervisor Type
|
//Hypervisor Type
|
||||||
usageRecResponse.setType(usageRecord.getType());
|
usageRecResponse.setType(usageRecord.getType());
|
||||||
@ -3326,7 +3326,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
//isSystem
|
//isSystem
|
||||||
usageRecResponse.setSystem((usageRecord.getSize() == 1)?true:false);
|
usageRecResponse.setSystem((usageRecord.getSize() == 1)?true:false);
|
||||||
//IP Address ID
|
//IP Address ID
|
||||||
IPAddressVO ip = _entityMgr.findByIdIncludingRemoved(IPAddressVO.class, usageRecord.getUsageId().toString());
|
IPAddressVO ip = _entityMgr.findById(IPAddressVO.class, usageRecord.getUsageId().toString());
|
||||||
usageRecResponse.setUsageId(ip.getUuid());
|
usageRecResponse.setUsageId(ip.getUuid());
|
||||||
|
|
||||||
} else if(usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_SENT || usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_RECEIVED){
|
} else if(usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_SENT || usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_RECEIVED){
|
||||||
@ -3334,15 +3334,15 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
usageRecResponse.setType(usageRecord.getType());
|
usageRecResponse.setType(usageRecord.getType());
|
||||||
if(usageRecord.getType().equals("DomainRouter")){
|
if(usageRecord.getType().equals("DomainRouter")){
|
||||||
//Domain Router Id
|
//Domain Router Id
|
||||||
VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getUsageId().toString());
|
VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getUsageId().toString());
|
||||||
usageRecResponse.setUsageId(vm.getUuid());
|
usageRecResponse.setUsageId(vm.getUuid());
|
||||||
} else {
|
} else {
|
||||||
//External Device Host Id
|
//External Device Host Id
|
||||||
HostVO host = _entityMgr.findByIdIncludingRemoved(HostVO.class, usageRecord.getUsageId().toString());
|
HostVO host = _entityMgr.findById(HostVO.class, usageRecord.getUsageId().toString());
|
||||||
usageRecResponse.setUsageId(host.getUuid());
|
usageRecResponse.setUsageId(host.getUuid());
|
||||||
}
|
}
|
||||||
//Network ID
|
//Network ID
|
||||||
NetworkVO network = _entityMgr.findByIdIncludingRemoved(NetworkVO.class, usageRecord.getNetworkId().toString());
|
NetworkVO network = _entityMgr.findById(NetworkVO.class, usageRecord.getNetworkId().toString());
|
||||||
usageRecResponse.setNetworkId(network.getUuid());
|
usageRecResponse.setNetworkId(network.getUuid());
|
||||||
|
|
||||||
} else if(usageRecord.getUsageType() == UsageTypes.VM_DISK_IO_READ || usageRecord.getUsageType() == UsageTypes.VM_DISK_IO_WRITE ||
|
} else if(usageRecord.getUsageType() == UsageTypes.VM_DISK_IO_READ || usageRecord.getUsageType() == UsageTypes.VM_DISK_IO_WRITE ||
|
||||||
@ -3350,27 +3350,27 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
//Device Type
|
//Device Type
|
||||||
usageRecResponse.setType(usageRecord.getType());
|
usageRecResponse.setType(usageRecord.getType());
|
||||||
//VM Instance Id
|
//VM Instance Id
|
||||||
VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getVmInstanceId().toString());
|
VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getVmInstanceId().toString());
|
||||||
usageRecResponse.setVirtualMachineId(vm.getUuid());
|
usageRecResponse.setVirtualMachineId(vm.getUuid());
|
||||||
//Volume ID
|
//Volume ID
|
||||||
VolumeVO volume = _entityMgr.findByIdIncludingRemoved(VolumeVO.class, usageRecord.getUsageId().toString());
|
VolumeVO volume = _entityMgr.findById(VolumeVO.class, usageRecord.getUsageId().toString());
|
||||||
usageRecResponse.setUsageId(volume.getUuid());
|
usageRecResponse.setUsageId(volume.getUuid());
|
||||||
|
|
||||||
} else if(usageRecord.getUsageType() == UsageTypes.VOLUME){
|
} else if(usageRecord.getUsageType() == UsageTypes.VOLUME){
|
||||||
//Volume ID
|
//Volume ID
|
||||||
VolumeVO volume = _entityMgr.findByIdIncludingRemoved(VolumeVO.class, usageRecord.getUsageId().toString());
|
VolumeVO volume = _entityMgr.findById(VolumeVO.class, usageRecord.getUsageId().toString());
|
||||||
usageRecResponse.setUsageId(volume.getUuid());
|
usageRecResponse.setUsageId(volume.getUuid());
|
||||||
//Volume Size
|
//Volume Size
|
||||||
usageRecResponse.setSize(usageRecord.getSize());
|
usageRecResponse.setSize(usageRecord.getSize());
|
||||||
//Disk Offering Id
|
//Disk Offering Id
|
||||||
if(usageRecord.getOfferingId() != null){
|
if(usageRecord.getOfferingId() != null){
|
||||||
DiskOfferingVO diskOff = _entityMgr.findByIdIncludingRemoved(DiskOfferingVO.class, usageRecord.getOfferingId().toString());
|
DiskOfferingVO diskOff = _entityMgr.findById(DiskOfferingVO.class, usageRecord.getOfferingId().toString());
|
||||||
usageRecResponse.setOfferingId(diskOff.getUuid());
|
usageRecResponse.setOfferingId(diskOff.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(usageRecord.getUsageType() == UsageTypes.TEMPLATE || usageRecord.getUsageType() == UsageTypes.ISO){
|
} else if(usageRecord.getUsageType() == UsageTypes.TEMPLATE || usageRecord.getUsageType() == UsageTypes.ISO){
|
||||||
//Template/ISO ID
|
//Template/ISO ID
|
||||||
VMTemplateVO tmpl = _entityMgr.findByIdIncludingRemoved(VMTemplateVO.class, usageRecord.getUsageId().toString());
|
VMTemplateVO tmpl = _entityMgr.findById(VMTemplateVO.class, usageRecord.getUsageId().toString());
|
||||||
usageRecResponse.setUsageId(tmpl.getUuid());
|
usageRecResponse.setUsageId(tmpl.getUuid());
|
||||||
//Template/ISO Size
|
//Template/ISO Size
|
||||||
usageRecResponse.setSize(usageRecord.getSize());
|
usageRecResponse.setSize(usageRecord.getSize());
|
||||||
@ -3382,35 +3382,35 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||||||
|
|
||||||
} else if(usageRecord.getUsageType() == UsageTypes.SNAPSHOT){
|
} else if(usageRecord.getUsageType() == UsageTypes.SNAPSHOT){
|
||||||
//Snapshot ID
|
//Snapshot ID
|
||||||
SnapshotVO snap = _entityMgr.findByIdIncludingRemoved(SnapshotVO.class, usageRecord.getUsageId().toString());
|
SnapshotVO snap = _entityMgr.findById(SnapshotVO.class, usageRecord.getUsageId().toString());
|
||||||
usageRecResponse.setUsageId(snap.getUuid());
|
usageRecResponse.setUsageId(snap.getUuid());
|
||||||
//Snapshot Size
|
//Snapshot Size
|
||||||
usageRecResponse.setSize(usageRecord.getSize());
|
usageRecResponse.setSize(usageRecord.getSize());
|
||||||
|
|
||||||
} else if(usageRecord.getUsageType() == UsageTypes.LOAD_BALANCER_POLICY){
|
} else if(usageRecord.getUsageType() == UsageTypes.LOAD_BALANCER_POLICY){
|
||||||
//Load Balancer Policy ID
|
//Load Balancer Policy ID
|
||||||
LoadBalancerVO lb = _entityMgr.findByIdIncludingRemoved(LoadBalancerVO.class, usageRecord.getUsageId().toString());
|
LoadBalancerVO lb = _entityMgr.findById(LoadBalancerVO.class, usageRecord.getUsageId().toString());
|
||||||
usageRecResponse.setUsageId(lb.getUuid());
|
usageRecResponse.setUsageId(lb.getUuid());
|
||||||
} else if(usageRecord.getUsageType() == UsageTypes.PORT_FORWARDING_RULE){
|
} else if(usageRecord.getUsageType() == UsageTypes.PORT_FORWARDING_RULE){
|
||||||
//Port Forwarding Rule ID
|
//Port Forwarding Rule ID
|
||||||
PortForwardingRuleVO pf = _entityMgr.findByIdIncludingRemoved(PortForwardingRuleVO.class, usageRecord.getUsageId().toString());
|
PortForwardingRuleVO pf = _entityMgr.findById(PortForwardingRuleVO.class, usageRecord.getUsageId().toString());
|
||||||
usageRecResponse.setUsageId(pf.getUuid());
|
usageRecResponse.setUsageId(pf.getUuid());
|
||||||
|
|
||||||
} else if(usageRecord.getUsageType() == UsageTypes.NETWORK_OFFERING){
|
} else if(usageRecord.getUsageType() == UsageTypes.NETWORK_OFFERING){
|
||||||
//Network Offering Id
|
//Network Offering Id
|
||||||
NetworkOfferingVO netOff = _entityMgr.findByIdIncludingRemoved(NetworkOfferingVO.class, usageRecord.getOfferingId().toString());
|
NetworkOfferingVO netOff = _entityMgr.findById(NetworkOfferingVO.class, usageRecord.getOfferingId().toString());
|
||||||
usageRecResponse.setOfferingId(netOff.getUuid());
|
usageRecResponse.setOfferingId(netOff.getUuid());
|
||||||
//is Default
|
//is Default
|
||||||
usageRecResponse.setDefault((usageRecord.getUsageId() == 1)? true:false);
|
usageRecResponse.setDefault((usageRecord.getUsageId() == 1)? true:false);
|
||||||
|
|
||||||
} else if(usageRecord.getUsageType() == UsageTypes.VPN_USERS){
|
} else if(usageRecord.getUsageType() == UsageTypes.VPN_USERS){
|
||||||
//VPN User ID
|
//VPN User ID
|
||||||
VpnUserVO vpnUser = _entityMgr.findByIdIncludingRemoved(VpnUserVO.class, usageRecord.getUsageId().toString());
|
VpnUserVO vpnUser = _entityMgr.findById(VpnUserVO.class, usageRecord.getUsageId().toString());
|
||||||
usageRecResponse.setUsageId(vpnUser.getUuid());
|
usageRecResponse.setUsageId(vpnUser.getUuid());
|
||||||
|
|
||||||
} else if(usageRecord.getUsageType() == UsageTypes.SECURITY_GROUP){
|
} else if(usageRecord.getUsageType() == UsageTypes.SECURITY_GROUP){
|
||||||
//Security Group Id
|
//Security Group Id
|
||||||
SecurityGroupVO sg = _entityMgr.findByIdIncludingRemoved(SecurityGroupVO.class, usageRecord.getUsageId().toString());
|
SecurityGroupVO sg = _entityMgr.findById(SecurityGroupVO.class, usageRecord.getUsageId().toString());
|
||||||
usageRecResponse.setUsageId(sg.getUuid());
|
usageRecResponse.setUsageId(sg.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.cloudstack</groupId>
|
<groupId>org.apache.cloudstack</groupId>
|
||||||
<artifactId>cloud-utils</artifactId>
|
<artifactId>cloud-api</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
|
|||||||
@ -82,11 +82,6 @@
|
|||||||
<artifactId>jsch</artifactId>
|
<artifactId>jsch</artifactId>
|
||||||
<version>${cs.jsch.version}</version>
|
<version>${cs.jsch.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.persistence</groupId>
|
|
||||||
<artifactId>javax.persistence</artifactId>
|
|
||||||
<version>${cs.jpa.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jasypt</groupId>
|
<groupId>org.jasypt</groupId>
|
||||||
<artifactId>jasypt</artifactId>
|
<artifactId>jasypt</artifactId>
|
||||||
|
|||||||
@ -1,57 +0,0 @@
|
|||||||
// 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
|
|
||||||
// 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.utils;
|
|
||||||
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
|
|
||||||
public class AnnotationHelper extends Object {
|
|
||||||
// This class contains routines to help query annotation elements of objects.
|
|
||||||
|
|
||||||
public static final Logger s_logger = Logger.getLogger(AnnotationHelper.class.getName());
|
|
||||||
|
|
||||||
public static String getTableName(Object proxyObj) {
|
|
||||||
// The cglib class is generated by cglib during runtime.
|
|
||||||
|
|
||||||
Class<?> curClass = proxyObj.getClass();
|
|
||||||
if (curClass == null) {
|
|
||||||
s_logger.trace("Could not retrieve class information for proxy object");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (curClass.getSuperclass() != null && curClass.getSuperclass().getName() != "java.lang.Object") {
|
|
||||||
curClass = curClass.getSuperclass();
|
|
||||||
}
|
|
||||||
// At this point, curClass is the root base class of proxyObj's class, and curClass is not java.lang.Object.
|
|
||||||
|
|
||||||
Table tabObj = curClass.getAnnotation(Table.class);
|
|
||||||
|
|
||||||
if (tabObj == null) {
|
|
||||||
s_logger.trace(curClass + "does not have a Table annotation");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tabObj.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -34,16 +34,6 @@ public interface EntityManager {
|
|||||||
*/
|
*/
|
||||||
public <T, K extends Serializable> T findById(Class<T> entityType, K id);
|
public <T, K extends Serializable> T findById(Class<T> entityType, K id);
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds an entity by its id including removed.
|
|
||||||
* @param <T> class of the entity you're trying to find.
|
|
||||||
* @param <K> class of the id that the entity uses.
|
|
||||||
* @param entityType Type of the entity.
|
|
||||||
* @param id id value
|
|
||||||
* @return T if found; null if not.
|
|
||||||
*/
|
|
||||||
public <T, K extends Serializable> T findByIdIncludingRemoved(Class<T> entityType, K id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds a unique entity by uuid string
|
* Finds a unique entity by uuid string
|
||||||
* @param <T> entity class
|
* @param <T> entity class
|
||||||
@ -53,15 +43,6 @@ public interface EntityManager {
|
|||||||
*/
|
*/
|
||||||
public <T> T findByUuid(Class<T> entityType, String uuid);
|
public <T> T findByUuid(Class<T> entityType, String uuid);
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds a unique entity by uuid string
|
|
||||||
* @param <T> entity class
|
|
||||||
* @param entityType type of entity you're looking for.
|
|
||||||
* @param uuid the unique id
|
|
||||||
* @return T if found, null if not.
|
|
||||||
*/
|
|
||||||
public <T> T findByUuidIncludingRemoved(Class<T> entityType, String uuid);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds an entity by external id which is always String
|
* Finds an entity by external id which is always String
|
||||||
* @param <T> entity class
|
* @param <T> entity class
|
||||||
@ -79,20 +60,6 @@ public interface EntityManager {
|
|||||||
*/
|
*/
|
||||||
public <T> List<? extends T> list(Class<T> entityType);
|
public <T> List<? extends T> list(Class<T> entityType);
|
||||||
|
|
||||||
/**
|
|
||||||
* Persists the entity.
|
|
||||||
* @param <T> entity class
|
|
||||||
* @param t entity
|
|
||||||
* @return persisted entity. Only use this after persisting.
|
|
||||||
*/
|
|
||||||
public <T> T persist(T t);
|
|
||||||
|
|
||||||
public <T> SearchBuilder<T> createSearchBuilder(Class<T> entityType);
|
|
||||||
|
|
||||||
public <T, K> GenericSearchBuilder<T, K> createGenericSearchBuilder(Class<T> entityType, Class<K> resultType);
|
|
||||||
|
|
||||||
public <T, K> List<K> search(Class<T> entityType, SearchCriteria<K> sc);
|
|
||||||
|
|
||||||
public <T, K extends Serializable> void remove(Class<T> entityType, K id);
|
public <T, K extends Serializable> void remove(Class<T> entityType, K id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,104 +0,0 @@
|
|||||||
// 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
|
|
||||||
// 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.utils.log;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.apache.log4j.*;
|
|
||||||
|
|
||||||
import com.cloud.utils.component.ComponentContext;
|
|
||||||
import com.cloud.utils.db.DB;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import org.apache.log4j.spi.RootLogger;
|
|
||||||
import org.apache.log4j.spi.ThrowableRenderer;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
||||||
|
|
||||||
import java.io.CharArrayWriter;
|
|
||||||
import java.io.Writer;
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
|
||||||
@ContextConfiguration(locations="classpath:/testContext.xml")
|
|
||||||
public class CglibThrowableRendererTest extends TestCase {
|
|
||||||
static Logger another = Logger.getLogger("TEST");
|
|
||||||
|
|
||||||
private final static Logger s_logger = Logger.getLogger(CglibThrowableRendererTest.class);
|
|
||||||
public static class TestClass {
|
|
||||||
|
|
||||||
public TestClass() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@DB
|
|
||||||
public void exception1() {
|
|
||||||
throw new IllegalArgumentException("What a bad exception");
|
|
||||||
}
|
|
||||||
public void exception2() {
|
|
||||||
try {
|
|
||||||
exception1();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new CloudRuntimeException("exception2", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@DB
|
|
||||||
public void exception() {
|
|
||||||
try {
|
|
||||||
exception2();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new CloudRuntimeException("exception", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Logger getAlternateLogger(Writer writer, ThrowableRenderer renderer) {
|
|
||||||
Hierarchy hierarchy = new Hierarchy(new RootLogger(Level.INFO));
|
|
||||||
if (renderer != null) {
|
|
||||||
hierarchy.setThrowableRenderer(renderer);
|
|
||||||
}
|
|
||||||
Logger alternateRoot = hierarchy.getRootLogger();
|
|
||||||
alternateRoot.addAppender(new WriterAppender(new SimpleLayout(), writer));
|
|
||||||
return alternateRoot;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testException() {
|
|
||||||
Writer w = new CharArrayWriter();
|
|
||||||
Logger alt = getAlternateLogger(w, null);
|
|
||||||
|
|
||||||
TestClass test = new TestClass();
|
|
||||||
try {
|
|
||||||
test.exception();
|
|
||||||
} catch (Exception e) {
|
|
||||||
alt.warn("exception caught", e);
|
|
||||||
}
|
|
||||||
// first check that we actually have some call traces containing "<generated>"
|
|
||||||
// assertTrue(w.toString().contains("<generated>"));
|
|
||||||
|
|
||||||
w = new CharArrayWriter();
|
|
||||||
alt = getAlternateLogger(w, new CglibThrowableRenderer());
|
|
||||||
|
|
||||||
try {
|
|
||||||
test.exception();
|
|
||||||
} catch (Exception e) {
|
|
||||||
alt.warn("exception caught", e);
|
|
||||||
}
|
|
||||||
// then we check that CglibThrowableRenderer indeed remove those occurrences
|
|
||||||
assertFalse(w.toString().contains("<generated>"));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -32,6 +32,11 @@
|
|||||||
<artifactId>cloud-utils</artifactId>
|
<artifactId>cloud-utils</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.cloudstack</groupId>
|
||||||
|
<artifactId>cloud-framework-db</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.cloudstack</groupId>
|
<groupId>org.apache.cloudstack</groupId>
|
||||||
<artifactId>cloud-api</artifactId>
|
<artifactId>cloud-api</artifactId>
|
||||||
|
|||||||
@ -27,21 +27,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
|
||||||
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
|
||||||
import com.cloud.network.Networks.BroadcastDomainType;
|
|
||||||
import com.cloud.utils.ActionDelegate;
|
|
||||||
import com.cloud.utils.Pair;
|
|
||||||
import com.cloud.utils.cisco.n1kv.vsm.NetconfHelper;
|
|
||||||
import com.cloud.utils.cisco.n1kv.vsm.PolicyMap;
|
|
||||||
import com.cloud.utils.cisco.n1kv.vsm.PortProfile;
|
|
||||||
import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.BindingType;
|
|
||||||
import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.OperationType;
|
|
||||||
import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.PortProfileType;
|
|
||||||
import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.SwitchPortMode;
|
|
||||||
import com.cloud.utils.db.GlobalLock;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import com.cloud.utils.net.NetUtils;
|
|
||||||
import com.vmware.vim25.AlreadyExistsFaultMsg;
|
import com.vmware.vim25.AlreadyExistsFaultMsg;
|
||||||
import com.vmware.vim25.BoolPolicy;
|
import com.vmware.vim25.BoolPolicy;
|
||||||
import com.vmware.vim25.DVPortSetting;
|
import com.vmware.vim25.DVPortSetting;
|
||||||
@ -79,6 +64,22 @@ import com.vmware.vim25.VmwareDistributedVirtualSwitchPvlanSpec;
|
|||||||
import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
|
import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
|
||||||
import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanSpec;
|
import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanSpec;
|
||||||
|
|
||||||
|
import com.cloud.hypervisor.vmware.util.VmwareContext;
|
||||||
|
import com.cloud.hypervisor.vmware.util.VmwareHelper;
|
||||||
|
import com.cloud.network.Networks.BroadcastDomainType;
|
||||||
|
import com.cloud.utils.ActionDelegate;
|
||||||
|
import com.cloud.utils.Pair;
|
||||||
|
import com.cloud.utils.cisco.n1kv.vsm.NetconfHelper;
|
||||||
|
import com.cloud.utils.cisco.n1kv.vsm.PolicyMap;
|
||||||
|
import com.cloud.utils.cisco.n1kv.vsm.PortProfile;
|
||||||
|
import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.BindingType;
|
||||||
|
import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.OperationType;
|
||||||
|
import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.PortProfileType;
|
||||||
|
import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.SwitchPortMode;
|
||||||
|
import com.cloud.utils.db.GlobalLock;
|
||||||
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
import com.cloud.utils.net.NetUtils;
|
||||||
|
|
||||||
public class HypervisorHostHelper {
|
public class HypervisorHostHelper {
|
||||||
private static final Logger s_logger = Logger.getLogger(HypervisorHostHelper.class);
|
private static final Logger s_logger = Logger.getLogger(HypervisorHostHelper.class);
|
||||||
private static final int DEFAULT_LOCK_TIMEOUT_SECONDS = 600;
|
private static final int DEFAULT_LOCK_TIMEOUT_SECONDS = 600;
|
||||||
@ -446,29 +447,29 @@ public class HypervisorHostHelper {
|
|||||||
Integer vid = null;
|
Integer vid = null;
|
||||||
Integer spvlanid = null; // secondary pvlan id
|
Integer spvlanid = null; // secondary pvlan id
|
||||||
|
|
||||||
/** This is the list of BroadcastDomainTypes we can actually
|
/** This is the list of BroadcastDomainTypes we can actually
|
||||||
* prepare networks for in this function.
|
* prepare networks for in this function.
|
||||||
*/
|
*/
|
||||||
BroadcastDomainType[] supportedBroadcastTypes =
|
BroadcastDomainType[] supportedBroadcastTypes =
|
||||||
new BroadcastDomainType[] { BroadcastDomainType.Lswitch,
|
new BroadcastDomainType[] { BroadcastDomainType.Lswitch,
|
||||||
BroadcastDomainType.LinkLocal,
|
BroadcastDomainType.LinkLocal,
|
||||||
BroadcastDomainType.Native,
|
BroadcastDomainType.Native,
|
||||||
BroadcastDomainType.Pvlan,
|
BroadcastDomainType.Pvlan,
|
||||||
BroadcastDomainType.Storage,
|
BroadcastDomainType.Storage,
|
||||||
BroadcastDomainType.UnDecided,
|
BroadcastDomainType.UnDecided,
|
||||||
BroadcastDomainType.Vlan };
|
BroadcastDomainType.Vlan };
|
||||||
|
|
||||||
if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
|
if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
|
||||||
throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType +
|
throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType +
|
||||||
" it not supported on a VMWare hypervisor at this time.");
|
" it not supported on a VMWare hypervisor at this time.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (broadcastDomainType == BroadcastDomainType.Lswitch) {
|
if (broadcastDomainType == BroadcastDomainType.Lswitch) {
|
||||||
if (vSwitchType == VirtualSwitchType.NexusDistributedVirtualSwitch) {
|
if (vSwitchType == VirtualSwitchType.NexusDistributedVirtualSwitch) {
|
||||||
throw new InvalidParameterException("Nexus Distributed Virtualswitch is not supported with BroadcastDomainType " +
|
throw new InvalidParameterException("Nexus Distributed Virtualswitch is not supported with BroadcastDomainType " +
|
||||||
broadcastDomainType);
|
broadcastDomainType);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Nicira NVP requires all vms to be connected to a single port-group.
|
* Nicira NVP requires all vms to be connected to a single port-group.
|
||||||
* A unique vlan needs to be set per port. This vlan is specific to
|
* A unique vlan needs to be set per port. This vlan is specific to
|
||||||
* this implementation and has no reference to other vlans in CS
|
* this implementation and has no reference to other vlans in CS
|
||||||
@ -552,7 +553,7 @@ public class HypervisorHostHelper {
|
|||||||
}
|
}
|
||||||
long averageBandwidth = 0L;
|
long averageBandwidth = 0L;
|
||||||
if (networkRateMbps != null && networkRateMbps.intValue() > 0) {
|
if (networkRateMbps != null && networkRateMbps.intValue() > 0) {
|
||||||
averageBandwidth = (long) (networkRateMbps.intValue() * 1024L * 1024L);
|
averageBandwidth = networkRateMbps.intValue() * 1024L * 1024L;
|
||||||
}
|
}
|
||||||
// We chose 50% higher allocation than average bandwidth.
|
// We chose 50% higher allocation than average bandwidth.
|
||||||
// TODO(sateesh): Optionally let user specify the peak coefficient
|
// TODO(sateesh): Optionally let user specify the peak coefficient
|
||||||
@ -601,7 +602,7 @@ public class HypervisorHostHelper {
|
|||||||
return vCenterApiVersion.compareTo(minVcenterApiVersionForFeature) >= 0 ? true : false;
|
return vCenterApiVersion.compareTo(minVcenterApiVersionForFeature) >= 0 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setupPVlanPair(DistributedVirtualSwitchMO dvSwitchMo, ManagedObjectReference morDvSwitch,
|
private static void setupPVlanPair(DistributedVirtualSwitchMO dvSwitchMo, ManagedObjectReference morDvSwitch,
|
||||||
Integer vid, Integer spvlanid) throws Exception {
|
Integer vid, Integer spvlanid) throws Exception {
|
||||||
Map<Integer, HypervisorHostHelper.PvlanType> vlanmap = dvSwitchMo.retrieveVlanPvlan(vid, spvlanid, morDvSwitch);
|
Map<Integer, HypervisorHostHelper.PvlanType> vlanmap = dvSwitchMo.retrieveVlanPvlan(vid, spvlanid, morDvSwitch);
|
||||||
if (!vlanmap.isEmpty()) {
|
if (!vlanmap.isEmpty()) {
|
||||||
@ -664,7 +665,7 @@ public class HypervisorHostHelper {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createPortGroup(String physicalNetwork, String networkName, Integer vid, Integer spvlanid, DatacenterMO dataCenterMo,
|
private static void createPortGroup(String physicalNetwork, String networkName, Integer vid, Integer spvlanid, DatacenterMO dataCenterMo,
|
||||||
DVSTrafficShapingPolicy shapingPolicy, DVSSecurityPolicy secPolicy, DistributedVirtualSwitchMO dvSwitchMo, int numPorts, boolean autoExpandSupported) throws Exception{
|
DVSTrafficShapingPolicy shapingPolicy, DVSSecurityPolicy secPolicy, DistributedVirtualSwitchMO dvSwitchMo, int numPorts, boolean autoExpandSupported) throws Exception{
|
||||||
VmwareDistributedVirtualSwitchVlanSpec vlanSpec = null;
|
VmwareDistributedVirtualSwitchVlanSpec vlanSpec = null;
|
||||||
VmwareDistributedVirtualSwitchPvlanSpec pvlanSpec = null;
|
VmwareDistributedVirtualSwitchPvlanSpec pvlanSpec = null;
|
||||||
@ -717,7 +718,7 @@ public class HypervisorHostHelper {
|
|||||||
throw new Exception(msg);
|
throw new Exception(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ManagedObjectReference waitForDvPortGroupReady(
|
public static ManagedObjectReference waitForDvPortGroupReady(
|
||||||
@ -806,12 +807,12 @@ public class HypervisorHostHelper {
|
|||||||
LongPolicy burstSize = new LongPolicy();
|
LongPolicy burstSize = new LongPolicy();
|
||||||
|
|
||||||
isEnabled.setValue(true);
|
isEnabled.setValue(true);
|
||||||
averageBandwidth.setValue((long) networkRateMbps.intValue() * 1024L * 1024L);
|
averageBandwidth.setValue(networkRateMbps.intValue() * 1024L * 1024L);
|
||||||
// We chose 50% higher allocation than average bandwidth.
|
// We chose 50% higher allocation than average bandwidth.
|
||||||
// TODO(sateesh): Also let user specify the peak coefficient
|
// TODO(sateesh): Also let user specify the peak coefficient
|
||||||
peakBandwidth.setValue((long) (averageBandwidth.getValue() * 1.5));
|
peakBandwidth.setValue((long) (averageBandwidth.getValue() * 1.5));
|
||||||
// TODO(sateesh): Also let user specify the burst coefficient
|
// TODO(sateesh): Also let user specify the burst coefficient
|
||||||
burstSize.setValue((long) (5 * averageBandwidth.getValue() / 8));
|
burstSize.setValue(5 * averageBandwidth.getValue() / 8);
|
||||||
|
|
||||||
shapingPolicy.setEnabled(isEnabled);
|
shapingPolicy.setEnabled(isEnabled);
|
||||||
shapingPolicy.setAverageBandwidth(averageBandwidth);
|
shapingPolicy.setAverageBandwidth(averageBandwidth);
|
||||||
@ -889,25 +890,25 @@ public class HypervisorHostHelper {
|
|||||||
String networkName;
|
String networkName;
|
||||||
Integer vid = null;
|
Integer vid = null;
|
||||||
|
|
||||||
/** This is the list of BroadcastDomainTypes we can actually
|
/** This is the list of BroadcastDomainTypes we can actually
|
||||||
* prepare networks for in this function.
|
* prepare networks for in this function.
|
||||||
*/
|
*/
|
||||||
BroadcastDomainType[] supportedBroadcastTypes =
|
BroadcastDomainType[] supportedBroadcastTypes =
|
||||||
new BroadcastDomainType[] { BroadcastDomainType.Lswitch,
|
new BroadcastDomainType[] { BroadcastDomainType.Lswitch,
|
||||||
BroadcastDomainType.LinkLocal,
|
BroadcastDomainType.LinkLocal,
|
||||||
BroadcastDomainType.Native,
|
BroadcastDomainType.Native,
|
||||||
BroadcastDomainType.Pvlan,
|
BroadcastDomainType.Pvlan,
|
||||||
BroadcastDomainType.Storage,
|
BroadcastDomainType.Storage,
|
||||||
BroadcastDomainType.UnDecided,
|
BroadcastDomainType.UnDecided,
|
||||||
BroadcastDomainType.Vlan };
|
BroadcastDomainType.Vlan };
|
||||||
|
|
||||||
if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
|
if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
|
||||||
throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType +
|
throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType +
|
||||||
" it not supported on a VMWare hypervisor at this time.");
|
" it not supported on a VMWare hypervisor at this time.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (broadcastDomainType == BroadcastDomainType.Lswitch) {
|
if (broadcastDomainType == BroadcastDomainType.Lswitch) {
|
||||||
/**
|
/**
|
||||||
* Nicira NVP requires each vm to have its own port-group with a dedicated
|
* Nicira NVP requires each vm to have its own port-group with a dedicated
|
||||||
* vlan. We'll set the name of the pg to the uuid of the nic.
|
* vlan. We'll set the name of the pg to the uuid of the nic.
|
||||||
*/
|
*/
|
||||||
@ -934,7 +935,7 @@ public class HypervisorHostHelper {
|
|||||||
if(networkRateMbps != null && networkRateMbps.intValue() > 0) {
|
if(networkRateMbps != null && networkRateMbps.intValue() > 0) {
|
||||||
shapingPolicy = new HostNetworkTrafficShapingPolicy();
|
shapingPolicy = new HostNetworkTrafficShapingPolicy();
|
||||||
shapingPolicy.setEnabled(true);
|
shapingPolicy.setEnabled(true);
|
||||||
shapingPolicy.setAverageBandwidth((long)networkRateMbps.intValue()*1024L*1024L);
|
shapingPolicy.setAverageBandwidth(networkRateMbps.intValue()*1024L*1024L);
|
||||||
|
|
||||||
//
|
//
|
||||||
// TODO : people may have different opinion on how to set the following
|
// TODO : people may have different opinion on how to set the following
|
||||||
@ -1062,10 +1063,10 @@ public class HypervisorHostHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void createNvpPortGroup(HostMO hostMo, HostVirtualSwitch vSwitch, String networkName, HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
|
private static void createNvpPortGroup(HostMO hostMo, HostVirtualSwitch vSwitch, String networkName, HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
|
||||||
/**
|
/**
|
||||||
* No portgroup created yet for this nic
|
* No portgroup created yet for this nic
|
||||||
* We need to find an unused vlan and create the pg
|
* We need to find an unused vlan and create the pg
|
||||||
* The vlan is limited to this vSwitch and the NVP vAPP,
|
* The vlan is limited to this vSwitch and the NVP vAPP,
|
||||||
* so no relation to the other vlans in use in CloudStack.
|
* so no relation to the other vlans in use in CloudStack.
|
||||||
*/
|
*/
|
||||||
String vSwitchName = vSwitch.getName();
|
String vSwitchName = vSwitch.getName();
|
||||||
@ -1096,7 +1097,7 @@ public class HypervisorHostHelper {
|
|||||||
secPolicy.setMacChanges(Boolean.FALSE);
|
secPolicy.setMacChanges(Boolean.FALSE);
|
||||||
|
|
||||||
// Create a portgroup with the uuid of the nic and the vlanid found above
|
// Create a portgroup with the uuid of the nic and the vlanid found above
|
||||||
hostMo.createPortGroup(vSwitch, networkName, nvpVlanId, secPolicy, shapingPolicy);
|
hostMo.createPortGroup(vSwitch, networkName, nvpVlanId, secPolicy, shapingPolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ManagedObjectReference waitForNetworkReady(HostMO hostMo,
|
public static ManagedObjectReference waitForNetworkReady(HostMO hostMo,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user