diff --git a/README.md b/README.md index 514e1d7c4b..4f13473b37 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ The argument expression *[OPTIONAL]* is used to set non-default values for: parsers yes if you want to rebuild flex/bison files new_xmlpc yes if you have an xmlrpc-c version >= 1.31 sunstone yes if you want to build sunstone minified files + systemd yes if you want to build systemd support ### Installation diff --git a/SConstruct b/SConstruct index fa6b8bcd05..8c805103b3 100644 --- a/SConstruct +++ b/SConstruct @@ -143,6 +143,15 @@ if xmlrpc_dir!='none': main_env.Append(LIBPATH=[xmlrpc_dir+"/lib", xmlrpc_dir+"/lib64"]) main_env.Append(CPPPATH=[xmlrpc_dir+"/include"]) +# systemd +systemd=ARGUMENTS.get('systemd', 'no') +if systemd=='yes': + main_env.Append(systemd='yes') + main_env.Append(CPPFLAGS=["-DSYSTEMD"]) + main_env.Append(LIBS=['systemd']) +else: + main_env.Append(systemd='no') + # build lex/bison build_parsers=ARGUMENTS.get('parsers', 'no') if build_parsers=='yes': diff --git a/share/hooks/raft/vip.sh b/share/hooks/raft/vip.sh index 14fd01f729..1139333a21 100755 --- a/share/hooks/raft/vip.sh +++ b/share/hooks/raft/vip.sh @@ -15,6 +15,14 @@ if [ -z "$IFADDR" ]; then exit 1 fi +### + +if which systemctl &>/dev/null && [ -d /etc/systemd ]; then + IS_SYSTEMD=yes +else + IS_SYSTEMD=no +fi + case $ACTION in leader) sudo ip address add $IFADDR dev $INTERFACE @@ -26,10 +34,22 @@ leader) sleep 1 done - if which oneflow-server &>/dev/null && - [ ! -e /var/run/one/oneflow.pid ]; - then - oneflow-server start + if [ "${IS_SYSTEMD}" = 'yes' ]; then + if systemctl is-enabled opennebula-flow >/dev/null 2>&1; then + sudo -n systemctl start opennebula-flow + fi + + if systemctl is-enabled opennebula-gate >/dev/null 2>&1; then + sudo -n systemctl start opennebula-gate + fi + else + if [ -e /usr/lib/one/oneflow/oneflow-server.rb ]; then + sudo -n service opennebula-flow start + fi + + if [ -e /usr/lib/one/onegate/onegate-server.rb ]; then + sudo -n service opennebula-gate start + fi fi ;; @@ -38,10 +58,22 @@ follower) sudo ip address del $IFADDR dev $INTERFACE fi - if which oneflow-server &>/dev/null && - [ -e /var/run/one/oneflow.pid ]; - then - oneflow-server stop + if [ "${IS_SYSTEMD}" = 'yes' ]; then + if systemctl is-active opennebula-flow >/dev/null 2>&1; then + sudo -n systemctl stop opennebula-flow + fi + + if systemctl is-active opennebula-gate >/dev/null 2>&1; then + sudo -n systemctl stop opennebula-gate + fi + else + if [ -e /usr/lib/one/oneflow/oneflow-server.rb ]; then + sudo -n service opennebula-flow stop + fi + + if [ -e /usr/lib/one/onegate/onegate-server.rb ]; then + sudo -n service opennebula-gate stop + fi fi ;; diff --git a/share/pkgs/CentOS/opennebula.sudoers b/share/pkgs/CentOS/opennebula.sudoers index 939f216fcc..972e88d6ec 100644 --- a/share/pkgs/CentOS/opennebula.sudoers +++ b/share/pkgs/CentOS/opennebula.sudoers @@ -8,5 +8,6 @@ Cmnd_Alias ONE_ISCSI = /sbin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm Cmnd_Alias ONE_CEPH = /usr/bin/rbd +Cmnd_Alias ONE_HA = /usr/bin/systemctl start opennebula-flow, /usr/bin/systemctl stop opennebula-flow, /usr/bin/systemctl start opennebula-gate, /usr/bin/systemctl stop opennebula-gate, /usr/sbin/service opennebula-flow start, /usr/sbin/service opennebula-flow stop, /usr/sbin/service opennebula-gate start, /usr/sbin/service opennebula-gate stop -oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN, ONE_CEPH +oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN, ONE_CEPH, ONE_HA diff --git a/share/pkgs/CentOS7/opennebula-econe.service b/share/pkgs/CentOS7/opennebula-econe.service index dd27cf80ee..d99874daf7 100644 --- a/share/pkgs/CentOS7/opennebula-econe.service +++ b/share/pkgs/CentOS7/opennebula-econe.service @@ -1,15 +1,15 @@ [Unit] Description=OpenNebula econe Server -After=syslog.target -After=network.target +After=syslog.target network.target +After=opennebula.service +AssertFileNotEmpty=/var/lib/one/.one/ec2_auth [Service] Type=simple Group=oneadmin User=oneadmin - +ExecStartPre=-/usr/sbin/logrotate -f /etc/logrotate.d/opennebula-econe -s /var/lib/one/.logrotate.status ExecStart=/usr/bin/ruby /usr/lib/one/ruby/cloud/econe/econe-server.rb -PIDFile=/var/run/one/econe-server.pid [Install] WantedBy=multi-user.target diff --git a/share/pkgs/CentOS7/opennebula-flow.service b/share/pkgs/CentOS7/opennebula-flow.service index ca1e685cb5..f0ac04effb 100644 --- a/share/pkgs/CentOS7/opennebula-flow.service +++ b/share/pkgs/CentOS7/opennebula-flow.service @@ -1,16 +1,15 @@ [Unit] Description=OpenNebula Flow Service -After=syslog.target -After=network.target +After=syslog.target network.target +After=opennebula.service +AssertFileNotEmpty=/var/lib/one/.one/oneflow_auth [Service] -Type=forking +Type=simple Group=oneadmin User=oneadmin -ExecStartPre=-/bin/bash -c 'for i in {1..20}; do test -f /var/lib/one/.one/oneflow_auth && break; sleep 1; done' -ExecStart=/usr/bin/oneflow-server start -ExecStop=/usr/bin/oneflow-server stop -PIDFile=/var/run/one/oneflow.pid +ExecStartPre=-/usr/sbin/logrotate -f /etc/logrotate.d/opennebula-flow -s /var/lib/one/.logrotate.status +ExecStart=/usr/bin/ruby /usr/lib/one/oneflow/oneflow-server.rb [Install] WantedBy=multi-user.target diff --git a/share/pkgs/CentOS7/opennebula-gate.service b/share/pkgs/CentOS7/opennebula-gate.service index 6c1ac30a20..3186f582b8 100644 --- a/share/pkgs/CentOS7/opennebula-gate.service +++ b/share/pkgs/CentOS7/opennebula-gate.service @@ -1,15 +1,15 @@ [Unit] Description=OpenNebula Gate Service -After=syslog.target -After=network.target +After=syslog.target network.target +After=opennebula.service +AssertFileNotEmpty=/var/lib/one/.one/onegate_auth [Service] Type=simple Group=oneadmin User=oneadmin - +ExecStartPre=-/usr/sbin/logrotate -f /etc/logrotate.d/opennebula-gate -s /var/lib/one/.logrotate.status ExecStart=/usr/bin/ruby /usr/lib/one/onegate/onegate-server.rb -PIDFile=/var/run/one/onegate.pid [Install] WantedBy=multi-user.target diff --git a/share/pkgs/CentOS7/opennebula-novnc.service b/share/pkgs/CentOS7/opennebula-novnc.service index 52de891c93..16f3a1728f 100644 --- a/share/pkgs/CentOS7/opennebula-novnc.service +++ b/share/pkgs/CentOS7/opennebula-novnc.service @@ -1,14 +1,12 @@ [Unit] Description=OpenNebula noVNC Server -After=syslog.target -After=network.target -Before=opennebula-sunstone.service +After=syslog.target network.target [Service] Type=forking Group=oneadmin User=oneadmin - +ExecStartPre=-/usr/sbin/logrotate -f /etc/logrotate.d/opennebula-novnc -s /var/lib/one/.logrotate.status ExecStart=/usr/bin/novnc-server start PIDFile=/var/lock/one/.novnc.lock diff --git a/share/pkgs/CentOS7/opennebula-scheduler.service b/share/pkgs/CentOS7/opennebula-scheduler.service index eb99b101dc..f3b00d2e2e 100644 --- a/share/pkgs/CentOS7/opennebula-scheduler.service +++ b/share/pkgs/CentOS7/opennebula-scheduler.service @@ -1,20 +1,16 @@ [Unit] Description=OpenNebula Cloud Scheduler Daemon -After=syslog.target -After=network.target -After=remote-fs.target +After=syslog.target network.target remote-fs.target After=opennebula.service -BindTo=opennebula.service [Service] Type=simple Group=oneadmin User=oneadmin - +ExecStartPre=-/usr/sbin/logrotate -f /etc/logrotate.d/opennebula-scheduler -s /var/lib/one/.logrotate.status ExecStart=/usr/bin/mm_sched -ExecStop=/bin/kill -TERM $MAINPID -PIDFile=/var/run/one/sched.pid +Restart=on-failure +RestartSec=1 [Install] WantedBy=multi-user.target - diff --git a/share/pkgs/CentOS7/opennebula-sunstone.service b/share/pkgs/CentOS7/opennebula-sunstone.service index 52414ea859..40ebe2ce56 100644 --- a/share/pkgs/CentOS7/opennebula-sunstone.service +++ b/share/pkgs/CentOS7/opennebula-sunstone.service @@ -1,19 +1,16 @@ [Unit] Description=OpenNebula Web UI Server -After=syslog.target -After=network.target +After=syslog.target network.target After=opennebula.service -After=opennebula-novnc.service -BindTo=opennebula-novnc.service +Wants=opennebula-novnc.service +AssertFileNotEmpty=/var/lib/one/.one/sunstone_auth [Service] Type=simple Group=oneadmin User=oneadmin - +ExecStartPre=-/usr/sbin/logrotate -f /etc/logrotate.d/opennebula-sunstone -s /var/lib/one/.logrotate.status ExecStart=/usr/bin/ruby /usr/lib/one/sunstone/sunstone-server.rb -ExecStartPre=-/usr/sbin/logrotate -s /tmp/logrotate.state -f /etc/logrotate.d/opennebula -PIDFile=/var/run/one/sunstone.pid [Install] WantedBy=multi-user.target diff --git a/share/pkgs/CentOS7/opennebula.service b/share/pkgs/CentOS7/opennebula.service index 31be9f8c5a..dce81aa3e7 100644 --- a/share/pkgs/CentOS7/opennebula.service +++ b/share/pkgs/CentOS7/opennebula.service @@ -1,28 +1,19 @@ [Unit] Description=OpenNebula Cloud Controller Daemon -After=syslog.target -After=network.target -After=remote-fs.target +After=syslog.target network.target remote-fs.target After=mariadb.service mysql.service -Before=opennebula-scheduler.service -BindTo=opennebula-scheduler.service +Wants=opennebula-scheduler.service [Service] -Type=simple +Type=notify Group=oneadmin User=oneadmin - -# Start daemon in foreground mode, when starting as forking process the -# daemon shuts down without obvious reason. +ExecStartPre=-/usr/sbin/logrotate -f /etc/logrotate.d/opennebula -s /var/lib/one/.logrotate.status ExecStart=/usr/bin/oned -f -# Log file location must exist -ExecStartPre=/bin/mkdir -p /var/log/one -ExecStartPre=/bin/chown oneadmin:oneadmin /var/log/one -ExecStartPre=-/usr/sbin/logrotate -s /tmp/logrotate.state -f /etc/logrotate.d/opennebula -ExecStop=/bin/kill -TERM $MAINPID -ExecStopPost=/bin/rm -f /var/lock/one/one ExecStopPost=/usr/share/one/follower_cleanup -PIDFile=/var/run/one/oned.pid +PIDFile=/var/lock/one/one +Restart=on-failure +RestartSec=1 [Install] WantedBy=multi-user.target diff --git a/share/pkgs/Debian7/opennebula.sudoers b/share/pkgs/Debian7/opennebula.sudoers index f98a236d22..ecafefd943 100644 --- a/share/pkgs/Debian7/opennebula.sudoers +++ b/share/pkgs/Debian7/opennebula.sudoers @@ -8,5 +8,6 @@ Cmnd_Alias ONE_ISCSI = /usr/bin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm Cmnd_Alias ONE_CEPH = /usr/bin/rbd +Cmnd_Alias ONE_HA = /bin/systemctl start opennebula-flow, /bin/systemctl stop opennebula-flow, /bin/systemctl start opennebula-gate, /bin/systemctl stop opennebula-gate, /usr/sbin/service opennebula-flow start, /usr/sbin/service opennebula-flow stop, /usr/sbin/service opennebula-gate start, /usr/sbin/service opennebula-gate stop -oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN, ONE_CEPH +oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN, ONE_CEPH, ONE_HA diff --git a/share/pkgs/Debian8/opennebula.sudoers b/share/pkgs/Debian8/opennebula.sudoers index f8f1ff6fab..0a1238a2f0 100644 --- a/share/pkgs/Debian8/opennebula.sudoers +++ b/share/pkgs/Debian8/opennebula.sudoers @@ -8,5 +8,6 @@ Cmnd_Alias ONE_ISCSI = /usr/bin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm Cmnd_Alias ONE_CEPH = /usr/bin/rbd +Cmnd_Alias ONE_HA = /bin/systemctl start opennebula-flow, /bin/systemctl stop opennebula-flow, /bin/systemctl start opennebula-gate, /bin/systemctl stop opennebula-gate, /usr/sbin/service opennebula-flow start, /usr/sbin/service opennebula-flow stop, /usr/sbin/service opennebula-gate start, /usr/sbin/service opennebula-gate stop -oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN, ONE_CEPH +oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN, ONE_CEPH, ONE_HA diff --git a/share/pkgs/Ubuntu/opennebula b/share/pkgs/Ubuntu/opennebula index 4f37595238..758fa89fcc 100755 --- a/share/pkgs/Ubuntu/opennebula +++ b/share/pkgs/Ubuntu/opennebula @@ -1,4 +1,4 @@ -#! /bin/sh +#! /bin/bash ### BEGIN INIT INFO # Provides: opennebula # Required-Start: $remote_fs $syslog @@ -38,7 +38,22 @@ do_start() { mkdir -p /var/run/one /var/lock/one chown oneadmin /var/run/one /var/lock/one + logrotate -f /etc/logrotate.d/opennebula /etc/logrotate.d/opennebula-scheduler su oneadmin -s /bin/sh -c 'one start' + ONE_START=$? + + # wait for the service to be ready + RETRIES=30 + while ! onegroup list >/dev/null 2>&1; do + RETRIES=$((RETRIES - 1)) + if [ ${RETRIES} -le 0 ]; then + return 2 + fi + + sleep 2 + done + + return $ONE_START } # @@ -51,6 +66,7 @@ do_stop() do_start_sched() { + logrotate -f /etc/logrotate.d/opennebula-scheduler su oneadmin -s /bin/sh -c 'one start-sched' } diff --git a/share/pkgs/Ubuntu/opennebula-econe b/share/pkgs/Ubuntu/opennebula-econe index 31003b2b0d..cc48eb0725 100755 --- a/share/pkgs/Ubuntu/opennebula-econe +++ b/share/pkgs/Ubuntu/opennebula-econe @@ -36,6 +36,7 @@ do_start() { mkdir -p /var/run/one /var/lock/one /var/log/one chown oneadmin /var/run/one /var/lock/one /var/log/one + logrotate -f /etc/logrotate.d/opennebula-econe su oneadmin -s /bin/sh -c "$DAEMON start" } diff --git a/share/pkgs/Ubuntu/opennebula-flow b/share/pkgs/Ubuntu/opennebula-flow index b670b8b05b..da821c138b 100755 --- a/share/pkgs/Ubuntu/opennebula-flow +++ b/share/pkgs/Ubuntu/opennebula-flow @@ -36,6 +36,7 @@ do_start() { mkdir -p /var/run/one /var/lock/one /var/log/one chown oneadmin /var/run/one /var/lock/one /var/log/one + logrotate -f /etc/logrotate.d/opennebula-flow su oneadmin -s /bin/sh -c "$DAEMON start" } diff --git a/share/pkgs/Ubuntu/opennebula-gate b/share/pkgs/Ubuntu/opennebula-gate index f4d7471df2..7b03dae32f 100755 --- a/share/pkgs/Ubuntu/opennebula-gate +++ b/share/pkgs/Ubuntu/opennebula-gate @@ -36,6 +36,7 @@ do_start() { mkdir -p /var/run/one /var/lock/one /var/log/one chown oneadmin /var/run/one /var/lock/one /var/log/one + logrotate -f /etc/logrotate.d/opennebula-gate su oneadmin -s /bin/sh -c "$DAEMON start" } diff --git a/share/pkgs/Ubuntu/opennebula-novnc b/share/pkgs/Ubuntu/opennebula-novnc index f583a5fe1c..2bff30a69c 100644 --- a/share/pkgs/Ubuntu/opennebula-novnc +++ b/share/pkgs/Ubuntu/opennebula-novnc @@ -35,6 +35,7 @@ do_start() { mkdir -p /var/lock/one /var/log/one chown oneadmin /var/lock/one /var/log/one + logrotate -f /etc/logrotate.d/opennebula-novnc su oneadmin -s /bin/sh -c "$DAEMON start" } diff --git a/share/pkgs/Ubuntu/opennebula-sunstone b/share/pkgs/Ubuntu/opennebula-sunstone index 34e9e1fbfb..d769427078 100755 --- a/share/pkgs/Ubuntu/opennebula-sunstone +++ b/share/pkgs/Ubuntu/opennebula-sunstone @@ -37,6 +37,7 @@ do_start() service opennebula-novnc start mkdir -p /var/run/one /var/lock/one /var/log/one chown oneadmin /var/run/one /var/lock/one /var/log/one + logrotate -f /etc/logrotate.d/opennebula-sunstone su oneadmin -s /bin/sh -c "$DAEMON start-sunstone" } diff --git a/share/pkgs/Ubuntu/opennebula.sudoers b/share/pkgs/Ubuntu/opennebula.sudoers index f8f1ff6fab..0a1238a2f0 100644 --- a/share/pkgs/Ubuntu/opennebula.sudoers +++ b/share/pkgs/Ubuntu/opennebula.sudoers @@ -8,5 +8,6 @@ Cmnd_Alias ONE_ISCSI = /usr/bin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm Cmnd_Alias ONE_CEPH = /usr/bin/rbd +Cmnd_Alias ONE_HA = /bin/systemctl start opennebula-flow, /bin/systemctl stop opennebula-flow, /bin/systemctl start opennebula-gate, /bin/systemctl stop opennebula-gate, /usr/sbin/service opennebula-flow start, /usr/sbin/service opennebula-flow stop, /usr/sbin/service opennebula-gate start, /usr/sbin/service opennebula-gate stop -oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN, ONE_CEPH +oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN, ONE_CEPH, ONE_HA diff --git a/share/pkgs/logrotate/opennebula b/share/pkgs/logrotate/opennebula index 6b8db4c0b8..d37ed3975d 100644 --- a/share/pkgs/logrotate/opennebula +++ b/share/pkgs/logrotate/opennebula @@ -6,20 +6,8 @@ compress weekly rotate 52 -/var/log/one/one_xmlrpc.log { - missingok - notifempty - copytruncate -} - -/var/log/one/oned.log { - missingok - notifempty - copytruncate -} - -/var/log/one/sched.log { - missingok - notifempty - copytruncate +/var/log/one/one_xmlrpc.log /var/log/one/oned.log { + missingok + notifempty + copytruncate } diff --git a/share/pkgs/logrotate/opennebula-econe b/share/pkgs/logrotate/opennebula-econe new file mode 100644 index 0000000000..6b1668e815 --- /dev/null +++ b/share/pkgs/logrotate/opennebula-econe @@ -0,0 +1,13 @@ +delaycompress +dateext +dateformat -%Y%m%d-%s + +compress +weekly +rotate 52 + +/var/log/one/econe-server.log { + missingok + notifempty + copytruncate +} diff --git a/share/pkgs/logrotate/opennebula-flow b/share/pkgs/logrotate/opennebula-flow new file mode 100644 index 0000000000..9d1fd2acfe --- /dev/null +++ b/share/pkgs/logrotate/opennebula-flow @@ -0,0 +1,13 @@ +delaycompress +dateext +dateformat -%Y%m%d-%s + +compress +weekly +rotate 52 + +/var/log/one/oneflow.log { + missingok + notifempty + copytruncate +} diff --git a/share/pkgs/logrotate/opennebula-gate b/share/pkgs/logrotate/opennebula-gate new file mode 100644 index 0000000000..a586d4d68c --- /dev/null +++ b/share/pkgs/logrotate/opennebula-gate @@ -0,0 +1,13 @@ +delaycompress +dateext +dateformat -%Y%m%d-%s + +compress +weekly +rotate 52 + +/var/log/one/onegate.log { + missingok + notifempty + copytruncate +} diff --git a/share/pkgs/logrotate/opennebula-novnc b/share/pkgs/logrotate/opennebula-novnc new file mode 100644 index 0000000000..07f69163d3 --- /dev/null +++ b/share/pkgs/logrotate/opennebula-novnc @@ -0,0 +1,13 @@ +delaycompress +dateext +dateformat -%Y%m%d-%s + +compress +weekly +rotate 52 + +/var/log/one/novnc.log { + missingok + notifempty + copytruncate +} diff --git a/share/pkgs/logrotate/opennebula-scheduler b/share/pkgs/logrotate/opennebula-scheduler new file mode 100644 index 0000000000..07752e3809 --- /dev/null +++ b/share/pkgs/logrotate/opennebula-scheduler @@ -0,0 +1,13 @@ +delaycompress +dateext +dateformat -%Y%m%d-%s + +compress +weekly +rotate 52 + +/var/log/one/sched.log { + missingok + notifempty + copytruncate +} diff --git a/share/pkgs/logrotate/opennebula-sunstone b/share/pkgs/logrotate/opennebula-sunstone new file mode 100644 index 0000000000..945885b744 --- /dev/null +++ b/share/pkgs/logrotate/opennebula-sunstone @@ -0,0 +1,13 @@ +delaycompress +dateext +dateformat -%Y%m%d-%s + +compress +weekly +rotate 52 + +/var/log/one/sunstone.log { + missingok + notifempty + copytruncate +} diff --git a/share/pkgs/openSUSE/opennebula.sudoers b/share/pkgs/openSUSE/opennebula.sudoers index f54a956592..fc6a53acc7 100644 --- a/share/pkgs/openSUSE/opennebula.sudoers +++ b/share/pkgs/openSUSE/opennebula.sudoers @@ -7,5 +7,6 @@ Cmnd_Alias ONE_LVM = /sbin/lvcreate, /sbin/lvremove, /sbin/lvs, /sbin/vgdisplay, Cmnd_Alias ONE_ISCSI = /sbin/iscsiadm, /usr/sbin/tgt-admin, /usr/sbin/tgtadm Cmnd_Alias ONE_OVS = /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl Cmnd_Alias ONE_XEN = /usr/sbin/xentop, /usr/sbin/xl, /usr/sbin/xm +Cmnd_Alias ONE_HA = /usr/bin/systemctl start opennebula-flow, /usr/bin/systemctl stop opennebula-flow, /usr/bin/systemctl start opennebula-gate, /usr/bin/systemctl stop opennebula-gate, /sbin/service opennebula-flow start, /sbin/service opennebula-flow stop, /sbin/service opennebula-gate start, /sbin/service opennebula-gate stop -oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN +oneadmin ALL=(ALL) NOPASSWD: ONE_MISC, ONE_NET, ONE_LVM, ONE_ISCSI, ONE_OVS, ONE_XEN, ONE_HA diff --git a/share/sudoers/sudo_commands.rb b/share/sudoers/sudo_commands.rb old mode 100644 new mode 100755 index 21b6fa2cfd..7a88246a50 --- a/share/sudoers/sudo_commands.rb +++ b/share/sudoers/sudo_commands.rb @@ -26,7 +26,17 @@ CMDS = { :ISCSI => %w(iscsiadm tgt-admin tgtadm), :OVS => %w(ovs-ofctl ovs-vsctl), :XEN => %w(xentop xl xm), - :CEPH => %w(rbd) + :CEPH => %w(rbd), + :HA => [ + 'systemctl start opennebula-flow', + 'systemctl stop opennebula-flow', + 'systemctl start opennebula-gate', + 'systemctl stop opennebula-gate', + 'service opennebula-flow start', + 'service opennebula-flow stop', + 'service opennebula-gate start', + 'service opennebula-gate stop' + ], } KEYS = CMDS.keys @@ -39,10 +49,12 @@ KEYS.each do |label| _abs_cmds = [] cmds.each do |cmd| - abs_cmd = `which #{cmd} 2>/dev/null` + cmd_parts = cmd.split + abs_cmd = `which #{cmd_parts[0]} 2>/dev/null` if !abs_cmd.empty? - _abs_cmds << abs_cmd.strip + cmd_parts[0] = abs_cmd.strip + _abs_cmds << cmd_parts.join(' ') else not_found_cmds << cmd end diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index 7c90fc769e..9f37be549e 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -32,6 +32,10 @@ #include #include +#ifdef SYSTEMD +#include +#endif + using namespace std; /* -------------------------------------------------------------------------- */ @@ -1091,6 +1095,12 @@ void Nebula::start(bool bootstrap_only) throw runtime_error("Could not start the Request Manager"); } +#ifdef SYSTEMD + // ---- Notify service manager ---- + + sd_notify(0, "READY=1"); +#endif + // ----------------------------------------------------------- // Wait for a SIGTERM or SIGINT signal // -----------------------------------------------------------