Merge branch 'master' into ui-restyle

This commit is contained in:
Brian Federle 2013-10-16 14:45:13 -07:00
commit 116e06e3ba
26 changed files with 255 additions and 62 deletions

View File

@ -41,7 +41,8 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit
StaticRoute,
VMSnapshot,
RemoteAccessVpn,
Zone
Zone,
ServiceOffering
}
/**

View File

@ -518,6 +518,7 @@ public class ApiConstants {
public static final String ROUTING = "isrouting";
public static final String MAX_CONNECTIONS = "maxconnections";
public static final String SERVICE_STATE = "servicestate";
public static final String RESOURCE_TAG = "resourcetag";
public enum HostDetails {
all, capacity, events, stats, min;
}

View File

@ -16,10 +16,16 @@
// under the License.
package org.apache.cloudstack.api.command.user.offering;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.BaseCmd.CommandType;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
@ -27,6 +33,8 @@ import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.log4j.Logger;
import com.cloud.exception.InvalidParameterValueException;
@APICommand(name = "listServiceOfferings", description="Lists all available service offerings.", responseObject=ServiceOfferingResponse.class)
public class ListServiceOfferingsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListServiceOfferingsCmd.class.getName());
@ -57,6 +65,9 @@ public class ListServiceOfferingsCmd extends BaseListCmd {
@Parameter(name=ApiConstants.SYSTEM_VM_TYPE, type=CommandType.STRING, description="the system VM type. Possible types are \"consoleproxy\", \"secondarystoragevm\" or \"domainrouter\".")
private String systemVmType;
@Parameter(name = ApiConstants.RESOURCE_TAG, type = CommandType.MAP, description = "List service offerings by resource tags (key/value pairs)", since="4.3")
private Map resourceTag;
/////////////////////////////////////////////////////
@ -86,6 +97,25 @@ public class ListServiceOfferingsCmd extends BaseListCmd {
public String getSystemVmType(){
return systemVmType;
}
public Map<String, String> getResourceTags() {
Map<String, String> tagsMap = null;
if (resourceTag != null && !resourceTag.isEmpty()) {
tagsMap = new HashMap<String, String>();
Collection<?> servicesCollection = resourceTag.values();
Iterator<?> iter = servicesCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> services = (HashMap<String, String>) iter.next();
String key = services.get("key");
String value = services.get("value");
if (value == null) {
throw new InvalidParameterValueException("No value is passed in for key " + key);
}
tagsMap.put(key, value);
}
}
return tagsMap;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
@ -98,7 +128,6 @@ public class ListServiceOfferingsCmd extends BaseListCmd {
@Override
public void execute(){
ListResponse<ServiceOfferingResponse> response = _queryService.searchForServiceOfferings(this);
response.setResponseName(getCommandName());
this.setResponseObject(response);

View File

@ -17,12 +17,9 @@
package org.apache.cloudstack.api.response;
import java.util.Date;
import com.google.gson.annotations.SerializedName;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
@ -30,6 +27,7 @@ import org.apache.cloudstack.api.EntityReference;
import com.cloud.offering.ServiceOffering;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@EntityReference(value = ServiceOffering.class)
public class ServiceOfferingResponse extends BaseResponse {
@ -108,6 +106,15 @@ public class ServiceOfferingResponse extends BaseResponse {
@SerializedName(ApiConstants.SERVICE_OFFERING_DETAILS)
@Param(description = "additional key/value details tied with this service offering", since = "4.2.0")
private Map<String, String> details;
@SerializedName(ApiConstants.RESOURCE_TAG) @Param(description="the list of resource tags associated with service offering." +
" The resource tags are not used for Volume/VM placement on the specific host.",
responseObject = ResourceTagResponse.class, since="4.3")
private Set<ResourceTagResponse> resourceTags;
public ServiceOfferingResponse(){
resourceTags = new LinkedHashSet<ResourceTagResponse>();
}
public String getId() {
return id;
@ -287,4 +294,8 @@ public class ServiceOfferingResponse extends BaseResponse {
public void setDetails(Map<String, String> details) {
this.details = details;
}
public void addTag(ResourceTagResponse tag){
this.resourceTags.add(tag);
}
}

View File

@ -18,15 +18,22 @@
package com.cloud.upgrade.dao;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Properties;
import com.cloud.utils.PropertiesUtil;
import com.cloud.utils.crypt.EncryptionSecretKeyChecker;
import org.apache.log4j.Logger;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.script.Script;
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.properties.EncryptableProperties;
public class Upgrade307to410 implements DbUpgrade {
final static Logger s_logger = Logger.getLogger(Upgrade307to410.class);
@ -62,7 +69,28 @@ public class Upgrade307to410 implements DbUpgrade {
}
private void updateRegionEntries(Connection conn) {
int region_id = Transaction.s_region_id;
File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
final Properties dbProps;
if (EncryptionSecretKeyChecker.useEncryption()) {
StandardPBEStringEncryptor encryptor = EncryptionSecretKeyChecker.getEncryptor();
dbProps = new EncryptableProperties(encryptor);
} else {
dbProps = new Properties();
}
try {
dbProps.load(new FileInputStream(dbPropsFile));
} catch (IOException e) {
s_logger.fatal("Unable to load db properties file, pl. check the classpath and file path configuration", e);
return;
} catch (NullPointerException e) {
s_logger.fatal("Unable to locate db properties file within classpath or absolute path: db.properties");
return;
}
int region_id = 1;
String regionId = dbProps.getProperty("region.id");
if(regionId != null){
region_id = Integer.parseInt(regionId);
}
PreparedStatement pstmt = null;
try {
//Update regionId in region table

View File

@ -17,16 +17,23 @@
package com.cloud.upgrade.dao;
import com.cloud.utils.PropertiesUtil;
import com.cloud.utils.crypt.EncryptionSecretKeyChecker;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.script.Script;
import org.apache.log4j.Logger;
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.properties.EncryptableProperties;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import java.util.UUID;
public class Upgrade40to41 implements DbUpgrade {
@ -74,7 +81,28 @@ public class Upgrade40to41 implements DbUpgrade {
}
private void updateRegionEntries(Connection conn) {
int region_id = Transaction.s_region_id;
File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
final Properties dbProps;
if (EncryptionSecretKeyChecker.useEncryption()) {
StandardPBEStringEncryptor encryptor = EncryptionSecretKeyChecker.getEncryptor();
dbProps = new EncryptableProperties(encryptor);
} else {
dbProps = new Properties();
}
try {
dbProps.load(new FileInputStream(dbPropsFile));
} catch (IOException e) {
s_logger.fatal("Unable to load db properties file, pl. check the classpath and file path configuration", e);
return;
} catch (NullPointerException e) {
s_logger.fatal("Unable to locate db properties file within classpath or absolute path: db.properties");
return;
}
int region_id = 1;
String regionId = dbProps.getProperty("region.id");
if(regionId != null){
region_id = Integer.parseInt(regionId);
}
PreparedStatement pstmt = null;
try {
//Update regionId in region table

View File

@ -23,5 +23,5 @@ import com.cloud.utils.db.GenericDao;
public interface RegionDao extends GenericDao<RegionVO, Integer> {
RegionVO findByName(String name);
int getRegionId();
}

View File

@ -45,4 +45,9 @@ public class RegionDaoImpl extends GenericDaoBase<RegionVO, Integer> implements
sc.setParameters("name", name);
return findOneBy(sc);
}
@Override
public int getRegionId(){
return 1;
}
}

View File

@ -265,8 +265,6 @@ public interface GenericDao<T, ID extends Serializable> {
*/
Class<T> getEntityBeanType();
public int getRegionId();
/**
* @param sc
* @param filter

View File

@ -1796,11 +1796,6 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
return builder.create();
}
@Override
public int getRegionId(){
return Transaction.s_region_id;
}
public Integer getCount(SearchCriteria<T> sc) {
String clause = sc != null ? sc.getWhereClause() : null;
if (clause != null && clause.length() == 0) {

View File

@ -83,7 +83,6 @@ public class Transaction {
public static final short AWSAPI_DB = 2;
public static final short SIMULATOR_DB = 3;
public static final short CONNECTED_DB = -1;
public static int s_region_id;
private static AtomicLong s_id = new AtomicLong();
private static final TransactionMBeanImpl s_mbean = new TransactionMBeanImpl();
@ -1079,12 +1078,6 @@ public class Transaction {
System.setProperty("javax.net.ssl.trustStorePassword", dbProps.getProperty("db.cloud.trustStorePassword"));
}
String regionId = dbProps.getProperty("region.id");
if(regionId == null){
s_region_id = 1;
} else {
s_region_id = Integer.parseInt(regionId);
}
final GenericObjectPool cloudConnectionPool = new GenericObjectPool(null, cloudMaxActive, GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION,
cloudMaxWait, cloudMaxIdle, cloudTestOnBorrow, false, cloudTimeBtwEvictionRunsMillis, 1, cloudMinEvcitableIdleTimeMillis, cloudTestWhileIdle);

View File

@ -3549,7 +3549,7 @@ ServerResource {
// pass cmdline info to system vms
if (vmSpec.getType() != VirtualMachine.Type.User) {
if ((_kernelVersion < 2006034) && (conn.getVersion() < 1001000)) { // CLOUDSTACK-2823: try passCmdLine some times if kernel < 2.6.34 and qemu < 1.1.0 on hypervisor (for instance, CentOS 6.4)
if ((conn.getVersion() < 1001000)) { // CLOUDSTACK-2823: try passCmdLine some times if kernel < 2.6.34 and qemu < 1.1.0 on hypervisor (for instance, CentOS 6.4)
//wait for 5 minutes at most
String controlIp = null;
for (NicTO nic : nics) {

View File

@ -1688,4 +1688,8 @@ public class ApiDBUtils {
public static boolean isAdmin(Account account) {
return _accountService.isAdmin(account.getType());
}
public static List<ResourceTagJoinVO> listResourceTagViewByResourceUUID(String resourceUUID, TaggedResourceType resourceType){
return _tagJoinDao.listBy(resourceUUID, resourceType);
}
}

View File

@ -26,7 +26,6 @@ import java.util.Set;
import javax.ejb.Local;
import javax.inject.Inject;
import com.cloud.network.dao.NetworkDetailsDao;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.affinity.AffinityGroupDomainMapVO;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
@ -142,6 +141,7 @@ import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.UnsupportedServiceException;
import com.cloud.ha.HighAvailabilityManager;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.dao.NetworkDetailsDao;
import com.cloud.network.security.SecurityGroupVMMapVO;
import com.cloud.network.security.dao.SecurityGroupVMMapDao;
import com.cloud.org.Grouping;
@ -168,6 +168,8 @@ import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Volume;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDetailsDao;
import com.cloud.tags.ResourceTagVO;
import com.cloud.tags.dao.ResourceTagDao;
import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
@ -179,6 +181,7 @@ import com.cloud.utils.Pair;
import com.cloud.utils.Ternary;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.db.Filter;
import com.cloud.utils.db.JoinBuilder;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.SearchCriteria.Func;
@ -335,6 +338,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
@Inject
NetworkDetailsDao _networkDetailsDao;
@Inject
ResourceTagDao _resourceTagDao;
/*
* (non-Javadoc)
@ -2375,8 +2381,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
isAscending = (isAscending == null ? true : isAscending);
Filter searchFilter = new Filter(ServiceOfferingJoinVO.class, "sortKey", isAscending, cmd.getStartIndex(),
cmd.getPageSizeVal());
SearchCriteria<ServiceOfferingJoinVO> sc = _srvOfferingJoinDao.createSearchCriteria();
Account caller = CallContext.current().getCallingAccount();
Object name = cmd.getServiceOfferingName();
Object id = cmd.getId();
@ -2385,6 +2390,22 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
Long domainId = cmd.getDomainId();
Boolean isSystem = cmd.getIsSystem();
String vmTypeStr = cmd.getSystemVmType();
Map<String, String> resourceTags = cmd.getResourceTags();
SearchBuilder<ServiceOfferingJoinVO> sb = _srvOfferingJoinDao.createSearchBuilder();
if (resourceTags != null && !resourceTags.isEmpty()) {
SearchBuilder<ResourceTagVO> tagSearch = _resourceTagDao.createSearchBuilder();
for (int count=0; count < resourceTags.size(); count++) {
tagSearch.or().op("key" + String.valueOf(count), tagSearch.entity().getKey(), SearchCriteria.Op.EQ);
tagSearch.and("value" + String.valueOf(count), tagSearch.entity().getValue(), SearchCriteria.Op.EQ);
tagSearch.cp();
}
tagSearch.and("resourceType", tagSearch.entity().getResourceType(), SearchCriteria.Op.EQ);
sb.groupBy(sb.entity().getId());
sb.join("tagSearch", tagSearch, sb.entity().getId(), tagSearch.entity().getResourceId(), JoinBuilder.JoinType.INNER);
}
SearchCriteria<ServiceOfferingJoinVO> sc = sb.create();
if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN && isSystem) {
throw new InvalidParameterValueException("Only ROOT admins can access system's offering");
@ -2483,9 +2504,19 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
if (vmTypeStr != null) {
sc.addAnd("vm_type", SearchCriteria.Op.EQ, vmTypeStr);
}
if (resourceTags != null && !resourceTags.isEmpty()) {
int count = 0;
sc.setJoinParameters("tagSearch", "resourceType", TaggedResourceType.ServiceOffering.toString());
for (String key : resourceTags.keySet()) {
sc.setJoinParameters("tagSearch", "key" + String.valueOf(count), key);
sc.setJoinParameters("tagSearch", "value" + String.valueOf(count), resourceTags.get(key));
count++;
}
}
return _srvOfferingJoinDao.searchAndCount(sc, searchFilter);
}
@Override

View File

@ -22,6 +22,7 @@ import org.apache.cloudstack.api.response.ResourceTagResponse;
import com.cloud.api.query.vo.ResourceTagJoinVO;
import com.cloud.server.ResourceTag;
import com.cloud.server.ResourceTag.TaggedResourceType;
import com.cloud.utils.db.GenericDao;
public interface ResourceTagJoinDao extends GenericDao<ResourceTagJoinVO, Long> {
@ -31,4 +32,6 @@ public interface ResourceTagJoinDao extends GenericDao<ResourceTagJoinVO, Long>
ResourceTagJoinVO newResourceTagView(ResourceTag vr);
List<ResourceTagJoinVO> searchByIds(Long... ids);
List<ResourceTagJoinVO> listBy(String resourceUUID, TaggedResourceType resourceType);
}

View File

@ -24,16 +24,17 @@ import javax.inject.Inject;
import org.apache.cloudstack.api.response.ResourceTagResponse;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.cloud.api.ApiResponseHelper;
import com.cloud.api.query.vo.ResourceTagJoinVO;
import com.cloud.server.ResourceTag;
import com.cloud.server.ResourceTag.TaggedResourceType;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.SearchCriteria.Op;
@Component
@Local(value={ResourceTagJoinDao.class})
@ -46,6 +47,9 @@ public class ResourceTagJoinDaoImpl extends GenericDaoBase<ResourceTagJoinVO, Lo
private final SearchBuilder<ResourceTagJoinVO> tagSearch;
private final SearchBuilder<ResourceTagJoinVO> tagIdSearch;
private final SearchBuilder<ResourceTagJoinVO> AllFieldsSearch;
protected ResourceTagJoinDaoImpl() {
@ -58,12 +62,14 @@ public class ResourceTagJoinDaoImpl extends GenericDaoBase<ResourceTagJoinVO, Lo
tagIdSearch.done();
this._count = "select count(distinct id) from resource_tag_view WHERE ";
AllFieldsSearch = createSearchBuilder();
AllFieldsSearch.and("resourceId", AllFieldsSearch.entity().getResourceId(), Op.EQ);
AllFieldsSearch.and("uuid", AllFieldsSearch.entity().getResourceUuid(), Op.EQ);
AllFieldsSearch.and("resourceType", AllFieldsSearch.entity().getResourceType(), Op.EQ);
AllFieldsSearch.done();
}
@Override
public ResourceTagResponse newResourceTagResponse(ResourceTagJoinVO resourceTag, boolean keyValueOnly) {
ResourceTagResponse response = new ResourceTagResponse();
@ -86,6 +92,15 @@ public class ResourceTagJoinDaoImpl extends GenericDaoBase<ResourceTagJoinVO, Lo
return response;
}
@Override
public List<ResourceTagJoinVO> listBy(String resourceUUID, TaggedResourceType resourceType) {
SearchCriteria<ResourceTagJoinVO> sc = AllFieldsSearch.create();
sc.setParameters("uuid", resourceUUID);
sc.setParameters("resourceType", resourceType);
return listBy(sc);
}
@Override

View File

@ -17,22 +17,22 @@
package com.cloud.api.query.dao;
import java.util.List;
import java.util.Map;
import javax.ejb.Local;
import org.apache.cloudstack.api.response.ResourceTagResponse;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.query.vo.ResourceTagJoinVO;
import com.cloud.api.query.vo.ServiceOfferingJoinVO;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
import com.cloud.offering.ServiceOffering;
import com.cloud.offering.NetworkOffering.Detail;
import com.cloud.server.ResourceTag.TaggedResourceType;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import org.springframework.stereotype.Component;
@Component
@Local(value={ServiceOfferingJoinDao.class})
@ -48,7 +48,7 @@ public class ServiceOfferingJoinDaoImpl extends GenericDaoBase<ServiceOfferingJo
sofIdSearch.and("id", sofIdSearch.entity().getId(), SearchCriteria.Op.EQ);
sofIdSearch.done();
this._count = "select count(distinct id) from service_offering_view WHERE ";
this._count = "select count(distinct service_offering_view.id) from service_offering_view WHERE ";
}
@ -84,6 +84,12 @@ public class ServiceOfferingJoinDaoImpl extends GenericDaoBase<ServiceOfferingJo
offeringResponse.setIopsWriteRate(offering.getIopsWriteRate());
offeringResponse.setDetails(ApiDBUtils.getServiceOfferingDetails(offering.getId()));
offeringResponse.setObjectName("serviceoffering");
// update tag information
List<ResourceTagJoinVO> resourceTags = ApiDBUtils.listResourceTagViewByResourceUUID(offering.getUuid(), TaggedResourceType.ServiceOffering);
for (ResourceTagJoinVO resourceTag : resourceTags) {
ResourceTagResponse tagResponse = ApiDBUtils.newResourceTagResponse(resourceTag, false);
offeringResponse.addTag(tagResponse); }
return offeringResponse;
}

View File

@ -1198,12 +1198,23 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
}
}
// In Advance zone only allow to do IP assoc
// - for Isolated networks with source nat service enabled
// - for shared networks with source nat service enabled
if (zone.getNetworkType() == NetworkType.Advanced && !(_networkModel.areServicesSupportedInNetwork(network.getId(), Service.SourceNat))) {
throw new InvalidParameterValueException("In zone of type " + NetworkType.Advanced + " ip address can be associated only to the network of guest type " +
GuestType.Isolated + " with the " + Service.SourceNat.getName() + " enabled");
if (zone.getNetworkType() == NetworkType.Advanced) {
// In Advance zone allow to do IP assoc only for Isolated networks with source nat service enabled
if (network.getGuestType() == GuestType.Isolated &&
!(_networkModel.areServicesSupportedInNetwork(network.getId(), Service.SourceNat))) {
throw new InvalidParameterValueException("In zone of type " + NetworkType.Advanced +
" ip address can be associated only to the network of guest type " + GuestType.Isolated +
" with the " + Service.SourceNat.getName() + " enabled");
}
// In Advance zone allow to do IP assoc only for shared networks with source nat/static nat/lb/pf services enabled
if (network.getGuestType() == GuestType.Shared &&
!isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) {
throw new InvalidParameterValueException("In zone of type " + NetworkType.Advanced +
" ip address can be associated with network of guest type " + GuestType.Shared + "only if at " +
"least one of the services " + Service.SourceNat.getName() + "/" + Service.StaticNat.getName() + "/" +
Service.Lb.getName() + "/" + Service.PortForwarding.getName() + " is enabled");
}
}
NetworkOffering offering = _networkOfferingDao.findById(network.getNetworkOfferingId());

View File

@ -25,16 +25,12 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.vm.dao.NicDao;
import com.cloud.network.vpc.NetworkACLItemDao;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.apache.cloudstack.context.CallContext;
import com.cloud.api.query.dao.ResourceTagJoinDao;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.domain.Domain;
import com.cloud.event.ActionEvent;
import com.cloud.event.EventTypes;
@ -47,12 +43,14 @@ import com.cloud.network.dao.NetworkDao;
import com.cloud.network.dao.RemoteAccessVpnDao;
import com.cloud.network.rules.dao.PortForwardingRulesDao;
import com.cloud.network.security.dao.SecurityGroupDao;
import com.cloud.network.vpc.NetworkACLItemDao;
import com.cloud.network.vpc.dao.StaticRouteDao;
import com.cloud.network.vpc.dao.VpcDao;
import com.cloud.projects.dao.ProjectDao;
import com.cloud.server.ResourceTag;
import com.cloud.server.ResourceTag.TaggedResourceType;
import com.cloud.server.TaggedResourceService;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.storage.dao.SnapshotDao;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDao;
@ -70,6 +68,7 @@ import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.uuididentity.dao.IdentityDao;
import com.cloud.vm.dao.NicDao;
import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.snapshot.dao.VMSnapshotDao;
@ -128,6 +127,8 @@ public class TaggedResourceManagerImpl extends ManagerBase implements TaggedReso
NetworkACLItemDao _networkACLItemDao;
@Inject
DataCenterDao _dataCenterDao;
@Inject
ServiceOfferingDao _serviceOffDao;
@Override
@ -151,6 +152,7 @@ public class TaggedResourceManagerImpl extends ManagerBase implements TaggedReso
_daoMap.put(TaggedResourceType.VMSnapshot, _vmSnapshotDao);
_daoMap.put(TaggedResourceType.RemoteAccessVpn, _vpnDao);
_daoMap.put(TaggedResourceType.Zone, _dataCenterDao);
_daoMap.put(TaggedResourceType.ServiceOffering, _serviceOffDao);
return true;
}

View File

@ -110,7 +110,9 @@ public class IdentityDaoImpl extends GenericDaoBase<IdentityVO, Long> implements
pstmt.setLong(1, identityId);
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
domainId = rs.getLong(1);
if (rs.getLong(1) != 0) {
domainId = rs.getLong(1);
}
}
} catch (SQLException e) {
}
@ -125,7 +127,9 @@ public class IdentityDaoImpl extends GenericDaoBase<IdentityVO, Long> implements
pstmt.setLong(1, identityId);
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
accountId = rs.getLong(1);
if (rs.getLong(1) != 0) {
accountId = rs.getLong(1);
}
}
} catch (SQLException e) {
}

View File

@ -26,22 +26,30 @@ import com.cloud.user.DomainManager;
import com.cloud.user.UserAccount;
import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.UserAccountDao;
import com.cloud.utils.PropertiesUtil;
import com.cloud.utils.component.Manager;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.crypt.EncryptionSecretKeyChecker;
import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
import org.apache.cloudstack.api.command.admin.domain.UpdateDomainCmd;
import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
import org.apache.cloudstack.region.dao.RegionDao;
import org.apache.log4j.Logger;
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.properties.EncryptableProperties;
import org.springframework.stereotype.Component;
import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@Component
@Local(value = { RegionManager.class })
@ -63,7 +71,28 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man
@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
_name = name;
_id = _regionDao.getRegionId();
File dbPropsFile = PropertiesUtil.findConfigFile("db.properties");
final Properties dbProps;
if (EncryptionSecretKeyChecker.useEncryption()) {
StandardPBEStringEncryptor encryptor = EncryptionSecretKeyChecker.getEncryptor();
dbProps = new EncryptableProperties(encryptor);
} else {
dbProps = new Properties();
}
try {
dbProps.load(new FileInputStream(dbPropsFile));
} catch (IOException e) {
s_logger.fatal("Unable to load db properties file, pl. check the classpath and file path configuration", e);
return false;
} catch (NullPointerException e) {
s_logger.fatal("Unable to locate db properties file within classpath or absolute path: db.properties");
return false;
}
String regionId = dbProps.getProperty("region.id");
_id = 1;
if(regionId != null){
_id = Integer.parseInt(regionId);
}
return true;
}

View File

@ -24,3 +24,6 @@ INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'manag
INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Storage", 'DEFAULT', 'management-server', "enable.ha.storage.migration", "true", "Enable/disable storage migration across primary storage during HA");
-- Remove Windows Server 8 from guest_os_type dropdown to use Windows Server 2012
DELETE FROM `cloud`.`guest_os_hypervisor` where guest_os_id=168;
DELETE FROM `cloud`.`guest_os` where id=168;

View File

@ -217,7 +217,6 @@ INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (164
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (165, UUID(), 6, 'Windows 8 (32-bit)');
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (166, UUID(), 6, 'Windows 8 (64-bit)');
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (167, UUID(), 6, 'Windows Server 2012 (64-bit)');
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (168, UUID(), 6, 'Windows Server 8 (64-bit)');
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (169, UUID(), 10, 'Ubuntu 11.04 (32-bit)');
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (170, UUID(), 10, 'Ubuntu 11.04 (64-bit)');
INSERT INTO `cloud`.`guest_os` (id, uuid, category_id, display_name) VALUES (171, UUID(), 1, 'CentOS 6.3 (32-bit)');
@ -373,8 +372,6 @@ INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest
INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Windows 8 (32-bit)', 165);
INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Windows 8 (64-bit)', 166);
INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Windows Server 2012 (64-bit)', 167);
INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'Windows Server 8 (64-bit)', 168);
INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Microsoft Windows 7(32-bit)', 48);
INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Microsoft Windows 7(64-bit)', 49);
@ -406,7 +403,6 @@ INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest
INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Windows 8 (32-bit)', 165);
INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Windows 8 (64-bit)', 166);
INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Windows Server 2012 (64-bit)', 167);
INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Windows Server 8 (64-bit)', 168);
INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Red Hat Enterprise Linux 5.0(32-bit)', 30);
INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("VmWare", 'Red Hat Enterprise Linux 5.1(32-bit)', 32);

View File

@ -4446,7 +4446,7 @@ Dialogs*/
/**** Alerts*/
.dashboard.admin .dashboard-container.sub.alerts {
float: left;
margin: 0 17px 0 0;
margin: 0 12px 0 0;
height: 313px;
overflow: hidden;
position: relative;

View File

@ -1314,7 +1314,7 @@
$(serviceofferings).each(function() {
items.push({
id: this.id,
description: this.displaytext
description: this.name
});
});
args.response.success({

View File

@ -60,7 +60,7 @@ public class VmwareGuestOsMapper {
s_mapper.put("Windows 8 (32-bit)", VirtualMachineGuestOsIdentifier.WINDOWS_8_GUEST);
s_mapper.put("Windows 8 (64-bit)", VirtualMachineGuestOsIdentifier.WINDOWS_8_64_GUEST);
s_mapper.put("Windows Server 8 (64-bit)", VirtualMachineGuestOsIdentifier.WINDOWS_8_SERVER_64_GUEST);
s_mapper.put("Windows Server 2012 (64-bit)", VirtualMachineGuestOsIdentifier.WINDOWS_8_SERVER_64_GUEST);
s_mapper.put("Apple Mac OS X 10.6 (32-bit)", VirtualMachineGuestOsIdentifier.DARWIN_10_GUEST);
s_mapper.put("Apple Mac OS X 10.6 (64-bit)", VirtualMachineGuestOsIdentifier.DARWIN_10_64_GUEST);