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/05 04:48:53 UTC
[01/11] git commit: updated refs/heads/vmware-datamodel to 3201dbf
Updated Branches:
refs/heads/vmware-datamodel 2acbe30cb -> 3201dbfe2
CLOUDSTACK-2317: NPE while cloudstack trying to get system ip and enable
static nat for the vm VM
splitting enableStaticNat() method in to a service and manager layer
method. So as to ensure action event annotation is present only on
service layer method.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a3a58623
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a3a58623
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a3a58623
Branch: refs/heads/vmware-datamodel
Commit: a3a5862301b5b3d79abcf8dfef66283728954d55
Parents: 3ae4819
Author: Murali Reddy <mu...@citrix.com>
Authored: Fri May 3 15:37:25 2013 +0530
Committer: Murali Reddy <mu...@citrix.com>
Committed: Fri May 3 15:37:25 2013 +0530
----------------------------------------------------------------------
api/src/com/cloud/network/rules/RulesService.java | 2 +-
.../com/cloud/network/rules/RulesManagerImpl.java | 13 +++++++++++--
.../com/cloud/network/MockRulesManagerImpl.java | 3 +--
3 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a3a58623/api/src/com/cloud/network/rules/RulesService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/rules/RulesService.java b/api/src/com/cloud/network/rules/RulesService.java
index d47b38f..45abd84 100644
--- a/api/src/com/cloud/network/rules/RulesService.java
+++ b/api/src/com/cloud/network/rules/RulesService.java
@@ -67,7 +67,7 @@ public interface RulesService {
boolean applyPortForwardingRules(long ipAdddressId, Account caller) throws ResourceUnavailableException;
- boolean enableStaticNat(long ipAddressId, long vmId, long networkId, boolean isSystemVm, String vmGuestIp) throws NetworkRuleConflictException, ResourceUnavailableException;
+ boolean enableStaticNat(long ipAddressId, long vmId, long networkId, String vmGuestIp) throws NetworkRuleConflictException, ResourceUnavailableException;
PortForwardingRule getPortForwardigRule(long ruleId);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a3a58623/server/src/com/cloud/network/rules/RulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/RulesManagerImpl.java b/server/src/com/cloud/network/rules/RulesManagerImpl.java
index 8636d85..2355635 100755
--- a/server/src/com/cloud/network/rules/RulesManagerImpl.java
+++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java
@@ -80,12 +80,14 @@ import com.cloud.utils.net.Ip;
import com.cloud.vm.Nic;
import com.cloud.vm.NicSecondaryIp;
import com.cloud.vm.UserVmVO;
+import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.Type;
import com.cloud.vm.dao.NicDao;
import com.cloud.vm.dao.NicSecondaryIpDao;
import com.cloud.vm.dao.NicSecondaryIpVO;
import com.cloud.vm.dao.UserVmDao;
+import com.cloud.vm.dao.VMInstanceDao;
@Component
@Local(value = { RulesManager.class, RulesService.class })
@@ -103,6 +105,8 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
@Inject
UserVmDao _vmDao;
@Inject
+ VMInstanceDao _vmInstanceDao;
+ @Inject
AccountManager _accountMgr;
@Inject
NetworkManager _networkMgr;
@@ -416,7 +420,12 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
@Override
@ActionEvent(eventType = EventTypes.EVENT_ENABLE_STATIC_NAT, eventDescription = "enabling static nat")
- public boolean enableStaticNat(long ipId, long vmId, long networkId, boolean isSystemVm, String vmGuestIp)
+ public boolean enableStaticNat(long ipId, long vmId, long networkId, String vmGuestIp)
+ throws NetworkRuleConflictException, ResourceUnavailableException {
+ return enableStaticNat(ipId, vmId, networkId, false, vmGuestIp);
+ }
+
+ private boolean enableStaticNat(long ipId, long vmId, long networkId, boolean isSystemVm, String vmGuestIp)
throws NetworkRuleConflictException, ResourceUnavailableException {
UserContext ctx = UserContext.current();
Account caller = ctx.getCaller();
@@ -1370,7 +1379,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
throw new CloudRuntimeException("Ip address is not associated with any network");
}
- UserVmVO vm = _vmDao.findById(sourceIp.getAssociatedWithVmId());
+ VMInstanceVO vm = _vmInstanceDao.findById(sourceIp.getAssociatedWithVmId());
Network network = _networkModel.getNetwork(networkId);
if (network == null) {
CloudRuntimeException ex = new CloudRuntimeException("Unable to find an ip address to map to specified vm id");
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a3a58623/server/test/com/cloud/network/MockRulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/MockRulesManagerImpl.java b/server/test/com/cloud/network/MockRulesManagerImpl.java
index e5a6894..200fd2c 100644
--- a/server/test/com/cloud/network/MockRulesManagerImpl.java
+++ b/server/test/com/cloud/network/MockRulesManagerImpl.java
@@ -76,8 +76,7 @@ public class MockRulesManagerImpl extends ManagerBase implements RulesManager, R
@Override
public boolean enableStaticNat(long ipAddressId, long vmId, long networkId,
- boolean isSystemVm, String ipAddr) throws NetworkRuleConflictException,
- ResourceUnavailableException {
+ String ipAddr) throws NetworkRuleConflictException, ResourceUnavailableException {
// TODO Auto-generated method stub
return false;
}
[09/11] git commit: updated refs/heads/vmware-datamodel to 3201dbf
Posted by sa...@apache.org.
CLOUDSTACK-1963 New mapping model for CloudStack zone and Vmware datacenter
Plugin, API & DB changes
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/7a8003e1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/7a8003e1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/7a8003e1
Branch: refs/heads/vmware-datamodel
Commit: 7a8003e1dad3c39396da46761154d6830e899583
Parents: 63f3ccd
Author: Sateesh Chodapuneedi <sa...@apache.org>
Authored: Fri May 3 22:38:57 2013 +0530
Committer: Sateesh Chodapuneedi <sa...@apache.org>
Committed: Sat May 4 23:23:50 2013 +0530
----------------------------------------------------------------------
client/tomcatconf/nonossComponentContext.xml.in | 2 +
.../cloud/hypervisor/vmware/VmwareDatacenter.java | 23 ++
.../hypervisor/vmware/VmwareDatacenterService.java | 15 +
.../hypervisor/vmware/VmwareDatacenterVO.java | 155 ++++++++
.../hypervisor/vmware/VmwareDatacenterZoneMap.java | 13 +
.../vmware/VmwareDatacenterZoneMapVO.java | 77 ++++
.../hypervisor/vmware/VmwareServerDiscoverer.java | 80 ++++-
.../hypervisor/vmware/dao/VmwareDatacenterDao.java | 48 +++
.../vmware/dao/VmwareDatacenterDaoImpl.java | 87 +++++
.../vmware/dao/VmwareDatacenterZoneMapDao.java | 18 +
.../vmware/dao/VmwareDatacenterZoneMapDaoImpl.java | 61 +++
.../vmware/manager/VmwareManagerImpl.java | 302 ++++++++++++++-
.../api/command/admin/zone/AddVmwareDcCmd.java | 103 +++++
.../api/command/admin/zone/RemoveVmwareDcCmd.java | 80 ++++
.../api/response/VmwareDatacenterResponse.java | 34 ++
setup/db/db/schema-410to420.sql | 18 +
.../hypervisor/vmware/mo/CustomFieldConstants.java | 1 +
.../cloud/hypervisor/vmware/mo/DatacenterMO.java | 5 +
18 files changed, 1118 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a8003e1/client/tomcatconf/nonossComponentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/nonossComponentContext.xml.in b/client/tomcatconf/nonossComponentContext.xml.in
index ff52457..6d97b9c 100644
--- a/client/tomcatconf/nonossComponentContext.xml.in
+++ b/client/tomcatconf/nonossComponentContext.xml.in
@@ -77,6 +77,8 @@
</bean>
<bean id="VmwareManager" class="com.cloud.hypervisor.vmware.manager.VmwareManagerImpl"/>
<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" />
<!--
Nicira support components
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a8003e1/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..246b477
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenter.java
@@ -0,0 +1,23 @@
+package com.cloud.hypervisor.vmware;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.api.InternalIdentity;
+
+import com.vmware.vim25.ManagedObjectReference;
+
+public interface VmwareDatacenter extends Identity, InternalIdentity {
+
+ String getVmwareDatacenterName();
+
+ ManagedObjectReference getVmwareDatacenterMor();
+
+ String getGuid();
+
+ String getVcenterHost();
+
+ long getId();
+
+ String getPassword();
+
+ String getUser();
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a8003e1/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterService.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterService.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterService.java
new file mode 100644
index 0000000..f04b2b5
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterService.java
@@ -0,0 +1,15 @@
+package com.cloud.hypervisor.vmware;
+
+import org.apache.cloudstack.api.command.admin.zone.AddVmwareDcCmd;
+import org.apache.cloudstack.api.command.admin.zone.RemoveVmwareDcCmd;
+
+import com.cloud.exception.DiscoveryException;
+import com.cloud.exception.ResourceInUseException;
+import com.cloud.utils.component.PluggableService;
+
+public interface VmwareDatacenterService extends PluggableService {
+
+ public VmwareDatacenterVO addVmwareDatacenter(AddVmwareDcCmd cmd) throws IllegalArgumentException, DiscoveryException, ResourceInUseException, Exception;
+
+ public boolean removeVmwareDatacenter(RemoveVmwareDcCmd cmd) throws IllegalArgumentException, ResourceInUseException, Exception;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a8003e1/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..aaeccc2
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterVO.java
@@ -0,0 +1,155 @@
+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;
+import com.vmware.vim25.ManagedObjectReference;
+
+/**
+ * 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 ManagedObjectReference getVmwareDatacenterMor() {
+ String morString = guid.split("@")[0];
+ ManagedObjectReference mor = new ManagedObjectReference();
+
+ mor.setType(morString.split(":")[0]);
+ mor.setValue(morString.split(":")[1]);
+
+ return mor;
+ }
+
+ @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();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a8003e1/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..840c633
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterZoneMap.java
@@ -0,0 +1,13 @@
+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/7a8003e1/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..e20386d
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterZoneMapVO.java
@@ -0,0 +1,77 @@
+//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 setVsmId(long vmwareDcId) {
+ this.vmwareDcId = vmwareDcId;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a8003e1/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 2f82b53..aec44b3 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java
@@ -30,6 +30,7 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
+import org.springframework.beans.NullValueInNestedPathException;
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.StartupRoutingCommand;
@@ -51,6 +52,8 @@ import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.dao.HypervisorCapabilitiesDao;
+import com.cloud.hypervisor.vmware.dao.VmwareDatacenterDao;
+import com.cloud.hypervisor.vmware.dao.VmwareDatacenterZoneMapDao;
import com.cloud.hypervisor.vmware.manager.VmwareManager;
import com.cloud.hypervisor.vmware.mo.ClusterMO;
import com.cloud.hypervisor.vmware.mo.HostMO;
@@ -107,11 +110,16 @@ public class VmwareServerDiscoverer extends DiscovererBase implements
@Inject
CiscoNexusVSMDeviceDao _nexusDao;
@Inject
- CiscoNexusVSMElementService _nexusElement;
+ CiscoNexusVSMElement _nexusElement;
@Inject
NetworkModel _netmgr;
@Inject
HypervisorCapabilitiesDao _hvCapabilitiesDao;
+ @Inject
+ VmwareDatacenterZoneMapDao _vmwareDcZoneMapDao;
+ @Inject
+ VmwareDatacenterDao _vmwareDcDao;
+
protected Map<String, String> _urlParams;
protected boolean useDVS = false;
protected boolean nexusDVS = false;
@@ -140,6 +148,18 @@ public class VmwareServerDiscoverer extends DiscovererBase implements
return null;
}
+ Map<String, String> clusterDetails = _clusterDetailsDao.findDetails(clusterId);
+ boolean legacyZone = false;
+ //Check if NOT a legacy zone.
+ if (!legacyZone) {
+ String updatedInventoryPath = validateCluster(dcId, url, username, password);
+ if (url.getPath() != updatedInventoryPath) {
+ // If url from API doesn't specifiy DC then update url in database with DC assocaited with this zone.
+ clusterDetails.put("url", url.getScheme() + "://" + url.getHost() + updatedInventoryPath);
+ _clusterDetailsDao.persist(clusterId, clusterDetails);
+ }
+ }
+
List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(clusterId);
if (hosts != null && hosts.size() > 0) {
int maxHostsPerCluster = _hvCapabilitiesDao.getMaxHostsPerCluster(hosts.get(0).getHypervisorType(), hosts.get(0).getHypervisorVersion());
@@ -164,7 +184,6 @@ public class VmwareServerDiscoverer extends DiscovererBase implements
VmwareTrafficLabel guestTrafficLabelObj = new VmwareTrafficLabel(TrafficType.Guest);
VmwareTrafficLabel publicTrafficLabelObj = new VmwareTrafficLabel(TrafficType.Public);
- Map<String, String> clusterDetails = _clusterDetailsDao.findDetails(clusterId);
DataCenterVO zone = _dcDao.findById(dcId);
NetworkType zoneType = zone.getNetworkType();
_readGlobalConfigParameters();
@@ -395,6 +414,63 @@ public class VmwareServerDiscoverer extends DiscovererBase implements
}
}
+ private String validateCluster(Long dcId, URI url, String username, String password) throws DiscoveryException {
+ String msg;
+ long vmwareDcId;
+ VmwareDatacenterVO vmwareDc;
+ String vmwareDcNameFromDb;
+ String vmwareDcNameFromApi;
+ String vCenterHost;
+ String updatedInventoryPath = url.getPath();
+ String clusterName = null;
+
+ // Check if zone is associated with DC
+ VmwareDatacenterZoneMapVO vmwareDcZone = _vmwareDcZoneMapDao.findByZoneId(dcId);
+ if (vmwareDcZone == null) {
+ msg = "Zone " + dcId + " is not associated with any VMware DC yet. "
+ + "Please add VMware DC to this zone first and then try to add clusters.";
+ s_logger.error(msg);
+ throw new DiscoveryException(msg);
+ }
+
+ // Retrieve DC added to this zone from database
+ vmwareDcId = vmwareDcZone.getVmwareDcId();
+ vmwareDc = _vmwareDcDao.findById(vmwareDcId);
+ vmwareDcNameFromApi = vmwareDcNameFromDb = vmwareDc.getVmwareDatacenterName();
+ vCenterHost = vmwareDc.getVcenterHost();
+ String inventoryPath = url.getPath();
+
+ assert (inventoryPath != null);
+
+ String[] pathTokens = inventoryPath.split("/");
+ if (pathTokens.length == 2) {
+ // DC name is not present in url.
+ // Using DC name read from database.
+ clusterName = pathTokens[1];
+ updatedInventoryPath = "/" + vmwareDcNameFromDb + "/" + clusterName;
+ } else if (pathTokens.length == 3) {
+ vmwareDcNameFromApi = pathTokens[1];
+ clusterName = pathTokens[2];
+ }
+
+ 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
+ + ". Make sure the cluster being added belongs to vCenter " + vCenterHost
+ + " and 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
+ + " in vCenter " + vCenterHost;
+ s_logger.error(msg);
+ throw new DiscoveryException(msg);
+ }
+ return updatedInventoryPath;
+ }
+
private boolean validateDiscoveredHosts(VmwareContext context,
ManagedObjectReference morCluster,
List<ManagedObjectReference> morHosts) throws Exception {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a8003e1/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..e339604
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterDao.java
@@ -0,0 +1,48 @@
+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/7a8003e1/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..b8fa715
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterDaoImpl.java
@@ -0,0 +1,87 @@
+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/7a8003e1/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..dff9bb0
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/dao/VmwareDatacenterZoneMapDao.java
@@ -0,0 +1,18 @@
+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/7a8003e1/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);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a8003e1/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 9f260f1..3b94537 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
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -35,6 +36,8 @@ import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
+import org.apache.cloudstack.api.command.admin.zone.AddVmwareDcCmd;
+import org.apache.cloudstack.api.command.admin.zone.RemoveVmwareDcCmd;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
@@ -51,15 +54,28 @@ import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.ClusterDetailsDao;
import com.cloud.dc.ClusterVO;
import com.cloud.dc.ClusterVSMMapVO;
+import com.cloud.dc.DataCenterVO;
import com.cloud.dc.dao.ClusterDao;
import com.cloud.dc.dao.ClusterVSMMapDao;
+import com.cloud.dc.dao.DataCenterDao;
import com.cloud.exception.DiscoveredWithErrorException;
+import com.cloud.exception.DiscoveryException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceInUseException;
import com.cloud.host.HostVO;
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.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.VmwareDatacenterDao;
+import com.cloud.hypervisor.vmware.dao.VmwareDatacenterZoneMapDao;
+import com.cloud.hypervisor.vmware.mo.CustomFieldConstants;
+import com.cloud.hypervisor.vmware.mo.CustomFieldsManagerMO;
+import com.cloud.hypervisor.vmware.mo.DatacenterMO;
import com.cloud.hypervisor.vmware.mo.DiskControllerType;
import com.cloud.hypervisor.vmware.mo.HostFirewallSystemMO;
import com.cloud.hypervisor.vmware.mo.HostMO;
@@ -68,8 +84,10 @@ import com.cloud.hypervisor.vmware.mo.TaskMO;
import com.cloud.hypervisor.vmware.mo.VirtualEthernetCardType;
import com.cloud.hypervisor.vmware.mo.VmwareHostType;
import com.cloud.utils.ssh.SshHelper;
+import com.cloud.hypervisor.vmware.resource.VmwareContextFactory;
import com.cloud.hypervisor.vmware.util.VmwareClient;
import com.cloud.hypervisor.vmware.util.VmwareContext;
+import com.cloud.hypervisor.vmware.util.VmwareHelper;
import com.cloud.network.CiscoNexusVSMDeviceVO;
import com.cloud.network.NetworkModel;
import com.cloud.network.dao.CiscoNexusVSMDeviceDao;
@@ -83,11 +101,13 @@ import com.cloud.storage.secondary.SecondaryStorageVmManager;
import com.cloud.utils.FileUtil;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
+import com.cloud.utils.UriUtils;
import com.cloud.utils.component.Manager;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.concurrency.NamedThreadFactory;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.GlobalLock;
+import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.script.Script;
import com.cloud.utils.ssh.SshHelper;
@@ -98,8 +118,8 @@ import com.vmware.vim25.HostConnectSpec;
import com.vmware.vim25.ManagedObjectReference;
-@Local(value = {VmwareManager.class})
-public class VmwareManagerImpl extends ManagerBase implements VmwareManager, VmwareStorageMount, Listener {
+@Local(value = {VmwareManager.class, VmwareDatacenterService.class})
+public class VmwareManagerImpl extends ManagerBase implements VmwareManager, VmwareStorageMount, Listener, VmwareDatacenterService {
private static final Logger s_logger = Logger.getLogger(VmwareManagerImpl.class);
private static final int STARTUP_DELAY = 60000; // 60 seconds
@@ -124,6 +144,9 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
@Inject ConfigurationDao _configDao;
@Inject ConfigurationServer _configServer;
@Inject HypervisorCapabilitiesDao _hvCapabilitiesDao;
+ @Inject DataCenterDao _dcDao;
+ @Inject VmwareDatacenterDao _vmwareDcDao;
+ @Inject VmwareDatacenterZoneMapDao _vmwareDcZoneMapDao;
String _mountParent;
StorageLayer _storage;
@@ -865,4 +888,279 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
public String getRootDiskController() {
return _rootDiskController;
}
+
+ @Override
+ public List<Class<?>> getCommands() {
+ List<Class<?>> cmdList = new ArrayList<Class<?>>();
+ cmdList.add(AddVmwareDcCmd.class);
+ cmdList.add(RemoveVmwareDcCmd.class);
+ return cmdList;
+ }
+
+ @Override
+ @DB
+ public VmwareDatacenterVO addVmwareDatacenter(AddVmwareDcCmd cmd) throws Exception {
+ VmwareDatacenterVO vmwareDc = null;
+ Long zoneId = cmd.getZoneId();
+ String url = cmd.getUrl();
+ String userName = cmd.getUsername();
+ String password = cmd.getPassword();
+ String vmwareDcName = cmd.getName();
+
+ // Zone validation
+ validateZone(zoneId, "add VMware datacenter to zone");
+
+ // Check if the zone exists in the system
+ // If no, throw invalid param value exception
+ DataCenterVO zone = _dcDao.findById(zoneId);
+ if (zone == null) {
+ InvalidParameterValueException ex = new InvalidParameterValueException(
+ "Can't find zone by the id specified");
+ ex.addProxyObject(zone, zoneId, "dcId");
+ throw ex;
+ }
+
+ VmwareDatacenterZoneMapVO vmwareDcZoneMap = _vmwareDcZoneMapDao.findByZoneId(zoneId);
+ // Check if zone is associated with VMware DC
+ if (vmwareDcZoneMap != null) {
+ throw new CloudRuntimeException("Zone " + zoneId + " is already associated with a VMware datacenter.");
+ }
+
+ // Check if zone has resources? - For now look for clusters
+ // If yes, throw resource in use execption
+ List<ClusterVO> clusters = _clusterDao.listByZoneId(zoneId);
+ if (clusters != null) {
+ try {
+ if (clusters.size() > 0) {
+ throw new ResourceInUseException("Zone has one or more clusters."
+ + " Can't add VMware datacenter to zone which already has clusters.");
+ }}catch(Throwable t) {
+ s_logger.error(t);
+ }
+ }
+
+ // Validate url and get uri
+ URI uri = getUri(url);
+
+ // Validate username and password and DC name
+ if (userName == null) {
+ throw new InvalidParameterValueException("Invalid parameter username.");
+ }
+
+ if (password == null) {
+ throw new InvalidParameterValueException("Invalid parameter password.");
+ }
+
+ if (vmwareDcName == null) {
+ throw new InvalidParameterValueException("Invalid parameter name. Please provide valid VMware datacenter name.");
+ }
+
+ // Check if DC is already part of zone
+ // In that case vmware_data_center table should have the DC
+ String vCenterHost = uri.getHost();
+ List<VmwareDatacenterVO> vmwareDcs = _vmwareDcDao.getVmwareDatacenterByNameAndVcenter(vmwareDcName, vCenterHost);
+ if (vmwareDcs != null && vmwareDcs.size() != 0) {
+ throw new ResourceInUseException("This DC is already part of other CloudStack zone(s). Cannot add this DC to more zones.");
+ }
+
+ VmwareContext context = null;
+ DatacenterMO dcMo = null;
+ String dcCustomFieldValue;
+ boolean addDcCustomFieldDef = false;
+ boolean dcInUse = false;
+ String guid;
+ ManagedObjectReference dcMor;
+ try {
+ context = VmwareContextFactory.create(vCenterHost, userName, password);
+
+ // Check if DC exists on vCenter
+ try {
+ dcMo = new DatacenterMO(context, vmwareDcName);
+ } catch(Throwable t) {
+ String msg = "Unable to find DC " + vmwareDcName + " in vCenter " + vCenterHost;
+ s_logger.error(msg);
+ throw new DiscoveryException(msg);
+ }
+ assert (dcMo != null);
+
+ // Check if DC is already associated with another cloudstack deployment
+ // Get custom field property cloud.zone over this DC
+ dcMor = dcMo.getMor();
+ guid = dcMor.getType() + ":" + dcMor.getValue() + "@" + vCenterHost;
+
+ dcCustomFieldValue = dcMo.getCustomFieldValue(CustomFieldConstants.CLOUD_ZONE);
+ if (dcCustomFieldValue == null) {
+ addDcCustomFieldDef = true;
+ }
+ dcInUse = Boolean.parseBoolean(dcCustomFieldValue);
+ if (dcInUse) {
+ throw new ResourceInUseException("This DC is being managed by other CloudStack deployment. Cannot add this DC to zone.");
+ }
+
+ // Add DC to database into vmware_data_center table
+ vmwareDc = new VmwareDatacenterVO(guid, vmwareDcName, vCenterHost, userName, password);
+ Transaction txn = Transaction.currentTxn();
+ try {
+ txn.start();
+ vmwareDc = _vmwareDcDao.persist(vmwareDc);
+ txn.commit();
+ } catch (Exception e) {
+ txn.rollback();
+ s_logger.error("Failed to persist VMware datacenter details to database. Exception: " + e.getMessage());
+ throw new CloudRuntimeException(e.getMessage());
+ }
+
+ // Map zone with vmware datacenter
+ vmwareDcZoneMap = new VmwareDatacenterZoneMapVO(zoneId, vmwareDc.getId());
+
+ txn = Transaction.currentTxn();
+ try {
+ txn.start();
+ vmwareDcZoneMap = _vmwareDcZoneMapDao.persist(vmwareDcZoneMap);
+ txn.commit();
+ } catch (Exception e) {
+ txn.rollback();
+ s_logger.error("Failed to associate VMware datacenter with zone " + zoneId + ". Exception: " + e.getMessage());
+ // Removing VMware datacenter from vmware_data_center table because association with zone failed.
+ _vmwareDcDao.remove(vmwareDcZoneMap.getId());
+ throw new CloudRuntimeException(e.getMessage());
+ }
+
+ // Set custom field for this DC
+ if (addDcCustomFieldDef) {
+ dcMo.ensureCustomFieldDef(CustomFieldConstants.CLOUD_ZONE);
+ }
+ dcMo.setCustomFieldValue(CustomFieldConstants.CLOUD_ZONE, "true");
+
+ } catch (Exception e) {
+ String msg = "VMware DC discovery failed due to : " + VmwareHelper.getExceptionMessage(e);
+ s_logger.error(msg);
+ throw new CloudRuntimeException(msg);
+ } finally {
+ if (context != null)
+ context.close();
+ context = null;
+ }
+ return vmwareDc;
+ }
+
+ @Override
+ public boolean removeVmwareDatacenter(RemoveVmwareDcCmd cmd) throws Exception {
+ Long zoneId = cmd.getZoneId();
+ // Validate zone
+ validateZone(zoneId, "remove VMware datacenter from zone");
+
+ // Get DC associated with this zone
+ VmwareDatacenterZoneMapVO vmwareDcZoneMap;
+ VmwareDatacenterVO vmwareDatacenter;
+ String vmwareDcName;
+ long vmwareDcId;
+ String vCenterHost;
+ String userName;
+ String password;
+ DatacenterMO dcMo = null;
+ Transaction txn;
+
+ vmwareDcZoneMap = _vmwareDcZoneMapDao.findByZoneId(zoneId);
+ // Check if zone is associated with VMware DC
+ if (vmwareDcZoneMap == null) {
+ throw new CloudRuntimeException("Zone " + zoneId + " is not associated with any VMware datacenter.");
+ }
+
+ vmwareDcId = vmwareDcZoneMap.getVmwareDcId();
+ vmwareDatacenter = _vmwareDcDao.findById(vmwareDcId);
+ vmwareDcName = vmwareDatacenter.getVmwareDatacenterName();
+ vCenterHost = vmwareDatacenter.getVcenterHost();
+ userName = vmwareDatacenter.getUser();
+ password = vmwareDatacenter.getPassword();
+ txn = Transaction.currentTxn();
+ try {
+ txn.start();
+ // Remove the VMware datacenter entry in table vmware_data_center
+ _vmwareDcDao.remove(vmwareDcId);
+ // Remove the map entry in table vmware_data_center_zone_map
+ _vmwareDcZoneMapDao.remove(vmwareDcZoneMap.getId());
+ txn.commit();
+ } catch (Exception e) {
+ s_logger.info("Caught exception when trying to delete VMware datacenter record.." + e.getMessage());
+ throw new CloudRuntimeException("Failed to delete VMware datacenter ");
+ }
+
+ // Construct context
+ VmwareContext context = null;
+ try {
+ context = VmwareContextFactory.create(vCenterHost, userName, password);
+
+ // Check if DC exists on vCenter
+ try {
+ dcMo = new DatacenterMO(context, vmwareDcName);
+ } catch(Throwable t) {
+ String msg = "able to find DC " + vmwareDcName + " in vCenter " + vCenterHost;
+ s_logger.error(msg);
+ throw new DiscoveryException(msg);
+ }
+
+ assert (dcMo != null);
+
+ // Reset custom field property cloud.zone over this DC
+ dcMo.setCustomFieldValue(CustomFieldConstants.CLOUD_ZONE, "false");
+ s_logger.info("Sucessfully reset custom field property cloud.zone over DC " + vmwareDcName);
+ } catch (Exception e) {
+ String msg = "Unable to reset custom field property cloud.zone over DC " + vmwareDcName
+ + " due to : " + VmwareHelper.getExceptionMessage(e);
+ s_logger.error(msg);
+ throw new CloudRuntimeException(msg);
+ } finally {
+ if (context != null)
+ context.close();
+ context = null;
+ }
+ return true;
+ }
+
+ private void validateZone(Long zoneId, String errStr) throws ResourceInUseException {
+ // Check if zone with specified id exists
+ DataCenterVO zone = _dcDao.findById(zoneId);
+ if (zone == null) {
+ InvalidParameterValueException ex = new InvalidParameterValueException(
+ "Can't find zone by the id specified");
+ ex.addProxyObject(zone, zoneId, "dcId");
+ throw ex;
+ }
+
+ // Check if zone has resources? - For now look for clusters
+ List<ClusterVO> clusters = _clusterDao.listByZoneId(zoneId);
+ if(clusters != null && clusters.size() != 0) {
+ throw new ResourceInUseException("Zone has one or more clusters."
+ + " Can't " + errStr + " which already has clusters.");
+ }
+ }
+
+ private URI getUri(String url) throws InvalidParameterValueException {
+ if (url == null) {
+ throw new InvalidParameterValueException("Invalid url.");
+ }
+
+ URI uri = null;
+ try {
+ uri = new URI(UriUtils.encodeURIComponent(url));
+ if (uri.getScheme() == null) {
+ throw new InvalidParameterValueException(
+ "uri.scheme is null " + url
+ + ", add http:// as a prefix");
+ } else if (uri.getScheme().equalsIgnoreCase("http")) {
+ if (uri.getHost() == null
+ || uri.getHost().equalsIgnoreCase("")
+ || uri.getPath() == null
+ || uri.getPath().equalsIgnoreCase("")) {
+ throw new InvalidParameterValueException(
+ "Your host and/or path is wrong. Make sure it's of the format http://hostname/path");
+ }
+ }
+ } catch (URISyntaxException e) {
+ throw new InvalidParameterValueException(url
+ + " is not a valid uri");
+ }
+ return uri;
+ }
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a8003e1/plugins/hypervisors/vmware/src/org/apache/cloudstack/api/command/admin/zone/AddVmwareDcCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/org/apache/cloudstack/api/command/admin/zone/AddVmwareDcCmd.java b/plugins/hypervisors/vmware/src/org/apache/cloudstack/api/command/admin/zone/AddVmwareDcCmd.java
new file mode 100644
index 0000000..3d9101b
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/org/apache/cloudstack/api/command/admin/zone/AddVmwareDcCmd.java
@@ -0,0 +1,103 @@
+package org.apache.cloudstack.api.command.admin.zone;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.response.VmwareDatacenterResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.exception.DiscoveryException;
+import com.cloud.exception.ResourceInUseException;
+import com.cloud.hypervisor.vmware.VmwareDatacenterService;
+import com.cloud.hypervisor.vmware.VmwareDatacenterVO;
+import com.cloud.user.Account;
+
+@APICommand(name = "addVmwareDc", description="Adds a VMware datacenter to specified zone", responseObject=VmwareDatacenterResponse.class)
+public class AddVmwareDcCmd extends BaseCmd {
+
+ @Inject public VmwareDatacenterService _vmwareDatacenterService;
+
+ public static final Logger s_logger = Logger.getLogger(AddVmwareDcCmd.class.getName());
+
+ private static final String s_name = "addvmwaredcresponse";
+
+ @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="Name of VMware datacenter to be added to specified zone.")
+ private String name;
+
+ @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=false, description="The URL of vCenter.")
+ private String url;
+
+ @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=false, description="The Username required to connect to resource.")
+ private String username;
+
+ @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=false, description="The password for specified username.")
+ private String password;
+
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class, required=true, description="The Zone ID.")
+ private Long zoneId;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ @Override
+ public void execute() {
+ try {
+ VmwareDatacenterResponse response = new VmwareDatacenterResponse();
+ VmwareDatacenterVO result = _vmwareDatacenterService.addVmwareDatacenter(this);
+ if (result != null){
+ response.setId(result.getUuid());
+ response.setName(result.getVmwareDatacenterName());
+ response.setResponseName(getCommandName());
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add VMware Datacenter to zone.");
+ }
+ this.setResponseObject(response);
+ } catch (DiscoveryException ex) {
+ s_logger.warn("Exception: ", ex);
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
+ } catch (ResourceInUseException ex) {
+ s_logger.warn("Exception: ", ex);
+ ServerApiException e = new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
+ for (String proxyObj : ex.getIdProxyList()) {
+ e.addProxyObject(proxyObj);
+ }
+ throw e;
+ } catch (IllegalArgumentException ex) {
+ throw new IllegalArgumentException(ex.getMessage());
+ } catch (Exception e) {
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a8003e1/plugins/hypervisors/vmware/src/org/apache/cloudstack/api/command/admin/zone/RemoveVmwareDcCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/org/apache/cloudstack/api/command/admin/zone/RemoveVmwareDcCmd.java b/plugins/hypervisors/vmware/src/org/apache/cloudstack/api/command/admin/zone/RemoveVmwareDcCmd.java
new file mode 100644
index 0000000..cf54698
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/org/apache/cloudstack/api/command/admin/zone/RemoveVmwareDcCmd.java
@@ -0,0 +1,80 @@
+package org.apache.cloudstack.api.command.admin.zone;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.BaseCmd.CommandType;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.log4j.Logger;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.DiscoveryException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceInUseException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.hypervisor.vmware.VmwareDatacenterService;
+import com.cloud.network.element.CiscoNexusVSMElementService;
+import com.cloud.user.Account;
+
+@APICommand(name = "removeVmwareDc", responseObject=SuccessResponse.class, description="Remove a VMware datacenter from a zone.")
+public class RemoveVmwareDcCmd extends BaseCmd {
+
+ @Inject public VmwareDatacenterService _vmwareDatacenterService;
+
+ public static final Logger s_logger = Logger.getLogger(AddVmwareDcCmd.class.getName());
+
+ private static final String s_name = "removevmwaredcresponse";
+
+ @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType=ZoneResponse.class, required=true,
+ description="The id of Zone from which VMware datacenter has to be removed.")
+
+ private Long zoneId;
+
+ public Long getZoneId() {
+ return zoneId;
+ }
+
+ @Override
+ public void execute() {
+ SuccessResponse response = new SuccessResponse();
+ try {
+ boolean result = _vmwareDatacenterService.removeVmwareDatacenter(this);
+ if (result) {
+ response.setResponseName(getCommandName());
+ this.setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove VMware datacenter from zone");
+ }
+ } catch (ResourceInUseException ex) {
+ s_logger.warn("The zone has one or more resources (like cluster), hence not able to remove VMware datacenter from zone."
+ + " Please remove all resource from zone, and retry. Exception: ", ex);
+ ServerApiException e = new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
+ for (String proxyObj : ex.getIdProxyList()) {
+ e.addProxyObject(proxyObj);
+ }
+ throw e;
+ } catch (IllegalArgumentException ex) {
+ throw new IllegalArgumentException(ex.getMessage());
+ } catch (Exception e) {
+ }
+ }
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a8003e1/plugins/hypervisors/vmware/src/org/apache/cloudstack/api/response/VmwareDatacenterResponse.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/org/apache/cloudstack/api/response/VmwareDatacenterResponse.java b/plugins/hypervisors/vmware/src/org/apache/cloudstack/api/response/VmwareDatacenterResponse.java
new file mode 100644
index 0000000..151d037
--- /dev/null
+++ b/plugins/hypervisors/vmware/src/org/apache/cloudstack/api/response/VmwareDatacenterResponse.java
@@ -0,0 +1,34 @@
+package org.apache.cloudstack.api.response;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseResponse;
+import org.apache.cloudstack.api.EntityReference;
+
+import com.cloud.hypervisor.vmware.VmwareDatacenter;
+import com.cloud.serializer.Param;
+import com.google.gson.annotations.SerializedName;
+
+@EntityReference(value = VmwareDatacenter.class)
+public class VmwareDatacenterResponse extends BaseResponse {
+ @SerializedName(ApiConstants.ID) @Param(description="The VMware Datacenter ID")
+ private String id;
+
+ @SerializedName(ApiConstants.NAME) @Param(description="The VMware Datacenter name")
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a8003e1/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 99b476d..5f90a55a 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -915,6 +915,24 @@ CREATE TABLE `cloud`.`network_asa1000v_map` (
CONSTRAINT `fk_network_asa1000v_map__asa1000v_id` FOREIGN KEY (`asa1000v_id`) REFERENCES `external_cisco_asa1000v_devices`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE `cloud`.`vmware_data_center` (
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+ `uuid` varchar(255) UNIQUE,
+ `name` varchar(255) NOT NULL COMMENT 'Name of VMware datacenter',
+ `guid` varchar(255) NOT NULL UNIQUE COMMENT 'id of VMware datacenter',
+ `vcenter_host` varchar(255) NOT NULL COMMENT 'vCenter host containing this VMware datacenter',
+ `username` varchar(255) NOT NULL COMMENT 'Name of vCenter host user',
+ `password` varchar(255) NOT NULL COMMENT 'Password of vCenter host user',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE `cloud`.`vmware_data_center_zone_map` (
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+ `zone_id` bigint unsigned NOT NULL UNIQUE COMMENT 'id of CloudStack zone',
+ `vmware_data_center_id` bigint unsigned NOT NULL UNIQUE COMMENT 'id of VMware datacenter',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_vmware_data_center_zone_map__vmware_data_center_id` FOREIGN KEY (`vmware_data_center_id`) REFERENCES `vmware_data_center`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `eip_associate_public_ip` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if public IP is associated with user VM creation by default when EIP service is enabled.' AFTER `elastic_ip_service`;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a8003e1/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java
index 4cd5f9b..11bc157 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldConstants.java
@@ -21,4 +21,5 @@ public interface CustomFieldConstants {
public final static String CLOUD_GC = "cloud.gc";
public final static String CLOUD_GC_DVP = "cloud.gc.dvp";
public final static String CLOUD_NIC_MASK = "cloud.nic.mask";
+ public final static String CLOUD_ZONE = "cloud.zone";
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7a8003e1/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
index 0a3e20b..cabb60a 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
@@ -488,4 +488,9 @@ public class DatacenterMO extends BaseMO {
dvSwitchMor = _context.getVimClient().getDecendentMoRef(networkFolderMor, "VmwareDistributedVirtualSwitch", dvSwitchName);
return dvSwitchMor;
}
+
+ public boolean ensureCustomFieldDef(String fieldName) throws Exception {
+ CustomFieldsManagerMO cfmMo = new CustomFieldsManagerMO(_context, _context.getServiceContent().getCustomFieldsManager());
+ return cfmMo.ensureCustomFieldDef("Datacenter", fieldName) > 0;
+ }
}
[08/11] git commit: updated refs/heads/vmware-datamodel to 3201dbf
Posted by sa...@apache.org.
CLOUDSTACK-2160:Refresh button functionality for security groups and statistics tab
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/63f3ccd4
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/63f3ccd4
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/63f3ccd4
Branch: refs/heads/vmware-datamodel
Commit: 63f3ccd4dfc835581305bb57c0878861106dcfe6
Parents: 870d21c
Author: Isaac Chiang <is...@gmail.com>
Authored: Sat May 4 13:41:02 2013 +0530
Committer: Pranav Saxena <pr...@citrix.com>
Committed: Sat May 4 13:41:02 2013 +0530
----------------------------------------------------------------------
ui/scripts/instances.js | 26 +++++++++++++++++++++-----
1 files changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/63f3ccd4/ui/scripts/instances.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index ab9d606..1b89d4f 100644
--- a/ui/scripts/instances.js
+++ b/ui/scripts/instances.js
@@ -1618,7 +1618,16 @@
}
],
dataProvider: function(args) {
- args.response.success({data: args.context.instances[0].securitygroup});
+ // args.response.success({data: args.context.instances[0].securitygroup});
+ $.ajax({
+ url:createURL("listVirtualMachines&details=secgrp&id=" + args.context.instances[0].id),
+ dataType: "json",
+ async:true,
+ success:function(json) {
+ args.response.success({data: json.listvirtualmachinesresponse.virtualmachine[0].securitygroup});
+ }
+
+ });
}
},
@@ -1634,15 +1643,22 @@
networkkbswrite: { label: 'label.network.write' }
},
dataProvider: function(args) {
- var jsonObj = args.context.instances[0];
- args.response.success({
+ $.ajax({
+ url:createURL("listVirtualMachines&details=stats&id=" + args.context.instances[0].id),
+ dataType: "json",
+ async:true,
+ success:function(json) {
+ var jsonObj = json.listvirtualmachinesresponse.virtualmachine[0];
+ args.response.success({
data: {
totalCPU: jsonObj.cpunumber + " x " + cloudStack.converters.convertHz(jsonObj.cpuspeed),
cpuused: jsonObj.cpuused,
networkkbsread: (jsonObj.networkkbsread == null)? "N/A": cloudStack.converters.convertBytes(jsonObj.networkkbsread * 1024),
networkkbswrite: (jsonObj.networkkbswrite == null)? "N/A": cloudStack.converters.convertBytes(jsonObj.networkkbswrite * 1024)
- }
- });
+ }
+ });
+ }
+ });
}
}
}
[11/11] git commit: updated refs/heads/vmware-datamodel to 3201dbf
Posted by sa...@apache.org.
Merge branch 'vmware-datamodel' of https://git-wip-us.apache.org/repos/asf/cloudstack into vmware-datamodel
Conflicts:
setup/db/db/schema-410to420.sql
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3201dbfe
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3201dbfe
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3201dbfe
Branch: refs/heads/vmware-datamodel
Commit: 3201dbfe2b51fc1c2ec5a05390df236dfa2d5a52
Parents: 5b83b13 2acbe30
Author: Sateesh Chodapuneedi <sa...@apache.org>
Authored: Sun May 5 08:17:06 2013 +0530
Committer: Sateesh Chodapuneedi <sa...@apache.org>
Committed: Sun May 5 08:17:06 2013 +0530
----------------------------------------------------------------------
----------------------------------------------------------------------
[04/11] git commit: updated refs/heads/vmware-datamodel to 3201dbf
Posted by sa...@apache.org.
CLOUDSTACK-2146: system vm scaleup failed ;{ "scalevirtualmachineresponse" : {"errorcode":530,"cserrorcode":9999,"errortext":"Failed to scale vm"} }
Only response generation for system vm scale up failed so fixed by changing the response object.
Signed-off-by: Abhinandan Prateek <ap...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/38b4f84f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/38b4f84f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/38b4f84f
Branch: refs/heads/vmware-datamodel
Commit: 38b4f84f1749f86ac058b25d86995fe54bc7fde6
Parents: 64fb826
Author: Harikrishna Patnala <ha...@citrix.com>
Authored: Fri May 3 14:52:45 2013 +0530
Committer: Abhinandan Prateek <ap...@apache.org>
Committed: Fri May 3 16:49:08 2013 +0530
----------------------------------------------------------------------
api/src/com/cloud/vm/UserVmService.java | 2 +-
.../cloudstack/api/command/user/vm/ScaleVMCmd.java | 10 ++--
.../api/command/test/ScaleVMCmdTest.java | 35 +++------------
server/src/com/cloud/vm/UserVmManagerImpl.java | 10 ++---
.../test/com/cloud/vm/MockUserVmManagerImpl.java | 4 +-
5 files changed, 19 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38b4f84f/api/src/com/cloud/vm/UserVmService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/UserVmService.java b/api/src/com/cloud/vm/UserVmService.java
index c8ccb67..fa89521 100755
--- a/api/src/com/cloud/vm/UserVmService.java
+++ b/api/src/com/cloud/vm/UserVmService.java
@@ -451,6 +451,6 @@ public interface UserVmService {
UserVm restoreVM(RestoreVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException;
- UserVm upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException;
+ boolean upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38b4f84f/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
index 4fc65c3..4f2ac75 100644
--- a/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/ScaleVMCmd.java
@@ -22,11 +22,12 @@ import com.cloud.user.UserContext;
import com.cloud.uservm.UserVm;
import org.apache.cloudstack.api.*;
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
+import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.log4j.Logger;
-@APICommand(name = "scaleVirtualMachine", description="Scales the virtual machine to a new service offering.", responseObject=UserVmResponse.class)
+@APICommand(name = "scaleVirtualMachine", description="Scales the virtual machine to a new service offering.", responseObject=SuccessResponse.class)
public class ScaleVMCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(ScaleVMCmd.class.getName());
private static final String s_name = "scalevirtualmachineresponse";
@@ -83,7 +84,7 @@ public class ScaleVMCmd extends BaseCmd {
@Override
public void execute(){
//UserContext.current().setEventDetails("Vm Id: "+getId());
- UserVm result = null;
+ boolean result;
try {
result = _userVmService.upgradeVirtualMachine(this);
} catch (ResourceUnavailableException ex) {
@@ -99,9 +100,8 @@ public class ScaleVMCmd extends BaseCmd {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
- if (result != null){
- UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
- response.setResponseName(getCommandName());
+ if (result){
+ SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to scale vm");
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38b4f84f/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java
----------------------------------------------------------------------
diff --git a/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java b/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java
index 301fa02..8a28290 100644
--- a/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java
+++ b/api/test/org/apache/cloudstack/api/command/test/ScaleVMCmdTest.java
@@ -16,31 +16,20 @@
// under the License.
package org.apache.cloudstack.api.command.test;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
import com.cloud.uservm.UserVm;
import com.cloud.vm.UserVmService;
import junit.framework.Assert;
import junit.framework.TestCase;
import org.apache.cloudstack.api.ResponseGenerator;
import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.command.admin.region.AddRegionCmd;
import org.apache.cloudstack.api.command.user.vm.ScaleVMCmd;
-import org.apache.cloudstack.api.response.RegionResponse;
-import org.apache.cloudstack.api.response.UserVmResponse;
-import org.apache.cloudstack.region.Region;
-import org.apache.cloudstack.region.RegionService;
+
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mockito;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-
public class ScaleVMCmdTest extends TestCase{
private ScaleVMCmd scaleVMCmd;
@@ -57,12 +46,11 @@ public class ScaleVMCmdTest extends TestCase{
public Long getId() {
return 2L;
}
+ @Override
+ public String getCommandName() {
+ return "scalevirtualmachineresponse";
+ }
};
-
- //Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid");
- //UserContext.registerContext(1, account, null, true);
-
-
}
@@ -71,11 +59,10 @@ public class ScaleVMCmdTest extends TestCase{
UserVmService userVmService = Mockito.mock(UserVmService.class);
- UserVm uservm = Mockito.mock(UserVm.class);
try {
Mockito.when(
userVmService.upgradeVirtualMachine(scaleVMCmd))
- .thenReturn(uservm);
+ .thenReturn(true);
}catch (Exception e){
Assert.fail("Received exception when success expected " +e.getMessage());
}
@@ -83,13 +70,6 @@ public class ScaleVMCmdTest extends TestCase{
scaleVMCmd._userVmService = userVmService;
responseGenerator = Mockito.mock(ResponseGenerator.class);
- UserVmResponse userVmResponse = Mockito.mock(UserVmResponse.class);
- List<UserVmResponse> responseList = new ArrayList<UserVmResponse>();
- responseList.add(userVmResponse);
-
- Mockito.when(responseGenerator.createUserVmResponse("virtualmachine",uservm))
- .thenReturn(responseList);
-
scaleVMCmd._responseGenerator = responseGenerator;
scaleVMCmd.execute();
@@ -101,10 +81,9 @@ public class ScaleVMCmdTest extends TestCase{
UserVmService userVmService = Mockito.mock(UserVmService.class);
try {
- UserVm uservm = Mockito.mock(UserVm.class);
Mockito.when(
userVmService.upgradeVirtualMachine(scaleVMCmd))
- .thenReturn(null);
+ .thenReturn(false);
}catch (Exception e){
Assert.fail("Received exception when success expected " +e.getMessage());
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38b4f84f/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 6179948..bc25bed 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1050,7 +1050,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
@Override
@ActionEvent(eventType = EventTypes.EVENT_VM_SCALE, eventDescription = "scaling Vm")
- public UserVm
+ public boolean
upgradeVirtualMachine(ScaleVMCmd cmd) throws InvalidParameterValueException {
Long vmId = cmd.getId();
Long newServiceOfferingId = cmd.getServiceOfferingId();
@@ -1076,8 +1076,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
}
// Dynamically upgrade the running vms
+ boolean success = false;
if(vmInstance.getState().equals(State.Running)){
- boolean success = false;
int retry = _scaleRetry;
while (retry-- != 0) { // It's != so that it can match -1.
try{
@@ -1095,7 +1095,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
vmInstance = _vmInstanceDao.findById(vmId);
vmInstance = _itMgr.reConfigureVm(vmInstance, oldServiceOffering, existingHostHasCapacity);
success = true;
- return _vmDao.findById(vmInstance.getId());
+ return success;
}catch(InsufficientCapacityException e ){
s_logger.warn("Received exception while scaling ",e);
} catch (ResourceUnavailableException e) {
@@ -1112,11 +1112,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
}
}
}
- if (!success)
- return null;
}
- return _vmDao.findById(vmInstance.getId());
+ return success;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/38b4f84f/server/test/com/cloud/vm/MockUserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/MockUserVmManagerImpl.java b/server/test/com/cloud/vm/MockUserVmManagerImpl.java
index 22bbbe8..8b0b1c7 100644
--- a/server/test/com/cloud/vm/MockUserVmManagerImpl.java
+++ b/server/test/com/cloud/vm/MockUserVmManagerImpl.java
@@ -407,8 +407,8 @@ public class MockUserVmManagerImpl extends ManagerBase implements UserVmManager,
}
@Override
- public UserVm upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException {
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ public boolean upgradeVirtualMachine(ScaleVMCmd scaleVMCmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
}
[10/11] git commit: updated refs/heads/vmware-datamodel to 3201dbf
Posted by sa...@apache.org.
Legacy zone support.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5b83b131
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5b83b131
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5b83b131
Branch: refs/heads/vmware-datamodel
Commit: 5b83b131f401270e8a35f0ff582ffaf1aae9e5d8
Parents: 7a8003e
Author: Sateesh Chodapuneedi <sa...@apache.org>
Authored: Sat May 4 23:20:59 2013 +0530
Committer: Sateesh Chodapuneedi <sa...@apache.org>
Committed: Sat May 4 23:23:50 2013 +0530
----------------------------------------------------------------------
setup/db/db/schema-410to420.sql | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5b83b131/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 5f90a55a..7769cba 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -934,6 +934,13 @@ CREATE TABLE `cloud`.`vmware_data_center_zone_map` (
CONSTRAINT `fk_vmware_data_center_zone_map__vmware_data_center_id` FOREIGN KEY (`vmware_data_center_id`) REFERENCES `vmware_data_center`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE `cloud`.`legacy_zones` (
+ `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
+ `zone_id` bigint unsigned NOT NULL UNIQUE COMMENT 'id of CloudStack zone',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_legacy_zones__zone_id` FOREIGN KEY (`zone_id`) REFERENCES `data_center`(`id`) ON DELETE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `eip_associate_public_ip` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if public IP is associated with user VM creation by default when EIP service is enabled.' AFTER `elastic_ip_service`;
-- Re-enable foreign key checking, at the end of the upgrade path
@@ -994,6 +1001,7 @@ CREATE VIEW `cloud`.`account_view` AS
select
account.id,
account.uuid,
+ account.uuid,
account.account_name,
account.type,
account.state,
[02/11] git commit: updated refs/heads/vmware-datamodel to 3201dbf
Posted by sa...@apache.org.
CLOUDSTACK-2320: On NetScaler RNAT rules are not getting created,
blocking public access to the VM's in basic zone using EIP.
Its required that both RNAT and INAT rules are required on the NetScaler
to provide public connectivity to user VM's in both in-bound and out-bound
directions. Currenely only INAT rule is added which permits inbound public
traffic to VM. This fix adds RNAT rule aswell, which ensures the outbound
public access from the user VM's
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8b909668
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8b909668
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8b909668
Branch: refs/heads/vmware-datamodel
Commit: 8b909668fb5adc6c5c92cb9f00e9931555668123
Parents: a3a5862
Author: Murali Reddy <mu...@citrix.com>
Authored: Fri May 3 16:06:43 2013 +0530
Committer: Murali Reddy <mu...@citrix.com>
Committed: Fri May 3 16:06:43 2013 +0530
----------------------------------------------------------------------
.../cloud/network/resource/NetscalerResource.java | 44 +++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8b909668/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
index 677bc78..563cbd4 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
@@ -1618,7 +1618,9 @@ public class NetscalerResource implements ServerResource {
String srcIp = rule.getSrcIp();
String dstIP = rule.getDstIp();
String iNatRuleName = generateInatRuleName(srcIp, dstIP);
+ String rNatRuleName = generateRnatRuleName(srcIp, dstIP);
inat iNatRule = null;
+ rnat rnatRule = null;
if (!rule.revoked()) {
try {
@@ -1645,9 +1647,47 @@ public class NetscalerResource implements ServerResource {
}
s_logger.debug("Created Inat rule on the Netscaler device " + _ip + " to enable static NAT from " + srcIp + " to " + dstIP);
}
+ try {
+ rnat[] rnatRules = rnat.get(_netscalerService);
+ if (rnatRules != null) {
+ for (rnat rantrule : rnatRules) {
+ if (rantrule.get_network().equalsIgnoreCase(rNatRuleName)) {
+ rnatRule = rantrule;
+ break;
+ }
+ }
+ }
+ } catch (nitro_exception e) {
+ throw e;
+ }
+
+ if (rnatRule == null) {
+ rnatRule = new rnat();
+ rnatRule.set_natip(srcIp);
+ rnatRule.set_network(dstIP);
+ rnatRule.set_netmask("255.255.255.255");
+ try {
+ apiCallResult = rnat.update(_netscalerService, rnatRule);
+ } catch (nitro_exception e) {
+ if (e.getErrorCode() != NitroError.NS_RESOURCE_EXISTS) {
+ throw e;
+ }
+ }
+ s_logger.debug("Created Rnat rule on the Netscaler device " + _ip + " to enable revese static NAT from " + dstIP + " to " + srcIp);
+ }
} else {
try {
inat.delete(_netscalerService, iNatRuleName);
+ rnat[] rnatRules = rnat.get(_netscalerService);
+ if (rnatRules != null) {
+ for (rnat rantrule : rnatRules) {
+ if (rantrule.get_network().equalsIgnoreCase(dstIP)) {
+ rnatRule = rantrule;
+ rnat.clear(_netscalerService, rnatRule);
+ break;
+ }
+ }
+ }
} catch (nitro_exception e) {
if (e.getErrorCode() != NitroError.NS_RESOURCE_NOT_EXISTS) {
throw e;
@@ -3090,6 +3130,10 @@ public class NetscalerResource implements ServerResource {
return genObjectName("Cloud-Inat", srcIp);
}
+ private String generateRnatRuleName(String srcIp, String dstIP) {
+ return genObjectName("Cloud-Rnat", srcIp);
+ }
+
private String generateNSVirtualServerName(String srcIp, long srcPort) {
return genObjectName("Cloud-VirtualServer", srcIp, srcPort);
}
[06/11] git commit: updated refs/heads/vmware-datamodel to 3201dbf
Posted by sa...@apache.org.
CLOUDSTACK-2303: upgrade failed from 2.2.14 to 4.1.0 - part2
Signed-off-by: Chip Childers <ch...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a3a5c134
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a3a5c134
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a3a5c134
Branch: refs/heads/vmware-datamodel
Commit: a3a5c13427d6871f87da291425314b18ef64fa2a
Parents: c8e3fff
Author: Wei Zhou <w....@leaseweb.com>
Authored: Fri May 3 16:01:44 2013 +0100
Committer: Chip Childers <ch...@gmail.com>
Committed: Fri May 3 16:03:56 2013 +0100
----------------------------------------------------------------------
.../src/com/cloud/upgrade/dao/Upgrade2214to30.java | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a3a5c134/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java b/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java
index 817231f..2d77429 100644
--- a/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java
+++ b/server/src/com/cloud/upgrade/dao/Upgrade2214to30.java
@@ -630,7 +630,7 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade {
//XenServer
try {
//Get 3.0.0 or later xenserer system Vm template Id
- pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name like 'systemvm-xenserver-%' and removed is null");
+ pstmt = conn.prepareStatement("select max(id) from `cloud`.`vm_template` where name like 'systemvm-xenserver-%' and removed is null");
rs = pstmt.executeQuery();
if(rs.next()){
long templateId = rs.getLong(1);
@@ -661,7 +661,7 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade {
s_logger.debug("Updating KVM System Vms");
try {
//Get 3.0.0 or later KVM system Vm template Id
- pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name like 'systemvm-kvm-%' and removed is null");
+ pstmt = conn.prepareStatement("select max(id) from `cloud`.`vm_template` where name like 'systemvm-kvm-%' and removed is null");
rs = pstmt.executeQuery();
if(rs.next()){
long templateId = rs.getLong(1);
@@ -692,7 +692,7 @@ public class Upgrade2214to30 extends Upgrade30xBase implements DbUpgrade {
s_logger.debug("Updating VMware System Vms");
try {
//Get 3.0.0 or later VMware system Vm template Id
- pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name like 'systemvm-vmware-%' and removed is null");
+ pstmt = conn.prepareStatement("select max(id) from `cloud`.`vm_template` where name like 'systemvm-vmware-%' and removed is null");
rs = pstmt.executeQuery();
if(rs.next()){
long templateId = rs.getLong(1);
[05/11] git commit: updated refs/heads/vmware-datamodel to 3201dbf
Posted by sa...@apache.org.
CLOUDSTACK-1849 Creation of LB Health Check policy fails if the value of Unhealthy Threshold parameter is 3 or more.
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/c8e3fff6
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c8e3fff6
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c8e3fff6
Branch: refs/heads/vmware-datamodel
Commit: c8e3fff6e43954bdd0c33aabcd0c17fa3799c4f3
Parents: 38b4f84
Author: Rajesh Battala <ra...@citrix.com>
Authored: Wed Apr 17 17:16:56 2013 +0530
Committer: Sateesh Chodapuneedi <sa...@apache.org>
Committed: Fri May 3 17:00:48 2013 +0530
----------------------------------------------------------------------
.../cloud/network/resource/NetscalerResource.java | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c8e3fff6/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
index 563cbd4..98e1461 100644
--- a/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
+++ b/plugins/network-elements/netscaler/src/com/cloud/network/resource/NetscalerResource.java
@@ -2297,6 +2297,7 @@ public class NetscalerResource implements ServerResource {
}
csMon.set_interval(hcp.getHealthcheckInterval());
+ csMon.set_retries(Math.max(hcp.getHealthcheckThresshold(), hcp.getUnhealthThresshold()) + 1);
csMon.set_resptimeout(hcp.getResponseTime());
csMon.set_failureretries(hcp.getUnhealthThresshold());
csMon.set_successretries(hcp.getHealthcheckThresshold());
[07/11] git commit: updated refs/heads/vmware-datamodel to 3201dbf
Posted by sa...@apache.org.
Summary: Release old DHCP entries
Detail: Refresh dnsmasq with updated entries live, no outage
BUG-ID: CLOUDSTACK-2299
Submitted-by: Dennis Lawler <dl...@gmail.com>
Signed-off-by: Marcus Sorensen <ma...@betterservers.com> 1367611792 -0600
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/870d21c4
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/870d21c4
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/870d21c4
Branch: refs/heads/vmware-datamodel
Commit: 870d21c436f8ca34f3d865409444e2f4c84a4319
Parents: a3a5c13
Author: Marcus Sorensen <ma...@betterservers.com>
Authored: Fri May 3 14:09:52 2013 -0600
Committer: Marcus Sorensen <ma...@betterservers.com>
Committed: Fri May 3 14:09:52 2013 -0600
----------------------------------------------------------------------
patches/systemvm/debian/config/root/edithosts.sh | 28 ++++++++++-----
scripts/network/exdhcp/dnsmasq_edithosts.sh | 19 ++++++++--
.../definitions/systemvmtemplate/postinstall.sh | 2 +-
.../definitions/systemvmtemplate64/postinstall.sh | 2 +-
4 files changed, 37 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/870d21c4/patches/systemvm/debian/config/root/edithosts.sh
----------------------------------------------------------------------
diff --git a/patches/systemvm/debian/config/root/edithosts.sh b/patches/systemvm/debian/config/root/edithosts.sh
index 8609da7..fb0c34f 100755
--- a/patches/systemvm/debian/config/root/edithosts.sh
+++ b/patches/systemvm/debian/config/root/edithosts.sh
@@ -19,12 +19,6 @@
# edithosts.sh -- edit the dhcphosts file on the routing domain
-# $mac : the mac address
-# $ip : the associated ip address
-# $host : the hostname
-# $4 : default router
-# $5 : nameserver on default nic
-# $6 : comma separated static routes
usage() {
printf "Usage: %s: -m <MAC address> -4 <IPv4 address> -6 <IPv6 address> -h <hostname> -d <default router> -n <name server address> -s <Routes> -u <DUID> [-N]\n" $(basename $0) >&2
@@ -84,6 +78,9 @@ fi
grep "redundant_router=1" /var/cache/cloud/cmdline > /dev/null
no_redundant=$?
+command -v dhcp_release > /dev/null 2>&1
+no_dhcp_release=$?
+
wait_for_dnsmasq () {
local _pid=$(pidof dnsmasq)
for i in 0 1 2 3 4 5 6 7 8 9 10
@@ -97,7 +94,15 @@ wait_for_dnsmasq () {
return 1
}
-logger -t cloud "edithosts: update $1 $2 $3 to hosts"
+if [ $no_dhcp_release -eq 0 ]
+then
+ #release previous dhcp lease if present
+ logger -t cloud "edithosts: releasing $ipv4"
+ dhcp_release lo $ipv4 $(grep $ipv4 $DHCP_LEASES | awk '{print $2}') > /dev/null 2>&1
+ logger -t cloud "edithosts: released $ipv4"
+fi
+
+logger -t cloud "edithosts: update $mac $ipv4 $ipv6 $host to hosts"
[ ! -f $DHCP_HOSTS ] && touch $DHCP_HOSTS
[ ! -f $DHCP_OPTS ] && touch $DHCP_OPTS
@@ -201,8 +206,13 @@ fi
pid=$(pidof dnsmasq)
if [ "$pid" != "" ]
then
- #service dnsmasq restart
- kill -HUP $pid
+ # use SIGHUP to avoid service outage if dhcp_release is available.
+ if [ $no_dhcp_release -eq 0 ]
+ then
+ kill -HUP $pid
+ else
+ service dnsmasq restart
+ fi
else
if [ $no_redundant -eq 1 ]
then
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/870d21c4/scripts/network/exdhcp/dnsmasq_edithosts.sh
----------------------------------------------------------------------
diff --git a/scripts/network/exdhcp/dnsmasq_edithosts.sh b/scripts/network/exdhcp/dnsmasq_edithosts.sh
index 05285d9..7990356 100755
--- a/scripts/network/exdhcp/dnsmasq_edithosts.sh
+++ b/scripts/network/exdhcp/dnsmasq_edithosts.sh
@@ -35,6 +35,9 @@ wait_for_dnsmasq () {
return 1
}
+command -v dhcp_release > /dev/null 2>&1
+no_dhcp_release=$?
+
[ ! -f /etc/dhcphosts.txt ] && touch /etc/dhcphosts.txt
[ ! -f /var/lib/misc/dnsmasq.leases ] && touch /var/lib/misc/dnsmasq.leases
@@ -44,6 +47,12 @@ sed -i /$3,/d /etc/dhcphosts.txt
echo "$1,$2,$3,infinite" >>/etc/dhcphosts.txt
+#release previous dhcp lease if present
+if [ $no_dhcp_release -eq 0 ]
+then
+ dhcp_release lo $2 $(grep $2 $DHCP_LEASES | awk '{print $2}') > /dev/null 2>&1
+fi
+
#delete leases to supplied mac and ip addresses
sed -i /$1/d /var/lib/misc/dnsmasq.leases
sed -i /"$2 "/d /var/lib/misc/dnsmasq.leases
@@ -61,9 +70,13 @@ echo "$2 $3" >> /etc/hosts
pid=$(pidof dnsmasq)
if [ "$pid" != "" ]
then
- # send SIGHUP to dnsmasq to reload /etc/hosts /etc/dhcphosts.txt
- # this will not reload /etc/dnsmasq.conf
- kill -s 1 $pid
+ # use SIGHUP to avoid service outage if dhcp_release is available.
+ if [ $no_dhcp_release -eq 0 ]
+ then
+ kill -HUP $pid
+ else
+ service dnsmasq restart
+ fi
else
service dnsmasq start
wait_for_dnsmasq
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/870d21c4/tools/appliance/definitions/systemvmtemplate/postinstall.sh
----------------------------------------------------------------------
diff --git a/tools/appliance/definitions/systemvmtemplate/postinstall.sh b/tools/appliance/definitions/systemvmtemplate/postinstall.sh
index ae8f1ad..38363d9 100644
--- a/tools/appliance/definitions/systemvmtemplate/postinstall.sh
+++ b/tools/appliance/definitions/systemvmtemplate/postinstall.sh
@@ -40,7 +40,7 @@ install_packages() {
# haproxy
apt-get --no-install-recommends -q -y --force-yes install haproxy
# dnsmasq
- apt-get --no-install-recommends -q -y --force-yes install dnsmasq
+ apt-get --no-install-recommends -q -y --force-yes install dnsmasq dnsmasq-utils
# nfs client
apt-get --no-install-recommends -q -y --force-yes install nfs-common
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/870d21c4/tools/appliance/definitions/systemvmtemplate64/postinstall.sh
----------------------------------------------------------------------
diff --git a/tools/appliance/definitions/systemvmtemplate64/postinstall.sh b/tools/appliance/definitions/systemvmtemplate64/postinstall.sh
index ae8f1ad..38363d9 100644
--- a/tools/appliance/definitions/systemvmtemplate64/postinstall.sh
+++ b/tools/appliance/definitions/systemvmtemplate64/postinstall.sh
@@ -40,7 +40,7 @@ install_packages() {
# haproxy
apt-get --no-install-recommends -q -y --force-yes install haproxy
# dnsmasq
- apt-get --no-install-recommends -q -y --force-yes install dnsmasq
+ apt-get --no-install-recommends -q -y --force-yes install dnsmasq dnsmasq-utils
# nfs client
apt-get --no-install-recommends -q -y --force-yes install nfs-common
[03/11] git commit: updated refs/heads/vmware-datamodel to 3201dbf
Posted by sa...@apache.org.
fixing build break due to commit a3a5862301b5b3d79abcf8dfef66283728954d55
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/64fb8266
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/64fb8266
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/64fb8266
Branch: refs/heads/vmware-datamodel
Commit: 64fb826640c0f10e5a58ccdfd53d0ce3a4d97a6b
Parents: 8b90966
Author: Murali Reddy <mu...@citrix.com>
Authored: Fri May 3 16:35:28 2013 +0530
Committer: Murali Reddy <mu...@citrix.com>
Committed: Fri May 3 16:35:28 2013 +0530
----------------------------------------------------------------------
.../api/command/user/nat/EnableStaticNatCmd.java | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/64fb8266/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java
index a0ec68e..902dbae 100644
--- a/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/nat/EnableStaticNatCmd.java
@@ -120,7 +120,7 @@ public class EnableStaticNatCmd extends BaseCmd{
@Override
public void execute() throws ResourceUnavailableException{
try {
- boolean result = _rulesService.enableStaticNat(ipAddressId, virtualMachineId, getNetworkId(), false, getVmSecondaryIp());
+ boolean result = _rulesService.enableStaticNat(ipAddressId, virtualMachineId, getNetworkId(), getVmSecondaryIp());
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);