Updated Branches: refs/heads/object_store ef30ee52e -> 09ba55103
Populate hypervisor_type column in registering ISO by referring it from guest os id to make listIsos and listTemplates implementation more consistent. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7ba1a8fa Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7ba1a8fa Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7ba1a8fa Branch: refs/heads/object_store Commit: 7ba1a8fa2154ab0db543f4df42310208d1aae881 Parents: ef30ee5 Author: Min Chen <[email protected]> Authored: Thu Apr 18 13:52:15 2013 -0700 Committer: Min Chen <[email protected]> Committed: Thu Apr 18 13:52:35 2013 -0700 ---------------------------------------------------------------------- api/src/com/cloud/storage/GuestOSHypervisor.java | 28 ++++++ client/tomcatconf/applicationContext.xml.in | 2 + .../src/com/cloud/storage/GuestOSHypervisorVO.java | 73 +++++++++++++++ .../cloud/storage/dao/GuestOSHypervisorDao.java | 27 ++++++ .../storage/dao/GuestOSHypervisorDaoImpl.java | 49 ++++++++++ .../com/cloud/template/TemplateAdapterBase.java | 9 ++- 6 files changed, 187 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ba1a8fa/api/src/com/cloud/storage/GuestOSHypervisor.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/storage/GuestOSHypervisor.java b/api/src/com/cloud/storage/GuestOSHypervisor.java new file mode 100644 index 0000000..f022722 --- /dev/null +++ b/api/src/com/cloud/storage/GuestOSHypervisor.java @@ -0,0 +1,28 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.storage; + +import org.apache.cloudstack.api.InternalIdentity; + +public interface GuestOSHypervisor extends InternalIdentity { + + String getHypervisorType(); + + String getGuestOsName(); + + long getGuestOsId(); +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ba1a8fa/client/tomcatconf/applicationContext.xml.in ---------------------------------------------------------------------- diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in index 7ad3bb5..7bbcf09 100644 --- a/client/tomcatconf/applicationContext.xml.in +++ b/client/tomcatconf/applicationContext.xml.in @@ -212,6 +212,8 @@ <bean id="globalLoadBalancerLbRuleMapDaoImpl" class="org.apache.cloudstack.region.gslb.GlobalLoadBalancerLbRuleMapDaoImpl" /> <bean id="guestOSCategoryDaoImpl" class="com.cloud.storage.dao.GuestOSCategoryDaoImpl" /> <bean id="guestOSDaoImpl" class="com.cloud.storage.dao.GuestOSDaoImpl" /> + <bean id="guestOSHypervisorDaoImpl" class="com.cloud.storage.dao.GuestOSHypervisorDaoImpl" /> + <bean id="guestOSDaoImpl" class="com.cloud.storage.dao.GuestOSDaoImpl" /> <bean id="highAvailabilityDaoImpl" class="com.cloud.ha.dao.HighAvailabilityDaoImpl" /> <bean id="hostDaoImpl" class="com.cloud.host.dao.HostDaoImpl" /> <bean id="engineHostDetailsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.HostDetailsDaoImpl" /> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ba1a8fa/core/src/com/cloud/storage/GuestOSHypervisorVO.java ---------------------------------------------------------------------- diff --git a/core/src/com/cloud/storage/GuestOSHypervisorVO.java b/core/src/com/cloud/storage/GuestOSHypervisorVO.java new file mode 100644 index 0000000..5ab3480 --- /dev/null +++ b/core/src/com/cloud/storage/GuestOSHypervisorVO.java @@ -0,0 +1,73 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.storage; + +import java.util.UUID; + +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 org.apache.cloudstack.api.Identity; +import org.apache.cloudstack.api.InternalIdentity; + +@Entity +@Table(name="guest_os_hypervisor") +public class GuestOSHypervisorVO implements GuestOSHypervisor { + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + @Column(name="id") + long id; + + @Column(name="guest_os_id") + private long guestOsId; + + @Column(name="guest_os_name") + String guestOsName; + + @Column(name="hypervisor_type") + String hypervisorType; + + + @Override + public long getId() { + return id; + } + + + @Override + public String getHypervisorType() { + return hypervisorType; + } + + + @Override + public String getGuestOsName() { + return guestOsName; + } + + + @Override + public long getGuestOsId() { + return guestOsId; + } + + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ba1a8fa/server/src/com/cloud/storage/dao/GuestOSHypervisorDao.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/dao/GuestOSHypervisorDao.java b/server/src/com/cloud/storage/dao/GuestOSHypervisorDao.java new file mode 100644 index 0000000..945a542 --- /dev/null +++ b/server/src/com/cloud/storage/dao/GuestOSHypervisorDao.java @@ -0,0 +1,27 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.storage.dao; + +import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.storage.GuestOSHypervisorVO; +import com.cloud.utils.db.GenericDao; + +public interface GuestOSHypervisorDao extends GenericDao<GuestOSHypervisorVO, Long> { + + HypervisorType findHypervisorTypeByGuestOsId(long guestOsId); + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ba1a8fa/server/src/com/cloud/storage/dao/GuestOSHypervisorDaoImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/dao/GuestOSHypervisorDaoImpl.java b/server/src/com/cloud/storage/dao/GuestOSHypervisorDaoImpl.java new file mode 100644 index 0000000..48de6e9 --- /dev/null +++ b/server/src/com/cloud/storage/dao/GuestOSHypervisorDaoImpl.java @@ -0,0 +1,49 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package com.cloud.storage.dao; + +import javax.ejb.Local; + +import org.springframework.stereotype.Component; + +import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.storage.GuestOSHypervisorVO; +import com.cloud.utils.db.GenericDaoBase; +import com.cloud.utils.db.SearchBuilder; +import com.cloud.utils.db.SearchCriteria; + +@Component +@Local(value = { GuestOSHypervisorDao.class }) +public class GuestOSHypervisorDaoImpl extends GenericDaoBase<GuestOSHypervisorVO, Long> implements GuestOSHypervisorDao { + + protected final SearchBuilder<GuestOSHypervisorVO> guestOsSearch; + + protected GuestOSHypervisorDaoImpl() { + guestOsSearch = createSearchBuilder(); + guestOsSearch.and("guest_os_id", guestOsSearch.entity().getGuestOsId(), SearchCriteria.Op.EQ); + guestOsSearch.done(); + } + + @Override + public HypervisorType findHypervisorTypeByGuestOsId(long guestOsId) { + SearchCriteria<GuestOSHypervisorVO> sc = guestOsSearch.create(); + sc.setParameters("guest_os_id", guestOsId); + GuestOSHypervisorVO goh = findOneBy(sc); + return HypervisorType.getType(goh.getHypervisorType()); + } + +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7ba1a8fa/server/src/com/cloud/template/TemplateAdapterBase.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/template/TemplateAdapterBase.java b/server/src/com/cloud/template/TemplateAdapterBase.java index 987e6ed..9826298 100755 --- a/server/src/com/cloud/template/TemplateAdapterBase.java +++ b/server/src/com/cloud/template/TemplateAdapterBase.java @@ -50,6 +50,7 @@ import com.cloud.storage.Storage.TemplateType; import com.cloud.storage.DataStoreRole; import com.cloud.storage.TemplateProfile; import com.cloud.storage.VMTemplateVO; +import com.cloud.storage.dao.GuestOSHypervisorDao; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplateHostDao; import com.cloud.storage.dao.VMTemplateZoneDao; @@ -81,6 +82,7 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat protected @Inject UsageEventDao _usageEventDao; protected @Inject HostDao _hostDao; protected @Inject UserVmDao _userVmDao; + protected @Inject GuestOSHypervisorDao _osHyperDao; protected @Inject ResourceLimitService _resourceLimitMgr; protected @Inject DataStoreManager storeMgr; @Inject TemplateManager templateMgr; @@ -232,9 +234,14 @@ public abstract class TemplateAdapterBase extends AdapterBase implements Templat Account owner = _accountMgr.getAccount(cmd.getEntityOwnerId()); _accountMgr.checkAccess(caller, null, true, owner); + HypervisorType hyperType = HypervisorType.None; + if ( cmd.getOsTypeId() != null ){ + hyperType = _osHyperDao.findHypervisorTypeByGuestOsId(cmd.getOsTypeId()); + } + return prepare(true, UserContext.current().getCallerUserId(), cmd.getIsoName(), cmd.getDisplayText(), 64, false, true, cmd.getUrl(), cmd.isPublic(), cmd.isFeatured(), cmd.isExtractable(), ImageFormat.ISO.toString(), cmd.getOsTypeId(), - cmd.getZoneId(), HypervisorType.None, cmd.getChecksum(), cmd.isBootable(), null, owner, null, false); + cmd.getZoneId(), hyperType, cmd.getChecksum(), cmd.isBootable(), null, owner, null, false); } protected VMTemplateVO persistTemplate(TemplateProfile profile) {
