You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2013/07/16 15:46:01 UTC
git commit: updated refs/heads/4.2 to 93621bb
Updated Branches:
refs/heads/4.2 ccc07cdb9 -> 93621bb5f
CLOUDSTACK-728 Remove the nvp portgroup when the virtual machine is
expunged.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/93621bb5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/93621bb5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/93621bb5
Branch: refs/heads/4.2
Commit: 93621bb5f9e407b042c95f2a3f0b5fd0d3e70dbb
Parents: ccc07cd
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Tue Jul 16 15:41:47 2013 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Tue Jul 16 15:44:40 2013 +0200
----------------------------------------------------------------------
.../vmware/resource/VmwareResource.java | 35 +++++++++++++++++---
1 file changed, 30 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93621bb5/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 8b8f706..abe99be 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -4860,14 +4860,39 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
* @return
*/
protected Answer execute(UnregisterNicCommand cmd) {
- if (s_logger.isInfoEnabled()) {
- s_logger.info("Executing resource UnregisterNicCommand: " + _gson.toJson(cmd));
+ s_logger.info("Executing resource UnregisterNicCommand: " + _gson.toJson(cmd));
+
+ if (_guestTrafficInfo == null) {
+ return new Answer(cmd, false, "No Guest Traffic Info found, unable to determine where to clean up");
}
- VmwareContext context = getServiceContext();
- getHyperHost(context);
try {
- return new Answer(cmd, true, "Not implemented yet");
+ if (_guestTrafficInfo.getVirtualSwitchType() != VirtualSwitchType.StandardVirtualSwitch) {
+ // For now we only need to cleanup the nvp specific portgroups
+ // on the standard switches
+ return new Answer(cmd, true, "Nothing to do");
+ }
+
+ s_logger.debug("Cleaning up portgroup " + cmd.getNicUuid() + " on switch "
+ + _guestTrafficInfo.getVirtualSwitchName());
+ VmwareContext context = getServiceContext();
+ VmwareHypervisorHost host = getHyperHost(context);
+ ManagedObjectReference clusterMO = host.getHyperHostCluster();
+
+ // Get a list of all the hosts in this cluster
+ @SuppressWarnings("unchecked")
+ List<ManagedObjectReference> hosts = (List<ManagedObjectReference>) context.getVimClient()
+ .getDynamicProperty(clusterMO, "host");
+ if (hosts == null) {
+ return new Answer(cmd, false, "No hosts in cluster, which is pretty weird");
+ }
+
+ for (ManagedObjectReference hostMOR : hosts) {
+ HostMO hostMo = new HostMO(context, hostMOR);
+ hostMo.deletePortGroup(cmd.getNicUuid().toString());
+ s_logger.debug("Removed portgroup " + cmd.getNicUuid() + " from host " + hostMo.getHostName());
+ }
+ return new Answer(cmd, true, "Unregistered resources for NIC " + cmd.getNicUuid());
} catch (Exception e) {
if (e instanceof RemoteException) {
s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");