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 10:21:48 UTC
[4/8] git commit: updated refs/heads/master to 55b3e69
Added check for legacy zones. Improved log statements.
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/55b3e697
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/55b3e697
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/55b3e697
Branch: refs/heads/master
Commit: 55b3e697335b00f22f15893939d0db5a9d1fbbdb
Parents: 4b67b1d
Author: Sateesh Chodapuneedi <sa...@apache.org>
Authored: Fri May 31 13:11:12 2013 +0530
Committer: Sateesh Chodapuneedi <sa...@apache.org>
Committed: Fri May 31 13:33:46 2013 +0530
----------------------------------------------------------------------
client/tomcatconf/nonossComponentContext.xml.in | 1 +
.../com/cloud/hypervisor/vmware/LegacyZone.java | 28 +++++
.../com/cloud/hypervisor/vmware/LegacyZoneVO.java | 81 +++++++++++++++
.../hypervisor/vmware/VmwareServerDiscoverer.java | 8 +-
.../cloud/hypervisor/vmware/dao/LegacyZoneDao.java | 37 +++++++
.../hypervisor/vmware/dao/LegacyZoneDaoImpl.java | 66 ++++++++++++
.../hypervisor/vmware/manager/VmwareManager.java | 2 +
.../vmware/manager/VmwareManagerImpl.java | 13 +++
.../vmware/VmwareDatacenterApiUnitTest.java | 6 +
9 files changed, 238 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55b3e697/client/tomcatconf/nonossComponentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/nonossComponentContext.xml.in b/client/tomcatconf/nonossComponentContext.xml.in
index 7dc331f..6bf7e14 100644
--- a/client/tomcatconf/nonossComponentContext.xml.in
+++ b/client/tomcatconf/nonossComponentContext.xml.in
@@ -79,6 +79,7 @@
<bean id="vmwareContextFactory" class="com.cloud.hypervisor.vmware.resource.VmwareContextFactory" />
<bean id="VmwareDatacenterDaoImpl" class="com.cloud.hypervisor.vmware.dao.VmwareDatacenterDaoImpl" />
<bean id="VmwareDatacenterZoneMapDaoImpl" class="com.cloud.hypervisor.vmware.dao.VmwareDatacenterZoneMapDaoImpl" />
+ <bean id="LegacyZoneDaoImpl" class="com.cloud.hypervisor.vmware.dao.LegacyZoneDaoImpl" />
<!--
Nicira support components
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55b3e697/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/LegacyZone.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/LegacyZone.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/LegacyZone.java
new file mode 100644
index 0000000..535b6a7
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/LegacyZone.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.hypervisor.vmware;
+
+import org.apache.cloudstack.api.InternalIdentity;
+
+public interface LegacyZone extends InternalIdentity {
+
+ long getId();
+
+ long getZoneId();
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55b3e697/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/LegacyZoneVO.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/LegacyZoneVO.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/LegacyZoneVO.java
new file mode 100644
index 0000000..390e56d
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/LegacyZoneVO.java
@@ -0,0 +1,81 @@
+//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;
+
+import com.cloud.utils.NumbersUtil;
+
+/**
+* LegacyZoneVO contains id of CloudStack zone containing clusters from multiple VMware vCetners and/or VMware Datacenters.
+*/
+
+@Entity
+@Table(name="legacy_zones")
+public class LegacyZoneVO implements LegacyZone {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "id")
+ private long id;
+
+ @Column(name = "zone_id")
+ private long zoneId;
+
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ @Override
+ public long getZoneId() {
+ return zoneId;
+ }
+
+ @Override
+ public int hashCode() {
+ return NumbersUtil.hash(id);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof LegacyZoneVO) {
+ return ((LegacyZoneVO)obj).getId() == this.getId();
+ } else {
+ return false;
+ }
+ }
+
+ public LegacyZoneVO() {
+ }
+
+ public LegacyZoneVO(long zoneId) {
+ this.id = zoneId;
+ }
+
+ public LegacyZoneVO(long id, long zoneId) {
+ this.id = id;
+ this.zoneId = zoneId;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55b3e697/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
index aec44b3..fa87374 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
@@ -149,7 +149,7 @@ public class VmwareServerDiscoverer extends DiscovererBase implements
}
Map<String, String> clusterDetails = _clusterDetailsDao.findDetails(clusterId);
- boolean legacyZone = false;
+ boolean legacyZone = _vmwareMgr.isLegacyZone(dcId);
//Check if NOT a legacy zone.
if (!legacyZone) {
String updatedInventoryPath = validateCluster(dcId, url, username, password);
@@ -455,15 +455,15 @@ public class VmwareServerDiscoverer extends DiscovererBase implements
if (!vCenterHost.equalsIgnoreCase(url.getHost())) {
msg = "This cluster " + clusterName + " belongs to vCenter " + url.getHost()
- + " .But this zone is associated with VMware DC from vCenter " + vCenterHost
+ + ". But this zone is associated with VMware DC from vCenter " + vCenterHost
+ ". Make sure the cluster being added belongs to vCenter " + vCenterHost
- + " and DC " + vmwareDcNameFromDb;
+ + " and VMware DC " + vmwareDcNameFromDb;
s_logger.error(msg);
throw new DiscoveryException(msg);
} else if (!vmwareDcNameFromDb.equalsIgnoreCase(vmwareDcNameFromApi)) {
msg = "This cluster " + clusterName + " belongs to VMware DC " + vmwareDcNameFromApi
+ " .But this zone is associated with VMware DC " + vmwareDcNameFromDb
- + ". Make sure the cluster being added belongs to DC " + vmwareDcNameFromDb
+ + ". Make sure the cluster being added belongs to VMware DC " + vmwareDcNameFromDb
+ " in vCenter " + vCenterHost;
s_logger.error(msg);
throw new DiscoveryException(msg);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55b3e697/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/LegacyZoneDao.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/LegacyZoneDao.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/LegacyZoneDao.java
new file mode 100644
index 0000000..4a858f8
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/LegacyZoneDao.java
@@ -0,0 +1,37 @@
+// 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.LegacyZoneVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface LegacyZoneDao extends GenericDao<LegacyZoneVO, Long> {
+ /**
+ * @param id of zone
+ * @return zone id of legacy zone
+ */
+ LegacyZoneVO findByZoneId(String zoneId);
+
+ /**
+ * Lists all legacy CloudStack zones
+ * @return list of ids of legacy CloudStack zones
+ */
+ List<LegacyZoneVO> listAllLegacyZones();
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55b3e697/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/LegacyZoneDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/LegacyZoneDaoImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/LegacyZoneDaoImpl.java
new file mode 100644
index 0000000..7d2d128
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/LegacyZoneDaoImpl.java
@@ -0,0 +1,66 @@
+ // 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.LegacyZoneVO;
+ 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=LegacyZoneDao.class) @DB(txn=false)
+ public class LegacyZoneDaoImpl extends GenericDaoBase<LegacyZoneVO, Long> implements LegacyZoneDao {
+ protected static final Logger s_logger = Logger.getLogger(LegacyZoneDaoImpl.class);
+
+ final SearchBuilder<LegacyZoneVO> zoneSearch;
+ final SearchBuilder<LegacyZoneVO> fullTableSearch;
+
+ public LegacyZoneDaoImpl() {
+ super();
+
+ zoneSearch = createSearchBuilder();
+ zoneSearch.and("zoneId", zoneSearch.entity().getZoneId(), Op.EQ);
+ zoneSearch.done();
+
+ fullTableSearch = createSearchBuilder();
+ fullTableSearch.done();
+ }
+
+ @Override
+ public LegacyZoneVO findByZoneId(String zoneId) {
+ SearchCriteria<LegacyZoneVO> sc = zoneSearch.create();
+ sc.setParameters("zoneId", zoneId);
+ return findOneBy(sc);
+ }
+
+ @Override
+ public List<LegacyZoneVO> listAllLegacyZones() {
+ SearchCriteria<LegacyZoneVO> sc = fullTableSearch.create();
+ return search(sc, null);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55b3e697/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
index fb6d3d6..45fd12b 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManager.java
@@ -66,4 +66,6 @@ public interface VmwareManager {
String getPrivateVSwitchName(long dcId, HypervisorType hypervisorType);
public String getRootDiskController();
+
+ boolean isLegacyZone(long dcId);
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55b3e697/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
index 3718762..f33a614 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
@@ -67,10 +67,12 @@ import com.cloud.host.Status;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
+import com.cloud.hypervisor.vmware.LegacyZoneVO;
import com.cloud.hypervisor.vmware.VmwareCleanupMaid;
import com.cloud.hypervisor.vmware.VmwareDatacenterService;
import com.cloud.hypervisor.vmware.VmwareDatacenterVO;
import com.cloud.hypervisor.vmware.VmwareDatacenterZoneMapVO;
+import com.cloud.hypervisor.vmware.dao.LegacyZoneDao;
import com.cloud.hypervisor.vmware.dao.VmwareDatacenterDao;
import com.cloud.hypervisor.vmware.dao.VmwareDatacenterZoneMapDao;
import com.cloud.hypervisor.vmware.mo.CustomFieldConstants;
@@ -147,6 +149,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
@Inject DataCenterDao _dcDao;
@Inject VmwareDatacenterDao _vmwareDcDao;
@Inject VmwareDatacenterZoneMapDao _vmwareDcZoneMapDao;
+ @Inject LegacyZoneDao _legacyZoneDao;
String _mountParent;
StorageLayer _storage;
@@ -1143,4 +1146,14 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
}
return uri;
}
+
+ @Override
+ public boolean isLegacyZone(long dcId) {
+ boolean isLegacyZone = false;
+ LegacyZoneVO legacyZoneVo = _legacyZoneDao.findById(dcId);
+ if (legacyZoneVo != null) {
+ isLegacyZone = true;
+ }
+ return isLegacyZone;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55b3e697/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/VmwareDatacenterApiUnitTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/VmwareDatacenterApiUnitTest.java b/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/VmwareDatacenterApiUnitTest.java
index f0fb08e..08bad9f 100644
--- a/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/VmwareDatacenterApiUnitTest.java
+++ b/plugins/hypervisors/vmware/test/com/cloud/hypervisor/vmware/VmwareDatacenterApiUnitTest.java
@@ -73,6 +73,7 @@ import com.cloud.exception.ResourceInUseException;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
+import com.cloud.hypervisor.vmware.dao.LegacyZoneDao;
import com.cloud.hypervisor.vmware.dao.VmwareDatacenterDao;
import com.cloud.hypervisor.vmware.dao.VmwareDatacenterZoneMapDao;
import com.cloud.hypervisor.vmware.manager.VmwareManager;
@@ -371,6 +372,11 @@ public class VmwareDatacenterApiUnitTest {
}
@Bean
+ public LegacyZoneDao legacyZoneDao() {
+ return Mockito.mock(LegacyZoneDao.class);
+ }
+
+ @Bean
public ConfigurationDao configurationDao() {
return Mockito.mock(ConfigurationDao.class);
}