cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [1/2] git commit: updated refs/heads/master to e752f88
Date Mon, 25 May 2015 12:41:52 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master dfafb441b -> e752f8899


CLOUDSTACK-8339: Allow non-root users to add KVM host

This allows non-root users to add KVM hosts, the user should be an admin or
added to sudoers to execute sudo cloudstack-setup-agent.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
Signed-off-by: Remi Bergsma <apache@remi.nl>

This closes #288

(cherry picked from commit d2b0c1a32b2d8719eafd6d4574de9a824d46d290)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e5d30845
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e5d30845
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e5d30845

Branch: refs/heads/master
Commit: e5d3084526abdadbb09a30fc30e7cbfd1b9afe11
Parents: dfafb44
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Fri May 22 14:36:16 2015 +0100
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Mon May 25 14:36:29 2015 +0200

----------------------------------------------------------------------
 agent/bindir/cloudstack-agent-profile.sh.in     | 20 ++++++++++++++++++++
 debian/cloudstack-agent.install                 |  1 +
 debian/rules                                    |  2 ++
 packaging/centos63/cloud.spec                   |  3 +++
 .../kvm/discoverer/LibvirtServerDiscoverer.java |  8 ++++++--
 5 files changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e5d30845/agent/bindir/cloudstack-agent-profile.sh.in
----------------------------------------------------------------------
diff --git a/agent/bindir/cloudstack-agent-profile.sh.in b/agent/bindir/cloudstack-agent-profile.sh.in
new file mode 100644
index 0000000..93b10b3
--- /dev/null
+++ b/agent/bindir/cloudstack-agent-profile.sh.in
@@ -0,0 +1,20 @@
+#!/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.
+
+# need access to lsmod for adding host as non-root
+PATH=$PATH:/sbin

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e5d30845/debian/cloudstack-agent.install
----------------------------------------------------------------------
diff --git a/debian/cloudstack-agent.install b/debian/cloudstack-agent.install
index d708514..94dd30d 100644
--- a/debian/cloudstack-agent.install
+++ b/debian/cloudstack-agent.install
@@ -18,6 +18,7 @@
 /etc/cloudstack/agent/agent.properties
 /etc/cloudstack/agent/environment.properties
 /etc/cloudstack/agent/log4j-cloud.xml
+/etc/profile.d/cloudstack-agent-profile.sh
 /etc/init.d/cloudstack-agent
 /usr/bin/cloudstack-setup-agent
 /usr/bin/cloudstack-ssh

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e5d30845/debian/rules
----------------------------------------------------------------------
diff --git a/debian/rules b/debian/rules
index b27b3c4..fd26f77 100755
--- a/debian/rules
+++ b/debian/rules
@@ -37,6 +37,7 @@ override_dh_auto_install:
 
 	# cloudstack-agent
 	mkdir $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/agent
+	mkdir $(DESTDIR)/$(SYSCONFDIR)/profile.d
 	mkdir $(DESTDIR)/var/log/$(PACKAGE)/agent
 	mkdir $(DESTDIR)/usr/share/$(PACKAGE)-agent
 	mkdir $(DESTDIR)/usr/share/$(PACKAGE)-agent/plugins
@@ -46,6 +47,7 @@ override_dh_auto_install:
 	install -D packaging/debian/init/cloud-agent $(DESTDIR)/$(SYSCONFDIR)/init.d/$(PACKAGE)-agent
 	install -D agent/target/transformed/cloud-setup-agent $(DESTDIR)/usr/bin/cloudstack-setup-agent
 	install -D agent/target/transformed/cloud-ssh $(DESTDIR)/usr/bin/cloudstack-ssh
+	install -D agent/target/transformed/cloudstack-agent-profile.sh $(DESTDIR)/$(SYSCONFDIR)/profile.d/cloudstack-agent-profile.sh
 	install -D agent/target/transformed/cloudstack-agent-upgrade $(DESTDIR)/usr/bin/cloudstack-agent-upgrade
 	install -D agent/target/transformed/libvirtqemuhook $(DESTDIR)/usr/share/$(PACKAGE)-agent/lib/
 	install -D agent/target/transformed/* $(DESTDIR)/$(SYSCONFDIR)/$(PACKAGE)/agent

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e5d30845/packaging/centos63/cloud.spec
----------------------------------------------------------------------
diff --git a/packaging/centos63/cloud.spec b/packaging/centos63/cloud.spec
index 1806027..afa29b8 100644
--- a/packaging/centos63/cloud.spec
+++ b/packaging/centos63/cloud.spec
@@ -224,6 +224,7 @@ mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/%{name}/mnt
 mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/%{name}/management
 mkdir -p ${RPM_BUILD_ROOT}%{_initrddir}
 mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig
+mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/profile.d
 
 # Common
 mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/scripts
@@ -321,6 +322,7 @@ install -D agent/target/transformed/cloud-setup-agent ${RPM_BUILD_ROOT}%{_bindir
 install -D agent/target/transformed/cloudstack-agent-upgrade ${RPM_BUILD_ROOT}%{_bindir}/%{name}-agent-upgrade
 install -D agent/target/transformed/libvirtqemuhook ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib/libvirtqemuhook
 install -D agent/target/transformed/cloud-ssh ${RPM_BUILD_ROOT}%{_bindir}/%{name}-ssh
+install -D agent/target/transformed/cloudstack-agent-profile.sh ${RPM_BUILD_ROOT}%{_sysconfdir}/profile.d/%{name}-agent-profile.sh
 install -D plugins/hypervisors/kvm/target/cloud-plugin-hypervisor-kvm-%{_maventag}.jar ${RPM_BUILD_ROOT}%{_datadir}/%name-agent/lib/cloud-plugin-hypervisor-kvm-%{_maventag}.jar
 cp plugins/hypervisors/kvm/target/dependencies/*  ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib
 
@@ -583,6 +585,7 @@ fi
 %attr(0755,root,root) %{_bindir}/%{name}-agent-upgrade
 %attr(0755,root,root) %{_bindir}/%{name}-ssh
 %attr(0755,root,root) %{_sysconfdir}/init.d/%{name}-agent
+%attr(0644,root,root) %{_sysconfdir}/profile.d/%{name}-agent-profile.sh
 %attr(0755,root,root) %{_datadir}/%{name}-common/scripts/network/cisco
 %config(noreplace) %{_sysconfdir}/%{name}/agent
 %dir %{_localstatedir}/log/%{name}/agent

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e5d30845/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java b/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java
index 774f68e..48be8f2 100644
--- a/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java
+++ b/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java
@@ -205,10 +205,14 @@ public abstract class LibvirtServerDiscoverer extends DiscovererBase
implements
             parameters += " --guestNic=" + kvmGuestNic;
             parameters += " --hypervisor=" + cluster.getHypervisorType().toString().toLowerCase();
 
+            String setupAgentCommand = "cloudstack-setup-agent ";
+            if (!username.equals("root")) {
+                setupAgentCommand = "sudo cloudstack-setup-agent ";
+            }
             if (!SSHCmdHelper.sshExecuteCmd(sshConnection,
-                    "cloudstack-setup-agent " + parameters, 3)) {
+                    setupAgentCommand + parameters, 3)) {
                 s_logger.info("cloudstack agent setup command failed: "
-                        + "cloudstack-setup-agent " + parameters);
+                        + setupAgentCommand + parameters);
                 return null;
             }
 


Mime
View raw message