You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by sa...@apache.org on 2013/05/31 09:49:43 UTC
[45/50] [abbrv] git commit: updated refs/heads/vmware-datamodel to
6a8c2bd
CLOUDSTACK-1963 New mapping model for CloudStack zone and Vmware datacenter
Support for DB changes for Vmware datacenter objects
Support for DB changes to store mapping with CloudStack zones.
Signed-off-by: Sateesh Chodapuneedi <sa...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/47e355c1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/47e355c1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/47e355c1
Branch: refs/heads/vmware-datamodel
Commit: 47e355c1c2bdcca7d6917870bb8521c729ed963f
Parents: abbf004
Author: Sateesh Chodapuneedi <sa...@apache.org>
Authored: Thu May 23 12:28:17 2013 +0530
Committer: Sateesh Chodapuneedi <sa...@apache.org>
Committed: Thu May 30 17:09:32 2013 +0530
----------------------------------------------------------------------
.../cloud/hypervisor/vmware/VmwareDatacenter.java | 36 ++++
.../hypervisor/vmware/VmwareDatacenterVO.java | 160 +++++++++++++++
.../hypervisor/vmware/VmwareDatacenterZoneMap.java | 30 +++
.../vmware/VmwareDatacenterZoneMapVO.java | 78 +++++++
.../hypervisor/vmware/dao/VmwareDatacenterDao.java | 65 ++++++
.../vmware/dao/VmwareDatacenterDaoImpl.java | 104 ++++++++++
.../vmware/dao/VmwareDatacenterZoneMapDao.java | 35 +++
.../vmware/dao/VmwareDatacenterZoneMapDaoImpl.java | 61 ++++++
8 files changed, 569 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/47e355c1/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenter.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenter.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenter.java
new file mode 100644
index 0000000..6d6d2eb
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenter.java
@@ -0,0 +1,36 @@
+// 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.hypervisor.vmware;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+public interface VmwareDatacenter extends Identity, InternalIdentity {
+
+ String getVmwareDatacenterName();
+
+ String getGuid();
+
+ String getVcenterHost();
+
+ long getId();
+
+ String getPassword();
+
+ String getUser();
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/47e355c1/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterVO.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterVO.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterVO.java
new file mode 100644
index 0000000..a13e59e
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterVO.java
@@ -0,0 +1,160 @@
+// 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.hypervisor.vmware;
+
+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 com.cloud.utils.NumbersUtil;
+import com.cloud.utils.db.Encrypt;
+
+/**
+ * VmwareDatacenterVO contains information of Vmware Datacenter associated with a CloudStack zone.
+ */
+
+@Entity
+@Table(name="vmware_data_center")
+public class VmwareDatacenterVO implements VmwareDatacenter {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private long id;
+
+ @Column(name = "guid")
+ private String guid;
+
+ @Column(name = "name")
+ private String name;
+
+ @Column(name = "vcenter_host")
+ private String vCenterHost;
+
+ @Column(name = "uuid")
+ private String uuid;
+
+ @Column(name = "username")
+ private String user;
+
+ @Encrypt
+ @Column(name = "password")
+ private String password;
+
+ @Override
+ public String getUuid() {
+ return uuid;
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ public String getVmwareDatacenterName() {
+ return name;
+ }
+
+ @Override
+ public String getGuid() {
+ return guid;
+ }
+
+ @Override
+ public String getUser() {
+ return user;
+ }
+
+ @Override
+ public String getPassword() {
+ return password;
+ }
+
+ @Override
+ public String getVcenterHost() {
+ return vCenterHost;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ public void setVmwareDatacenterName(String name) {
+ this.name = name;
+ }
+
+ public void setVcenterHost(String vCenterHost) {
+ this.vCenterHost = vCenterHost;
+ }
+
+ public void setUser(String user) {
+ this.user = user; ;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("VmwareDatacenter[").append(guid).append("]").toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return NumbersUtil.hash(id);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof VmwareDatacenterVO) {
+ return ((VmwareDatacenterVO)obj).getId() == this.getId();
+ } else {
+ return false;
+ }
+ }
+
+ public VmwareDatacenterVO(String guid, String name, String vCenterHost, String user, String password) {
+ this.uuid = UUID.randomUUID().toString();
+ this.name = name;
+ this.guid = guid;
+ this.vCenterHost = vCenterHost;
+ this.user = user;
+ this.password = password;
+ }
+
+ public VmwareDatacenterVO(long id, String guid, String name, String vCenterHost, String user, String password) {
+ this(guid, name, vCenterHost, user, password);
+ this.id = id;
+ }
+
+ public VmwareDatacenterVO() {
+ this.uuid = UUID.randomUUID().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/47e355c1/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterZoneMap.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterZoneMap.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterZoneMap.java
new file mode 100644
index 0000000..f70a541
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterZoneMap.java
@@ -0,0 +1,30 @@
+// 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.hypervisor.vmware;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+import com.cloud.org.Grouping;
+
+public interface VmwareDatacenterZoneMap extends Grouping, InternalIdentity {
+ public long getId();
+
+ public long getZoneId();
+
+ public long getVmwareDcId();
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/47e355c1/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterZoneMapVO.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterZoneMapVO.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterZoneMapVO.java
new file mode 100644
index 0000000..93b0e26
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterZoneMapVO.java
@@ -0,0 +1,78 @@
+//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.hypervisor.vmware;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+
+//NOTE: This particular table is totally internal to the CS MS.
+//Do not ever include a uuid/guid field in this table. We just
+//need it map zone ids with VMware datacenter Ids.
+
+@Entity
+@Table(name="vmware_data_center_zone_map")
+public class VmwareDatacenterZoneMapVO implements VmwareDatacenterZoneMap {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name="id")
+ private long id;
+
+ @Column(name="zone_id")
+ private long zoneId;
+
+ @Column(name="vmware_data_center_id")
+ private long vmwareDcId;
+
+ public VmwareDatacenterZoneMapVO(long zoneId, long vmwareDcId) {
+ this.zoneId = zoneId;
+ this.vmwareDcId = vmwareDcId;
+ }
+
+ public VmwareDatacenterZoneMapVO() {
+ // Do nothing.
+ }
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ public long getZoneId() {
+ return zoneId;
+ }
+
+ @Override
+ public long getVmwareDcId() {
+ return vmwareDcId;
+ }
+
+ public void setZoneId(long zoneId) {
+ this.zoneId = zoneId;
+ }
+
+ public void setVmwareDcId(long vmwareDcId) {
+ this.vmwareDcId = vmwareDcId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/47e355c1/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterDao.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterDao.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterDao.java
new file mode 100644
index 0000000..2754e91
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterDao.java
@@ -0,0 +1,65 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.hypervisor.vmware.dao;
+
+import java.util.List;
+
+import com.cloud.hypervisor.vmware.VmwareDatacenterVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface VmwareDatacenterDao extends GenericDao<VmwareDatacenterVO, Long> {
+
+ /**
+ * Return a VMware Datacenter given guid
+ * @param guid of VMware datacenter
+ * @return VmwareDatacenterVO for the VMware datacenter having the specified guid.
+ */
+ VmwareDatacenterVO getVmwareDatacenterByGuid(String guid);
+
+ /**
+ * Return a VMware Datacenter given name and vCenter host.
+ * For legacy zones multiple records will be present in the table.
+ * @param name of VMware datacenter
+ * @param vCenter host
+ * @return VmwareDatacenterVO for the VMware datacenter with given name and
+ * belonging to specified vCenter host.
+ */
+ List<VmwareDatacenterVO> getVmwareDatacenterByNameAndVcenter(String name, String vCenterHost);
+
+ /**
+ * Return a list of VMware Datacenter given name.
+ * @param name of Vmware datacenter
+ * @return list of VmwareDatacenterVO for VMware datacenters having the specified name.
+ */
+ List<VmwareDatacenterVO> listVmwareDatacenterByName(String name);
+
+ /**
+ * Return a list of VMware Datacenters belonging to specified vCenter
+ * @param vCenter Host
+ * @return list of VmwareDatacenterVO for all VMware datacenters belonging to
+ * specified vCenter
+ */
+ List<VmwareDatacenterVO> listVmwareDatacenterByVcenter(String vCenterHost);
+
+ /**
+ * Lists all associated VMware datacenter on the management server.
+ * @return list of VmwareDatacenterVO for all associated VMware datacenters
+ */
+ List<VmwareDatacenterVO> listAllVmwareDatacenters();
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/47e355c1/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterDaoImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterDaoImpl.java
new file mode 100644
index 0000000..8324e93
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterDaoImpl.java
@@ -0,0 +1,104 @@
+// 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.hypervisor.vmware.dao;
+
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.hypervisor.vmware.VmwareDatacenterVO;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Op;
+
+@Component
+@Local(value=VmwareDatacenterDao.class) @DB(txn=false)
+public class VmwareDatacenterDaoImpl extends GenericDaoBase<VmwareDatacenterVO, Long> implements VmwareDatacenterDao {
+ protected static final Logger s_logger = Logger.getLogger(VmwareDatacenterDaoImpl.class);
+
+ final SearchBuilder<VmwareDatacenterVO> nameSearch;
+ final SearchBuilder<VmwareDatacenterVO> guidSearch;
+ final SearchBuilder<VmwareDatacenterVO> vcSearch;
+ final SearchBuilder<VmwareDatacenterVO> nameVcSearch;
+ final SearchBuilder<VmwareDatacenterVO> fullTableSearch;
+
+ public VmwareDatacenterDaoImpl() {
+ super();
+
+ nameSearch = createSearchBuilder();
+ nameSearch.and("name", nameSearch.entity().getVmwareDatacenterName(), Op.EQ);
+ nameSearch.done();
+
+ nameVcSearch = createSearchBuilder();
+ nameVcSearch.and("name", nameVcSearch.entity().getVmwareDatacenterName(), Op.EQ);
+ nameVcSearch.and("vCenterHost", nameVcSearch.entity().getVcenterHost(), Op.EQ);
+ nameVcSearch.done();
+
+ vcSearch = createSearchBuilder();
+ vcSearch.and("vCenterHost", vcSearch.entity().getVcenterHost(), Op.EQ);
+ vcSearch.done();
+
+ guidSearch = createSearchBuilder();
+ guidSearch.and("guid", guidSearch.entity().getGuid(), Op.EQ);
+ guidSearch.done();
+
+ fullTableSearch = createSearchBuilder();
+ fullTableSearch.done();
+ }
+
+ @Override
+ public VmwareDatacenterVO getVmwareDatacenterByGuid(String guid) {
+ SearchCriteria<VmwareDatacenterVO> sc = guidSearch.create();
+ sc.setParameters("guid", guid);
+ return findOneBy(sc);
+ }
+
+ @Override
+ public List<VmwareDatacenterVO> getVmwareDatacenterByNameAndVcenter(String name, String vCenterHost) {
+ SearchCriteria<VmwareDatacenterVO> sc = guidSearch.create();
+ sc.setParameters("name", name);
+ sc.setParameters("vCenterHost", vCenterHost);
+ return search(sc, null);
+ }
+
+ @Override
+ public List<VmwareDatacenterVO> listVmwareDatacenterByName(String name) {
+ SearchCriteria<VmwareDatacenterVO> sc = guidSearch.create();
+ sc.setParameters("name", name);
+ return search(sc, null);
+ }
+
+ @Override
+ public List<VmwareDatacenterVO> listVmwareDatacenterByVcenter(String vCenterHost) {
+ SearchCriteria<VmwareDatacenterVO> sc = vcSearch.create();
+ sc.setParameters("vCenterHost", vCenterHost);
+ return search(sc, null);
+ }
+
+ @Override
+ public List<VmwareDatacenterVO> listAllVmwareDatacenters() {
+ SearchCriteria<VmwareDatacenterVO> sc = fullTableSearch.create();
+ return search(sc, null);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/47e355c1/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterZoneMapDao.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterZoneMapDao.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterZoneMapDao.java
new file mode 100644
index 0000000..be693aa
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterZoneMapDao.java
@@ -0,0 +1,35 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.hypervisor.vmware.dao;
+
+import com.cloud.hypervisor.vmware.VmwareDatacenterZoneMapVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface VmwareDatacenterZoneMapDao extends GenericDao<VmwareDatacenterZoneMapVO, Long> {
+ /**
+ * @param id of zone
+ * @return map object of VMware datacenter & zone
+ */
+ VmwareDatacenterZoneMapVO findByZoneId(long zoneId);
+
+ /**
+ * @param id of VMware datacenter
+ * @return map object of VMware datacenter & zone
+ */
+ VmwareDatacenterZoneMapVO findByVmwareDcId(long vmwareDcId);
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/47e355c1/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterZoneMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterZoneMapDaoImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterZoneMapDaoImpl.java
new file mode 100644
index 0000000..1c13269
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterZoneMapDaoImpl.java
@@ -0,0 +1,61 @@
+//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.hypervisor.vmware.dao;
+
+import javax.ejb.Local;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.hypervisor.vmware.VmwareDatacenterZoneMapVO;
+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=VmwareDatacenterZoneMapDao.class)
+public class VmwareDatacenterZoneMapDaoImpl extends GenericDaoBase<VmwareDatacenterZoneMapVO, Long>
+ implements VmwareDatacenterZoneMapDao {
+
+ protected final SearchBuilder<VmwareDatacenterZoneMapVO> zoneSearch;
+ protected final SearchBuilder<VmwareDatacenterZoneMapVO> vmwareDcSearch;
+
+ public VmwareDatacenterZoneMapDaoImpl() {
+ zoneSearch = createSearchBuilder();
+ zoneSearch.and("zoneId", zoneSearch.entity().getZoneId(), Op.EQ);
+ zoneSearch.done();
+
+ vmwareDcSearch = createSearchBuilder();
+ vmwareDcSearch.and("vmwareDcId", vmwareDcSearch.entity().getVmwareDcId(), Op.EQ);
+ vmwareDcSearch.done();
+ }
+
+ @Override
+ public VmwareDatacenterZoneMapVO findByZoneId(long zoneId) {
+ SearchCriteria<VmwareDatacenterZoneMapVO> sc = zoneSearch.create();
+ sc.setParameters("zoneId", zoneId);
+ return findOneBy(sc);
+ }
+
+ @Override
+ public VmwareDatacenterZoneMapVO findByVmwareDcId(long vmwareDcId) {
+ SearchCriteria<VmwareDatacenterZoneMapVO> sc = vmwareDcSearch.create();
+ sc.setParameters("vmwareDcId", vmwareDcId);
+ return findOneBy(sc);
+ }
+}