You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by an...@apache.org on 2014/01/31 03:08:04 UTC
[01/11] git commit: updated refs/heads/4.3 to e089b91
Updated Branches:
refs/heads/4.3 210b19c1f -> e089b9138
LOUDSTACK-5987: when listTemplates with filter=community/featured, get public templates from all domains in the system, not just parent/child subdomains of the caller
Conflicts:
server/src/com/cloud/api/query/QueryManagerImpl.java
(cherry picked from commit b1d4c06ad1d8931f5c810dcd8b1f1df01db174f3)
Signed-off-by: Animesh Chaturvedi <an...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/45e45b93
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/45e45b93
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/45e45b93
Branch: refs/heads/4.3
Commit: 45e45b930a6e3217feb6a60de412564091a13015
Parents: 210b19c
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Wed Jan 29 17:12:46 2014 -0800
Committer: Animesh Chaturvedi <an...@apache.org>
Committed: Thu Jan 30 17:39:28 2014 -0800
----------------------------------------------------------------------
.../com/cloud/api/query/QueryManagerImpl.java | 30 +++++++++++++-------
1 file changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/45e45b93/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java
index 3cbe727..6671ab9 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -26,10 +26,6 @@ import java.util.Set;
import javax.ejb.Local;
import javax.inject.Inject;
-import org.apache.cloudstack.engine.subsystem.api.storage.*;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.affinity.AffinityGroupDomainMapVO;
import org.apache.cloudstack.affinity.AffinityGroupResponse;
@@ -85,8 +81,15 @@ import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.api.response.VolumeResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.query.QueryService;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
import com.cloud.api.query.dao.AccountJoinDao;
import com.cloud.api.query.dao.AffinityGroupJoinDao;
@@ -172,8 +175,8 @@ import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDetailsDao;
import com.cloud.tags.ResourceTagVO;
import com.cloud.tags.dao.ResourceTagDao;
-import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
import com.cloud.template.VirtualMachineTemplate.State;
+import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.DomainManager;
@@ -2930,10 +2933,17 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
if (!permittedAccounts.isEmpty()) {
for (Account account : permittedAccounts) {
permittedAccountIds.add(account.getId());
- DomainVO accountDomain = _domainDao.findById(account.getDomainId());
+ boolean publicTemplates = (templateFilter == TemplateFilter.featured || templateFilter == TemplateFilter.community);
// get all parent domain ID's all the way till root domain
- DomainVO domainTreeNode = accountDomain;
+ DomainVO domainTreeNode = null;
+ //if template filter is featured, or community, all child domains should be included in search
+ if (publicTemplates) {
+ domainTreeNode = _domainDao.findById(Domain.ROOT_DOMAIN);
+
+ } else {
+ domainTreeNode = _domainDao.findById(account.getDomainId());
+ }
relatedDomainIds.add(domainTreeNode.getId());
while (domainTreeNode.getParent() != null) {
domainTreeNode = _domainDao.findById(domainTreeNode.getParent());
@@ -2941,10 +2951,8 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
}
// get all child domain ID's
- if (_accountMgr.isAdmin(account.getType())
- || (templateFilter == TemplateFilter.featured || templateFilter == TemplateFilter.community)) {
- List<DomainVO> allChildDomains = _domainDao.findAllChildren(accountDomain.getPath(),
- accountDomain.getId());
+ if (_accountMgr.isAdmin(account.getType()) || publicTemplates) {
+ List<DomainVO> allChildDomains = _domainDao.findAllChildren(domainTreeNode.getPath(), domainTreeNode.getId());
for (DomainVO childDomain : allChildDomains) {
relatedDomainIds.add(childDomain.getId());
}
[03/11] git commit: updated refs/heads/4.3 to e089b91
Posted by an...@apache.org.
CLOUDSTACK-5966 Update the schema-421-430.sql for EnableServiceMonitoring global setting
(cherry picked from commit 888b90677623da745a01db0a5087272f0dabe42c)
Signed-off-by: Animesh Chaturvedi <an...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/bbe62ea1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/bbe62ea1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/bbe62ea1
Branch: refs/heads/4.3
Commit: bbe62ea134ddd2e0e301909e1d36434a08116e59
Parents: 6f7653d
Author: Jayapal <ja...@apache.org>
Authored: Thu Jan 30 19:29:54 2014 +0530
Committer: Animesh Chaturvedi <an...@apache.org>
Committed: Thu Jan 30 17:42:21 2014 -0800
----------------------------------------------------------------------
setup/db/db/schema-421to430.sql | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bbe62ea1/setup/db/db/schema-421to430.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-421to430.sql b/setup/db/db/schema-421to430.sql
index 1ed6c6b..6e96947 100644
--- a/setup/db/db/schema-421to430.sql
+++ b/setup/db/db/schema-421to430.sql
@@ -1091,3 +1091,4 @@ CREATE VIEW `cloud`.`user_vm_view` AS
INSERT INTO `cloud`.`configuration`(category, instance, component, name, value, description, default_value) VALUES ('NetworkManager', 'DEFAULT', 'management-server', 'network.router.EnableServiceMonitoring', 'false', 'service monitoring in router enable/disable option, default false', 'false') ON DUPLICATE KEY UPDATE category='NetworkManager';
+INSERT IGNORE INTO `cloud`.`configuration`(category, instance, component, name, value, description, default_value) VALUES ('NetworkManager', 'DEFAULT', 'management-server', 'network.router.EnableServiceMonitoring', 'true', 'service monitoring in router enable/disable option, default true', 'true') ON DUPLICATE KEY UPDATE category='NetworkManager';
[09/11] git commit: updated refs/heads/4.3 to e089b91
Posted by an...@apache.org.
Fixed API doc that got broken by adding new commands for stratosphere ssp plugin
(cherry picked from commit 54f2234e2191533be21b328534dc20b1871ca3ad)
Signed-off-by: Animesh Chaturvedi <an...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a31eccc4
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a31eccc4
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a31eccc4
Branch: refs/heads/4.3
Commit: a31eccc4053da471fccdfc889a4d8b6e0b0aa813
Parents: 55ec8f3
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Thu Jan 30 10:42:52 2014 -0800
Committer: Animesh Chaturvedi <an...@apache.org>
Committed: Thu Jan 30 17:58:30 2014 -0800
----------------------------------------------------------------------
tools/apidoc/gen_toc.py | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a31eccc4/tools/apidoc/gen_toc.py
----------------------------------------------------------------------
diff --git a/tools/apidoc/gen_toc.py b/tools/apidoc/gen_toc.py
index 4cfbeb4..9e4cd31 100644
--- a/tools/apidoc/gen_toc.py
+++ b/tools/apidoc/gen_toc.py
@@ -6,9 +6,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
@@ -126,7 +126,7 @@ known_categories = {
'Project': 'Project',
'Lun': 'Storage',
'Pool': 'Pool',
- 'VPC': 'VPC',
+ 'VPC': 'VPC',
'PrivateGateway': 'VPC',
'Simulator': 'simulator',
'StaticRoute': 'VPC',
@@ -159,7 +159,8 @@ known_categories = {
'UCS' : 'UCS',
'Ucs' : 'UCS',
'CacheStores' : 'Cache Stores',
- 'CacheStore' : 'Cache Store'
+ 'CacheStore' : 'Cache Store',
+ 'StratosphereSsp' : ' Stratosphere SSP'
}
@@ -204,7 +205,7 @@ for f in sys.argv:
pass
except IndexError, e:
print fn
-
+
def xml_for(command):
name = command['name']
@@ -219,7 +220,7 @@ def xml_for(command):
def write_xml(out, user):
with file(out, 'w') as f:
cat_strings = []
-
+
for category in categories.keys():
strings = []
for command in categories[category]:
@@ -241,7 +242,7 @@ def write_xml(out, user):
<xsl:for-each select="commands/command">
%(all_strings)s
</xsl:for-each>
-</ul>
+</ul>
</div>
''' % locals()
@@ -267,7 +268,7 @@ def java_for_user(user):
for command in categories[category]:
if command['user'] == user:
strings.append(java_for(command, user))
- func = user_to_func[user]
+ func = user_to_func[user]
all_strings = ''.join(strings)
return '''
public void %(func)s() {
[06/11] git commit: updated refs/heads/4.3 to e089b91
Posted by an...@apache.org.
CLOUDSTACK-5989: Trying to start a vm while 'vm snapshot' is in progress results in inconsistency
The fix is to fail the start operation if a vm snapshot is in progress
(cherry picked from commit 775fa0f0d02f182e3cba02faed569272b00e9926)
Signed-off-by: Animesh Chaturvedi <an...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/523cbdda
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/523cbdda
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/523cbdda
Branch: refs/heads/4.3
Commit: 523cbdda687f259fd0bee7e6b79fa0fb035fc990
Parents: d7e1d38
Author: Koushik Das <ko...@apache.org>
Authored: Thu Jan 30 18:07:24 2014 +0530
Committer: Animesh Chaturvedi <an...@apache.org>
Committed: Thu Jan 30 17:54:50 2014 -0800
----------------------------------------------------------------------
.../src/com/cloud/vm/VirtualMachineManagerImpl.java | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/523cbdda/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 6dc5894..e533386 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -1529,6 +1529,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
}
protected boolean stateTransitTo(VMInstanceVO vm, VirtualMachine.Event e, Long hostId, String reservationId) throws NoTransitionException {
+ // if there are active vm snapshots task, state change is not allowed
+ if (_vmSnapshotMgr.hasActiveVMSnapshotTasks(vm.getId())) {
+ s_logger.error("State transit with event: " + e + " failed due to: " + vm.getInstanceName() + " has active VM snapshots tasks");
+ return false;
+ }
vm.setReservationId(reservationId);
return _stateMachine.transitTo(vm, e, new Pair<Long, Long>(vm.getHostId(), hostId), _vmDao);
}
[02/11] git commit: updated refs/heads/4.3 to e089b91
Posted by an...@apache.org.
CLOUDSTACK-5986: Make dnsmasq handle dnsmasq.leases when dhcp_release is available
The original issue has been exposed due to CloudStack VR would modify the
dnsmasq.leases, thus make it unsync with dnsmasq's memory lease.
Make the modification to let dnsmasq handle the lease file if dhcp_release is
available.
(cherry picked from commit 441d02dd402e632c3eba1062a55fc0d752e76003)
Signed-off-by: Animesh Chaturvedi <an...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/6f7653d5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/6f7653d5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/6f7653d5
Branch: refs/heads/4.3
Commit: 6f7653d56a36ca6fe748011d24de594c7fbfa72c
Parents: 45e45b9
Author: Sheng Yang <sh...@citrix.com>
Authored: Wed Jan 29 16:15:24 2014 -0800
Committer: Animesh Chaturvedi <an...@apache.org>
Committed: Thu Jan 30 17:40:17 2014 -0800
----------------------------------------------------------------------
.../debian/config/etc/init.d/cloud-early-config | 10 ++++
.../patches/debian/config/root/edithosts.sh | 53 +++++++++-----------
2 files changed, 35 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6f7653d5/systemvm/patches/debian/config/etc/init.d/cloud-early-config
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/etc/init.d/cloud-early-config b/systemvm/patches/debian/config/etc/init.d/cloud-early-config
index d6dc8f0..77e0f17 100755
--- a/systemvm/patches/debian/config/etc/init.d/cloud-early-config
+++ b/systemvm/patches/debian/config/etc/init.d/cloud-early-config
@@ -750,6 +750,16 @@ setup_dnsmasq() {
sed -i -e "/^dhcp-client-update/d" /etc/dnsmasq.conf
echo 'dhcp-client-update' >> /etc/dnsmasq.conf
fi
+
+ command -v dhcp_release > /dev/null 2>&1
+ no_dhcp_release=$?
+ if [ $no_dhcp_release -eq 0 -a -z "$ETH0_IP6" ]
+ then
+ echo 1 > /var/cache/cloud/dnsmasq_managed_lease
+ sed -i -e "/^leasefile-ro/d" /etc/dnsmasq.conf
+ else
+ echo 0 > /var/cache/cloud/dnsmasq_managed_lease
+ fi
}
setup_sshd(){
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6f7653d5/systemvm/patches/debian/config/root/edithosts.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/root/edithosts.sh b/systemvm/patches/debian/config/root/edithosts.sh
index b82fb8e..8e7ddac 100755
--- a/systemvm/patches/debian/config/root/edithosts.sh
+++ b/systemvm/patches/debian/config/root/edithosts.sh
@@ -80,8 +80,7 @@ fi
grep "redundant_router=1" /var/cache/cloud/cmdline > /dev/null
no_redundant=$?
-command -v dhcp_release > /dev/null 2>&1
-no_dhcp_release=$?
+dnsmasq_managed_lease=`cat /var/cache/cloud/dnsmasq_managed_lease`
wait_for_dnsmasq () {
local _pid=$(pidof dnsmasq)
@@ -96,12 +95,7 @@ wait_for_dnsmasq () {
return 1
}
-if [ $ipv6 ]
-then
- no_dhcp_release=1
-fi
-
-if [ $no_dhcp_release -eq 0 ]
+if [ $dnsmasq_managed_lease ]
then
#release previous dhcp lease if present
logger -t cloud "edithosts: releasing $ipv4"
@@ -145,27 +139,30 @@ then
fi
fi
-#delete leases to supplied mac and ip addresses
-if [ $ipv4 ]
-then
- sed -i /$mac/d $DHCP_LEASES
- sed -i /"$ipv4 "/d $DHCP_LEASES
-fi
-if [ $ipv6 ]
+if [ $dnsmasq_managed_lease -eq 0 ]
then
- sed -i /$duid/d $DHCP_LEASES
- sed -i /"$ipv6 "/d $DHCP_LEASES
-fi
-sed -i /"$host "/d $DHCP_LEASES
+ #delete leases to supplied mac and ip addresses
+ if [ $ipv4 ]
+ then
+ sed -i /$mac/d $DHCP_LEASES
+ sed -i /"$ipv4 "/d $DHCP_LEASES
+ fi
+ if [ $ipv6 ]
+ then
+ sed -i /$duid/d $DHCP_LEASES
+ sed -i /"$ipv6 "/d $DHCP_LEASES
+ fi
+ sed -i /"$host "/d $DHCP_LEASES
-#put in the new entry
-if [ $ipv4 ]
-then
- echo "0 $mac $ipv4 $host *" >> $DHCP_LEASES
-fi
-if [ $ipv6 ]
-then
- echo "0 $duid $ipv6 $host *" >> $DHCP_LEASES
+ #put in the new entry
+ if [ $ipv4 ]
+ then
+ echo "0 $mac $ipv4 $host *" >> $DHCP_LEASES
+ fi
+ if [ $ipv6 ]
+ then
+ echo "0 $duid $ipv6 $host *" >> $DHCP_LEASES
+ fi
fi
#edit hosts file as well
@@ -215,7 +212,7 @@ pid=$(pidof dnsmasq)
if [ "$pid" != "" ]
then
# use SIGHUP to avoid service outage if dhcp_release is available.
- if [ $no_dhcp_release -eq 0 ]
+ if [ $dnsmasq_managed_lease ]
then
kill -HUP $pid
else
[10/11] git commit: updated refs/heads/4.3 to e089b91
Posted by an...@apache.org.
CLOUDSTACK-5996: UI - In project view, the first listRotuers API(without projectid=-1) will return the same objects as the second listRouters API(with projectid=-1), because in project view, all API calls are appended with projectid=[projectID]. Therefore, we only call the second listRouters API(with projectid=-1) in non-project view.
(cherry picked from commit 713240baef97ddd62b646ad35c86e1e3ab6702d6)
Signed-off-by: Animesh Chaturvedi <an...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/32fd3b83
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/32fd3b83
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/32fd3b83
Branch: refs/heads/4.3
Commit: 32fd3b837c5f3cd6d8fd08e51c1594e5553915b1
Parents: a31eccc
Author: Jessica Wang <je...@apache.org>
Authored: Thu Jan 30 14:26:04 2014 -0800
Committer: Animesh Chaturvedi <an...@apache.org>
Committed: Thu Jan 30 17:59:04 2014 -0800
----------------------------------------------------------------------
ui/scripts/system.js | 113 ++++++++++++++++++++++++++++++++--------------
1 file changed, 78 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/32fd3b83/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index 72f9e33..6b89182 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -318,7 +318,6 @@
virtualRouterCount: function(data) {
var data2 = {
- projectid: -1,
page: 1,
pagesize: 1 //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
};
@@ -327,24 +326,35 @@
data: data2,
success: function(json) {
var total1 = json.listroutersresponse.count ? json.listroutersresponse.count : 0;
+ var total2 = 0; //reset
+ /*
+ * In project view, the first listRotuers API(without projectid=-1) will return the same objects as the second listRouters API(with projectid=-1),
+ * because in project view, all API calls are appended with projectid=[projectID].
+ * Therefore, we only call the second listRouters API(with projectid=-1) in non-project view.
+ */
+ if (cloudStack.context && cloudStack.context.projects == null) { //non-project view
var data3 = {
listAll: true,
+ projectid: -1,
page: 1,
pagesize: 1 //specifying pagesize as 1 because we don't need any embedded objects to be returned here. The only thing we need from API response is "count" property.
};
$.ajax({
url: createURL('listRouters'),
data: data3,
+ async: false,
success: function(json) {
- var total2 = json.listroutersresponse.count ? json.listroutersresponse.count : 0;
+ total2 = json.listroutersresponse.count ? json.listroutersresponse.count : 0;
+ }
+ });
+ }
+
dataFns.capacity($.extend(data, {
virtualRouterCount: (total1 + total2)
}));
}
});
- }
- });
},
capacity: function(data) {
@@ -2317,10 +2327,16 @@
routers.push(item);
});
- // Get project routers
+ /*
+ * In project view, the first listRotuers API(without projectid=-1) will return the same objects as the second listRouters API(with projectid=-1),
+ * because in project view, all API calls are appended with projectid=[projectID].
+ * Therefore, we only call the second listRouters API(with projectid=-1) in non-project view.
+ */
+ if (cloudStack.context && cloudStack.context.projects == null) { //non-project view
$.ajax({
url: createURL("listRouters&zoneid=" + selectedZoneObj.id + "&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("") + "&projectid=-1"),
data: data2,
+ async: false,
success: function(json) {
var items = json.listroutersresponse.router ?
json.listroutersresponse.router : [];
@@ -2328,14 +2344,16 @@
$(items).map(function(index, item) {
routers.push(item);
});
+ }
+ });
+ }
+
args.response.success({
actionFilter: routerActionfilter,
data: $(routers).map(mapRouterType)
});
}
});
- }
- });
},
detailView: {
name: 'Virtual applicance details',
@@ -3397,25 +3415,32 @@
routers.push(item);
});
- // Get project routers
+ /*
+ * In project view, the first listRotuers API(without projectid=-1) will return the same objects as the second listRouters API(with projectid=-1),
+ * because in project view, all API calls are appended with projectid=[projectID].
+ * Therefore, we only call the second listRouters API(with projectid=-1) in non-project view.
+ */
+ if (cloudStack.context && cloudStack.context.projects == null) { //non-project view
$.ajax({
url: createURL("listRouters&zoneid=" + selectedZoneObj.id + "&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("") + "&projectid=-1"),
dataType: 'json',
data: data2,
- async: true,
+ async: false,
success: function(json) {
var items = json.listroutersresponse.router;
$(items).map(function(index, item) {
routers.push(item);
});
+ }
+ });
+ }
+
args.response.success({
actionFilter: routerActionfilter,
data: $(routers).map(mapRouterType)
});
}
});
- }
- });
},
detailView: {
name: 'Virtual applicance details',
@@ -7392,32 +7417,41 @@
$(items).map(function(index, item) {
routers.push(item);
});
-
- //get project-owned routers
- var toSearchByProjectid = true;
+
+ //if account is specified in advanced search, don't search project-owned routers
+ var accountIsNotSpecifiedInAdvSearch = true;
if (args.filterBy != null) {
if (args.filterBy.advSearch != null && typeof(args.filterBy.advSearch) == "object") { //advanced search
- if ('account' in args.filterBy.advSearch && args.filterBy.advSearch.account.length > 0) { //if account is specified in advanced search, don't search project-owned routers
- toSearchByProjectid = false; //since account and projectid can't be specified together
+ if ('account' in args.filterBy.advSearch && args.filterBy.advSearch.account.length > 0) {
+ accountIsNotSpecifiedInAdvSearch = false; //since account and projectid can't be specified together
}
}
}
- if (toSearchByProjectid) {
- $.ajax({
- url: createURL('listRouters'),
- data: $.extend(data,{
- listAll: true,
- projectid: -1
- }),
- async: false,
- success: function(json) {
- var items = json.listroutersresponse.router ? json.listroutersresponse.router : [];
- $(items).map(function(index, item) {
- routers.push(item);
- });
- }
- });
- }
+ if (accountIsNotSpecifiedInAdvSearch) {
+ /*
+ * In project view, the first listRotuers API(without projectid=-1) will return the same objects as the second listRouters API(with projectid=-1),
+ * because in project view, all API calls are appended with projectid=[projectID].
+ * Therefore, we only call the second listRouters API(with projectid=-1) in non-project view.
+ */
+ if (cloudStack.context && cloudStack.context.projects == null) { //non-project view
+ $.ajax({
+ url: createURL("listRouters&listAll=true&page=" + args.page + "&pagesize=" + pageSize + "&projectid=-1"),
+ async: false,
+ success: function(json) {
+ var items = json.listroutersresponse.router ? json.listroutersresponse.router : [];
+ $(items).map(function(index, item) {
+ routers.push(item);
+ });
+ }
+ });
+
+ }
+ }
+
+ args.response.success({
+ actionFilter: routerActionfilter,
+ data: $(routers).map(mapRouterType)
+ });
}
});
@@ -7681,10 +7715,17 @@
$(items).map(function(index, item) {
routers.push(item);
});
- // Get project routers
+
+ /*
+ * In project view, the first listRotuers API(without projectid=-1) will return the same objects as the second listRouters API(with projectid=-1),
+ * because in project view, all API calls are appended with projectid=[projectID].
+ * Therefore, we only call the second listRouters API(with projectid=-1) in non-project view.
+ */
+ if (cloudStack.context && cloudStack.context.projects == null) { //non-project view
$.ajax({
url: createURL("listRouters&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("") + "&projectid=-1"),
data: data2,
+ async: false,
success: function(json) {
var items = json.listroutersresponse.router ?
json.listroutersresponse.router : [];
@@ -7692,14 +7733,16 @@
$(items).map(function(index, item) {
routers.push(item);
});
+ }
+ });
+ }
+
args.response.success({
actionFilter: routerActionfilter,
data: $(routers).map(mapRouterType)
});
}
});
- }
- });
},
detailView: {
name: 'Virtual applicance details',
[04/11] git commit: updated refs/heads/4.3 to e089b91
Posted by an...@apache.org.
CLOUDSTACK-5966 Updated service monitoring config to start by default.
Global settings EnableServiceMonitoring param set to true
(cherry picked from commit 7255e50f2051aff1cb5e1991e2dde4ef48f57454)
Signed-off-by: Animesh Chaturvedi <an...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ccc8aa78
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ccc8aa78
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ccc8aa78
Branch: refs/heads/4.3
Commit: ccc8aa78cd8f02b175adad99417d83796e3d4a82
Parents: bbe62ea
Author: Jayapal <ja...@apache.org>
Authored: Thu Jan 30 14:16:58 2014 +0530
Committer: Animesh Chaturvedi <an...@apache.org>
Committed: Thu Jan 30 17:42:42 2014 -0800
----------------------------------------------------------------------
server/src/com/cloud/configuration/Config.java | 2 +-
setup/db/db/schema-421to430.sql | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ccc8aa78/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index da79995..2d55f46 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -105,7 +105,7 @@ public enum Config {
SecurityGroupDefaultAdding("Network", ManagementServer.class, Boolean.class, "network.securitygroups.defaultadding", "true", "If true, the user VM would be added to the default security group by default", null),
GuestOSNeedGatewayOnNonDefaultNetwork("Network", NetworkOrchestrationService.class, String.class, "network.dhcp.nondefaultnetwork.setgateway.guestos", "Windows", "The guest OS's name start with this fields would result in DHCP server response gateway information even when the network it's on is not default network. Names are separated by comma.", null),
- EnableServiceMonitoring("Network", ManagementServer.class, Boolean.class, "network.router.enableserviceMonitoring", "false", "service monitoring in router enable/disable option, default false", null),
+ EnableServiceMonitoring("Network", ManagementServer.class, Boolean.class, "network.router.enableserviceMonitoring", "true", "service monitoring in router enable/disable option, default true", null),
//VPN
RemoteAccessVpnPskLength("Network", AgentManager.class, Integer.class, "remote.access.vpn.psk.length", "24", "The length of the ipsec preshared key (minimum 8, maximum 256)", null),
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ccc8aa78/setup/db/db/schema-421to430.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-421to430.sql b/setup/db/db/schema-421to430.sql
index 6e96947..316cbe9 100644
--- a/setup/db/db/schema-421to430.sql
+++ b/setup/db/db/schema-421to430.sql
@@ -1089,6 +1089,5 @@ CREATE VIEW `cloud`.`user_vm_view` AS
left join
`cloud`.`user_vm_details` `custom_ram_size` ON (((`custom_ram_size`.`vm_id` = `cloud`.`vm_instance`.`id`) and (`custom_ram_size`.`name` = 'memory')));
-INSERT INTO `cloud`.`configuration`(category, instance, component, name, value, description, default_value) VALUES ('NetworkManager', 'DEFAULT', 'management-server', 'network.router.EnableServiceMonitoring', 'false', 'service monitoring in router enable/disable option, default false', 'false') ON DUPLICATE KEY UPDATE category='NetworkManager';
INSERT IGNORE INTO `cloud`.`configuration`(category, instance, component, name, value, description, default_value) VALUES ('NetworkManager', 'DEFAULT', 'management-server', 'network.router.EnableServiceMonitoring', 'true', 'service monitoring in router enable/disable option, default true', 'true') ON DUPLICATE KEY UPDATE category='NetworkManager';
[11/11] git commit: updated refs/heads/4.3 to e089b91
Posted by an...@apache.org.
CLOUDSTACK-5994. Hitting IndexOutOfBoundsException in GetVmStatsCommand after upgrade.
To obtain network read/write statistics, multiply sample duration with the
average of the particular performance metric obtained over the sample period.
(cherry picked from commit 16c3f53793517e3c924df5ff6d9dc872dd508731)
Signed-off-by: Animesh Chaturvedi <an...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e089b913
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e089b913
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e089b913
Branch: refs/heads/4.3
Commit: e089b91385ad032af5e39029f1203664f07b848b
Parents: 32fd3b8
Author: Likitha Shetty <li...@citrix.com>
Authored: Thu Jan 30 18:01:28 2014 +0530
Committer: Animesh Chaturvedi <an...@apache.org>
Committed: Thu Jan 30 17:59:37 2014 -0800
----------------------------------------------------------------------
.../cloud/hypervisor/vmware/resource/VmwareResource.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e089b913/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 7439f12..d1fea92 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -6690,11 +6690,16 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
if(vals.get(vi) instanceof PerfMetricIntSeries) {
PerfMetricIntSeries val = (PerfMetricIntSeries)vals.get(vi);
List<Long> perfValues = val.getValue();
+ Long sumRate = 0L;
+ for (int j = 0; j < infos.size(); j++) { // Size of the array matches the size as the PerfSampleInfo
+ sumRate += perfValues.get(j);
+ }
+ Long averageRate = sumRate / infos.size();
if (vals.get(vi).getId().getCounterId() == rxPerfCounterInfo.getKey()) {
- networkReadKBs = sampleDuration * perfValues.get(3); //get the average RX rate multiplied by sampled duration
+ networkReadKBs = sampleDuration * averageRate; //get the average RX rate multiplied by sampled duration
}
if (vals.get(vi).getId().getCounterId() == txPerfCounterInfo.getKey()) {
- networkWriteKBs = sampleDuration * perfValues.get(3);//get the average TX rate multiplied by sampled duration
+ networkWriteKBs = sampleDuration * averageRate; //get the average TX rate multiplied by sampled duration
}
}
}
[05/11] git commit: updated refs/heads/4.3 to e089b91
Posted by an...@apache.org.
CLOUDSTACK-5660: Migrate vm live migration succeeds but throws error as "Failed to migrate the system vm".
(cherry picked from commit cff312ef743763c69b0c3b0cfd9faf906f3cf22c)
Signed-off-by: Animesh Chaturvedi <an...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d7e1d38d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d7e1d38d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d7e1d38d
Branch: refs/heads/4.3
Commit: d7e1d38d48f7362944092755e0ea0b5f025aab8b
Parents: ccc8aa7
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Thu Jan 30 16:17:19 2014 +0530
Committer: Animesh Chaturvedi <an...@apache.org>
Committed: Thu Jan 30 17:44:48 2014 -0800
----------------------------------------------------------------------
server/src/com/cloud/vm/UserVmManagerImpl.java | 7 ++++++-
ui/scripts/system.js | 12 ++++++------
2 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d7e1d38d/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 363c663..d9923d2 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -4216,7 +4216,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
collectVmDiskStatistics(uservm);
}
_itMgr.migrate(vm.getUuid(), srcHostId, dest);
- return _vmDao.findById(vmId);
+ VMInstanceVO vmInstance = _vmInstanceDao.findById(vmId);
+ if (vmInstance.getType().equals(VirtualMachine.Type.User)) {
+ return _vmDao.findById(vmId);
+ } else {
+ return vmInstance;
+ }
}
private boolean checkIfHostIsDedicated(HostVO host) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d7e1d38d/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index 960f1aa..72f9e33 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -2508,7 +2508,7 @@
getUpdatedItem: function(json) {
//return json.queryasyncjobresultresponse.jobresult.systemvminstance; //not all properties returned in systemvminstance
$.ajax({
- url: createURL("listRouters&id=" + json.queryasyncjobresultresponse.jobresult.systemvminstance.id),
+ url: createURL("listRouters&id=" + json.queryasyncjobresultresponse.jobresult.systemvm.id),
dataType: "json",
async: false,
success: function(json) {
@@ -3030,7 +3030,7 @@
getUpdatedItem: function(json) {
//return json.queryasyncjobresultresponse.jobresult.systemvminstance; //not all properties returned in systemvminstance
$.ajax({
- url: createURL("listInternalLoadBalancerVMs&id=" + json.queryasyncjobresultresponse.jobresult.systemvminstance.id),
+ url: createURL("listInternalLoadBalancerVMs&id=" + json.queryasyncjobresultresponse.jobresult.systemvm.id),
dataType: "json",
async: false,
success: function(json) {
@@ -3624,7 +3624,7 @@
getUpdatedItem: function(json) {
//return json.queryasyncjobresultresponse.jobresult.systemvminstance; //not all properties returned in systemvminstance
$.ajax({
- url: createURL("listRouters&id=" + json.queryasyncjobresultresponse.jobresult.systemvminstance.id),
+ url: createURL("listRouters&id=" + json.queryasyncjobresultresponse.jobresult.systemvm.id),
dataType: "json",
async: false,
success: function(json) {
@@ -6788,7 +6788,7 @@
getUpdatedItem: function(json) {
//return json.queryasyncjobresultresponse.jobresult.systemvminstance; //not all properties returned in systemvminstance
$.ajax({
- url: createURL("listSystemVms&id=" + json.queryasyncjobresultresponse.jobresult.systemvminstance.id),
+ url: createURL("listSystemVms&id=" + json.queryasyncjobresultresponse.jobresult.systemvm.id),
dataType: "json",
async: false,
success: function(json) {
@@ -7941,7 +7941,7 @@
getUpdatedItem: function(json) {
//return json.queryasyncjobresultresponse.jobresult.systemvminstance; //not all properties returned in systemvminstance
$.ajax({
- url: createURL("listRouters&id=" + json.queryasyncjobresultresponse.jobresult.systemvminstance.id),
+ url: createURL("listRouters&id=" + json.queryasyncjobresultresponse.jobresult.systemvm.id),
dataType: "json",
async: false,
success: function(json) {
@@ -9167,7 +9167,7 @@
getUpdatedItem: function(json) {
//return json.queryasyncjobresultresponse.jobresult.systemvminstance; //not all properties returned in systemvminstance
$.ajax({
- url: createURL("listSystemVms&id=" + json.queryasyncjobresultresponse.jobresult.systemvminstance.id),
+ url: createURL("listSystemVms&id=" + json.queryasyncjobresultresponse.jobresult.systemvm.id),
dataType: "json",
async: false,
success: function(json) {
[07/11] git commit: updated refs/heads/4.3 to e089b91
Posted by an...@apache.org.
Revertng based on mail thread discussion "Fix findbug issues within LDAP authenticator"
This reverts commit 92b4f66d73562e4211d2d787554ff229dbeb5705.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/602faeca
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/602faeca
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/602faeca
Branch: refs/heads/4.3
Commit: 602faecafe2f24f21e199e2b21c618f9f41a5ce1
Parents: 523cbdd
Author: Animesh Chaturvedi <an...@apache.org>
Authored: Thu Jan 30 17:55:39 2014 -0800
Committer: Animesh Chaturvedi <an...@apache.org>
Committed: Thu Jan 30 17:55:39 2014 -0800
----------------------------------------------------------------------
.../cloudstack/api/command/LDAPConfigCmd.java | 2 +-
.../api/command/LdapCreateAccountCmd.java | 244 +++++++++----------
.../api/command/LdapImportUsersCmd.java | 17 +-
.../cloudstack/ldap/LdapContextFactory.java | 2 +
.../ldap/LdapAuthenticatorSpec.groovy | 8 +-
.../cloudstack/ldap/LdapManagerImplSpec.groovy | 16 +-
6 files changed, 152 insertions(+), 137 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/602faeca/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LDAPConfigCmd.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LDAPConfigCmd.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LDAPConfigCmd.java
index a4883c5..3faf8b7 100644
--- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LDAPConfigCmd.java
+++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LDAPConfigCmd.java
@@ -209,7 +209,7 @@ public class LDAPConfigCmd extends BaseCmd {
}
private boolean updateLDAP() {
- _ldapManager.addConfiguration(hostname, port);
+ LdapConfigurationResponse response = _ldapManager.addConfiguration(hostname, port);
/**
* There is no query filter now. It is derived from ldap.user.object and ldap.search.group.principle
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/602faeca/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapCreateAccountCmd.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapCreateAccountCmd.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapCreateAccountCmd.java
index b78b484..981e72e 100644
--- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapCreateAccountCmd.java
+++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapCreateAccountCmd.java
@@ -35,6 +35,7 @@ import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.ldap.LdapManager;
import org.apache.cloudstack.ldap.LdapUser;
import org.apache.log4j.Logger;
+import org.bouncycastle.util.encoders.Base64;
import com.cloud.user.Account;
import com.cloud.user.AccountService;
@@ -42,126 +43,125 @@ import com.cloud.user.UserAccount;
@APICommand(name = "ldapCreateAccount", description = "Creates an account from an LDAP user", responseObject = AccountResponse.class, since = "4.2.0")
public class LdapCreateAccountCmd extends BaseCmd {
- public static final Logger s_logger = Logger
- .getLogger(LdapCreateAccountCmd.class.getName());
- private static final String s_name = "createaccountresponse";
-
- @Inject
- private LdapManager _ldapManager;
-
- @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "Creates the user under the specified account. If no account is specified, the username will be used as the account name.")
- private String accountName;
-
- @Parameter(name = ApiConstants.ACCOUNT_TYPE, type = CommandType.SHORT, required = true, description = "Type of the account. Specify 0 for user, 1 for root admin, and 2 for domain admin")
- private Short accountType;
-
- @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "Creates the user under the specified domain.")
- private Long domainId;
-
- @Parameter(name = ApiConstants.TIMEZONE, type = CommandType.STRING, description = "Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.")
- private String timezone;
-
- @Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, required = true, description = "Unique username.")
- private String username;
-
- @Parameter(name = ApiConstants.NETWORK_DOMAIN, type = CommandType.STRING, description = "Network domain for the account's networks")
- private String networkDomain;
-
- @Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "details for account used to store specific parameters")
- private Map<String, String> 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;
-
- public LdapCreateAccountCmd() {
- super();
- }
-
- public LdapCreateAccountCmd(final LdapManager ldapManager,
- final AccountService accountService) {
- super();
- _ldapManager = ldapManager;
- _accountService = accountService;
- }
-
- UserAccount createCloudstackUserAccount(final LdapUser user) {
- return _accountService.createUserAccount(username, generatePassword(),
- user.getFirstname(), user.getLastname(), user.getEmail(),
- timezone, accountName, accountType, domainId, networkDomain,
- details, accountUUID, userUUID);
- }
-
- @Override
- public void execute() throws ServerApiException {
- final CallContext callContext = getCurrentContext();
- callContext.setEventDetails("Account Name: " + accountName
- + ", Domain Id:" + domainId);
- try {
- final LdapUser user = _ldapManager.getUser(username);
- validateUser(user);
- final UserAccount userAccount = createCloudstackUserAccount(user);
- if (userAccount != null) {
- final AccountResponse response = _responseGenerator
- .createUserAccountResponse(userAccount);
- response.setResponseName(getCommandName());
- setResponseObject(response);
- } else {
- throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
- "Failed to create a user account");
- }
- } catch (final NamingException e) {
- throw new ServerApiException(
- ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR,
- "No LDAP user exists with the username of " + username);
- }
- }
-
- private String generatePassword() throws ServerApiException {
- final SecureRandom random = new SecureRandom();
- final int length = 20;
- final String characters = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789!@£$%^&*()_+=";
-
- String password = "";
- for (int i = 0; i < length; i++) {
- int index = (int) (random.nextDouble() * characters.length());
- password += characters.charAt(index);
- }
- return password;
- }
-
- @Override
- public String getCommandName() {
- return s_name;
- }
-
- CallContext getCurrentContext() {
- return CallContext.current();
- }
-
- @Override
- public long getEntityOwnerId() {
- return Account.ACCOUNT_ID_SYSTEM;
- }
-
- private boolean validateUser(final LdapUser user) throws ServerApiException {
- if (user.getEmail() == null) {
- throw new ServerApiException(
- ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, username
- + " has no email address set within LDAP");
- }
- if (user.getFirstname() == null) {
- throw new ServerApiException(
- ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, username
- + " has no firstname set within LDAP");
- }
- if (user.getLastname() == null) {
- throw new ServerApiException(
- ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, username
- + " has no lastname set within LDAP");
- }
- return true;
- }
+ public static final Logger s_logger = Logger
+ .getLogger(LdapCreateAccountCmd.class.getName());
+ private static final String s_name = "createaccountresponse";
+
+ @Inject
+ private LdapManager _ldapManager;
+
+ @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "Creates the user under the specified account. If no account is specified, the username will be used as the account name.")
+ private String accountName;
+
+ @Parameter(name = ApiConstants.ACCOUNT_TYPE, type = CommandType.SHORT, required = true, description = "Type of the account. Specify 0 for user, 1 for root admin, and 2 for domain admin")
+ private Short accountType;
+
+ @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "Creates the user under the specified domain.")
+ private Long domainId;
+
+ @Parameter(name = ApiConstants.TIMEZONE, type = CommandType.STRING, description = "Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format.")
+ private String timezone;
+
+ @Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, required = true, description = "Unique username.")
+ private String username;
+
+ @Parameter(name = ApiConstants.NETWORK_DOMAIN, type = CommandType.STRING, description = "Network domain for the account's networks")
+ private String networkDomain;
+
+ @Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "details for account used to store specific parameters")
+ private Map<String, String> 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;
+
+ public LdapCreateAccountCmd() {
+ super();
+ }
+
+ public LdapCreateAccountCmd(final LdapManager ldapManager,
+ final AccountService accountService) {
+ super();
+ _ldapManager = ldapManager;
+ _accountService = accountService;
+ }
+
+ UserAccount createCloudstackUserAccount(final LdapUser user) {
+ return _accountService.createUserAccount(username, generatePassword(),
+ user.getFirstname(), user.getLastname(), user.getEmail(),
+ timezone, accountName, accountType, domainId, networkDomain,
+ details, accountUUID, userUUID);
+ }
+
+ @Override
+ public void execute() throws ServerApiException {
+ final CallContext callContext = getCurrentContext();
+ callContext.setEventDetails("Account Name: " + accountName
+ + ", Domain Id:" + domainId);
+ try {
+ final LdapUser user = _ldapManager.getUser(username);
+ validateUser(user);
+ final UserAccount userAccount = createCloudstackUserAccount(user);
+ if (userAccount != null) {
+ final AccountResponse response = _responseGenerator
+ .createUserAccountResponse(userAccount);
+ response.setResponseName(getCommandName());
+ setResponseObject(response);
+ } else {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
+ "Failed to create a user account");
+ }
+ } catch (final NamingException e) {
+ throw new ServerApiException(
+ ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR,
+ "No LDAP user exists with the username of " + username);
+ }
+ }
+
+ private String generatePassword() throws ServerApiException {
+ try {
+ final SecureRandom randomGen = SecureRandom.getInstance("SHA1PRNG");
+ final byte bytes[] = new byte[20];
+ randomGen.nextBytes(bytes);
+ return Base64.encode(bytes).toString();
+ } catch (final NoSuchAlgorithmException e) {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
+ "Failed to generate random password");
+ }
+ }
+
+ @Override
+ public String getCommandName() {
+ return s_name;
+ }
+
+ CallContext getCurrentContext() {
+ return CallContext.current();
+ }
+
+ @Override
+ public long getEntityOwnerId() {
+ return Account.ACCOUNT_ID_SYSTEM;
+ }
+
+ private boolean validateUser(final LdapUser user) throws ServerApiException {
+ if (user.getEmail() == null) {
+ throw new ServerApiException(
+ ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, username
+ + " has no email address set within LDAP");
+ }
+ if (user.getFirstname() == null) {
+ throw new ServerApiException(
+ ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, username
+ + " has no firstname set within LDAP");
+ }
+ if (user.getLastname() == null) {
+ throw new ServerApiException(
+ ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, username
+ + " has no lastname set within LDAP");
+ }
+ return true;
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/602faeca/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapImportUsersCmd.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapImportUsersCmd.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapImportUsersCmd.java
index d82276c..1855d5d 100644
--- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapImportUsersCmd.java
+++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapImportUsersCmd.java
@@ -34,6 +34,7 @@ import org.apache.cloudstack.ldap.LdapUser;
import org.apache.cloudstack.ldap.NoLdapUserMatchingQueryException;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
+import org.bouncycastle.util.encoders.Base64;
import com.cloud.domain.Domain;
import com.cloud.exception.*;
@@ -170,15 +171,13 @@ public class LdapImportUsersCmd extends BaseListCmd {
}
private String generatePassword() throws ServerApiException {
- final SecureRandom random = new SecureRandom();
- final int length = 20;
- final String characters = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789!@£$%^&*()_+=";
-
- String password = "";
- for (int i = 0; i < length; i++) {
- int index = (int) (random.nextDouble() * characters.length());
- password += characters.charAt(index);
+ try {
+ final SecureRandom randomGen = SecureRandom.getInstance("SHA1PRNG");
+ final byte bytes[] = new byte[20];
+ randomGen.nextBytes(bytes);
+ return Base64.encode(bytes).toString();
+ } catch (final NoSuchAlgorithmException e) {
+ throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to generate random password");
}
- return password;
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/602faeca/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapContextFactory.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapContextFactory.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapContextFactory.java
index c0d5d50..ceeed68 100644
--- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapContextFactory.java
+++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/ldap/LdapContextFactory.java
@@ -95,6 +95,8 @@ public class LdapContextFactory {
environment.put(Context.INITIAL_CONTEXT_FACTORY, factory);
environment.put(Context.PROVIDER_URL, url);
+ environment.put("com.sun.jndi.ldap.read.timeout", "500");
+ environment.put("com.sun.jndi.ldap.connect.pool", "true");
enableSSL(environment);
setAuthentication(environment, isSystemContext);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/602faeca/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapAuthenticatorSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapAuthenticatorSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapAuthenticatorSpec.groovy
index 51f8e84..416c133 100644
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapAuthenticatorSpec.groovy
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapAuthenticatorSpec.groovy
@@ -34,7 +34,7 @@ class LdapAuthenticatorSpec extends spock.lang.Specification {
when: "A user authentications"
def result = ldapAuthenticator.authenticate("rmurphy", "password", 0, null)
then: "their authentication fails"
- result.first() == false
+ result == false
}
def "Test failed authentication due to ldap bind being unsuccessful"() {
@@ -51,7 +51,7 @@ class LdapAuthenticatorSpec extends spock.lang.Specification {
def result = ldapAuthenticator.authenticate("rmurphy", "password", 0, null)
then: "their authentication fails"
- result.first() == false
+ result == false
}
def "Test failed authentication due to ldap not being configured"() {
@@ -66,7 +66,7 @@ class LdapAuthenticatorSpec extends spock.lang.Specification {
when: "The user authenticates"
def result = ldapAuthenticator.authenticate("rmurphy", "password", 0, null)
then: "their authentication fails"
- result.first() == false
+ result == false
}
def "Test successful authentication"() {
@@ -83,7 +83,7 @@ class LdapAuthenticatorSpec extends spock.lang.Specification {
def result = ldapAuthenticator.authenticate("rmurphy", "password", 0, null)
then: "their authentication passes"
- result.first() == true
+ result == true
}
def "Test that encode doesn't change the input"() {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/602faeca/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapManagerImplSpec.groovy
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapManagerImplSpec.groovy b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapManagerImplSpec.groovy
index c0ca2e8..42988e0 100644
--- a/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapManagerImplSpec.groovy
+++ b/plugins/user-authenticators/ldap/test/groovy/org/apache/cloudstack/ldap/LdapManagerImplSpec.groovy
@@ -297,16 +297,30 @@ class LdapManagerImplSpec extends spock.lang.Specification {
thrown InvalidParameterValueException
}
+ def supportedLdapCommands() {
+ List<Class<?>> cmdList = new ArrayList<Class<?>>();
+ cmdList.add(LdapUserSearchCmd.class);
+ cmdList.add(LdapListUsersCmd.class);
+ cmdList.add(LdapAddConfigurationCmd.class);
+ cmdList.add(LdapDeleteConfigurationCmd.class);
+ cmdList.add(LdapListConfigurationCmd.class);
+ cmdList.add(LdapCreateAccountCmd.class);
+ cmdList.add(LdapImportUsersCmd.class);
+ return cmdList
+ }
+
def "Test that getCommands isn't empty"() {
given: "We have an LdapConfigurationDao, LdapContextFactory, LdapUserManager and LdapManager"
def ldapConfigurationDao = Mock(LdapConfigurationDaoImpl)
def ldapContextFactory = Mock(LdapContextFactory)
def ldapUserManager = Mock(LdapUserManager)
+ final List<Class<?>> cmdList = supportedLdapCommands()
def ldapManager = new LdapManagerImpl(ldapConfigurationDao, ldapContextFactory, ldapUserManager)
when: "Get commands is called"
def result = ldapManager.getCommands()
- then: "it must contain commands"
+ then: "it must return all the commands"
result.size() > 0
+ result == cmdList
}
def "Testing of listConfigurations"() {
[08/11] git commit: updated refs/heads/4.3 to e089b91
Posted by an...@apache.org.
findbugs replaced byte[].toString() with Arrays.toString(byte[])(cherry picked from commit ce7c6d23575d455a8273b77702a56b7bb419b37b)
Signed-off-by: Animesh Chaturvedi <an...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/55ec8f3a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/55ec8f3a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/55ec8f3a
Branch: refs/heads/4.3
Commit: 55ec8f3a2d8ae73ae1e20a806a8f8d0ee29fa274
Parents: 602faec
Author: Daan Hoogland <dh...@schubergphilis.com>
Authored: Thu Jan 30 15:25:19 2014 +0100
Committer: Animesh Chaturvedi <an...@apache.org>
Committed: Thu Jan 30 17:57:50 2014 -0800
----------------------------------------------------------------------
.../api/command/LdapCreateAccountCmd.java | 3 ++-
.../cloudstack/api/command/LdapImportUsersCmd.java | 17 ++++++++++++++---
2 files changed, 16 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55ec8f3a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapCreateAccountCmd.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapCreateAccountCmd.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapCreateAccountCmd.java
index 981e72e..3afa22b 100644
--- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapCreateAccountCmd.java
+++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapCreateAccountCmd.java
@@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
+import java.util.Arrays;
import java.util.Map;
import javax.inject.Inject;
@@ -125,7 +126,7 @@ public class LdapCreateAccountCmd extends BaseCmd {
final SecureRandom randomGen = SecureRandom.getInstance("SHA1PRNG");
final byte bytes[] = new byte[20];
randomGen.nextBytes(bytes);
- return Base64.encode(bytes).toString();
+ return Arrays.toString(Base64.encode(bytes));
} catch (final NoSuchAlgorithmException e) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
"Failed to generate random password");
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55ec8f3a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapImportUsersCmd.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapImportUsersCmd.java b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapImportUsersCmd.java
index 1855d5d..41eacf0 100644
--- a/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapImportUsersCmd.java
+++ b/plugins/user-authenticators/ldap/src/org/apache/cloudstack/api/command/LdapImportUsersCmd.java
@@ -19,13 +19,19 @@ package org.apache.cloudstack.api.command;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.inject.Inject;
-import org.apache.cloudstack.api.*;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.BaseListCmd;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.LdapUserResponse;
import org.apache.cloudstack.api.response.ListResponse;
@@ -37,7 +43,12 @@ import org.apache.log4j.Logger;
import org.bouncycastle.util.encoders.Base64;
import com.cloud.domain.Domain;
-import com.cloud.exception.*;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.AccountService;
import com.cloud.user.DomainService;
@@ -175,7 +186,7 @@ public class LdapImportUsersCmd extends BaseListCmd {
final SecureRandom randomGen = SecureRandom.getInstance("SHA1PRNG");
final byte bytes[] = new byte[20];
randomGen.nextBytes(bytes);
- return Base64.encode(bytes).toString();
+ return Arrays.toString(Base64.encode(bytes));
} catch (final NoSuchAlgorithmException e) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to generate random password");
}