From 8d7d1cd5623a6744a954fb35eeff8408d6381083 Mon Sep 17 00:00:00 2001 From: Marcus Sorensen Date: Wed, 13 Mar 2013 11:10:56 -0600 Subject: [PATCH 01/20] Summary: KVM - undefine persistent VMs on stop Detail: A previous patch fixed an issue where we are defining VMs to persist locally on KVM hosts, which can cause issues if the agent isn't running and libvirt decides to start the VM unbeknownst to cloudstack. The previous patch stopped defining VMs as persistent. This patch adds compatibility for existing cloudstack environments, removing the persistent definition on stop if needed. BUG-ID: CLOUDSTACK-600 Signed-off-by: Marcus Sorensen 1363194656 -0600 --- .../hypervisor/kvm/resource/LibvirtComputingResource.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 0a25bab2a10..af4ae372681 100755 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -3937,9 +3937,13 @@ ServerResource { try { dm = conn.domainLookupByUUID(UUID.nameUUIDFromBytes(vmName .getBytes())); + int persist = dm.isPersistent(); if (force) { if (dm.getInfo().state != DomainInfo.DomainState.VIR_DOMAIN_SHUTOFF) { dm.destroy(); + if (persist == 1) { + dm.undefine(); + } } } else { if (dm.getInfo().state == DomainInfo.DomainState.VIR_DOMAIN_SHUTOFF) { @@ -3957,6 +3961,10 @@ ServerResource { s_logger.warn("Timed out waiting for domain " + vmName + " to shutdown gracefully"); return Script.ERR_TIMEOUT; + } else { + if (persist == 1) { + dm.undefine(); + } } } } catch (LibvirtException e) { From 05f73d0950d3a12591facce03e43201e2fbbff17 Mon Sep 17 00:00:00 2001 From: Min Chen Date: Tue, 12 Mar 2013 17:36:13 -0700 Subject: [PATCH 02/20] CLOUDSTACK-1656: NicResponses in a UserVmResponse are not preseving the natural order. --- .../cloudstack/api/response/DomainRouterResponse.java | 5 +++-- .../cloudstack/api/response/SecurityGroupResponse.java | 7 ++++--- .../org/apache/cloudstack/api/response/UserVmResponse.java | 7 ++++--- .../org/apache/cloudstack/api/response/VolumeResponse.java | 3 ++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java b/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java index 274e7a5becb..b2bc02e9b83 100644 --- a/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java +++ b/api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java @@ -18,6 +18,7 @@ package org.apache.cloudstack.api.response; import java.util.Date; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import org.apache.cloudstack.api.ApiConstants; @@ -157,7 +158,7 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView private Set nics; public DomainRouterResponse(){ - nics = new HashSet(); + nics = new LinkedHashSet(); } @@ -344,7 +345,7 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView public void addNic(NicResponse nic) { this.nics.add(nic); } - + public String getIp6Dns1() { return ip6Dns1; } diff --git a/api/src/org/apache/cloudstack/api/response/SecurityGroupResponse.java b/api/src/org/apache/cloudstack/api/response/SecurityGroupResponse.java index 1130ec03f37..96a8bc28ed2 100644 --- a/api/src/org/apache/cloudstack/api/response/SecurityGroupResponse.java +++ b/api/src/org/apache/cloudstack/api/response/SecurityGroupResponse.java @@ -17,6 +17,7 @@ package org.apache.cloudstack.api.response; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import org.apache.cloudstack.api.ApiConstants; @@ -65,9 +66,9 @@ public class SecurityGroupResponse extends BaseResponse implements ControlledVie private Set tags; public SecurityGroupResponse(){ - this.ingressRules = new HashSet(); - this.egressRules = new HashSet(); - this.tags = new HashSet(); + this.ingressRules = new LinkedHashSet(); + this.egressRules = new LinkedHashSet(); + this.tags = new LinkedHashSet(); } diff --git a/api/src/org/apache/cloudstack/api/response/UserVmResponse.java b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java index cb2113e1eaf..71d1b823c6a 100644 --- a/api/src/org/apache/cloudstack/api/response/UserVmResponse.java +++ b/api/src/org/apache/cloudstack/api/response/UserVmResponse.java @@ -18,6 +18,7 @@ package org.apache.cloudstack.api.response; import java.util.Date; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import org.apache.cloudstack.api.ApiConstants; @@ -169,9 +170,9 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp private String keyPairName; public UserVmResponse(){ - securityGroupList = new HashSet(); - nics = new HashSet(); - tags = new HashSet(); + securityGroupList = new LinkedHashSet(); + nics = new LinkedHashSet(); + tags = new LinkedHashSet(); } public void setHypervisor(String hypervisor) { diff --git a/api/src/org/apache/cloudstack/api/response/VolumeResponse.java b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java index b10da0c032a..d5054f0bc26 100644 --- a/api/src/org/apache/cloudstack/api/response/VolumeResponse.java +++ b/api/src/org/apache/cloudstack/api/response/VolumeResponse.java @@ -18,6 +18,7 @@ package org.apache.cloudstack.api.response; import java.util.Date; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import org.apache.cloudstack.api.ApiConstants; @@ -161,7 +162,7 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity private Set tags; public VolumeResponse(){ - tags = new HashSet(); + tags = new LinkedHashSet(); } @Override From 22d9277ad9c96ef424b28c8c23c93e0defec61b8 Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Wed, 13 Mar 2013 19:20:33 +0100 Subject: [PATCH 03/20] debian: Bump the version to 4.2.0 This is needed since we have to be in sync with the Maven version --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index cbbaad32cad..f56dbd820d4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cloudstack (4.2.0-incubating-0.0.snapshot) unstable; urgency=low + + * Update the version to 4.2.0 to be in sync with Maven + + -- Wido den Hollander Wed, 13 Mar 2013 19:15:00 +0100 + cloudstack (4.1.0-incubating-0.0.snapshot) unstable; urgency=low * Incorporate incubating into version, remove epoch From 97d2e3fe7772fa01941295397f9d59d35cf47671 Mon Sep 17 00:00:00 2001 From: Marcus Sorensen Date: Wed, 13 Mar 2013 12:57:46 -0600 Subject: [PATCH 04/20] Summary: KVM - remove harmless message about domain not found on VM stop Detail: When we stop a VM, it's definition is no longer valid. Therefore, we need to catch the exception thrown from libvirt in trying to lookup a non-existent domain by UUID while trying to check if it's shut down. BUG-ID:CLOUDSTACK-600 Signed-off-by: Marcus Sorensen 1363201066 -0600 --- .../resource/LibvirtComputingResource.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index af4ae372681..4e1779b9441 100755 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -3939,23 +3939,32 @@ ServerResource { .getBytes())); int persist = dm.isPersistent(); if (force) { - if (dm.getInfo().state != DomainInfo.DomainState.VIR_DOMAIN_SHUTOFF) { + if (dm.isActive() == 1) { dm.destroy(); if (persist == 1) { dm.undefine(); } } } else { - if (dm.getInfo().state == DomainInfo.DomainState.VIR_DOMAIN_SHUTOFF) { + if (dm.isActive() == 0) { return null; } dm.shutdown(); int retry = _stopTimeout / 2000; - /* Wait for the domain gets into shutoff state */ - while ((dm.getInfo().state != DomainInfo.DomainState.VIR_DOMAIN_SHUTOFF) - && (retry >= 0)) { - Thread.sleep(2000); - retry--; + /* Wait for the domain gets into shutoff state. When it does + the dm object will no longer work, so we need to catch it. */ + try { + while ( dm.isActive() == 1 && (retry >= 0)) { + Thread.sleep(2000); + retry--; + } + } catch (LibvirtException e) { + String error = e.toString(); + if (error.contains("Domain not found")) { + s_logger.debug("successfully shut down vm " + vmName); + } else { + s_logger.debug("Error in waiting for vm shutdown:" + error); + } } if (retry < 0) { s_logger.warn("Timed out waiting for domain " + vmName From cd65d26a931fb4599cc9831a33a52cd5a2759a42 Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Wed, 13 Mar 2013 20:25:49 +0100 Subject: [PATCH 05/20] debian: Further improve the usage server package We no longer symlink db.properties to the management server, but we create a own db.properties for the usage server. During a upgrade we copy the file to make the upgrade easier. --- debian/cloudstack-usage.postinst | 37 ++++++++++++++++++++++++++++++++ debian/rules | 1 - usage/conf/db.properties.in | 12 +++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 debian/cloudstack-usage.postinst create mode 100644 usage/conf/db.properties.in diff --git a/debian/cloudstack-usage.postinst b/debian/cloudstack-usage.postinst new file mode 100644 index 00000000000..2e15d5d3a43 --- /dev/null +++ b/debian/cloudstack-usage.postinst @@ -0,0 +1,37 @@ +#!/bin/bash + +# 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. + +set -e + +case "$1" in + configure) + # We copy the db.properties file from the management server to the usage server + # This used to be a symlink, but we don't do that anymore + if [ -f "/etc/cloud/management/db.properties" ]; then + cp -a /etc/cloud/management/db.properties /etc/cloudstack/usage/db.properties + fi + + # We also retain the log4j configuration + if [ -f "/etc/cloud/usage/log4j-cloud_usage.xml" ]; then + cp -a /etc/cloud/usage/log4j-cloud_usage.xml /etc/cloudstack/usage/log4j-cloud_usage.xml + fi + ;; +esac + +exit 0 \ No newline at end of file diff --git a/debian/rules b/debian/rules index 7fc6425b34f..a1356018eba 100755 --- a/debian/rules +++ b/debian/rules @@ -129,7 +129,6 @@ install: install -D usage/target/cloud-usage-$(VERSION)-SNAPSHOT.jar $(DESTDIR)/usr/share/$(PACKAGE)-usage/lib/$(PACKAGE)-usage.jar install -D usage/target/dependencies/* $(DESTDIR)/usr/share/$(PACKAGE)-usage/lib/ cp usage/target/transformed/* $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/usage/ - ln -s ../management/db.properties $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/usage/db.properties install -D packaging/debian/init/cloud-usage $(DESTDIR)/$(SYSCONFDIR)/init.d/$(PACKAGE)-usage # cloudstack-awsapi diff --git a/usage/conf/db.properties.in b/usage/conf/db.properties.in new file mode 100644 index 00000000000..21e67c6d4cb --- /dev/null +++ b/usage/conf/db.properties.in @@ -0,0 +1,12 @@ +# usage database settings +db.usage.username=@DBUSER@ +db.usage.password=@DBPW@ +db.usage.host=@DBHOST@ +db.usage.port=3306 +db.usage.name=cloud_usage + +# usage database tuning parameters +db.usage.maxActive=100 +db.usage.maxIdle=30 +db.usage.maxWait=10000 +db.usage.autoReconnect=true From 7bb8ed4d05ac9ea1242201e0e4fafc36916d5c51 Mon Sep 17 00:00:00 2001 From: Pradeep Soundararajan Date: Wed, 13 Mar 2013 14:09:27 -0700 Subject: [PATCH 06/20] BUG-ID: CLOUDSTACK-1557 Summary: EC2 REST API : cloudbridge database is missing on the CloudStack Installation After this change, cloudstack-setup-databases is launching cloud-bridge related databases properly. --- setup/bindir/cloud-setup-databases.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/bindir/cloud-setup-databases.in b/setup/bindir/cloud-setup-databases.in index 1603c23eecb..0b5cbaca249 100755 --- a/setup/bindir/cloud-setup-databases.in +++ b/setup/bindir/cloud-setup-databases.in @@ -257,7 +257,7 @@ for full help self.runMysql(text, p, True) self.info(None, True) - awsApiDbDir = '/usr/share/cloud/setup/bridge/db' + awsApiDbDir = '/usr/share/cloudstack-bridge/setup' for f in ["cloudbridge_db.sql"]: p = os.path.join(awsApiDbDir,f) if not os.path.exists(p): continue From a94ff361dd26e3fae62eeee5a1d2285caed5ade7 Mon Sep 17 00:00:00 2001 From: Marcus Sorensen Date: Wed, 13 Mar 2013 15:29:09 -0600 Subject: [PATCH 07/20] CLOUDSTACK-1648 - KVM - make storage pools non-persistent in libvirt. Persisting cloud-defined resources on the host has caused various problems. As a backward compatible fix, if an existing pool with a different name collides with a pool being created (by path), the pool will be redefined with the name cloudstack knows about. This is actually what brought up the bug, a persisted storage pool cloudstack wasn't managing. Signed-off-by: Marcus Sorensen 1363210149 -0600 --- .../resource/LibvirtComputingResource.java | 2 +- .../kvm/storage/LibvirtStorageAdaptor.java | 109 +++++++++++++++--- 2 files changed, 91 insertions(+), 20 deletions(-) diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 4e1779b9441..c2d5a94cd31 100755 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -3496,7 +3496,7 @@ ServerResource { sscmd.setDataCenter(_dcId); sscmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL); } catch (CloudRuntimeException e) { - + s_logger.debug("Unable to initialize local storage pool: " + e); } if (sscmd != null) { diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java index 070c1327ba3..d5e6ad6fe00 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java @@ -120,14 +120,18 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { StoragePool sp = null; try { s_logger.debug(spd.toString()); - sp = conn.storagePoolDefineXML(spd.toString(), 0); - sp.create(0); + sp = conn.storagePoolCreateXML(spd.toString(), 0); return sp; } catch (LibvirtException e) { s_logger.error(e.toString()); if (sp != null) { try { - sp.undefine(); + if (sp.isPersistent() == 1) { + sp.destroy(); + sp.undefine(); + } else { + sp.destroy(); + } sp.free(); } catch (LibvirtException l) { s_logger.debug("Failed to define nfs storage pool with: " @@ -150,15 +154,18 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { StoragePool sp = null; try { s_logger.debug(spd.toString()); - sp = conn.storagePoolDefineXML(spd.toString(), 0); - sp.create(0); - + sp = conn.storagePoolCreateXML(spd.toString(), 0); return sp; } catch (LibvirtException e) { s_logger.error(e.toString()); if (sp != null) { try { - sp.undefine(); + if (sp.isPersistent() == 1) { + sp.destroy(); + sp.undefine(); + } else { + sp.destroy(); + } sp.free(); } catch (LibvirtException l) { s_logger.debug("Failed to define shared mount point storage pool with: " @@ -181,14 +188,18 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { StoragePool sp = null; try { s_logger.debug(spd.toString()); - sp = conn.storagePoolDefineXML(spd.toString(), 0); - sp.create(0); + sp = conn.storagePoolCreateXML(spd.toString(), 0); return sp; } catch (LibvirtException e) { s_logger.error(e.toString()); if (sp != null) { try { - sp.undefine(); + if (sp.isPersistent() == 1) { + sp.destroy(); + sp.undefine(); + } else { + sp.destroy(); + } sp.free(); } catch (LibvirtException l) { s_logger.debug("Failed to define clvm storage pool with: " @@ -236,14 +247,18 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { try { s_logger.debug(spd.toString()); - sp = conn.storagePoolDefineXML(spd.toString(), 0); - sp.create(0); + sp = conn.storagePoolCreateXML(spd.toString(), 0); return sp; } catch (LibvirtException e) { s_logger.debug(e.toString()); if (sp != null) { try { - sp.undefine(); + if (sp.isPersistent() == 1) { + sp.destroy(); + sp.undefine(); + } else { + sp.destroy(); + } sp.free(); } catch (LibvirtException l) { s_logger.debug("Failed to define RBD storage pool with: " + l.toString()); @@ -385,15 +400,59 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { try { sp = conn.storagePoolLookupByUUIDString(name); - if (sp.getInfo().state != StoragePoolState.VIR_STORAGE_POOL_RUNNING) { + if (sp != null && sp.isActive() == 0) { sp.undefine(); sp = null; + s_logger.debug("Found existing defined storage pool " + name + ". It wasn't running, so we undefined it."); + } + if (sp != null) { + s_logger.debug("Found existing defined storage pool " + name + ", using it."); } } catch (LibvirtException e) { + sp = null; + s_logger.debug("createStoragePool didn't find existing running pool: " + e + ", need to create it"); + } + // libvirt strips trailing slashes off of path, we will too in order to match + // existing paths + if (path.endsWith("/")) { + path = path.substring(0, path.length() - 1); } if (sp == null) { + // see if any existing pool by another name is using our storage path. + // if anyone is, undefine the pool so we can define it as requested. + // This should be safe since a pool in use can't be removed, and no + // volumes are affected by unregistering the pool with libvirt. + s_logger.debug("Didn't find an existing storage pool " + name + + " by UUID, checking for pools with duplicate paths"); + + try { + String[] poolnames = conn.listStoragePools(); + for (String poolname : poolnames) { + s_logger.debug("Checking path of existing pool " + poolname + + " against pool we want to create"); + StoragePool p = conn.storagePoolLookupByName(poolname); + LibvirtStoragePoolDef pdef = getStoragePoolDef(conn, p); + + if (pdef.getTargetPath().equals(path)) { + s_logger.debug("Storage pool utilizing path '" + path + "' already exists as pool " + + poolname + ", undefining so we can re-define with correct name " + name); + if (p.isPersistent() == 1) { + p.destroy(); + p.undefine(); + } else { + p.destroy(); + } + } + } + } catch (LibvirtException e) { + s_logger.error("Failure in attempting to see if an existing storage pool might " + + "be using the path of the pool to be created:" + e); + } + + s_logger.debug("Attempting to create storage pool " + name); + if (type == StoragePoolType.NetworkFilesystem) { sp = createNfsStoragePool(conn, name, host, path); } else if (type == StoragePoolType.SharedMountPoint @@ -407,8 +466,8 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } try { - StoragePoolInfo spi = sp.getInfo(); - if (spi.state != StoragePoolState.VIR_STORAGE_POOL_RUNNING) { + if (sp.isActive() == 0) { + s_logger.debug("attempting to activate pool " + name); sp.create(0); } @@ -427,7 +486,15 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { return pool; } catch (LibvirtException e) { - throw new CloudRuntimeException(e.toString()); + String error = e.toString(); + if (error.contains("Storage source conflict")) { + throw new CloudRuntimeException("A pool matching this location already exists in libvirt, " + + " but has a different UUID/Name. Cannot create new pool without first " + + " removing it. Check for inactive pools via 'virsh pool-list --all'. " + + error); + } else { + throw new CloudRuntimeException(error); + } } } @@ -459,8 +526,12 @@ public class LibvirtStorageAdaptor implements StorageAdaptor { } try { - sp.destroy(); - sp.undefine(); + if (sp.isPersistent() == 1) { + sp.destroy(); + sp.undefine(); + } else { + sp.destroy(); + } sp.free(); if (s != null) { s.undefine(); From 381f737e64ed9192e6eea4aeffe1920637f7d835 Mon Sep 17 00:00:00 2001 From: John Kinsella Date: Wed, 13 Mar 2013 16:52:49 -0700 Subject: [PATCH 08/20] Summary: Fix exception handling in security_group.py Detail: Code was attempting to concatinate an exception to a string. Updated to convert to text and concatinate that. BUG-ID: CLOUDSTACK-1052 Bugfix-for: master Reported-by: Noa Resare Signed-off-by: John Kinsella 1363218769 -0700 --- scripts/vm/network/security_group.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/vm/network/security_group.py b/scripts/vm/network/security_group.py index ed4180a508e..50a164105bb 100755 --- a/scripts/vm/network/security_group.py +++ b/scripts/vm/network/security_group.py @@ -25,6 +25,8 @@ import os import xml.dom.minidom from optparse import OptionParser, OptionGroup, OptParseError, BadOptionError, OptionError, OptionConflictError, OptionValueError import re +import traceback + iptables = Command("iptables") bash = Command("/bin/bash") virsh = Command("virsh") @@ -692,7 +694,8 @@ def add_network_rules(vm_name, vm_id, vm_ip, signature, seqno, vmMac, rules, vif return 'true' except: - logging.debug("Failed to network rule !: " + sys.exc_type) + exceptionText = traceback.format_exc() + logging.debug("Failed to network rule !: " + exceptionText) def getVifs(vmName): vifs = [] From 1079d63b6f978b2124db26d7f84f7ae62ba9daa0 Mon Sep 17 00:00:00 2001 From: John Kinsella Date: Wed, 13 Mar 2013 17:54:50 -0700 Subject: [PATCH 09/20] Summary: Prevent deletion of wrong iptables rules Detail: A grep in security_group.py wasn't defined well enough, could potentially delete rules for VMs other than intended BUG-ID: CLOUDSTACK-309 Bugfix-for: master Reviewed-by: Reported-by: Francois Scala Signed-off-by: John Kinsella 1363222521 -0700 --- scripts/vm/network/security_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/vm/network/security_group.py b/scripts/vm/network/security_group.py index 50a164105bb..1bcbc3e10fc 100755 --- a/scripts/vm/network/security_group.py +++ b/scripts/vm/network/security_group.py @@ -344,7 +344,7 @@ def post_default_network_rules(vm_name, vm_id, vm_ip, vm_mac, vif, brname, dhcpS def delete_rules_for_vm_in_bridge_firewall_chain(vmName): vm_name = vmName if vm_name.startswith('i-') or vm_name.startswith('r-'): - vm_name = '-'.join(vm_name.split('-')[:-1]) + vm_name = '-'.join(vm_name.split('-')[:-1]) + "-def" vmchain = vm_name From 01151331f57ee466454ef093b0c2dd9999f3f8d4 Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Wed, 13 Mar 2013 20:08:24 -0700 Subject: [PATCH 10/20] Separate out the target directories for eclipse and the one for regular builds --- .gitignore | 1 + pom.xml | 462 +++++++++++++++++++++++++---------------------------- 2 files changed, 219 insertions(+), 244 deletions(-) diff --git a/.gitignore b/.gitignore index b2a905641ba..15f7f91c864 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ tools/cli/build/ *.iso *.tar.gz *.tgz +target-eclipse awsapi/modules/* !.gitignore .classpath diff --git a/pom.xml b/pom.xml index 86482d7a77b..e75c420a616 100644 --- a/pom.xml +++ b/pom.xml @@ -1,23 +1,15 @@ - + + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 @@ -43,7 +35,7 @@ - + 1.6 UTF-8 @@ -92,6 +84,7 @@ 0.10 build/replace.properties 0.4.9 + target @@ -174,11 +167,11 @@ - - mysql - mysql-connector-java - ${cs.mysql.version} - + + mysql + mysql-connector-java + ${cs.mysql.version} + @@ -188,13 +181,13 @@ junit ${cs.junit.version} test - - - - org.springframework - spring-core - ${org.springframework.version} - + + + + org.springframework + spring-core + ${org.springframework.version} + org.springframework spring-context @@ -205,74 +198,37 @@ spring-web ${org.springframework.version} - + - org.mockito - mockito-all - 1.9.5 - test + org.mockito + mockito-all + 1.9.5 + test - - org.springframework - spring-test - ${org.springframework.version} - test - + + org.springframework + spring-test + ${org.springframework.version} + test + org.aspectj @@ -285,17 +241,19 @@ 1.7.1 - javax.inject - javax.inject - 1 + javax.inject + javax.inject + 1 install + ${basedir}/${cs.target.dir}/classes + ${basedir}/${cs.target.dir}/test-classes - org.eclipse.m2e @@ -453,41 +411,41 @@ ${cs.jdk.version} ${cs.jdk.version} - true - 128m - 512m - -XDignore.symbol.file=true + true + 128m + 512m + -XDignore.symbol.file=true - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - - true - true - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.7 - - - remove-old-installers - - remove-project-artifact - - - true - - - - + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + true + true + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.7 + + + remove-old-installers + + remove-project-artifact + + + true + + + + org.apache.maven.plugins maven-dependency-plugin @@ -515,15 +473,31 @@ + eclipse + + target-eclipse + + + developer - - tools/devcloud/devcloud.cfg - + + tools/devcloud/devcloud.cfg + developer tools + + impatient + + tools/devcloud/devcloud.cfg + + + developer + + + vmware @@ -536,112 +510,112 @@ - simulator - - - deploydb-simulator - - - - - - org.codehaus.mojo - properties-maven-plugin - 1.0-alpha-2 - - - initialize - - read-project-properties - - - - ${project.basedir}/utils/conf/db.properties - ${project.basedir}/utils/conf/db.properties.override - - true - - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - - mysql - mysql-connector-java - ${cs.mysql.version} - - - commons-dbcp - commons-dbcp - ${cs.dbcp.version} - - - commons-pool - commons-pool - ${cs.pool.version} - - - org.jasypt - jasypt - ${cs.jasypt.version} - - - org.apache.cloudstack - cloud-utils - ${project.version} - - - org.apache.cloudstack - cloud-server - ${project.version} - - - - - process-resources - create-schema - - java - - - - - false - true - - org.apache.cloudstack - cloud-server - - com.cloud.upgrade.DatabaseCreator - - - ${project.basedir}/utils/conf/db.properties - ${project.basedir}/utils/conf/db.properties.override - - ${basedir}/target/db/create-schema-simulator.sql - ${basedir}/target/db/templates.simulator.sql - - com.cloud.upgrade.DatabaseUpgradeChecker - --database=simulator - --rootpassword=${db.root.password} - - - - - catalina.home - ${project.basedir}/utils - - - - - - - + simulator + + + deploydb-simulator + + + + + + org.codehaus.mojo + properties-maven-plugin + 1.0-alpha-2 + + + initialize + + read-project-properties + + + + ${project.basedir}/utils/conf/db.properties + ${project.basedir}/utils/conf/db.properties.override + + true + + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + + mysql + mysql-connector-java + ${cs.mysql.version} + + + commons-dbcp + commons-dbcp + ${cs.dbcp.version} + + + commons-pool + commons-pool + ${cs.pool.version} + + + org.jasypt + jasypt + ${cs.jasypt.version} + + + org.apache.cloudstack + cloud-utils + ${project.version} + + + org.apache.cloudstack + cloud-server + ${project.version} + + + + + process-resources + create-schema + + java + + + + + false + true + + org.apache.cloudstack + cloud-server + + com.cloud.upgrade.DatabaseCreator + + + ${project.basedir}/utils/conf/db.properties + ${project.basedir}/utils/conf/db.properties.override + + ${basedir}/target/db/create-schema-simulator.sql + ${basedir}/target/db/templates.simulator.sql + + com.cloud.upgrade.DatabaseUpgradeChecker + --database=simulator + --rootpassword=${db.root.password} + + + + + catalina.home + ${project.basedir}/utils + + + + + + + From 164d3a1a39f3d0b9f52a1254dd7a53ee37d957c4 Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Wed, 13 Mar 2013 20:20:10 -0700 Subject: [PATCH 11/20] Added a shell script to set the maven profiles in eclipse --- tools/eclipse/set-eclipse-profile.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tools/eclipse/set-eclipse-profile.sh diff --git a/tools/eclipse/set-eclipse-profile.sh b/tools/eclipse/set-eclipse-profile.sh new file mode 100644 index 00000000000..1abc662e6d3 --- /dev/null +++ b/tools/eclipse/set-eclipse-profile.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# 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. + +for file in `find . -name org.eclipse.m2e.core.prefs | xargs`; do + if grep -q activeProfiles=eclipse $file; then + echo Skipping $file; + else + echo Replacing $file; + sed -i s/activeProfiles=/activeProfiles=eclipse/g $file; + fi; +done \ No newline at end of file From 4ee387e9ad58f71eac8b81c751fd06ad5df80ca4 Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Wed, 13 Mar 2013 20:40:43 -0700 Subject: [PATCH 12/20] fixed rat --- usage/conf/db.properties.in | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/usage/conf/db.properties.in b/usage/conf/db.properties.in index 21e67c6d4cb..e88e01ab83e 100644 --- a/usage/conf/db.properties.in +++ b/usage/conf/db.properties.in @@ -1,3 +1,20 @@ +# 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. + # usage database settings db.usage.username=@DBUSER@ db.usage.password=@DBPW@ From c9082c91260d5c749153e21af9e15ddc7b222188 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Thu, 14 Mar 2013 11:52:06 +0530 Subject: [PATCH 13/20] CLOUDSTACK-1643: Don't force load aesni_intel module, fix as per Chiradeep Signed-off-by: Rohit Yadav --- patches/systemvm/debian/config/etc/init.d/cloud-early-config | 4 ---- 1 file changed, 4 deletions(-) diff --git a/patches/systemvm/debian/config/etc/init.d/cloud-early-config b/patches/systemvm/debian/config/etc/init.d/cloud-early-config index 408264b478a..1f0b9a7a187 100755 --- a/patches/systemvm/debian/config/etc/init.d/cloud-early-config +++ b/patches/systemvm/debian/config/etc/init.d/cloud-early-config @@ -597,10 +597,6 @@ setup_aesni() { if [ `grep aes /proc/cpuinfo | wc -l` -gt 0 ] then modprobe aesni_intel - if [ `lsmod | grep aesni_intel | wc -l` -gt 0 ] - then - echo aesni_intel >> /etc/modules - fi fi } From 2dd31f331d84431e2dc55a56147001426b672a86 Mon Sep 17 00:00:00 2001 From: Kishan Kavala Date: Wed, 13 Mar 2013 23:01:46 +0530 Subject: [PATCH 14/20] CLOUDSTACK-1636: Removed the concept of owner region. Removed region_id from user/account and domain tables. Removed forwarding of api calls to owner region. Removed api_key and secret_key from region table. Included related DB upgrade changes. --- api/src/com/cloud/domain/Domain.java | 1 - api/src/com/cloud/user/Account.java | 2 - api/src/com/cloud/user/AccountService.java | 4 +- api/src/com/cloud/user/DomainService.java | 2 +- api/src/com/cloud/user/User.java | 1 - .../admin/account/CreateAccountCmd.java | 15 +- .../command/admin/domain/CreateDomainCmd.java | 9 +- .../command/admin/region/AddRegionCmd.java | 16 +- .../command/admin/region/UpdateRegionCmd.java | 15 +- .../api/command/admin/user/CreateUserCmd.java | 9 +- .../org/apache/cloudstack/region/Region.java | 3 - .../cloudstack/region/RegionService.java | 8 +- .../api/command/test/RegionCmdTest.java | 4 +- core/src/com/cloud/user/AccountVO.java | 13 +- core/src/com/cloud/user/UserVO.java | 13 +- server/src/com/cloud/domain/DomainVO.java | 16 +- .../cloud/projects/ProjectManagerImpl.java | 2 +- .../com/cloud/upgrade/dao/Upgrade40to41.java | 24 -- server/src/com/cloud/user/AccountManager.java | 4 +- .../com/cloud/user/AccountManagerImpl.java | 51 +-- server/src/com/cloud/user/DomainManager.java | 2 +- .../src/com/cloud/user/DomainManagerImpl.java | 18 +- .../cloudstack/region/RegionManager.java | 6 +- .../cloudstack/region/RegionManagerImpl.java | 345 +----------------- .../cloudstack/region/RegionServiceImpl.java | 8 +- .../apache/cloudstack/region/RegionVO.java | 27 +- .../cloudstack/region/RegionsApiUtil.java | 4 +- .../cloud/user/MockAccountManagerImpl.java | 9 +- .../com/cloud/user/MockDomainManagerImpl.java | 4 +- .../cloudstack/region/RegionManagerTest.java | 17 +- setup/db/db/schema-40to410.sql | 9 +- 31 files changed, 104 insertions(+), 557 deletions(-) diff --git a/api/src/com/cloud/domain/Domain.java b/api/src/com/cloud/domain/Domain.java index f8277c2cd28..befed073072 100644 --- a/api/src/com/cloud/domain/Domain.java +++ b/api/src/com/cloud/domain/Domain.java @@ -62,5 +62,4 @@ public interface Domain extends OwnedBy, Identity, InternalIdentity { public String getUuid(); - int getRegionId(); } diff --git a/api/src/com/cloud/user/Account.java b/api/src/com/cloud/user/Account.java index e65e017c266..5d32fb23253 100755 --- a/api/src/com/cloud/user/Account.java +++ b/api/src/com/cloud/user/Account.java @@ -63,7 +63,5 @@ public interface Account extends ControlledEntity, InternalIdentity, Identity { public Long getDefaultZoneId(); - public int getRegionId(); - public String getUuid(); } diff --git a/api/src/com/cloud/user/AccountService.java b/api/src/com/cloud/user/AccountService.java index f9c6ddb38ef..903eebc5bf8 100755 --- a/api/src/com/cloud/user/AccountService.java +++ b/api/src/com/cloud/user/AccountService.java @@ -62,7 +62,7 @@ public interface AccountService { * @return the user if created successfully, null otherwise */ UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain, - Map details); + Map details, String accountUUID, String userUUID); /** * Locks a user by userId. A locked user cannot access the API, but will still have running VMs/IP addresses @@ -77,7 +77,7 @@ public interface AccountService { User getSystemUser(); - User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId); + User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId, String userUUID); boolean isAdmin(short accountType); diff --git a/api/src/com/cloud/user/DomainService.java b/api/src/com/cloud/user/DomainService.java index 1f030196420..7c302e377fd 100644 --- a/api/src/com/cloud/user/DomainService.java +++ b/api/src/com/cloud/user/DomainService.java @@ -27,7 +27,7 @@ import com.cloud.utils.Pair; public interface DomainService { - Domain createDomain(String name, Long parentId, String networkDomain); + Domain createDomain(String name, Long parentId, String networkDomain, String domainUUID); Domain getDomain(long id); diff --git a/api/src/com/cloud/user/User.java b/api/src/com/cloud/user/User.java index 7d80c435e3d..3742c7bf3e2 100644 --- a/api/src/com/cloud/user/User.java +++ b/api/src/com/cloud/user/User.java @@ -73,5 +73,4 @@ public interface User extends OwnedBy, InternalIdentity { boolean isRegistered(); - public int getRegionId(); } diff --git a/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java b/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java index 4121651d499..89673ea6123 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java @@ -78,6 +78,11 @@ public class CreateAccountCmd extends BaseCmd { @Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "details for account used to store specific parameters") private Map details; + @Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.STRING, description="Account UUID, required for adding account from external provisioning system") + private String accountUUID; + + @Parameter(name=ApiConstants.USER_ID, type=CommandType.STRING, description="User UUID, required for adding account from external provisioning system") + private String userUUID; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -133,6 +138,14 @@ public class CreateAccountCmd extends BaseCmd { return params; } + public String getAccountUUID() { + return accountUUID; + } + + public String getUserUUID() { + return userUUID; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -151,7 +164,7 @@ public class CreateAccountCmd extends BaseCmd { public void execute(){ UserContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId()); UserAccount userAccount = _accountService.createUserAccount(getUsername(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimeZone(), getAccountName(), getAccountType(), - getDomainId(), getNetworkDomain(), getDetails()); + getDomainId(), getNetworkDomain(), getDetails(), getAccountUUID(), getUserUUID()); if (userAccount != null) { AccountResponse response = _responseGenerator.createUserAccountResponse(userAccount); response.setResponseName(getCommandName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java index 5eae4865732..91d61ccf582 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/domain/CreateDomainCmd.java @@ -49,6 +49,9 @@ public class CreateDomainCmd extends BaseCmd { @Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="Network domain for networks in the domain") private String networkDomain; + @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.STRING, description="Domain UUID, required for adding domain from another Region") + private String domainUUID; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -65,6 +68,10 @@ public class CreateDomainCmd extends BaseCmd { return networkDomain; } + public String getDomainUUID() { + return domainUUID; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -82,7 +89,7 @@ public class CreateDomainCmd extends BaseCmd { @Override public void execute(){ UserContext.current().setEventDetails("Domain Name: "+getDomainName()+((getParentDomainId()!=null)?", Parent DomainId :"+getParentDomainId():"")); - Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain()); + Domain domain = _domainService.createDomain(getDomainName(), getParentDomainId(), getNetworkDomain(), getDomainUUID()); if (domain != null) { DomainResponse response = _responseGenerator.createDomainResponse(domain); response.setResponseName(getCommandName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/region/AddRegionCmd.java b/api/src/org/apache/cloudstack/api/command/admin/region/AddRegionCmd.java index 20366702dd1..dce1e8b8028 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/region/AddRegionCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/region/AddRegionCmd.java @@ -49,12 +49,6 @@ public class AddRegionCmd extends BaseCmd { @Parameter(name=ApiConstants.END_POINT, type=CommandType.STRING, required=true, description="Region service endpoint") private String endPoint; - @Parameter(name=ApiConstants.API_KEY, type=CommandType.STRING, description="API key of Admin user") - private String apiKey; - - @Parameter(name=ApiConstants.SECRET_KEY, type=CommandType.STRING, description="Secret Key of Admin user") - private String secretKey; - @Inject public RegionService _regionService; ///////////////////////////////////////////////////// @@ -73,14 +67,6 @@ public class AddRegionCmd extends BaseCmd { return endPoint; } - public String getApiKey() { - return apiKey; - } - - public String getSecretKey() { - return secretKey; - } - ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -97,7 +83,7 @@ public class AddRegionCmd extends BaseCmd { @Override public void execute(){ - Region region = _regionService.addRegion(getId(), getRegionName(), getEndPoint(), getApiKey(), getSecretKey()); + Region region = _regionService.addRegion(getId(), getRegionName(), getEndPoint()); if (region != null) { RegionResponse response = _responseGenerator.createRegionResponse(region); response.setResponseName(getCommandName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/region/UpdateRegionCmd.java b/api/src/org/apache/cloudstack/api/command/admin/region/UpdateRegionCmd.java index 16693b64650..79890d00eca 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/region/UpdateRegionCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/region/UpdateRegionCmd.java @@ -49,12 +49,6 @@ public class UpdateRegionCmd extends BaseCmd { @Parameter(name=ApiConstants.END_POINT, type=CommandType.STRING, description="updates region with this end point") private String endPoint; - @Parameter(name=ApiConstants.API_KEY, type=CommandType.STRING, description="new API key for the Region") - private String apiKey; - - @Parameter(name=ApiConstants.SECRET_KEY, type=CommandType.STRING, description="new Secret Key for the Region") - private String secretKey; - @Inject RegionService _regionService; ///////////////////////////////////////////////////// @@ -73,13 +67,6 @@ public class UpdateRegionCmd extends BaseCmd { return endPoint; } - public String getApiKey() { - return apiKey; - } - - public String getSecretKey() { - return secretKey; - } ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -96,7 +83,7 @@ public class UpdateRegionCmd extends BaseCmd { @Override public void execute(){ - Region region = _regionService.updateRegion(getId(), getRegionName(), getEndPoint(), getApiKey(), getSecretKey()); + Region region = _regionService.updateRegion(getId(), getRegionName(), getEndPoint()); if (region != null) { RegionResponse response = _responseGenerator.createRegionResponse(region); response.setResponseName(getCommandName()); diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java index 6ea8d9b20cb..fb29e1a2629 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java @@ -65,6 +65,9 @@ public class CreateUserCmd extends BaseCmd { @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="Unique username.") private String username; + @Parameter(name=ApiConstants.USER_ID, type=CommandType.STRING, description="User UUID, required for adding account from external provisioning system") + private String userUUID; + ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// @@ -101,6 +104,10 @@ public class CreateUserCmd extends BaseCmd { return username; } + public String getUserUUID() { + return userUUID; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// @@ -132,7 +139,7 @@ public class CreateUserCmd extends BaseCmd { @Override public void execute(){ UserContext.current().setEventDetails("UserName: "+getUserName()+", FirstName :"+getFirstName()+", LastName: "+getLastName()); - User user = _accountService.createUser(getUserName(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimezone(), getAccountName(), getDomainId()); + User user = _accountService.createUser(getUserName(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimezone(), getAccountName(), getDomainId(), getUserUUID()); if (user != null) { UserResponse response = _responseGenerator.createUserResponse(user); response.setResponseName(getCommandName()); diff --git a/api/src/org/apache/cloudstack/region/Region.java b/api/src/org/apache/cloudstack/region/Region.java index 7f0aeeab2ef..f8926ee8d07 100644 --- a/api/src/org/apache/cloudstack/region/Region.java +++ b/api/src/org/apache/cloudstack/region/Region.java @@ -29,7 +29,4 @@ public interface Region { public String getEndPoint(); - public String getApiKey(); - - public String getSecretKey(); } diff --git a/api/src/org/apache/cloudstack/region/RegionService.java b/api/src/org/apache/cloudstack/region/RegionService.java index 8679ca92b10..303b58c8127 100644 --- a/api/src/org/apache/cloudstack/region/RegionService.java +++ b/api/src/org/apache/cloudstack/region/RegionService.java @@ -43,22 +43,18 @@ public interface RegionService { * @param id * @param name * @param endPoint - * @param apiKey - * @param secretKey * @return Return added Region object */ - public Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey); + public Region addRegion(int id, String name, String endPoint); /** * Update details of the Region with specified Id * @param id * @param name * @param endPoint - * @param apiKey - * @param secretKey * @return Return updated Region object */ - public Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey); + public Region updateRegion(int id, String name, String endPoint); /** * @param id diff --git a/api/test/org/apache/cloudstack/api/command/test/RegionCmdTest.java b/api/test/org/apache/cloudstack/api/command/test/RegionCmdTest.java index 01cd33bec80..f57dc084472 100644 --- a/api/test/org/apache/cloudstack/api/command/test/RegionCmdTest.java +++ b/api/test/org/apache/cloudstack/api/command/test/RegionCmdTest.java @@ -64,7 +64,7 @@ public class RegionCmdTest extends TestCase { Region region = Mockito.mock(Region.class); Mockito.when( - regionService.addRegion(Mockito.anyInt(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) + regionService.addRegion(Mockito.anyInt(), Mockito.anyString(), Mockito.anyString())) .thenReturn(region); addRegionCmd._regionService = regionService; @@ -87,7 +87,7 @@ public class RegionCmdTest extends TestCase { Region region = Mockito.mock(Region.class); Mockito.when( - regionService.addRegion(Mockito.anyInt(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString())) + regionService.addRegion(Mockito.anyInt(), Mockito.anyString(), Mockito.anyString())) .thenReturn(null); addRegionCmd._regionService = regionService; diff --git a/core/src/com/cloud/user/AccountVO.java b/core/src/com/cloud/user/AccountVO.java index fd37c772d11..5e939c52173 100644 --- a/core/src/com/cloud/user/AccountVO.java +++ b/core/src/com/cloud/user/AccountVO.java @@ -66,9 +66,6 @@ public class AccountVO implements Account { @Column(name="default_zone_id") private Long defaultZoneId = null; - @Column(name="region_id") - private int regionId; - public AccountVO() { this.uuid = UUID.randomUUID().toString(); } @@ -78,14 +75,13 @@ public class AccountVO implements Account { this.uuid = UUID.randomUUID().toString(); } - public AccountVO(String accountName, long domainId, String networkDomain, short type, String uuid, int regionId) { + public AccountVO(String accountName, long domainId, String networkDomain, short type, String uuid) { this.accountName = accountName; this.domainId = domainId; this.networkDomain = networkDomain; this.type = type; this.state = State.enabled; this.uuid = uuid; - this.regionId = regionId; } public void setNeedsCleanup(boolean value) { @@ -183,11 +179,4 @@ public class AccountVO implements Account { this.uuid = uuid; } - public int getRegionId() { - return regionId; - } - - public void setRegionId(int regionId) { - this.regionId = regionId; - } } diff --git a/core/src/com/cloud/user/UserVO.java b/core/src/com/cloud/user/UserVO.java index de7f31bd2be..8b7c4e3f1e1 100644 --- a/core/src/com/cloud/user/UserVO.java +++ b/core/src/com/cloud/user/UserVO.java @@ -93,9 +93,6 @@ public class UserVO implements User, Identity, InternalIdentity { @Column(name="uuid") private String uuid; - @Column(name="region_id") - private int regionId; - public UserVO() { this.uuid = UUID.randomUUID().toString(); } @@ -105,7 +102,7 @@ public class UserVO implements User, Identity, InternalIdentity { this.uuid = UUID.randomUUID().toString(); } - public UserVO(long accountId, String username, String password, String firstName, String lastName, String email, String timezone, String uuid, int regionId) { + public UserVO(long accountId, String username, String password, String firstName, String lastName, String email, String timezone, String uuid) { this.accountId = accountId; this.username = username; this.password = password; @@ -115,7 +112,6 @@ public class UserVO implements User, Identity, InternalIdentity { this.timezone = timezone; this.state = State.enabled; this.uuid = uuid; - this.regionId = regionId; } @Override @@ -266,11 +262,4 @@ public class UserVO implements User, Identity, InternalIdentity { this.uuid = uuid; } - public int getRegionId() { - return regionId; - } - - public void setRegionId(int regionId) { - this.regionId = regionId; - } } diff --git a/server/src/com/cloud/domain/DomainVO.java b/server/src/com/cloud/domain/DomainVO.java index 346e19f8f06..a87bedc1e1e 100644 --- a/server/src/com/cloud/domain/DomainVO.java +++ b/server/src/com/cloud/domain/DomainVO.java @@ -75,12 +75,9 @@ public class DomainVO implements Domain { @Column(name="uuid") private String uuid; - @Column(name="region_id") - private int regionId; - public DomainVO() {} - public DomainVO(String name, long owner, Long parentId, String networkDomain, int regionId) { + public DomainVO(String name, long owner, Long parentId, String networkDomain) { this.parent = parentId; this.name = name; this.accountId = owner; @@ -89,10 +86,9 @@ public class DomainVO implements Domain { this.state = Domain.State.Active; this.networkDomain = networkDomain; this.uuid = UUID.randomUUID().toString(); - this.regionId = regionId; } - public DomainVO(String name, long owner, Long parentId, String networkDomain, String uuid, int regionId) { + public DomainVO(String name, long owner, Long parentId, String networkDomain, String uuid) { this.parent = parentId; this.name = name; this.accountId = owner; @@ -101,7 +97,6 @@ public class DomainVO implements Domain { this.state = Domain.State.Active; this.networkDomain = networkDomain; this.uuid = uuid; - this.regionId = regionId; } @Override @@ -216,12 +211,5 @@ public class DomainVO implements Domain { this.uuid = uuid; } - public int getRegionId() { - return regionId; - } - - public void setRegionId(int regionId) { - this.regionId = regionId; - } } diff --git a/server/src/com/cloud/projects/ProjectManagerImpl.java b/server/src/com/cloud/projects/ProjectManagerImpl.java index 33feb5dd57e..de4f3ccd11b 100755 --- a/server/src/com/cloud/projects/ProjectManagerImpl.java +++ b/server/src/com/cloud/projects/ProjectManagerImpl.java @@ -205,7 +205,7 @@ public class ProjectManagerImpl extends ManagerBase implements ProjectManager { StringBuilder acctNm = new StringBuilder("PrjAcct-"); acctNm.append(name).append("-").append(owner.getDomainId()); - Account projectAccount = _accountMgr.createAccount(acctNm.toString(), Account.ACCOUNT_TYPE_PROJECT, domainId, null, null, UUID.randomUUID().toString(), 0); + Account projectAccount = _accountMgr.createAccount(acctNm.toString(), Account.ACCOUNT_TYPE_PROJECT, domainId, null, null, UUID.randomUUID().toString()); Project project = _projectDao.persist(new ProjectVO(name, displayText, owner.getDomainId(), projectAccount.getId())); diff --git a/server/src/com/cloud/upgrade/dao/Upgrade40to41.java b/server/src/com/cloud/upgrade/dao/Upgrade40to41.java index 92687643185..4a2fe4fc331 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade40to41.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade40to41.java @@ -88,30 +88,6 @@ public class Upgrade40to41 implements DbUpgrade { pstmt.setInt(1, region_id); pstmt.executeUpdate(); - //Update regionId in account table - s_logger.debug("Updating account table with Id: "+region_id); - pstmt = conn.prepareStatement("update `cloud`.`account` set region_id = ?"); - pstmt.setInt(1, region_id); - pstmt.executeUpdate(); - - //Update regionId in user table - s_logger.debug("Updating user table with Id: "+region_id); - pstmt = conn.prepareStatement("update `cloud`.`user` set region_id = ?"); - pstmt.setInt(1, region_id); - pstmt.executeUpdate(); - - //Update regionId in domain table - s_logger.debug("Updating domain table with Id: "+region_id); - pstmt = conn.prepareStatement("update `cloud`.`domain` set region_id = ?"); - pstmt.setInt(1, region_id); - pstmt.executeUpdate(); - - //Update regionId in cloud_usage account table - s_logger.debug("Updating cloud_usage account table with Id: "+region_id); - pstmt = conn.prepareStatement("update `cloud_usage`.`account` set region_id = ?"); - pstmt.setInt(1, region_id); - pstmt.executeUpdate(); - s_logger.debug("Successfully updated region entries with regionId: "+region_id); } catch (SQLException e) { throw new CloudRuntimeException("Error while updating region entries", e); } finally { diff --git a/server/src/com/cloud/user/AccountManager.java b/server/src/com/cloud/user/AccountManager.java index 4b3a601b802..6ba1f6a7f96 100755 --- a/server/src/com/cloud/user/AccountManager.java +++ b/server/src/com/cloud/user/AccountManager.java @@ -51,9 +51,9 @@ public interface AccountManager extends AccountService { Long checkAccessAndSpecifyAuthority(Account caller, Long zoneId); - Account createAccount(String accountName, short accountType, Long domainId, String networkDomain, Map details, String uuid, int regionId); + Account createAccount(String accountName, short accountType, Long domainId, String networkDomain, Map details, String uuid); - UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone); + UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone, String userUUID); /** * Logs out a user diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index 9b916024cbb..be5f4f4d77d 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -54,9 +54,6 @@ import com.cloud.api.ApiDBUtils; import com.cloud.api.query.dao.UserAccountJoinDao; import com.cloud.api.query.vo.ControlledViewEntity; - -import org.apache.cloudstack.region.RegionManager; - import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.ResourceLimit; @@ -217,8 +214,6 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M @Inject private IPAddressDao _ipAddressDao; @Inject - private RegionManager _regionMgr; - @Inject private VpcManager _vpcMgr; @Inject private DomainRouterDao _routerDao; @@ -764,7 +759,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M @DB @ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_CREATE, eventDescription = "creating Account") public UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, - Long domainId, String networkDomain, Map details) { + Long domainId, String networkDomain, Map details, String accountUUID, String userUUID) { if (accountName == null) { accountName = userName; @@ -810,11 +805,14 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M txn.start(); // create account - AccountVO account = createAccount(accountName, accountType, domainId, networkDomain, details, UUID.randomUUID().toString(), _regionMgr.getId()); + if(accountUUID == null){ + accountUUID = UUID.randomUUID().toString(); + } + AccountVO account = createAccount(accountName, accountType, domainId, networkDomain, details, accountUUID); long accountId = account.getId(); // create the first user for the account - UserVO user = createUser(accountId, userName, password, firstName, lastName, email, timezone); + UserVO user = createUser(accountId, userName, password, firstName, lastName, email, timezone, userUUID); if (accountType == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) { // set registration token @@ -829,7 +827,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M } @Override - public UserVO createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId) { + public UserVO createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId, String userUUID) { // default domain to ROOT if not specified if (domainId == null) { @@ -858,7 +856,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M throw new CloudRuntimeException("The user " + userName + " already exists in domain " + domainId); } UserVO user = null; - user = createUser(account.getId(), userName, password, firstName, lastName, email, timeZone); + user = createUser(account.getId(), userName, password, firstName, lastName, email, timeZone, userUUID); return user; } @@ -1646,7 +1644,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M @Override @DB - public AccountVO createAccount(String accountName, short accountType, Long domainId, String networkDomain, Map details, String uuid, int regionId) { + public AccountVO createAccount(String accountName, short accountType, Long domainId, String networkDomain, Map details, String uuid) { // Validate domain Domain domain = _domainMgr.getDomain(domainId); if (domain == null) { @@ -1690,7 +1688,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M Transaction txn = Transaction.currentTxn(); txn.start(); - AccountVO account = _accountDao.persist(new AccountVO(accountName, domainId, networkDomain, accountType, uuid, regionId)); + AccountVO account = _accountDao.persist(new AccountVO(accountName, domainId, networkDomain, accountType, uuid)); if (account == null) { throw new CloudRuntimeException("Failed to create account name " + accountName + " in domain id=" + domainId); @@ -1714,7 +1712,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M @Override @ActionEvent(eventType = EventTypes.EVENT_USER_CREATE, eventDescription = "creating User") - public UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone) { + public UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone, String userUUID) { if (s_logger.isDebugEnabled()) { s_logger.debug("Creating user: " + userName + ", accountId: " + accountId + " timezone:" + timezone); } @@ -1730,30 +1728,10 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M throw new CloudRuntimeException("Failed to encode password"); } - UserVO user = _userDao.persist(new UserVO(accountId, userName, encodedPassword, firstName, lastName, email, timezone, UUID.randomUUID().toString(), _regionMgr.getId())); - - return user; - } - - //ToDo Add events?? - public UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone, String uuid, int regionId) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Creating user: " + userName + ", accountId: " + accountId + " timezone:" + timezone); + if(userUUID == null){ + userUUID = UUID.randomUUID().toString(); } - - String encodedPassword = null; - for (Iterator en = _userAuthenticators.iterator(); en.hasNext();) { - UserAuthenticator authenticator = en.next(); - encodedPassword = authenticator.encode(password); - if (encodedPassword != null) { - break; - } - } - if (encodedPassword == null) { - throw new CloudRuntimeException("Failed to encode password"); - } - - UserVO user = _userDao.persist(new UserVO(accountId, userName, encodedPassword, firstName, lastName, email, timezone, uuid, regionId)); + UserVO user = _userDao.persist(new UserVO(accountId, userName, encodedPassword, firstName, lastName, email, timezone, userUUID)); return user; } @@ -1983,7 +1961,6 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M @Override @DB public String[] createApiKeyAndSecretKey(RegisterCmd cmd) { - //Send keys to other Regions Long userId = cmd.getId(); User user = getUserIncludingRemoved(userId); diff --git a/server/src/com/cloud/user/DomainManager.java b/server/src/com/cloud/user/DomainManager.java index f268f6ec4eb..7bc2abbc756 100644 --- a/server/src/com/cloud/user/DomainManager.java +++ b/server/src/com/cloud/user/DomainManager.java @@ -27,7 +27,7 @@ import com.cloud.domain.DomainVO; public interface DomainManager extends DomainService { Set getDomainChildrenIds(String parentDomainPath); - Domain createDomain(String name, Long parentId, Long ownerId, String networkDomain); + Domain createDomain(String name, Long parentId, Long ownerId, String networkDomain, String domainUUID); Set getDomainParentIds(long domainId); diff --git a/server/src/com/cloud/user/DomainManagerImpl.java b/server/src/com/cloud/user/DomainManagerImpl.java index babaed37494..dbcbe4ee431 100644 --- a/server/src/com/cloud/user/DomainManagerImpl.java +++ b/server/src/com/cloud/user/DomainManagerImpl.java @@ -16,10 +16,7 @@ // under the License. package com.cloud.user; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import javax.ejb.Local; import javax.inject.Inject; @@ -118,7 +115,7 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom @Override @ActionEvent(eventType = EventTypes.EVENT_DOMAIN_CREATE, eventDescription = "creating Domain") - public Domain createDomain(String name, Long parentId, String networkDomain) { + public Domain createDomain(String name, Long parentId, String networkDomain, String domainUUID) { Account caller = UserContext.current().getCaller(); if (parentId == null) { @@ -136,13 +133,13 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom _accountMgr.checkAccess(caller, parentDomain); - return createDomain(name, parentId, caller.getId(), networkDomain); + return createDomain(name, parentId, caller.getId(), networkDomain, domainUUID); } @Override @DB - public Domain createDomain(String name, Long parentId, Long ownerId, String networkDomain) { + public Domain createDomain(String name, Long parentId, Long ownerId, String networkDomain, String domainUUID) { // Verify network domain if (networkDomain != null) { if (!NetUtils.verifyDomainName(networkDomain)) { @@ -161,10 +158,13 @@ public class DomainManagerImpl extends ManagerBase implements DomainManager, Dom throw new InvalidParameterValueException("Domain with name " + name + " already exists for the parent id=" + parentId); } + if(domainUUID == null){ + domainUUID = UUID.randomUUID().toString(); + } + Transaction txn = Transaction.currentTxn(); txn.start(); - - DomainVO domain = _domainDao.create(new DomainVO(name, ownerId, parentId, networkDomain, _regionMgr.getId())); + DomainVO domain = _domainDao.create(new DomainVO(name, ownerId, parentId, networkDomain, domainUUID)); _resourceCountDao.createResourceCounts(domain.getId(), ResourceLimit.ResourceOwnerType.Domain); txn.commit(); return domain; diff --git a/server/src/org/apache/cloudstack/region/RegionManager.java b/server/src/org/apache/cloudstack/region/RegionManager.java index 4cbd664ce5a..2d517302081 100644 --- a/server/src/org/apache/cloudstack/region/RegionManager.java +++ b/server/src/org/apache/cloudstack/region/RegionManager.java @@ -43,11 +43,9 @@ public interface RegionManager { * @param id * @param name * @param endPoint - * @param apiKey - * @param secretKey * @return Returns added Region object */ - Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey); + Region addRegion(int id, String name, String endPoint); /** * Update details of the Region with specified Id @@ -59,7 +57,7 @@ public interface RegionManager { * @param secretKey * @return Returns update Region object */ - Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey); + Region updateRegion(int id, String name, String endPoint); /** * @param id diff --git a/server/src/org/apache/cloudstack/region/RegionManagerImpl.java b/server/src/org/apache/cloudstack/region/RegionManagerImpl.java index cb0b1a69ad8..9bcf4be69c8 100755 --- a/server/src/org/apache/cloudstack/region/RegionManagerImpl.java +++ b/server/src/org/apache/cloudstack/region/RegionManagerImpl.java @@ -17,30 +17,22 @@ package org.apache.cloudstack.region; import com.cloud.domain.Domain; -import com.cloud.domain.DomainVO; -import com.cloud.domain.dao.DomainDao; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; import com.cloud.user.AccountManager; -import com.cloud.user.AccountVO; import com.cloud.user.DomainManager; import com.cloud.user.UserAccount; -import com.cloud.user.UserVO; import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.UserAccountDao; -import com.cloud.user.dao.UserDao; import com.cloud.utils.component.Manager; import com.cloud.utils.component.ManagerBase; -import com.cloud.utils.exception.CloudRuntimeException; -import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd; import org.apache.cloudstack.api.command.admin.domain.UpdateDomainCmd; import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd; import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd; import org.apache.cloudstack.region.dao.RegionDao; -import org.apache.commons.httpclient.NameValuePair; import org.apache.log4j.Logger; import org.springframework.stereotype.Component; @@ -63,13 +55,7 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man @Inject private AccountManager _accountMgr; @Inject - private UserDao _userDao; - @Inject - private DomainDao _domainDao; - @Inject private DomainManager _domainMgr; - @Inject - private UserAccountDao _userAccountDao; private String _name; private int _id; @@ -104,7 +90,7 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man * {@inheritDoc} */ @Override - public Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey) { + public Region addRegion(int id, String name, String endPoint) { //Region Id should be unique if( _regionDao.findById(id) != null ){ throw new InvalidParameterValueException("Region with id: "+id+" already exists"); @@ -113,7 +99,7 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man if( _regionDao.findByName(name) != null ){ throw new InvalidParameterValueException("Region with name: "+name+" already exists"); } - RegionVO region = new RegionVO(id, name, endPoint, apiKey, secretKey); + RegionVO region = new RegionVO(id, name, endPoint); return _regionDao.persist(region); } @@ -121,7 +107,7 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man * {@inheritDoc} */ @Override - public Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey) { + public Region updateRegion(int id, String name, String endPoint) { RegionVO region = _regionDao.findById(id); if(region == null){ @@ -144,14 +130,6 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man region.setEndPoint(endPoint); } - if(apiKey != null){ - region.setApiKey(apiKey); - } - - if(secretKey != null){ - region.setSecretKey(secretKey); - } - _regionDao.update(id, region); return _regionDao.findById(id); } @@ -196,30 +174,7 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man */ @Override public boolean deleteUserAccount(long accountId) { - AccountVO account = _accountDao.findById(accountId); - if(account == null){ - throw new InvalidParameterValueException("The specified account does not exist in the system"); - } - String accountUUID = account.getUuid(); - int regionId = account.getRegionId(); - - String command = "deleteAccount"; - List params = new ArrayList(); - params.add(new NameValuePair(ApiConstants.ID, accountUUID)); - - if(getId() == regionId){ - return _accountMgr.deleteUserAccount(accountId); - } else { - //First delete in the Region where account is created - Region region = _regionDao.findById(regionId); - if (RegionsApiUtil.makeAPICall(region, command, params)) { - s_logger.debug("Successfully deleted account :"+accountUUID+" in Region: "+region.getId()); - return true; - } else { - s_logger.error("Error while deleting account :"+accountUUID+" in Region: "+region.getId()); - return false; - } - } + return _accountMgr.deleteUserAccount(accountId); } /** @@ -227,51 +182,7 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man */ @Override public Account updateAccount(UpdateAccountCmd cmd) { - Long accountId = cmd.getId(); - Long domainId = cmd.getDomainId(); - DomainVO domain = _domainDao.findById(domainId); - String accountName = cmd.getAccountName(); - String newAccountName = cmd.getNewName(); - String networkDomain = cmd.getNetworkDomain(); - //ToDo send details - Map details = cmd.getDetails(); - - Account account = null; - if (accountId != null) { - account = _accountDao.findById(accountId); - } else { - account = _accountDao.findEnabledAccount(accountName, domainId); - } - - // Check if account exists - if (account == null || account.getType() == Account.ACCOUNT_TYPE_PROJECT) { - s_logger.error("Unable to find account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId); - throw new InvalidParameterValueException("Unable to find account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId); - } - - String command = "updateAccount"; - List params = new ArrayList(); - params.add(new NameValuePair(ApiConstants.ID, account.getUuid())); - params.add(new NameValuePair(ApiConstants.ACCOUNT, accountName)); - params.add(new NameValuePair(ApiConstants.DOMAIN_ID, domain.getUuid())); - params.add(new NameValuePair(ApiConstants.NETWORK_DOMAIN, networkDomain)); - params.add(new NameValuePair(ApiConstants.NEW_NAME, newAccountName)); - if(details != null){ - params.add(new NameValuePair(ApiConstants.ACCOUNT_DETAILS, details.toString())); - } - int regionId = account.getRegionId(); - if(getId() == regionId){ - return _accountMgr.updateAccount(cmd); - } else { - //First update in the Region where account is created - Region region = _regionDao.findById(regionId); - if (RegionsApiUtil.makeAPICall(region, command, params)) { - s_logger.debug("Successfully updated account :"+account.getUuid()+" in source Region: "+region.getId()); - return account; - } else { - throw new CloudRuntimeException("Error while updating account :"+account.getUuid()+" in source Region: "+region.getId()); - } - } + return _accountMgr.updateAccount(cmd); } /** @@ -280,46 +191,12 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man @Override public Account disableAccount(String accountName, Long domainId, Long accountId, Boolean lockRequested) throws ConcurrentOperationException, ResourceUnavailableException { Account account = null; - if (accountId != null) { - account = _accountDao.findById(accountId); + if(lockRequested){ + account = _accountMgr.lockAccount(accountName, domainId, accountId); } else { - account = _accountDao.findActiveAccount(accountName, domainId); - } - - if (account == null || account.getType() == Account.ACCOUNT_TYPE_PROJECT) { - throw new InvalidParameterValueException("Unable to find active account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId); - } - - String accountUUID = account.getUuid(); - - String command = "disableAccount"; - List params = new ArrayList(); - params.add(new NameValuePair(ApiConstants.LOCK, lockRequested.toString())); - params.add(new NameValuePair(ApiConstants.ID, accountUUID)); - DomainVO domain = _domainDao.findById(domainId); - if(domain != null){ - params.add(new NameValuePair(ApiConstants.DOMAIN_ID, domain.getUuid())); - } - - int regionId = account.getRegionId(); - if(getId() == regionId){ - Account retAccount = null; - if(lockRequested){ - retAccount = _accountMgr.lockAccount(accountName, domainId, accountId); - } else { - retAccount = _accountMgr.disableAccount(accountName, domainId, accountId); - } - return retAccount; - } else { - //First disable account in the Region where account is created - Region region = _regionDao.findById(regionId); - if (RegionsApiUtil.makeAPICall(region, command, params)) { - s_logger.debug("Successfully disabled account :"+accountUUID+" in source Region: "+region.getId()); - return account; - } else { - throw new CloudRuntimeException("Error while disabling account :"+accountUUID+" in source Region: "+region.getId()); - } + account = _accountMgr.disableAccount(accountName, domainId, accountId); } + return account; } /** @@ -327,42 +204,7 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man */ @Override public Account enableAccount(String accountName, Long domainId, Long accountId) { - // Check if account exists - Account account = null; - if (accountId != null) { - account = _accountDao.findById(accountId); - } else { - account = _accountDao.findActiveAccount(accountName, domainId); - } - - if (account == null || account.getType() == Account.ACCOUNT_TYPE_PROJECT) { - throw new InvalidParameterValueException("Unable to find account by accountId: " + accountId + " OR by name: " + accountName + " in domain " + domainId); - } - - String accountUUID = account.getUuid(); - - String command = "enableAccount"; - List params = new ArrayList(); - params.add(new NameValuePair(ApiConstants.ID, accountUUID)); - params.add(new NameValuePair(ApiConstants.ACCOUNT, accountName)); - DomainVO domain = _domainDao.findById(domainId); - if(domain != null){ - params.add(new NameValuePair(ApiConstants.DOMAIN_ID, domain.getUuid())); - } - - int regionId = account.getRegionId(); - if(getId() == regionId){ - return _accountMgr.enableAccount(accountName, domainId, accountId); - } else { - //First disable account in the Region where account is created - Region region = _regionDao.findById(regionId); - if (RegionsApiUtil.makeAPICall(region, command, params)) { - s_logger.debug("Successfully enabled account :"+accountUUID+" in source Region: "+region.getId()); - return account; - } else { - throw new CloudRuntimeException("Error while enabling account :"+accountUUID+" in source Region: "+region.getId()); - } - } + return _accountMgr.enableAccount(accountName, domainId, accountId); } /** @@ -370,34 +212,7 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man */ @Override public boolean deleteUser(DeleteUserCmd cmd) { - long id = cmd.getId(); - - UserVO user = _userDao.findById(id); - - if (user == null) { - throw new InvalidParameterValueException("The specified user doesn't exist in the system"); - } - - String userUUID = user.getUuid(); - int regionId = user.getRegionId(); - - String command = "deleteUser"; - List params = new ArrayList(); - params.add(new NameValuePair(ApiConstants.ID, userUUID)); - - if(getId() == regionId){ - return _accountMgr.deleteUser(cmd); - } else { - //First delete in the Region where user is created - Region region = _regionDao.findById(regionId); - if (RegionsApiUtil.makeAPICall(region, command, params)) { - s_logger.debug("Successfully deleted user :"+userUUID+" in source Region: "+region.getId()); - return true; - } else { - s_logger.error("Error while deleting user :"+userUUID+" in source Region: "+region.getId()); - return false; - } - } + return _accountMgr.deleteUser(cmd); } /** @@ -405,33 +220,7 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man */ @Override public Domain updateDomain(UpdateDomainCmd cmd) { - long id = cmd.getId(); - DomainVO domain = _domainDao.findById(id); - if(domain == null){ - throw new InvalidParameterValueException("The specified domain doesn't exist in the system"); - } - - String domainUUID = domain.getUuid(); - - String command = "updateDomain"; - List params = new ArrayList(); - params.add(new NameValuePair(ApiConstants.ID, domainUUID)); - params.add(new NameValuePair(ApiConstants.NAME, cmd.getDomainName())); - params.add(new NameValuePair(ApiConstants.NETWORK_DOMAIN, cmd.getNetworkDomain())); - - int regionId = domain.getRegionId(); - if(getId() == regionId){ - return _domainMgr.updateDomain(cmd); - } else { - //First update in the Region where domain was created - Region region = _regionDao.findById(regionId); - if (RegionsApiUtil.makeAPICall(region, command, params)) { - s_logger.debug("Successfully updated user :"+domainUUID+" in source Region: "+region.getId()); - return domain; - } else { - throw new CloudRuntimeException("Error while updating user :"+domainUUID+" in source Region: "+region.getId()); - } - } + return _domainMgr.updateDomain(cmd); } /** @@ -439,32 +228,7 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man */ @Override public boolean deleteDomain(Long id, Boolean cleanup) { - DomainVO domain = _domainDao.findById(id); - if(domain == null){ - throw new InvalidParameterValueException("The specified domain doesn't exist in the system"); - } - - String domainUUID = domain.getUuid(); - - String command = "deleteDomain"; - List params = new ArrayList(); - params.add(new NameValuePair(ApiConstants.ID, domainUUID)); - params.add(new NameValuePair(ApiConstants.CLEANUP, cleanup.toString())); - - int regionId = domain.getRegionId(); - if(getId() == regionId){ - return _domainMgr.deleteDomain(id, cleanup); - } else { - //First delete in the Region where domain is created - Region region = _regionDao.findById(regionId); - if (RegionsApiUtil.makeAPICall(region, command, params)) { - s_logger.debug("Successfully deleted domain :"+domainUUID+" in Region: "+region.getId()); - return true; - } else { - s_logger.error("Error while deleting domain :"+domainUUID+" in Region: "+region.getId()); - return false; - } - } + return _domainMgr.deleteDomain(id, cleanup); } /** @@ -472,40 +236,7 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man */ @Override public UserAccount updateUser(UpdateUserCmd cmd) { - long id = cmd.getId(); - - UserVO user = _userDao.findById(id); - if (user == null) { - throw new InvalidParameterValueException("The specified user doesn't exist in the system"); - } - - String userUUID = user.getUuid(); - - String command = "updateUser"; - List params = new ArrayList(); - params.add(new NameValuePair(ApiConstants.ID, userUUID)); - params.add(new NameValuePair(ApiConstants.API_KEY, cmd.getApiKey())); - params.add(new NameValuePair(ApiConstants.EMAIL, cmd.getEmail())); - params.add(new NameValuePair(ApiConstants.FIRSTNAME, cmd.getFirstname())); - params.add(new NameValuePair(ApiConstants.LASTNAME, cmd.getLastname())); - params.add(new NameValuePair(ApiConstants.PASSWORD, cmd.getPassword())); - params.add(new NameValuePair(ApiConstants.SECRET_KEY, cmd.getSecretKey())); - params.add(new NameValuePair(ApiConstants.TIMEZONE, cmd.getTimezone())); - params.add(new NameValuePair(ApiConstants.USERNAME, cmd.getUsername())); - - int regionId = user.getRegionId(); - if(getId() == regionId){ - return _accountMgr.updateUser(cmd); - } else { - //First update in the Region where user was created - Region region = _regionDao.findById(regionId); - if (RegionsApiUtil.makeAPICall(region, command, params)) { - s_logger.debug("Successfully updated user :"+userUUID+" in source Region: "+region.getId()); - return _userAccountDao.findById(id); - } else { - throw new CloudRuntimeException("Error while updating user :"+userUUID+" in source Region: "+region.getId()); - } - } + return _accountMgr.updateUser(cmd); } /** @@ -513,29 +244,7 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man */ @Override public UserAccount disableUser(Long userId) { - UserVO user = _userDao.findById(userId); - if (user == null || user.getRemoved() != null) { - throw new InvalidParameterValueException("Unable to find active user by id " + userId); - } - - int regionId = user.getRegionId(); - - String command = "disableUser"; - List params = new ArrayList(); - params.add(new NameValuePair(ApiConstants.ID, user.getUuid())); - - if(getId() == regionId){ - return _accountMgr.disableUser(userId); - } else { - //First disable in the Region where user was created - Region region = _regionDao.findById(regionId); - if (RegionsApiUtil.makeAPICall(region, command, params)) { - s_logger.debug("Successfully disabled user :"+user.getUuid()+" in source Region: "+region.getId()); - return _userAccountDao.findById(userId); - } else { - throw new CloudRuntimeException("Error while disabling user :"+user.getUuid()+" in source Region: "+region.getId()); - } - } + return _accountMgr.disableUser(userId); } /** @@ -543,29 +252,7 @@ public class RegionManagerImpl extends ManagerBase implements RegionManager, Man */ @Override public UserAccount enableUser(long userId) { - UserVO user = _userDao.findById(userId); - if (user == null || user.getRemoved() != null) { - throw new InvalidParameterValueException("Unable to find active user by id " + userId); - } - - int regionId = user.getRegionId(); - - String command = "enableUser"; - List params = new ArrayList(); - params.add(new NameValuePair(ApiConstants.ID, user.getUuid())); - - if(getId() == regionId){ - return _accountMgr.enableUser(userId); - } else { - //First enable in the Region where user was created - Region region = _regionDao.findById(regionId); - if (RegionsApiUtil.makeAPICall(region, command, params)) { - s_logger.debug("Successfully enabled user :"+user.getUuid()+" in source Region: "+region.getId()); - return _userAccountDao.findById(userId); - } else { - throw new CloudRuntimeException("Error while enabling user :"+user.getUuid()+" in source Region: "+region.getId()); - } - } + return _accountMgr.enableUser(userId); } } diff --git a/server/src/org/apache/cloudstack/region/RegionServiceImpl.java b/server/src/org/apache/cloudstack/region/RegionServiceImpl.java index 0662c320145..cb03df6bddc 100755 --- a/server/src/org/apache/cloudstack/region/RegionServiceImpl.java +++ b/server/src/org/apache/cloudstack/region/RegionServiceImpl.java @@ -78,20 +78,20 @@ public class RegionServiceImpl extends ManagerBase implements RegionService, Man * {@inheritDoc} */ @Override - public Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey) { + public Region addRegion(int id, String name, String endPoint) { //Check for valid Name //Check valid end_point url - return _regionMgr.addRegion(id, name, endPoint, apiKey, secretKey); + return _regionMgr.addRegion(id, name, endPoint); } /** * {@inheritDoc} */ @Override - public Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey) { + public Region updateRegion(int id, String name, String endPoint) { //Check for valid Name //Check valid end_point url - return _regionMgr.updateRegion(id, name, endPoint, apiKey, secretKey); + return _regionMgr.updateRegion(id, name, endPoint); } /** diff --git a/server/src/org/apache/cloudstack/region/RegionVO.java b/server/src/org/apache/cloudstack/region/RegionVO.java index 0c36db2caff..907c11dff86 100644 --- a/server/src/org/apache/cloudstack/region/RegionVO.java +++ b/server/src/org/apache/cloudstack/region/RegionVO.java @@ -36,21 +36,13 @@ public class RegionVO implements Region{ @Column(name="end_point") private String endPoint; - @Column(name="api_key") - private String apiKey; - - @Column(name="secret_key") - private String secretKey; - public RegionVO() { } - public RegionVO(int id, String name, String endPoint, String apiKey, String secretKey) { + public RegionVO(int id, String name, String endPoint) { this.id = id; this.name = name; this.endPoint = endPoint; - this.apiKey = apiKey; - this.secretKey = secretKey; } public int getId() { @@ -73,21 +65,4 @@ public class RegionVO implements Region{ this.endPoint = endPoint; } - public String getApiKey() { - return apiKey; - } - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } - - public String getSecretKey() { - return secretKey; - } - - public void setSecretKey(String secretKey) { - this.secretKey = secretKey; - } - - } diff --git a/server/src/org/apache/cloudstack/region/RegionsApiUtil.java b/server/src/org/apache/cloudstack/region/RegionsApiUtil.java index 2ace4f9295c..0dbee5fb541 100644 --- a/server/src/org/apache/cloudstack/region/RegionsApiUtil.java +++ b/server/src/org/apache/cloudstack/region/RegionsApiUtil.java @@ -227,8 +227,8 @@ public class RegionsApiUtil { */ private static String buildUrl(String apiParams, Region region) { - String apiKey = region.getApiKey(); - String secretKey = region.getSecretKey(); + String apiKey = ""; + String secretKey = ""; if (apiKey == null || secretKey == null) { diff --git a/server/test/com/cloud/user/MockAccountManagerImpl.java b/server/test/com/cloud/user/MockAccountManagerImpl.java index b637c2aaf4e..64919afa74f 100644 --- a/server/test/com/cloud/user/MockAccountManagerImpl.java +++ b/server/test/com/cloud/user/MockAccountManagerImpl.java @@ -264,7 +264,7 @@ public class MockAccountManagerImpl extends ManagerBase implements Manager, Acco } @Override - public UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone) { + public UserVO createUser(long accountId, String userName, String password, String firstName, String lastName, String email, String timezone, String userUUID) { return null; } @@ -328,7 +328,7 @@ public class MockAccountManagerImpl extends ManagerBase implements Manager, Acco public UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, - String networkDomain, Map details) { + String networkDomain, Map details, String accountUUID, String userUUID) { // TODO Auto-generated method stub return null; } @@ -336,15 +336,14 @@ public class MockAccountManagerImpl extends ManagerBase implements Manager, Acco @Override public User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, - Long domainId) { + Long domainId, String userUUID) { // TODO Auto-generated method stub return null; } @Override public Account createAccount(String accountName, short accountType, - Long domainId, String networkDomain, Map details, String uuid, - int regionId) { + Long domainId, String networkDomain, Map details, String uuid) { // TODO Auto-generated method stub return null; } diff --git a/server/test/com/cloud/user/MockDomainManagerImpl.java b/server/test/com/cloud/user/MockDomainManagerImpl.java index bc92965849c..616e12de0d3 100644 --- a/server/test/com/cloud/user/MockDomainManagerImpl.java +++ b/server/test/com/cloud/user/MockDomainManagerImpl.java @@ -139,7 +139,7 @@ public class MockDomainManagerImpl extends ManagerBase implements DomainManager, @Override public Domain createDomain(String name, Long parentId, - String networkDomain) { + String networkDomain, String domainUUID) { // TODO Auto-generated method stub return null; } @@ -152,7 +152,7 @@ public class MockDomainManagerImpl extends ManagerBase implements DomainManager, @Override public Domain createDomain(String name, Long parentId, Long ownerId, - String networkDomain) { + String networkDomain, String domainUUID) { // TODO Auto-generated method stub return null; } diff --git a/server/test/org/apache/cloudstack/region/RegionManagerTest.java b/server/test/org/apache/cloudstack/region/RegionManagerTest.java index 330f0b49d22..b6d1969a107 100644 --- a/server/test/org/apache/cloudstack/region/RegionManagerTest.java +++ b/server/test/org/apache/cloudstack/region/RegionManagerTest.java @@ -48,27 +48,14 @@ public class RegionManagerTest extends TestCase { public void testUniqueName() { RegionManagerImpl regionMgr = new RegionManagerImpl(); RegionDao regionDao = Mockito.mock(RegionDao.class); - RegionVO region = new RegionVO(2, "APAC", "", null, null); + RegionVO region = new RegionVO(2, "APAC", ""); Mockito.when(regionDao.findByName(Mockito.anyString())).thenReturn(region); regionMgr._regionDao = regionDao; try { - regionMgr.addRegion(2, "APAC", "", null, null); + regionMgr.addRegion(2, "APAC", ""); } catch (InvalidParameterValueException e){ Assert.assertEquals("Region with name: APAC already exists", e.getMessage()); } } - - @Test - public void testUserDelete() { - RegionManagerImpl regionMgr = new RegionManagerImpl(); - AccountDao accountDao = Mockito.mock(AccountDao.class); - Mockito.when(accountDao.findById(Mockito.anyLong())).thenReturn(null); - regionMgr._accountDao = accountDao; - try { - regionMgr.deleteUserAccount(5); - } catch (InvalidParameterValueException e){ - Assert.assertEquals("The specified account does not exist in the system", e.getMessage()); - } - } } diff --git a/setup/db/db/schema-40to410.sql b/setup/db/db/schema-40to410.sql index b9bfe1aae4f..865fbd3181c 100644 --- a/setup/db/db/schema-40to410.sql +++ b/setup/db/db/schema-40to410.sql @@ -258,17 +258,10 @@ CREATE TABLE `cloud`.`region` ( `id` int unsigned NOT NULL UNIQUE, `name` varchar(255) NOT NULL UNIQUE, `end_point` varchar(255) NOT NULL, - `api_key` varchar(255), - `secret_key` varchar(255), PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -INSERT INTO `cloud`.`region` values ('1','Local','http://localhost:8080/client/api','',''); - -ALTER TABLE `cloud`.`account` ADD COLUMN `region_id` int unsigned NOT NULL DEFAULT '1'; -ALTER TABLE `cloud`.`user` ADD COLUMN `region_id` int unsigned NOT NULL DEFAULT '1'; -ALTER TABLE `cloud`.`domain` ADD COLUMN `region_id` int unsigned NOT NULL DEFAULT '1'; +INSERT INTO `cloud`.`region` values ('1','Local','http://localhost:8080/client/api'); INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Account Defaults', 'DEFAULT', 'management-server', 'max.account.cpus', '40', 'The default maximum number of cpu cores that can be used for an account'); From 845e332dbf412388381255310a5bccaa1f9f0f07 Mon Sep 17 00:00:00 2001 From: radhikap Date: Thu, 14 Mar 2013 13:22:27 +0530 Subject: [PATCH 15/20] CLOUDSTACK-1357 --- docs/en-US/autoscale.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/en-US/autoscale.xml b/docs/en-US/autoscale.xml index d63281f9e7e..26e795b7bf5 100644 --- a/docs/en-US/autoscale.xml +++ b/docs/en-US/autoscale.xml @@ -34,8 +34,10 @@ AutoScaling to launch an additional VM whenever CPU usage exceeds 80 percent for 15 minutes, or to remove a VM whenever CPU usage is less than 20 percent for 30 minutes. &PRODUCT; uses the NetScaler load balancer to monitor all aspects of a system's health and - work in unison with &PRODUCT; to initiate scale-up or scale-down actions. The supported - NetScaler version is 10.0. + work in unison with &PRODUCT; to initiate scale-up or scale-down actions. + + AutoScale is supported on NetScaler Release 10 Build 73.e and beyond. + Prerequisites Before you configure an AutoScale rule, consider the following: From 2a337d5b01109e4a4793e8115e94cc90d6a68fd0 Mon Sep 17 00:00:00 2001 From: Pranav Saxena Date: Thu, 14 Mar 2013 13:59:52 +0530 Subject: [PATCH 16/20] CLOUDSTACK-1661: UI for Delete/Archive Events/Alerts --- ui/scripts/docs.js | 53 ++++++++ ui/scripts/events.js | 310 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 363 insertions(+) diff --git a/ui/scripts/docs.js b/ui/scripts/docs.js index 34835d6fc95..4a70ca1df7f 100755 --- a/ui/scripts/docs.js +++ b/ui/scripts/docs.js @@ -16,6 +16,59 @@ // under the License. cloudStack.docs = { + //Delete/archive events + helpEventsDeleteType:{ + + desc:'Delete all the events by specifying its TYPE eg . USER.LOGIN', + externalLink:'' + + }, + + helpEventsDeleteDate:{ + + desc:'Delete all the events which have been created after this date ', + externalLink:'' + }, + + helpEventsArchiveType:{ + + desc:'Archive all the events by specifying its TYPE (integer number)', + externalLink:'' + }, + + helpEventsArchiveDate:{ + + desc:'Archive all the events which have been created after this date', + externalLink:'' + }, + + //Delete/archive Alerts + helpAlertsDeleteType:{ + + desc:'Delete all the alerts by specifying its TYPE eg . USER.LOGIN', + externalLink:'' + + }, + + helpAlertsDeleteDate:{ + + desc:'Delete all the alerts which have been created after this date ', + externalLink:'' + }, + + helpAlertsArchiveType:{ + + desc:'Archive all the alerts by specifying its TYPE (integer number)', + externalLink:'' + }, + + helpAlertsArchiveDate:{ + + desc:'Archive all the alerts which have been created after this date', + externalLink:'' + }, + + //Ldap helpLdapQueryFilter: { diff --git a/ui/scripts/events.js b/ui/scripts/events.js index 38f77284de1..b18acd75d25 100644 --- a/ui/scripts/events.js +++ b/ui/scripts/events.js @@ -41,6 +41,103 @@ account: { label: 'label.account' }, created: { label: 'label.date', converter: cloudStack.converters.toLocalDate } }, + + actions: { + // Remove multiple events + remove: { + label: 'Delete Events', + isHeader: true, + addRow: false, + messages: { + notification: function(args) { + return 'Events Deleted'; + } + }, + createForm: { + title:'Delete Events', + desc: '', + fields: { + type: { label: 'By event type' , docID:'helpEventsDeleteType'}, + date: { label: 'By date (older than)' ,docID:'helpEventsDeleteDate'} + } + }, + action: function(args) { + + var data={}; + + if(args.data.type != "") + $.extend(data, { type:args.data.type }); + + if(args.data.date != "") + $.extend(data, {date:args.data.date }); + + $.ajax({ + + url:createURL("deleteEvents"), + data:data, + dataType:'json', + async: false, + + success:function(data){ + + args.response.success(); + + } + }); + // Reloads window with events removed + $(window).trigger('cloudStack.fullRefresh'); + } + }, + + // Archive multiple events + archive: { + label: 'Archive Events', + isHeader: true, + addRow: false, + messages: { + notification: function(args) { + return 'Archive events'; + } + }, + createForm: { + title:'Archive Events', + desc: '', + fields: { + type: { label: 'By event type' , docID:'helpEventsArchiveType'}, + date: { label: 'By date (older than)' , docID:'helpEventsArchiveDate'} + } + }, + action: function(args) { + var data={}; + + if(args.data.type != "") + $.extend(data, { type:args.data.type }); + + if(args.data.date != "") + $.extend(data, {date:args.data.date }); + + $.ajax({ + + url:createURL("archiveEvents"), + data:data, + dataType:'json', + async: false, + + success:function(data){ + + args.response.success(); + + } + }); + + // Reloads window with events removed + $(window).trigger('cloudStack.fullRefresh'); + } + } + + }, + + advSearchFields: { level: { @@ -132,6 +229,64 @@ }, detailView: { name: 'label.details', + actions: { + + // Remove single event + remove: { + label: 'Delete', + messages: { + notification: function(args) { + return 'Event Deleted'; + }, + confirm: function() { + return 'Are you sure you want to remove this event?'; + } + }, + action: function(args) { + + $.ajax({ + url:createURL("deleteEvents&ids=" +args.context.events[0].id), + success:function(json){ + + args.response.success(); + + } + + }); + $(window).trigger('cloudStack.fullRefresh'); + + } + }, + + // Archive single event + archive: { + label: 'Archive', + messages: { + notification: function(args) { + return 'Event Archived'; + }, + confirm: function() { + return 'Please confirm that you want to archive this event.'; + } + }, + action: function(args) { + + $.ajax({ + url:createURL("archiveEvents&ids=" +args.context.events[0].id), + success:function(json){ + + args.response.success(); + + } + + }); + + + // Reloads window with item archived + $(window).trigger('cloudStack.fullRefresh'); + } + } + }, tabs: { details: { title: 'label.details', @@ -174,6 +329,102 @@ description: { label: 'label.description' }, sent: { label: 'label.date', converter: cloudStack.converters.toLocalDate } }, + + actions: { + // Remove multiple Alerts + remove: { + label: 'Delete Alerts', + isHeader: true, + addRow: false, + messages: { + notification: function(args) { + return 'Alerts Deleted'; + } + }, + createForm: { + title:'Delete Alerts', + desc: '', + fields: { + type: { label: 'By event type' , docID:'helpAlertsDeleteType'}, + date: { label: 'By date (older than)' ,docID:'helpAlertsDeleteDate' } + } + }, + action: function(args) { + + var data={}; + + if(args.data.type != "") + $.extend(data, { type:args.data.type }); + + if(args.data.date != "") + $.extend(data, {date:args.data.date }); + + $.ajax({ + + url:createURL("deleteAlerts"), + data:data, + dataType:'json', + async: false, + + success:function(data){ + + args.response.success(); + + } + }); + // Reloads window with events removed + $(window).trigger('cloudStack.fullRefresh'); + } + }, + + // Archive multiple Alerts + archive: { + label: 'Archive Alerts', + isHeader: true, + addRow: false, + messages: { + notification: function(args) { + return 'Alerts Archived'; + } + }, + createForm: { + title:'Archive Alerts', + desc: '', + fields: { + type: { label: 'By event type', docID:'helpAlertsArchiveType' }, + date: { label: 'By date (older than)' , docID:'helpAlertsArchiveDate'} + } + }, + action: function(args) { + var data={}; + + if(args.data.type != "") + $.extend(data, { type:args.data.type }); + + if(args.data.date != "") + $.extend(data, {date:args.data.date }); + + $.ajax({ + + url:createURL("archiveAlerts"), + data:data, + dataType:'json', + async: false, + + success:function(data){ + + args.response.success(); + + } + }); + + // Reloads window with events removed + $(window).trigger('cloudStack.fullRefresh'); + } + } + + }, + dataProvider: function(args) { var data = {}; listViewDataProvider(args, data); @@ -190,6 +441,65 @@ }, detailView: { name: 'Alert details', + actions: { + + // Remove single Alert + remove: { + label: 'Delete', + messages: { + notification: function(args) { + return 'Alert Deleted'; + }, + confirm: function() { + return 'Are you sure you want to delete this alert ?'; + } + }, + action: function(args) { + + $.ajax({ + url:createURL("deleteAlerts&ids=" +args.context.alerts[0].id), + success:function(json){ + + args.response.success(); + + } + + }); + $(window).trigger('cloudStack.fullRefresh'); + + } + }, + + archive: { + label: 'Archive', + messages: { + notification: function(args) { + return 'Alert Archived'; + }, + confirm: function() { + return 'Please confirm that you want to archive this alert.'; + } + }, + action: function(args) { + + $.ajax({ + url:createURL("archiveAlerts&ids=" +args.context.alerts[0].id), + success:function(json){ + + args.response.success(); + + } + + }); + + + // Reloads window with item archived + $(window).trigger('cloudStack.fullRefresh'); + } + } + + }, + tabs: { details: { title: 'label.details', From 8e8decfe2aba8f5ee77c8f91385f47b9bedab19b Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Thu, 14 Mar 2013 10:51:13 +0100 Subject: [PATCH 17/20] license: Remove trailing spaces in license header --- usage/conf/db.properties.in | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/usage/conf/db.properties.in b/usage/conf/db.properties.in index e88e01ab83e..0dd49ede8b2 100644 --- a/usage/conf/db.properties.in +++ b/usage/conf/db.properties.in @@ -1,19 +1,19 @@ -# 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. +# 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. # usage database settings db.usage.username=@DBUSER@ From a6ea691d644e8a871f93f1e1e08d3720ca4b601c Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Thu, 14 Mar 2013 16:43:48 +0530 Subject: [PATCH 18/20] usage: Revert 7a79451 due to duplicate declaration of plugin definition Signed-off-by: Rohit Yadav --- usage/pom.xml | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/usage/pom.xml b/usage/pom.xml index 31df358ea4c..37501fe2744 100644 --- a/usage/pom.xml +++ b/usage/pom.xml @@ -74,7 +74,7 @@ copy-dependencies - target/dependencies + ${project.build.directory}/dependencies runtime @@ -127,24 +127,6 @@ - - org.apache.maven.plugins - maven-dependency-plugin - 2.5.1 - - - copy-dependencies - package - - copy-dependencies - - - ${project.build.directory}/dependencies - runtime - - - - From 41e3db39c3bc15ecd15ea0cce35376f048b51abe Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Thu, 14 Mar 2013 11:04:29 +0100 Subject: [PATCH 19/20] debian: Package ulimits and sudo rules The old packages used to write this data to the configuration in a postinst file. That was horrible to track since system administrators had no idea what was going on. --- debian/cloudstack-management.install | 6 ++++-- debian/rules | 12 ++++++++++-- server/conf/cloudstack-limits.conf.in | 21 +++++++++++++++++++++ server/conf/cloudstack-sudoers.in | 22 ++++++++++++++++++++++ 4 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 server/conf/cloudstack-limits.conf.in create mode 100644 server/conf/cloudstack-sudoers.in diff --git a/debian/cloudstack-management.install b/debian/cloudstack-management.install index 12478e132a1..cecc31181a9 100644 --- a/debian/cloudstack-management.install +++ b/debian/cloudstack-management.install @@ -5,9 +5,9 @@ # 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 @@ -18,6 +18,8 @@ /etc/cloudstack/server/* /etc/cloudstack/management/* /etc/init.d/cloudstack-management +/etc/security/limits.d/cloudstack-limits.conf +/etc/sudoers.d/cloudstack /var/cache/cloudstack/management /var/cache/cloudstack/management/work /var/cache/cloudstack/management/temp diff --git a/debian/rules b/debian/rules index a1356018eba..613d76a63f6 100755 --- a/debian/rules +++ b/debian/rules @@ -38,12 +38,12 @@ build-indep-stamp: configure -Dcs.replace.properties=replace.properties.tmp touch $@ -clean: +clean: dh_testdir dh_testroot rm -f build-arch-stamp build-indep-stamp configure-stamp rm -f replace.properties.tmp - dh_clean + dh_clean install: dh_testdir @@ -75,6 +75,8 @@ install: # cloudstack-management mkdir $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/server mkdir $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/management + mkdir -p $(DESTDIR)/$(SYSCONFDIR)/security/limits.d/ + mkdir -p $(DESTDIR)/$(SYSCONFDIR)/sudoers.d/ mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)-management mkdir -p $(DESTDIR)/usr/share/$(PACKAGE)-management/webapps/client mkdir $(DESTDIR)/usr/share/$(PACKAGE)-management/setup @@ -89,6 +91,12 @@ install: cp -r client/target/cloud-client-ui-$(VERSION)-SNAPSHOT/* $(DESTDIR)/usr/share/$(PACKAGE)-management/webapps/client/ cp server/target/conf/* $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/server/ cp client/target/conf/* $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/management/ + + # nast hack for a couple of configuration files + mv $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/server/cloudstack-limits.conf $(DESTDIR)/$(SYSCONFDIR)/security/limits.d/ + mv $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/server/cloudstack-sudoers $(DESTDIR)/$(SYSCONFDIR)/sudoers.d/cloudstack + chmod 0440 $(DESTDIR)/$(SYSCONFDIR)/sudoers.d/cloudstack + ln -s tomcat6-nonssl.conf $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/management/tomcat6.conf mkdir -p $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/management/Catalina/localhost/client install -D packaging/debian/init/cloud-management $(DESTDIR)/$(SYSCONFDIR)/init.d/$(PACKAGE)-management diff --git a/server/conf/cloudstack-limits.conf.in b/server/conf/cloudstack-limits.conf.in new file mode 100644 index 00000000000..c28ad8c3c78 --- /dev/null +++ b/server/conf/cloudstack-limits.conf.in @@ -0,0 +1,21 @@ +# 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. + +# Specific limits for the CloudStack management server which +# runs under the user 'cloud' by default +@MSUSER hard nofile 4096 +@MSUSER soft nofile 4096 diff --git a/server/conf/cloudstack-sudoers.in b/server/conf/cloudstack-sudoers.in new file mode 100644 index 00000000000..c525d3cf44b --- /dev/null +++ b/server/conf/cloudstack-sudoers.in @@ -0,0 +1,22 @@ +# 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. + +# The CloudStack management server needs sudo permissions +# without a password. + +@MSUSER ALL =NOPASSWD : ALL + From 7d0db5d1582a190d10829e3b572c79d582d68641 Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Thu, 14 Mar 2013 16:08:15 +0100 Subject: [PATCH 20/20] Delete ApiConstants.java.orig This file should have never been committed in the first place? --- .../cloudstack/api/ApiConstants.java.orig | 468 ------------------ 1 file changed, 468 deletions(-) delete mode 100644 api/src/org/apache/cloudstack/api/ApiConstants.java.orig diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java.orig b/api/src/org/apache/cloudstack/api/ApiConstants.java.orig deleted file mode 100644 index 3801506ffaa..00000000000 --- a/api/src/org/apache/cloudstack/api/ApiConstants.java.orig +++ /dev/null @@ -1,468 +0,0 @@ -// 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 org.apache.cloudstack.api; - - -public class ApiConstants { - public static final String ACCOUNT = "account"; - public static final String ACCOUNTS = "accounts"; - public static final String ACCOUNT_TYPE = "accounttype"; - public static final String ACCOUNT_ID = "accountid"; - public static final String ALGORITHM = "algorithm"; - public static final String ALLOCATED_ONLY = "allocatedonly"; - public static final String API_KEY = "userapikey"; - public static final String APPLIED = "applied"; - public static final String AVAILABLE = "available"; - public static final String BITS = "bits"; - public static final String BOOTABLE = "bootable"; - public static final String BIND_DN = "binddn"; - public static final String BIND_PASSWORD = "bindpass"; - public static final String CATEGORY = "category"; - public static final String CERTIFICATE = "certificate"; - public static final String PRIVATE_KEY = "privatekey"; - public static final String DOMAIN_SUFFIX = "domainsuffix"; - public static final String DNS_SEARCH_ORDER = "dnssearchorder"; - public static final String CIDR = "cidr"; - public static final String IP6_CIDR = "ip6cidr"; - public static final String CIDR_LIST = "cidrlist"; - public static final String CLEANUP = "cleanup"; - public static final String CLUSTER_ID = "clusterid"; - public static final String CLUSTER_NAME = "clustername"; - public static final String CLUSTER_TYPE = "clustertype"; - public static final String COMPONENT = "component"; - public static final String CPU_NUMBER = "cpunumber"; - public static final String CPU_SPEED = "cpuspeed"; - public static final String CREATED = "created"; - public static final String CUSTOMIZED = "customized"; - public static final String DESCRIPTION = "description"; - public static final String DESTINATION_ZONE_ID = "destzoneid"; - public static final String DETAILS = "details"; - public static final String DEVICE_ID = "deviceid"; - public static final String DISK_OFFERING_ID = "diskofferingid"; - public static final String DISK_SIZE = "disksize"; - public static final String DISPLAY_NAME = "displayname"; - public static final String DISPLAY_TEXT = "displaytext"; - public static final String DNS1 = "dns1"; - public static final String DNS2 = "dns2"; - public static final String DOMAIN = "domain"; - public static final String DOMAIN_ID = "domainid"; - public static final String DURATION = "duration"; - public static final String EMAIL = "email"; - public static final String END_DATE = "enddate"; - public static final String END_IP = "endip"; - public static final String END_IPV6 = "endipv6"; - public static final String END_PORT = "endport"; - public static final String ENTRY_TIME = "entrytime"; - public static final String FETCH_LATEST = "fetchlatest"; - public static final String FIRSTNAME = "firstname"; - public static final String FORCED = "forced"; - public static final String FORCED_DESTROY_LOCAL_STORAGE = "forcedestroylocalstorage"; - public static final String FORMAT = "format"; - public static final String FOR_VIRTUAL_NETWORK = "forvirtualnetwork"; - public static final String GATEWAY = "gateway"; - public static final String IP6_GATEWAY = "ip6gateway"; - public static final String GROUP = "group"; - public static final String GROUP_ID = "groupid"; - public static final String GUEST_CIDR_ADDRESS = "guestcidraddress"; - public static final String HA_ENABLE = "haenable"; - public static final String HOST_ID = "hostid"; - public static final String HOST_NAME = "hostname"; - public static final String HYPERVISOR = "hypervisor"; - public static final String INLINE = "inline"; - public static final String INSTANCE = "instance"; - public static final String ICMP_CODE = "icmpcode"; - public static final String ICMP_TYPE = "icmptype"; - public static final String ID = "id"; - public static final String IDS = "ids"; - public static final String INTERNAL_DNS1 = "internaldns1"; - public static final String INTERNAL_DNS2 = "internaldns2"; - public static final String INTERVAL_TYPE = "intervaltype"; - public static final String IP_ADDRESS = "ipaddress"; - public static final String IP6_ADDRESS = "ip6address"; - public static final String IP_ADDRESS_ID = "ipaddressid"; - public static final String IS_ASYNC = "isasync"; - public static final String IP_AVAILABLE = "ipavailable"; - public static final String IP_LIMIT = "iplimit"; - public static final String IP_TOTAL = "iptotal"; - public static final String IS_CLEANUP_REQUIRED = "iscleanuprequired"; - public static final String IS_EXTRACTABLE = "isextractable"; - public static final String IS_FEATURED = "isfeatured"; - public static final String IS_PUBLIC = "ispublic"; - public static final String IS_PERSISTENT = "ispersistent"; - public static final String IS_READY = "isready"; - public static final String IS_RECURSIVE = "isrecursive"; - public static final String ISO_FILTER = "isofilter"; - public static final String ISO_GUEST_OS_NONE = "None"; - public static final String JOB_ID = "jobid"; - public static final String JOB_STATUS = "jobstatus"; - public static final String LASTNAME = "lastname"; - public static final String LEVEL = "level"; - public static final String LENGTH = "length"; - public static final String LIMIT_CPU_USE = "limitcpuuse"; - public static final String LOCK = "lock"; - public static final String LUN = "lun"; - public static final String LBID = "lbruleid"; - public static final String MAX = "max"; - public static final String MAX_SNAPS = "maxsnaps"; - public static final String MEMORY = "memory"; - public static final String MODE = "mode"; - public static final String NAME = "name"; - public static final String METHOD_NAME = "methodname"; - public static final String NETWORK_DOMAIN = "networkdomain"; - public static final String NETMASK = "netmask"; - public static final String NEW_NAME = "newname"; - public static final String NUM_RETRIES = "numretries"; - public static final String OFFER_HA = "offerha"; - public static final String IS_SYSTEM_OFFERING = "issystem"; - public static final String IS_DEFAULT_USE = "defaultuse"; - public static final String OP = "op"; - public static final String OS_CATEGORY_ID = "oscategoryid"; - public static final String OS_TYPE_ID = "ostypeid"; - public static final String PARAMS = "params"; - public static final String PARENT_DOMAIN_ID = "parentdomainid"; - public static final String PASSWORD = "password"; - public static final String NEW_PASSWORD = "new_password"; - public static final String PASSWORD_ENABLED = "passwordenabled"; - public static final String SSHKEY_ENABLED = "sshkeyenabled"; - public static final String PATH = "path"; - public static final String POD_ID = "podid"; - public static final String POD_IDS = "podids"; - public static final String POLICY_ID = "policyid"; - public static final String PORT = "port"; - public static final String PORTAL = "portal"; - public static final String PORT_FORWARDING_SERVICE_ID = "portforwardingserviceid"; - public static final String PRIVATE_INTERFACE = "privateinterface"; - public static final String PRIVATE_IP = "privateip"; - public static final String PRIVATE_PORT = "privateport"; - public static final String PRIVATE_START_PORT = "privateport"; - public static final String PRIVATE_END_PORT = "privateendport"; - public static final String PRIVATE_ZONE = "privatezone"; - public static final String PROTOCOL = "protocol"; - public static final String PUBLIC_INTERFACE = "publicinterface"; - public static final String PUBLIC_IP_ID = "publicipid"; - public static final String PUBLIC_IP = "publicip"; - public static final String PUBLIC_PORT = "publicport"; - public static final String PUBLIC_START_PORT = "publicport"; - public static final String PUBLIC_END_PORT = "publicendport"; - public static final String PUBLIC_ZONE = "publiczone"; - public static final String RECEIVED_BYTES = "receivedbytes"; - public static final String REQUIRES_HVM = "requireshvm"; - public static final String RESOURCE_TYPE = "resourcetype"; - public static final String RESPONSE = "response"; - public static final String QUERY_FILTER = "queryfilter"; - public static final String SCHEDULE = "schedule"; - public static final String SCOPE = "scope"; - public static final String SECRET_KEY = "usersecretkey"; - public static final String SINCE = "since"; - public static final String KEY = "key"; - public static final String SEARCH_BASE = "searchbase"; - public static final String SECURITY_GROUP_IDS = "securitygroupids"; - public static final String SECURITY_GROUP_NAMES = "securitygroupnames"; - public static final String SECURITY_GROUP_NAME = "securitygroupname"; - public static final String SECURITY_GROUP_ID = "securitygroupid"; - public static final String SENT = "sent"; - public static final String SENT_BYTES = "sentbytes"; - public static final String SERVICE_OFFERING_ID = "serviceofferingid"; - public static final String SHOW_CAPACITIES = "showcapacities"; - public static final String SIZE = "size"; - public static final String SNAPSHOT_ID = "snapshotid"; - public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid"; - public static final String SNAPSHOT_TYPE = "snapshottype"; - public static final String SOURCE_ZONE_ID = "sourcezoneid"; - public static final String START_DATE = "startdate"; - public static final String START_IP = "startip"; - public static final String START_IPV6 = "startipv6"; - public static final String START_PORT = "startport"; - public static final String STATE = "state"; - public static final String STATUS = "status"; - public static final String STORAGE_TYPE = "storagetype"; - public static final String SYSTEM_VM_TYPE = "systemvmtype"; - public static final String TAGS = "tags"; - public static final String TARGET_IQN = "targetiqn"; - public static final String TEMPLATE_FILTER = "templatefilter"; - public static final String TEMPLATE_ID = "templateid"; - public static final String ISO_ID = "isoid"; - public static final String TIMEOUT = "timeout"; - public static final String TIMEZONE = "timezone"; - public static final String TYPE = "type"; - public static final String TRUST_STORE = "truststore"; - public static final String TRUST_STORE_PASSWORD = "truststorepass"; - public static final String URL = "url"; - public static final String USAGE_INTERFACE = "usageinterface"; - public static final String USER_DATA = "userdata"; - public static final String USER_ID = "userid"; - public static final String USE_SSL = "ssl"; - public static final String USERNAME = "username"; - public static final String USER_SECURITY_GROUP_LIST = "usersecuritygrouplist"; - public static final String USE_VIRTUAL_NETWORK = "usevirtualnetwork"; - public static final String VALUE = "value"; - public static final String VIRTUAL_MACHINE_ID = "virtualmachineid"; - public static final String VIRTUAL_MACHINE_IDS = "virtualmachineids"; - public static final String VLAN = "vlan"; - public static final String VLAN_ID = "vlanid"; - public static final String VM_AVAILABLE = "vmavailable"; - public static final String VM_LIMIT = "vmlimit"; - public static final String VM_TOTAL = "vmtotal"; - public static final String VNET = "vnet"; - public static final String VOLUME_ID = "volumeid"; - public static final String ZONE_ID = "zoneid"; - public static final String ZONE_NAME = "zonename"; - public static final String NETWORK_TYPE = "networktype"; - public static final String PAGE = "page"; - public static final String PAGE_SIZE = "pagesize"; - public static final String COUNT = "count"; - public static final String TRAFFIC_TYPE = "traffictype"; - public static final String NETWORK_OFFERING_ID = "networkofferingid"; - public static final String NETWORK_IDS = "networkids"; - public static final String NETWORK_ID = "networkid"; - public static final String NIC_ID = "nicid"; - public static final String SPECIFY_VLAN = "specifyvlan"; - public static final String IS_DEFAULT = "isdefault"; - public static final String IS_SYSTEM = "issystem"; - public static final String AVAILABILITY = "availability"; - public static final String NETWORKRATE = "networkrate"; - public static final String HOST_TAGS = "hosttags"; - public static final String SSH_KEYPAIR = "keypair"; - public static final String HOST_CPU_CAPACITY = "hostcpucapacity"; - public static final String HOST_CPU_NUM = "hostcpunum"; - public static final String HOST_MEM_CAPACITY = "hostmemcapacity"; - public static final String HOST_MAC = "hostmac"; - public static final String HOST_TAG = "hosttag"; - public static final String PXE_SERVER_TYPE = "pxeservertype"; - public static final String LINMIN_USERNAME = "linminusername"; - public static final String LINMIN_PASSWORD = "linminpassword"; - public static final String LINMIN_APID = "linminapid"; - public static final String DHCP_SERVER_TYPE = "dhcpservertype"; - public static final String LINK_LOCAL_IP = "linklocalip"; - public static final String LINK_LOCAL_MAC_ADDRESS = "linklocalmacaddress"; - public static final String LINK_LOCAL_MAC_NETMASK = "linklocalnetmask"; - public static final String LINK_LOCAL_NETWORK_ID = "linklocalnetworkid"; - public static final String PRIVATE_MAC_ADDRESS = "privatemacaddress"; - public static final String PRIVATE_NETMASK = "privatenetmask"; - public static final String PRIVATE_NETWORK_ID = "privatenetworkid"; - public static final String ALLOCATION_STATE = "allocationstate"; - public static final String MANAGED_STATE = "managedstate"; - public static final String STORAGE_ID = "storageid"; - public static final String PING_STORAGE_SERVER_IP = "pingstorageserverip"; - public static final String PING_DIR = "pingdir"; - public static final String TFTP_DIR = "tftpdir"; - public static final String PING_CIFS_USERNAME = "pingcifsusername"; - public static final String PING_CIFS_PASSWORD = "pingcifspassword"; - public static final String CHECKSUM = "checksum"; - public static final String NETWORK_DEVICE_TYPE = "networkdevicetype"; - public static final String NETWORK_DEVICE_PARAMETER_LIST = "networkdeviceparameterlist"; - public static final String ZONE_TOKEN = "zonetoken"; - public static final String DHCP_PROVIDER = "dhcpprovider"; - public static final String RESULT = "success"; - public static final String LUN_ID = "lunId"; - public static final String IQN = "iqn"; - public static final String AGGREGATE_NAME = "aggregatename"; - public static final String POOL_NAME = "poolname"; - public static final String VOLUME_NAME = "volumename"; - public static final String SNAPSHOT_POLICY = "snapshotpolicy"; - public static final String SNAPSHOT_RESERVATION = "snapshotreservation"; - public static final String IP_NETWORK_LIST = "iptonetworklist"; - public static final String PARAM_LIST = "param"; - public static final String FOR_LOAD_BALANCING = "forloadbalancing"; - public static final String KEYBOARD = "keyboard"; - public static final String OPEN_FIREWALL = "openfirewall"; - public static final String TEMPLATE_TAG = "templatetag"; - public static final String HYPERVISOR_VERSION = "hypervisorversion"; - public static final String MAX_GUESTS_LIMIT = "maxguestslimit"; - public static final String PROJECT_ID = "projectid"; - public static final String PROJECT_IDS = "projectids"; - public static final String PROJECT = "project"; - public static final String ROLE = "role"; - public static final String USER = "user"; - public static final String ACTIVE_ONLY = "activeonly"; - public static final String TOKEN = "token"; - public static final String ACCEPT = "accept"; - public static final String SORT_KEY = "sortkey"; - public static final String ACCOUNT_DETAILS = "accountdetails"; - public static final String SERVICE_PROVIDER_LIST = "serviceproviderlist"; - public static final String SERVICE_CAPABILITY_LIST = "servicecapabilitylist"; - public static final String CAN_CHOOSE_SERVICE_CAPABILITY = "canchooseservicecapability"; - public static final String PROVIDER = "provider"; - public static final String NETWORK_SPEED = "networkspeed"; - public static final String BROADCAST_DOMAIN_RANGE = "broadcastdomainrange"; - public static final String ISOLATION_METHODS = "isolationmethods"; - public static final String PHYSICAL_NETWORK_ID = "physicalnetworkid"; - public static final String DEST_PHYSICAL_NETWORK_ID = "destinationphysicalnetworkid"; - public static final String ENABLED = "enabled"; - public static final String SERVICE_NAME = "servicename"; - public static final String DHCP_RANGE = "dhcprange"; - public static final String UUID = "uuid"; - public static final String SECURITY_GROUP_EANBLED = "securitygroupenabled"; - public static final String LOCAL_STORAGE_ENABLED = "localstorageenabled"; - public static final String GUEST_IP_TYPE = "guestiptype"; - public static final String XEN_NETWORK_LABEL = "xennetworklabel"; - public static final String KVM_NETWORK_LABEL = "kvmnetworklabel"; - public static final String VMWARE_NETWORK_LABEL = "vmwarenetworklabel"; - public static final String NETWORK_SERVICE_PROVIDER_ID = "nspid"; - public static final String SERVICE_LIST = "servicelist"; - public static final String CAN_ENABLE_INDIVIDUAL_SERVICE = "canenableindividualservice"; - public static final String SUPPORTED_SERVICES = "supportedservices"; - public static final String NSP_ID = "nspid"; - public static final String ACL_TYPE = "acltype"; - public static final String SUBDOMAIN_ACCESS = "subdomainaccess"; - public static final String LOAD_BALANCER_DEVICE_ID = "lbdeviceid"; - public static final String LOAD_BALANCER_DEVICE_NAME = "lbdevicename"; - public static final String LOAD_BALANCER_DEVICE_STATE = "lbdevicestate"; - public static final String LOAD_BALANCER_DEVICE_CAPACITY = "lbdevicecapacity"; - public static final String LOAD_BALANCER_DEVICE_DEDICATED = "lbdevicededicated"; - public static final String FIREWALL_DEVICE_ID = "fwdeviceid"; - public static final String FIREWALL_DEVICE_NAME = "fwdevicename"; - public static final String FIREWALL_DEVICE_STATE = "fwdevicestate"; - public static final String FIREWALL_DEVICE_CAPACITY = "fwdevicecapacity"; - public static final String FIREWALL_DEVICE_DEDICATED = "fwdevicededicated"; - public static final String SERVICE = "service"; - public static final String ASSOCIATED_NETWORK_ID = "associatednetworkid"; - public static final String ASSOCIATED_NETWORK_NAME = "associatednetworkname"; - public static final String SOURCE_NAT_SUPPORTED = "sourcenatsupported"; - public static final String RESOURCE_STATE = "resourcestate"; - public static final String PROJECT_INVITE_REQUIRED = "projectinviterequired"; - public static final String REQUIRED = "required"; - public static final String RESTART_REQUIRED = "restartrequired"; - public static final String ALLOW_USER_CREATE_PROJECTS = "allowusercreateprojects"; - public static final String CONSERVE_MODE = "conservemode"; - public static final String TRAFFIC_TYPE_IMPLEMENTOR = "traffictypeimplementor"; - public static final String KEYWORD = "keyword"; - public static final String LIST_ALL = "listall"; - public static final String SPECIFY_IP_RANGES = "specifyipranges"; - public static final String IS_SOURCE_NAT = "issourcenat"; - public static final String IS_STATIC_NAT = "isstaticnat"; - public static final String SORT_BY = "sortby"; - public static final String CHANGE_CIDR = "changecidr"; - public static final String PURPOSE = "purpose"; - public static final String IS_TAGGED = "istagged"; - public static final String INSTANCE_NAME = "instancename"; - public static final String START_VM = "startvm"; - public static final String HA_HOST = "hahost"; - public static final String CUSTOM_DISK_OFF_MAX_SIZE = "customdiskofferingmaxsize"; - public static final String DEFAULT_ZONE_ID = "defaultzoneid"; - public static final String GUID = "guid"; - - public static final String EXTERNAL_SWITCH_MGMT_DEVICE_ID = "vsmdeviceid"; - public static final String EXTERNAL_SWITCH_MGMT_DEVICE_NAME = "vsmdevicename"; - public static final String EXTERNAL_SWITCH_MGMT_DEVICE_STATE = "vsmdevicestate"; - // Would we need to have a capacity field for Cisco N1KV VSM? Max hosts managed by it perhaps? May remove this later. - public static final String EXTERNAL_SWITCH_MGMT_DEVICE_CAPACITY = "vsmdevicecapacity"; - public static final String CISCO_NEXUS_VSM_NAME = "vsmname"; - public static final String VSM_USERNAME = "vsmusername"; - public static final String VSM_PASSWORD = "vsmpassword"; - public static final String VSM_IPADDRESS = "vsmipaddress"; - public static final String VSM_MGMT_VLAN_ID = "vsmmgmtvlanid"; - public static final String VSM_PKT_VLAN_ID = "vsmpktvlanid"; - public static final String VSM_CTRL_VLAN_ID = "vsmctrlvlanid"; - public static final String VSM_STORAGE_VLAN_ID = "vsmstoragevlanid"; - public static final String VSM_DOMAIN_ID = "vsmdomainid"; - public static final String VSM_CONFIG_MODE = "vsmconfigmode"; - public static final String VSM_CONFIG_STATE = "vsmconfigstate"; - public static final String VSM_DEVICE_STATE = "vsmdevicestate"; - public static final String ADD_VSM_FLAG = "addvsmflag"; - public static final String END_POINT = "endpoint"; - public static final String REGION_ID = "regionid"; - public static final String IS_PROPAGATE = "ispropagate"; - public static final String VPC_OFF_ID = "vpcofferingid"; - public static final String NETWORK = "network"; - public static final String VPC_ID = "vpcid"; - public static final String GATEWAY_ID = "gatewayid"; - public static final String CAN_USE_FOR_DEPLOY = "canusefordeploy"; - public static final String RESOURCE_IDS = "resourceids"; - public static final String RESOURCE_ID = "resourceid"; - public static final String CUSTOMER = "customer"; - public static final String S2S_VPN_GATEWAY_ID = "s2svpngatewayid"; - public static final String S2S_CUSTOMER_GATEWAY_ID = "s2scustomergatewayid"; - public static final String IPSEC_PSK = "ipsecpsk"; - public static final String GUEST_IP = "guestip"; - public static final String REMOVED = "removed"; - public static final String IKE_POLICY = "ikepolicy"; - public static final String ESP_POLICY = "esppolicy"; - public static final String IKE_LIFETIME = "ikelifetime"; - public static final String ESP_LIFETIME = "esplifetime"; - public static final String DPD = "dpd"; - public static final String FOR_VPC = "forvpc"; - public static final String SHRINK_OK = "shrinkok"; - public static final String NICIRA_NVP_DEVICE_ID = "nvpdeviceid"; - public static final String NICIRA_NVP_TRANSPORT_ZONE_UUID = "transportzoneuuid"; - public static final String NICIRA_NVP_DEVICE_NAME = "niciradevicename"; - public static final String NICIRA_NVP_GATEWAYSERVICE_UUID = "l3gatewayserviceuuid"; - public static final String S3_ACCESS_KEY = "accesskey"; - public static final String S3_SECRET_KEY = "secretkey"; - public static final String S3_END_POINT = "endpoint"; - public static final String S3_BUCKET_NAME = "bucket"; - public static final String S3_HTTPS_FLAG = "usehttps"; - public static final String S3_CONNECTION_TIMEOUT = "connectiontimeout"; - public static final String S3_MAX_ERROR_RETRY = "maxerrorretry"; - public static final String S3_SOCKET_TIMEOUT = "sockettimeout"; - public static final String INCL_ZONES = "includezones"; - public static final String EXCL_ZONES = "excludezones"; - public static final String SOURCE = "source"; - public static final String COUNTER_ID = "counterid"; - public static final String AGGR_OPERATOR = "aggroperator"; - public static final String AGGR_FUNCTION = "aggrfunction"; - public static final String AGGR_VALUE = "aggrvalue"; - public static final String THRESHOLD = "threshold"; - public static final String RELATIONAL_OPERATOR = "relationaloperator"; - public static final String OTHER_DEPLOY_PARAMS = "otherdeployparams"; - public static final String MIN_MEMBERS = "minmembers"; - public static final String MAX_MEMBERS = "maxmembers"; - public static final String AUTOSCALE_VM_DESTROY_TIME = "destroyvmgraceperiod"; - public static final String VMPROFILE_ID = "vmprofileid"; - public static final String VMGROUP_ID = "vmgroupid"; - public static final String CS_URL = "csurl"; - public static final String SCALEUP_POLICY_IDS = "scaleuppolicyids"; - public static final String SCALEDOWN_POLICY_IDS = "scaledownpolicyids"; - public static final String SCALEUP_POLICIES = "scaleuppolicies"; - public static final String SCALEDOWN_POLICIES = "scaledownpolicies"; - public static final String INTERVAL = "interval"; - public static final String QUIETTIME = "quiettime"; - public static final String ACTION = "action"; - public static final String CONDITION_ID = "conditionid"; - public static final String CONDITION_IDS = "conditionids"; - public static final String COUNTERPARAM_LIST = "counterparam"; - public static final String AUTOSCALE_USER_ID = "autoscaleuserid"; - public static final String BAREMETAL_DISCOVER_NAME = "baremetaldiscovername"; -<<<<<<< HEAD - public static final String UCS_DN = "ucsdn"; -======= - public static final String VM_SNAPSHOT_DESCRIPTION = "description"; - public static final String VM_SNAPSHOT_DISPLAYNAME = "name"; - public static final String VM_SNAPSHOT_ID = "vmsnapshotid"; - public static final String VM_SNAPSHOT_DISK_IDS = "vmsnapshotdiskids"; - public static final String VM_SNAPSHOT_MEMORY = "snapshotmemory"; ->>>>>>> CLOUDSTACK-684 Support VM Snapshot - - public enum HostDetails { - all, capacity, events, stats, min; - } - - public enum VMDetails { - all, group, nics, stats, secgrp, tmpl, servoff, iso, volume, min; - } - - public enum LDAPParams { - hostname, port, usessl, queryfilter, searchbase, dn, passwd, truststore, truststorepass; - - @Override - public String toString() { - return "ldap." + name(); - } - } - - -}