This is an automated email from the ASF dual-hosted git repository. bhaisaab pushed a commit to branch debian9-systemvmtemplate in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 11031acfbc64ad4c40a40f5dd1806c718a9ff6eb Author: Rohit Yadav <[email protected]> AuthorDate: Sun Dec 3 22:32:13 2017 +0530 password server improvements and postinit reintroduction merge vpn to debian/ disable rvr setup for now Signed-off-by: Rohit Yadav <[email protected]> --- .../kvm/resource/LibvirtComputingResource.java | 11 +- .../patches/debian/etc/init.d/cloud-early-config | 6 +- .../patches/debian/etc/init.d/cloud-passwd-srvr | 118 --------------------- systemvm/patches/{vpn => debian}/etc/ipsec.conf | 0 .../patches/{vpn => debian}/etc/ipsec.d/l2tp.conf | 0 systemvm/patches/{vpn => debian}/etc/ipsec.secrets | 0 .../patches/{vpn => debian}/etc/ppp/options.xl2tpd | 0 systemvm/patches/debian/etc/rc.local | 9 ++ .../systemd/system/[email protected] | 11 ++ .../etc/systemd/system/cloud-postinit.service | 13 +++ .../debian/etc/systemd/system/cloud.service | 13 +++ .../patches/{vpn => debian}/etc/xl2tpd/xl2tpd.conf | 0 .../patches/debian/opt/cloud/bin/cs/CsAddress.py | 8 +- systemvm/patches/debian/opt/cloud/bin/cs/CsApp.py | 14 +-- .../patches/debian/opt/cloud/bin/cs/CsRedundant.py | 5 +- .../patches/debian/opt/cloud/bin/setup/common.sh | 6 +- .../debian/opt/cloud/bin/setup/consoleproxy.sh | 2 +- .../patches/debian/opt/cloud/bin/setup/dhcpsrvr.sh | 2 +- .../patches/debian/opt/cloud/bin/setup/elbvm.sh | 2 +- .../patches/debian/opt/cloud/bin/setup/ilbvm.sh | 2 +- .../debian/opt/cloud/bin/setup/patchsystemvm.sh | 3 +- .../opt/cloud/bin/setup/{ilbvm.sh => postinit.sh} | 32 ++---- .../debian/opt/cloud/bin/setup/secstorage.sh | 2 +- .../patches/debian/opt/cloud/bin/update_config.py | 17 ++- .../{vpn => debian}/opt/cloud/bin/vpn_l2tp.sh | 0 systemvm/pom.xml | 3 - .../configure_systemvm_services.sh | 36 ++----- tools/appliance/shar_cloud_scripts.sh | 7 +- 28 files changed, 99 insertions(+), 223 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 e139ecb..76f5e4c 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -341,17 +341,18 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv @Override public ExecutionResult createFileInVR(final String routerIp, final String path, final String filename, final String content) { final File permKey = new File("/root/.ssh/id_rsa.cloud"); - String error = null; - - s_logger.debug("Creating file in VR, with ip: " + routerIp + ", file: " + filename); + boolean success = true; + String details = "Creating file in VR, with ip: " + routerIp + ", file: " + filename; + s_logger.debug(details); try { SshHelper.scpTo(routerIp, 3922, "root", permKey, null, path, content.getBytes(), filename, null); } catch (final Exception e) { s_logger.warn("Fail to create file " + path + filename + " in VR " + routerIp, e); - error = e.getMessage(); + details = e.getMessage(); + success = false; } - return new ExecutionResult(error == null, error); + return new ExecutionResult(success, details); } @Override diff --git a/systemvm/patches/debian/etc/init.d/cloud-early-config b/systemvm/patches/debian/etc/init.d/cloud-early-config index 9964f90..5e3f7b6 100755 --- a/systemvm/patches/debian/etc/init.d/cloud-early-config +++ b/systemvm/patches/debian/etc/init.d/cloud-early-config @@ -192,10 +192,10 @@ patch() { tar xzf $patchfile -C / echo ${newmd5} > ${md5file} log_it "Patched scripts using $patchfile" - fi - log_it "Patching cloud service" - /opt/cloud/bin/setup/patchsystemvm.sh $PATCH_MOUNT $TYPE + log_it "Patching cloud service" + /opt/cloud/bin/setup/patchsystemvm.sh $PATCH_MOUNT $TYPE + fi [ -f $privkey ] && cp -f $privkey /root/.ssh/ && chmod go-rwx /root/.ssh/authorized_keys umount $PATCH_MOUNT diff --git a/systemvm/patches/debian/etc/init.d/cloud-passwd-srvr b/systemvm/patches/debian/etc/init.d/cloud-passwd-srvr deleted file mode 100755 index ffd0ec8..0000000 --- a/systemvm/patches/debian/etc/init.d/cloud-passwd-srvr +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash -### BEGIN INIT INFO -# Provides: cloud-passwd-srvr -# Required-Start: $local_fs cloud-early-config -# Required-Stop: $local_fs -# Default-Start: 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Web server that sends passwords to User VMs -### END INIT INFO -# 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. - -add_iptables_rules() -{ - #Delete any old iptables rule for port 8080 on eth0 - remove_iptables_rules - - #For all cidrs on eth0 for port 8080 accept only if source is withing that cidr - for cidr in $(ip addr | grep eth0 | grep inet | awk '{print $2}'); - do - count=1 - #Try for 10 times, if it still fails then bail - while [ $count -le 10 ]; - do - (( count++ )) - iptables -A INPUT -i eth0 -p tcp -m state --state NEW -m tcp -s $cidr --dport 8080 -j ACCEPT - if [ `iptables -L INPUT -n -v | grep eth0 | grep 8080 | grep ACCEPT | wc -l` -gt 0 ] - then - break - else - sleep 2 - fi - done - done - echo "Added cloud-passwd-srvr iptables rules" && return 0 -} - -remove_iptables_rules() -{ - #Change the Internal Field Separator so the for loop, loops on lines and not spaces - OIFS="${IFS}" - NIFS=$'\n' - IFS="${NIFS}" - - #Removed all iptable rules for port 8080 on eth0, they were added in start() - for srcdest in `iptables -L -n -v | grep eth0 | grep 8080 | grep ACCEPT | awk '{print "--source "$8" --destination "$9}'`; - do - eval "iptables -D INPUT -i eth0 -p tcp -m state --state NEW -m tcp $srcdest --dport 8080 -j ACCEPT"; - done - - #Restore IFS - IFS="${OIFS}" - - echo "Removed cloud-passwd-srvr iptables rules" && return 0 -} - -start() { - pid=$(getpid) - [ "$pid" != "" ] && echo "Password server is already running (pid=$pid)" && return 0 - add_iptables_rules - nohup bash /opt/cloud/bin/passwd_server & -} - -getpid() { - pid=$(ps -ef | grep passwd_server_ip | grep -v grep | awk '{print $2}') - echo $pid -} - -stop_password_server() { - spid=$(pidof -s python passwd_server_ip.py) - [ "$spid" != "" ] && kill -9 $spid && echo "Killed password server (pid=$spid)" - return 0 -} - -stop () { - stop_password_server - pid=$(getpid) - [ "$pid" != "" ] && kill -9 $pid && remove_iptables_rules && echo "Stopped password server (pid=$pid)" && stop_password_server && return 0 - - echo "Password server is not running" && return 0 -} - -status () { - pid=$(getpid) - [ "$pid" != "" ] && echo "Password server is running (pid=$pid)" && return 0 - echo "Password server is not running" && return 0 -} - -case "$1" in - start) start - ;; - stop) stop - ;; - status) status - ;; - restart) stop - start - ;; - *) echo "Usage: $0 {start|stop|status|restart}" - exit 1 - ;; -esac - -exit 0 diff --git a/systemvm/patches/vpn/etc/ipsec.conf b/systemvm/patches/debian/etc/ipsec.conf similarity index 100% rename from systemvm/patches/vpn/etc/ipsec.conf rename to systemvm/patches/debian/etc/ipsec.conf diff --git a/systemvm/patches/vpn/etc/ipsec.d/l2tp.conf b/systemvm/patches/debian/etc/ipsec.d/l2tp.conf similarity index 100% rename from systemvm/patches/vpn/etc/ipsec.d/l2tp.conf rename to systemvm/patches/debian/etc/ipsec.d/l2tp.conf diff --git a/systemvm/patches/vpn/etc/ipsec.secrets b/systemvm/patches/debian/etc/ipsec.secrets similarity index 100% rename from systemvm/patches/vpn/etc/ipsec.secrets rename to systemvm/patches/debian/etc/ipsec.secrets diff --git a/systemvm/patches/vpn/etc/ppp/options.xl2tpd b/systemvm/patches/debian/etc/ppp/options.xl2tpd similarity index 100% rename from systemvm/patches/vpn/etc/ppp/options.xl2tpd rename to systemvm/patches/debian/etc/ppp/options.xl2tpd diff --git a/systemvm/patches/debian/etc/rc.local b/systemvm/patches/debian/etc/rc.local index 895c120..bb4e251 100755 --- a/systemvm/patches/debian/etc/rc.local +++ b/systemvm/patches/debian/etc/rc.local @@ -67,3 +67,12 @@ then python /opt/cloud/bin/baremetal-vr.py & logger -t cloud "Started baremetal-vr service" fi + +if [ "$TYPE" == "router" ] || [ "$TYPE" == "vpcrouter" ] || [ "$TYPE" == "dhcpsrvr" ] +then + if [ -x /opt/cloud/bin/update_config.py ] + then + /opt/cloud/bin/update_config.py cmd_line.json + logger -t cloud "Updated config: cmd_line.json" + fi +fi diff --git a/systemvm/patches/debian/etc/systemd/system/[email protected] b/systemvm/patches/debian/etc/systemd/system/[email protected] new file mode 100644 index 0000000..8ee9e79 --- /dev/null +++ b/systemvm/patches/debian/etc/systemd/system/[email protected] @@ -0,0 +1,11 @@ +[Unit] +Description=Cloud password server on %I +After=network.target local-fs.target + +[Install] +WantedBy=multi-user.target + +[Service] +Type=simple +WorkingDirectory=/opt/cloud/bin +ExecStart=/opt/cloud/bin/passwd_server_ip.py %I diff --git a/systemvm/patches/debian/etc/systemd/system/cloud-postinit.service b/systemvm/patches/debian/etc/systemd/system/cloud-postinit.service new file mode 100644 index 0000000..a5ca9b0 --- /dev/null +++ b/systemvm/patches/debian/etc/systemd/system/cloud-postinit.service @@ -0,0 +1,13 @@ +[Unit] +Description=cloud-postinit: post init script +After=cloud-early-config.service network.target local-fs.target +Before=ssh.service +Requires=network.service + +[Install] +WantedBy=multi-user.target + +[Service] +Type=oneshot +ExecStart=/opt/cloud/bin/setup/postinit.sh +RemainAfterExit=true diff --git a/systemvm/patches/debian/etc/systemd/system/cloud.service b/systemvm/patches/debian/etc/systemd/system/cloud.service new file mode 100644 index 0000000..9cd0f49 --- /dev/null +++ b/systemvm/patches/debian/etc/systemd/system/cloud.service @@ -0,0 +1,13 @@ +[Unit] +Description=cloud: startup cloud service +After=cloud-early-config.service network.target local-fs.target + +[Install] +WantedBy=multi-user.target + +[Service] +Type=simple +WorkingDirectory=/usr/local/cloud/systemvm +ExecStart=/usr/local/cloud/systemvm/_run.sh +Restart=always +RestartSec=5 diff --git a/systemvm/patches/vpn/etc/xl2tpd/xl2tpd.conf b/systemvm/patches/debian/etc/xl2tpd/xl2tpd.conf similarity index 100% rename from systemvm/patches/vpn/etc/xl2tpd/xl2tpd.conf rename to systemvm/patches/debian/etc/xl2tpd/xl2tpd.conf diff --git a/systemvm/patches/debian/opt/cloud/bin/cs/CsAddress.py b/systemvm/patches/debian/opt/cloud/bin/cs/CsAddress.py index d190a72..3980b18 100755 --- a/systemvm/patches/debian/opt/cloud/bin/cs/CsAddress.py +++ b/systemvm/patches/debian/opt/cloud/bin/cs/CsAddress.py @@ -565,9 +565,11 @@ class CsIP: app.setup() cmdline = self.config.cmdline() - # If redundant then this is dealt with by the master backup functions - if self.get_type() in ["guest"] and not cmdline.is_redundant(): - pwdsvc = CsPasswdSvc(self.address['public_ip']).start() + # Start password server on non-redundant routers and on master rVR + if self.get_type() in ["guest"] and (not cmdline.is_redundant() or cmdline.is_master()): + CsPasswdSvc(self.address['public_ip']).start() + else: + CsPasswdSvc(self.address['public_ip']).stop() if self.get_type() == "public" and self.config.is_vpc() and method == "add": if self.address["source_nat"]: diff --git a/systemvm/patches/debian/opt/cloud/bin/cs/CsApp.py b/systemvm/patches/debian/opt/cloud/bin/cs/CsApp.py index 496a0e7..2085088 100755 --- a/systemvm/patches/debian/opt/cloud/bin/cs/CsApp.py +++ b/systemvm/patches/debian/opt/cloud/bin/cs/CsApp.py @@ -16,7 +16,6 @@ # specific language governing permissions and limitations # under the License. import os -import CsHelper from CsFile import CsFile from CsProcess import CsProcess import CsHelper @@ -74,20 +73,13 @@ class CsPasswdSvc(): self.ip = ip def start(self): - proc = CsProcess(["dummy"]) - if proc.grep("passwd_server_ip %s" % self.ip) == -1: - proc.start("/opt/cloud/bin/passwd_server_ip %s >> /var/log/cloud.log 2>&1" % self.ip, "&") + CsHelper.service("cloud-password-server@%s" % self.ip, "start") def stop(self): - proc = CsProcess(["Password Service"]) - pid = proc.grep("passwd_server_ip %s" % self.ip) - proc.kill(pid) - pid = proc.grep("8080,reuseaddr,fork,crnl,bind=%s" % self.ip) - proc.kill(pid) + CsHelper.service("cloud-password-server@%s" % self.ip, "stop") def restart(self): - self.stop() - self.start() + CsHelper.service("cloud-password-server@%s" % self.ip, "restart") class CsDnsmasq(CsApp): diff --git a/systemvm/patches/debian/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/opt/cloud/bin/cs/CsRedundant.py index 99c7458..71c4eba 100755 --- a/systemvm/patches/debian/opt/cloud/bin/cs/CsRedundant.py +++ b/systemvm/patches/debian/opt/cloud/bin/cs/CsRedundant.py @@ -76,10 +76,11 @@ class CsRedundant(object): CsHelper.service("keepalived", "stop") #CsHelper.umount_tmpfs(self.CS_RAMDISK_DIR) #CsHelper.rmdir(self.CS_RAMDISK_DIR) - CsHelper.rm(self.CONNTRACKD_CONF) - CsHelper.rm(self.KEEPALIVED_CONF) + #CsHelper.rm(self.CONNTRACKD_CONF) + #CsHelper.rm(self.KEEPALIVED_CONF) def _redundant_on(self): + return guest = self.address.get_guest_if() # No redundancy if there is no guest network diff --git a/systemvm/patches/debian/opt/cloud/bin/setup/common.sh b/systemvm/patches/debian/opt/cloud/bin/setup/common.sh index e476745..4fc883d 100755 --- a/systemvm/patches/debian/opt/cloud/bin/setup/common.sh +++ b/systemvm/patches/debian/opt/cloud/bin/setup/common.sh @@ -596,18 +596,16 @@ routing_svcs() { echo "cloud nfs-common portmap" > /var/cache/cloud/disabled_svcs if [ $RROUTER -eq 1 ] then - systemctl disable --now cloud-passwd-srvr systemctl disable --now dnsmasq systemctl enable conntrackd systemctl enable keepalived echo "keepalived conntrackd" >> /var/cache/cloud/enabled_svcs - echo "dnsmasq cloud-passwd-srvr" >> /var/cache/cloud/disabled_svcs + echo "dnsmasq" >> /var/cache/cloud/disabled_svcs else systemctl disable --now conntrackd systemctl disable --now keepalived - systemctl enable cloud-passwd-srvr systemctl enable dnsmasq - echo "dnsmasq cloud-passwd-srvr " >> /var/cache/cloud/enabled_svcs + echo "dnsmasq" >> /var/cache/cloud/enabled_svcs echo "keepalived conntrackd " >> /var/cache/cloud/disabled_svcs fi } diff --git a/systemvm/patches/debian/opt/cloud/bin/setup/consoleproxy.sh b/systemvm/patches/debian/opt/cloud/bin/setup/consoleproxy.sh index 36c1fa4..ad23381 100755 --- a/systemvm/patches/debian/opt/cloud/bin/setup/consoleproxy.sh +++ b/systemvm/patches/debian/opt/cloud/bin/setup/consoleproxy.sh @@ -20,7 +20,7 @@ consoleproxy_svcs() { echo "cloud ssh" > /var/cache/cloud/enabled_svcs - echo "cloud-passwd-srvr haproxy dnsmasq apache2 nfs-common portmap" > /var/cache/cloud/disabled_svcs + echo "haproxy dnsmasq apache2 nfs-common portmap" > /var/cache/cloud/disabled_svcs mkdir -p /var/log/cloud } diff --git a/systemvm/patches/debian/opt/cloud/bin/setup/dhcpsrvr.sh b/systemvm/patches/debian/opt/cloud/bin/setup/dhcpsrvr.sh index 1e28ab4..d9a9c1a 100755 --- a/systemvm/patches/debian/opt/cloud/bin/setup/dhcpsrvr.sh +++ b/systemvm/patches/debian/opt/cloud/bin/setup/dhcpsrvr.sh @@ -19,7 +19,7 @@ . /opt/cloud/bin/setup/common.sh dhcpsrvr_svcs() { - echo "ssh dnsmasq cloud-passwd-srvr apache2" > /var/cache/cloud/enabled_svcs + echo "ssh dnsmasq apache2" > /var/cache/cloud/enabled_svcs echo "cloud nfs-common conntrackd keepalived haproxy portmap" > /var/cache/cloud/disabled_svcs } diff --git a/systemvm/patches/debian/opt/cloud/bin/setup/elbvm.sh b/systemvm/patches/debian/opt/cloud/bin/setup/elbvm.sh index 23a2607..fbae405 100755 --- a/systemvm/patches/debian/opt/cloud/bin/setup/elbvm.sh +++ b/systemvm/patches/debian/opt/cloud/bin/setup/elbvm.sh @@ -20,7 +20,7 @@ elbvm_svcs() { echo "ssh haproxy" > /var/cache/cloud/enabled_svcs - echo "cloud dnsmasq conntrackd keepalived cloud-passwd-srvr apache2 nfs-common portmap" > /var/cache/cloud/disabled_svcs + echo "cloud dnsmasq conntrackd keepalived apache2 nfs-common portmap" > /var/cache/cloud/disabled_svcs } setup_elbvm() { diff --git a/systemvm/patches/debian/opt/cloud/bin/setup/ilbvm.sh b/systemvm/patches/debian/opt/cloud/bin/setup/ilbvm.sh index 4cd599f..809be09 100755 --- a/systemvm/patches/debian/opt/cloud/bin/setup/ilbvm.sh +++ b/systemvm/patches/debian/opt/cloud/bin/setup/ilbvm.sh @@ -20,7 +20,7 @@ ilbvm_svcs() { echo "ssh haproxy" > /var/cache/cloud/enabled_svcs - echo "cloud dnsmasq conntrackd keepalived cloud-passwd-srvr apache2 nfs-common portmap" > /var/cache/cloud/disabled_svcs + echo "cloud dnsmasq conntrackd keepalived apache2 nfs-common portmap" > /var/cache/cloud/disabled_svcs } setup_ilbvm() { diff --git a/systemvm/patches/debian/opt/cloud/bin/setup/patchsystemvm.sh b/systemvm/patches/debian/opt/cloud/bin/setup/patchsystemvm.sh index d09cc03..2e9634d 100755 --- a/systemvm/patches/debian/opt/cloud/bin/setup/patchsystemvm.sh +++ b/systemvm/patches/debian/opt/cloud/bin/setup/patchsystemvm.sh @@ -1,4 +1,4 @@ -#/bin/bash +#!/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 @@ -55,3 +55,4 @@ then exit 1 fi fi +systemctl daemon-reload diff --git a/systemvm/patches/debian/opt/cloud/bin/setup/ilbvm.sh b/systemvm/patches/debian/opt/cloud/bin/setup/postinit.sh similarity index 55% copy from systemvm/patches/debian/opt/cloud/bin/setup/ilbvm.sh copy to systemvm/patches/debian/opt/cloud/bin/setup/postinit.sh index 4cd599f..6024329 100755 --- a/systemvm/patches/debian/opt/cloud/bin/setup/ilbvm.sh +++ b/systemvm/patches/debian/opt/cloud/bin/setup/postinit.sh @@ -18,31 +18,11 @@ . /opt/cloud/bin/setup/common.sh -ilbvm_svcs() { - echo "ssh haproxy" > /var/cache/cloud/enabled_svcs - echo "cloud dnsmasq conntrackd keepalived cloud-passwd-srvr apache2 nfs-common portmap" > /var/cache/cloud/disabled_svcs -} - -setup_ilbvm() { - log_it "Setting up Internal Load Balancer system vm" - setup_common eth0 eth1 - #eth0 = guest network, eth1=control network - - sed -i /$NAME/d /etc/hosts - echo "$ETH0_IP $NAME" >> /etc/hosts - - cp /etc/iptables/iptables-ilbvm /etc/iptables/rules.v4 - cp /etc/iptables/iptables-ilbvm /etc/iptables/rules - setup_sshd $ETH1_IP "eth1" - - enable_fwding 0 - enable_irqbalance 1 -} - -ilbvm_svcs -if [ $? -gt 0 ] +if [ "$TYPE" == "router" ] || [ "$TYPE" == "vpcrouter" ] || [ "$TYPE" == "dhcpsrvr" ] then - log_it "Failed to execute ilbvm svcs" - exit 1 + if [ -x /opt/cloud/bin/update_config.py ] + then + /opt/cloud/bin/update_config.py cmd_line.json + logger -t cloud "Updated config: cmd_line.json" + fi fi -setup_ilbvm diff --git a/systemvm/patches/debian/opt/cloud/bin/setup/secstorage.sh b/systemvm/patches/debian/opt/cloud/bin/setup/secstorage.sh index 327353c..5cdc4bb 100755 --- a/systemvm/patches/debian/opt/cloud/bin/setup/secstorage.sh +++ b/systemvm/patches/debian/opt/cloud/bin/setup/secstorage.sh @@ -20,7 +20,7 @@ secstorage_svcs() { echo "apache2 cloud ssh nfs-common portmap" > /var/cache/cloud/enabled_svcs - echo "cloud-passwd-srvr conntrackd keepalived haproxy dnsmasq" > /var/cache/cloud/disabled_svcs + echo "conntrackd keepalived haproxy dnsmasq" > /var/cache/cloud/disabled_svcs mkdir -p /var/log/cloud } diff --git a/systemvm/patches/debian/opt/cloud/bin/update_config.py b/systemvm/patches/debian/opt/cloud/bin/update_config.py index e36980a..9427bc8 100755 --- a/systemvm/patches/debian/opt/cloud/bin/update_config.py +++ b/systemvm/patches/debian/opt/cloud/bin/update_config.py @@ -24,11 +24,12 @@ from subprocess import PIPE, STDOUT import os import os.path import configure +import glob import json OCCURRENCES = 1 -logging.basicConfig(filename='/var/log/cloud.log', level=logging.INFO, format='%(asctime)s %(filename)s %(funcName)s:%(lineno)d %(message)s') +logging.basicConfig(filename='/var/log/cloud.log', level=logging.DEBUG, format='%(asctime)s %(filename)s %(funcName)s:%(lineno)d %(message)s') # first commandline argument should be the file to process if (len(sys.argv) != 2): @@ -41,14 +42,6 @@ jsonCmdConfigPath = jsonPath % sys.argv[1] currentGuestNetConfig = "/etc/cloudstack/guestnetwork.json" -# If the command line json file is unprocessed process it -# This is important or, the control interfaces will get deleted! -if os.path.isfile(jsonPath % "cmd_line.json"): - qf = QueueFile() - qf.setFile("cmd_line.json") - qf.load(None) - - def finish_config(): # Converge returncode = configure.main(sys.argv) @@ -82,7 +75,8 @@ def is_guestnet_configured(guestnet_dict, keys): print "[WARN] update_config.py :: Reconfiguring guest network..." return False - file = open(jsonCmdConfigPath) + filename = min(glob.iglob(jsonCmdConfigPath + '*'), key=os.path.getctime) + file = open(filename) new_guestnet_dict = json.load(file) if not new_guestnet_dict['add']: @@ -121,7 +115,8 @@ def is_guestnet_configured(guestnet_dict, keys): return exists -filename = jsonCmdConfigPath + +filename = min(glob.iglob(jsonCmdConfigPath + '*'), key=os.path.getctime) if not (os.path.isfile(filename) and os.access(filename, os.R_OK)): print "[ERROR] update_config.py :: You are telling me to process %s, but i can't access it" % jsonCmdConfigPath sys.exit(1) diff --git a/systemvm/patches/vpn/opt/cloud/bin/vpn_l2tp.sh b/systemvm/patches/debian/opt/cloud/bin/vpn_l2tp.sh similarity index 100% rename from systemvm/patches/vpn/opt/cloud/bin/vpn_l2tp.sh rename to systemvm/patches/debian/opt/cloud/bin/vpn_l2tp.sh diff --git a/systemvm/pom.xml b/systemvm/pom.xml index 0ae3e02..c22f71c 100644 --- a/systemvm/pom.xml +++ b/systemvm/pom.xml @@ -115,9 +115,6 @@ <fileset dir="${basedir}/patches/debian/"> <include name="**/*" /> </fileset> - <fileset dir="${basedir}/patches/vpn/"> - <include name="**/*" /> - </fileset> </copy> <copy overwrite="true" todir="${basedir}/target/build-patch/opt/cloud/bin/"> <fileset dir="${basedir}/../scripts/util/"> diff --git a/tools/appliance/definitions/systemvmtemplate/configure_systemvm_services.sh b/tools/appliance/definitions/systemvmtemplate/configure_systemvm_services.sh index 791f2ea..b4aaec9 100644 --- a/tools/appliance/definitions/systemvmtemplate/configure_systemvm_services.sh +++ b/tools/appliance/definitions/systemvmtemplate/configure_systemvm_services.sh @@ -36,7 +36,7 @@ function install_cloud_scripts() { rsync -av ./cloud_scripts/ / chmod +x /opt/cloud/bin/* \ /root/{clearUsageRules.sh,reconfigLB.sh,monitorServices.py} \ - /etc/init.d/{cloud-early-config,cloud-passwd-srvr} \ + /etc/init.d/{cloud-early-config} \ /etc/profile.d/cloud.sh cat > /etc/systemd/system/cloud-early-config.service << EOF @@ -62,42 +62,26 @@ TimeoutStartSec=5min EOF - cat > /etc/systemd/system/cloud.service << EOF + cat > /etc/systemd/system/cloud-postinit.service << EOF [Unit] -Description=cloud: startup cloud service +Description=cloud-postinit: post init script After=cloud-early-config.service network.target local-fs.target +Before=ssh.service +Requires=network.service [Install] WantedBy=multi-user.target [Service] -Type=simple -WorkingDirectory=/usr/local/cloud/systemvm -ExecStart=/usr/local/cloud/systemvm/_run.sh -Restart=always -RestartSec=5 -EOF - - cat > /etc/systemd/system/cloud-passwd-srvr.service << EOF -[Unit] -Description=cloud-passwd-srvr: cloud password server -After=network.target local-fs.target - -[Install] -WantedBy=multi-user.target - -[Service] -Type=forking -ExecStart=/etc/init.d/cloud-passwd-srvr start -ExecStop=/etc/init.d/cloud-passwd-srvr stop -Restart=always -RestartSec=5 +Type=oneshot +ExecStart=/opt/cloud/bin/setup/postinit.sh +RemainAfterExit=true +TimeoutStartSec=1min EOF systemctl daemon-reload systemctl enable cloud-early-config - systemctl disable cloud - systemctl disable cloud-passwd-srvr + systemctl enable cloud-postinit } function do_signature() { diff --git a/tools/appliance/shar_cloud_scripts.sh b/tools/appliance/shar_cloud_scripts.sh index 5504d16..d67f889 100755 --- a/tools/appliance/shar_cloud_scripts.sh +++ b/tools/appliance/shar_cloud_scripts.sh @@ -37,14 +37,11 @@ TEMP_DIR=`mktemp -d ${TMPDIR}/shar_cloud.XXXXXXXX` cd ${TEMP_DIR} mkdir cloud_scripts mkdir -p cloud_scripts/opt/cloudstack -cp -r ${CLOUDSTACK_DIR}/systemvm/patches/debian/config/* cloud_scripts/ -cp -r ${CLOUDSTACK_DIR}/systemvm/patches/debian/vpn/* cloud_scripts/ +cp -r ${CLOUDSTACK_DIR}/systemvm/patches/debian/* cloud_scripts/ mkdir -p cloud_scripts/usr/share/cloud -cd ${CLOUDSTACK_DIR}/systemvm/patches/debian/config +cd ${CLOUDSTACK_DIR}/systemvm/patches/debian tar -cf ${TEMP_DIR}/cloud_scripts/usr/share/cloud/cloud-scripts.tar * -cd ${CLOUDSTACK_DIR}/systemvm/patches/debian/vpn -tar -rf ${TEMP_DIR}/cloud_scripts/usr/share/cloud/cloud-scripts.tar * cd ${TEMP_DIR} shar `find . -print` > ${CURR_DIR}/cloud_scripts_shar_archive.sh -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
