cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mohammad Aladwan <m.alse...@gmail.com>
Subject Re: [GitHub] rhtyd closed pull request #2214: Speed-up VR initialisation/configuration
Date Mon, 11 Dec 2017 07:40:28 GMT
hi,

please i want to leave this group,i am not sure how i  can leave it


my best regards

On Sun, Dec 10, 2017 at 4:07 PM, GitBox <git@apache.org> wrote:

> rhtyd closed pull request #2214: Speed-up VR initialisation/configuration
> URL: https://github.com/apache/cloudstack/pull/2214
>
>
>
>
> This is a PR merged from a forked repository.
> As GitHub hides the original diff on merge, it is displayed below for
> the sake of provenance:
>
> As this is a foreign pull request (from a fork), the diff is supplied
> below (as it won't show otherwise due to GitHub magic):
>
> diff --git a/systemvm/patches/debian/buildsystemvm.sh
> b/systemvm/patches/debian/buildsystemvm.sh
> index a34b1dd0a61..f8726439925 100755
> --- a/systemvm/patches/debian/buildsystemvm.sh
> +++ b/systemvm/patches/debian/buildsystemvm.sh
> @@ -228,7 +228,7 @@ cat > etc/init.d/iptables-persistent << EOF
>  #!/bin/sh
>  ### BEGIN INIT INFO
>  # Provides:          iptables
> -# Required-Start:    mountkernfs $local_fs
> +# Required-Start:    mountkernfs $local_fs cloud-early-init
>  # Required-Stop:     $local_fs
>  # Should-Start:      cloud-early-config
>  # Default-Start:     S
> @@ -418,6 +418,8 @@ services() {
>
>    /bin/cp -r ${scriptdir}/config/* ./
>    chroot . chkconfig xl2tpd off
> +  chroot . chkconfig --add cloud-early-init
> +  chroot . chkconfig cloud-early-init on
>    chroot . chkconfig --add cloud-early-config
>    chroot . chkconfig cloud-early-config on
>    chroot . chkconfig --add iptables-persistent
> diff --git a/systemvm/patches/debian/config/etc/init.d/cloud
> b/systemvm/patches/debian/config/etc/init.d/cloud
> index f9a9915223e..47dd47b74da 100755
> --- a/systemvm/patches/debian/config/etc/init.d/cloud
> +++ b/systemvm/patches/debian/config/etc/init.d/cloud
> @@ -1,11 +1,11 @@
> -#!/bin/bash
> +#!/bin/bash
>  ### BEGIN INIT INFO
>  # Provides:          cloud
> -# Required-Start:    mountkernfs $local_fs cloud-early-config
> +# Required-Start:    mountkernfs $local_fs cloud-early-init
>  # Required-Stop:     $local_fs
> -# Should-Start:
> -# Should-Stop:
> -# Default-Start:
> +# Should-Start:
> +# Should-Stop:
> +# Default-Start:
>  # Default-Stop:      0 1 6
>  # Short-Description:   Start up the CloudStack cloud service
>  ### END INIT INFO
> @@ -44,7 +44,7 @@ for i in $CMDLINE
>    do
>      # search for foo=bar pattern and cut out foo
>      FIRSTPATTERN=$(echo $i | cut -d= -f1)
> -    case $FIRSTPATTERN in
> +    case $FIRSTPATTERN in
>        type)
>            TYPE=$(echo $i | cut -d= -f2)
>        ;;
> @@ -104,7 +104,7 @@ start() {
>       then
>         (cd $CLOUDSTACK_HOME/systemvm; nohup ./run.sh > $LOG_FILE 2>&1 &
)
>         pid=$(get_pids)
> -       echo $pid > /var/run/cloud.pid
> +       echo $pid > /var/run/cloud.pid
>       fi
>       _success
>     else
> @@ -137,7 +137,7 @@ status() {
>    return 0
>  }
>
> -[ "$ENABLED" != 0 ] || exit 0
> +[ "$ENABLED" != 0 ] || exit 0
>
>  case "$1" in
>     start) start
> 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 3bdebdbb798..cfbdd90f1cb 100755
> --- a/systemvm/patches/debian/config/etc/init.d/cloud-early-config
> +++ b/systemvm/patches/debian/config/etc/init.d/cloud-early-config
> @@ -1,10 +1,10 @@
>  #!/bin/bash
>  ### BEGIN INIT INFO
>  # Provides:          cloud-early-config
> -# Required-Start:    mountkernfs $local_fs
> -# Required-Stop:     $local_fs
> -# Should-Start:
> -# Should-Stop:
> +# Required-Start:    mountkernfs $local_fs cloud-early-init
> +# Required-Stop:     $local_fs cloud-early-init
> +# Should-Start:
> +# Should-Stop:
>  # Default-Start:     S
>  # Default-Stop:      0 6
>  # Short-Description: configure according to cmdline
> @@ -43,7 +43,7 @@ rm -f /var/cache/cloud/boot_up_done
>  . /lib/lsb/init-functions
>
>  log_it() {
> -  echo "$(date) $@" >> /var/log/cloud.log
> +  echo "$(date) cloud-early-config $@" >> /var/log/cloud.log
>    log_action_msg "$@"
>  }
>
> @@ -52,11 +52,11 @@ init_interfaces_orderby_macs() {
>      total_nics=${#macs[@]}
>      interface_file=${2:-"/etc/network/interfaces"}
>      rule_file=${3:-"/etc/udev/rules.d/70-persistent-net.rules"}
> -
> +
>      echo -n "auto lo" > $interface_file
>      for((i=0; i<total_nics; i++))
>      do
> -        if [[ $i < 3 ]]
> +        if [[ $i < 3 ]]
>          then
>             echo -n " eth$i" >> $interface_file
>          fi
> @@ -70,7 +70,7 @@ EOF
>      echo "" > $rule_file
>      for((i=0; i < ${#macs[@]}; i++))
>      do
> -        echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\",
> ATTR{address}==\"${macs[$i]}\", NAME=\"eth$i\"" >> $rule_file
> +        echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\",
> ATTR{address}==\"${macs[$i]}\", NAME=\"eth$i\"" >> $rule_file
>      done
>  }
>
> @@ -151,7 +151,7 @@ get_boot_params() {
>            chmod go-rwx /root/.ssh/authorized_keys
>            ;;
>       vmware)
> -          vmtoolsd --cmd 'machine.id.get' > /var/cache/cloud/cmdline
> +          vmtoolsd --cmd 'machine.id.get' > /var/cache/cloud/cmdline
>            ;;
>       virtualpc|hyperv)
>            # Hyper-V is recognized as virtualpc hypervisor type. Boot args
> are passed using KVP Daemon
> @@ -183,7 +183,6 @@ patch() {
>    local cdrom_dev=
>    mkdir -p $PATCH_MOUNT
>
> -
>    if [ -e /dev/xvdd ]; then
>         cdrom_dev=/dev/xvdd
>    elif [ -e /dev/cdrom ]; then
> @@ -204,11 +203,11 @@ patch() {
>      [ -f ${md5file} ] && oldmd5=$(cat ${md5file})
>      local newmd5=
>      [ -f ${patchfile} ] && newmd5=$(md5sum ${patchfile} | awk '{print
> $1}')
> -
> +
>     if [ "$oldmd5" != "$newmd5" ] && [ -f ${patchfile} ] && [ "$newmd5"
!=
> "" ]
>      then
>        shouldpatch=true
> -      log_it "Patching  scripts oldmd5=$oldmd5 newmd5=$newmd5"
> +      log_it "Patching  scripts oldmd5=$oldmd5 newmd5=$newmd5 with
> $patchfile"
>        tar xzf $patchfile -C /
>        echo ${newmd5} > ${md5file}
>      fi
> @@ -216,8 +215,8 @@ patch() {
>      hyperVisor=$(hypervisor)
>      /opt/cloud/bin/patchsystemvm.sh $PATCH_MOUNT $hyperVisor
>      umount $PATCH_MOUNT
> -
> -    if [ "$shouldpatch" == "true" ]
> +
> +    if [ "$shouldpatch" == "true" ]
>      then
>        log_it "Rebooting system since we patched init scripts"
>        sync
> @@ -355,7 +354,7 @@ setup_interface() {
>    local mask=$3
>    local gw=$4
>    local force=$5
> -  local intf=eth${intfnum}
> +  local intf=eth${intfnum}
>    local bootproto="static"
>
>
> @@ -449,7 +448,7 @@ enable_fwding() {
>  disable_rpfilter() {
>    log_it "cloud: disable rp_filter"
>    log_it "disable rpfilter"
> -  sed -i "s/net.ipv4.conf.default.rp_filter.*$/net.ipv4.conf.default.rp_filter
> = 0/" /etc/sysctl.conf
> +  sed -i "s/net.ipv4.conf.default.rp_filter.*$/net.ipv4.conf.default.rp_filter
> = 0/" /etc/sysctl.conf
>  }
>
>  get_public_vif_list() {
> @@ -461,32 +460,32 @@ get_public_vif_list() {
>        vif_list="$vif_list $vif";
>      fi
>    done
> -
> +
>    echo $vif_list
>  }
>
>  disable_rpfilter_domR() {
>    log_it "cloud: Tuning rp_filter on public interfaces"
> -
> +
>    VIF_LIST=$(get_public_vif_list)
>    log_it "rpfilter public interfaces :  $VIF_LIST"
>    if [ "$DISABLE_RP_FILTER" == "true" ]
>    then
>        log_it "cloud: disable rp_filter on public interfaces"
> -      sed -i "s/net.ipv4.conf.default.rp_filter.*$/net.ipv4.conf.default.rp_filter
> = 0/" /etc/sysctl.conf
> +      sed -i "s/net.ipv4.conf.default.rp_filter.*$/net.ipv4.conf.default.rp_filter
> = 0/" /etc/sysctl.conf
>        echo "0" > /proc/sys/net/ipv4/conf/default/rp_filter
>        for vif in $VIF_LIST; do
>           log_it "cloud: disable rp_filter on public interface: $vif"
> -         sed -i "s/net.ipv4.conf.$vif.rp_filter.*$/net.ipv4.conf.$vif.rp_filter
> = 0/" /etc/sysctl.conf
> +         sed -i "s/net.ipv4.conf.$vif.rp_filter.*$/net.ipv4.conf.$vif.rp_filter
> = 0/" /etc/sysctl.conf
>           echo "0" > /proc/sys/net/ipv4/conf/$vif/rp_filter
>        done
>    else
>        log_it "cloud: enable rp_filter on public interfaces"
> -      sed -i "s/net.ipv4.conf.default.rp_filter.*$/net.ipv4.conf.default.rp_filter
> = 1/" /etc/sysctl.conf
> +      sed -i "s/net.ipv4.conf.default.rp_filter.*$/net.ipv4.conf.default.rp_filter
> = 1/" /etc/sysctl.conf
>        echo "1" > /proc/sys/net/ipv4/conf/default/rp_filter
>        for vif in $VIF_LIST; do
>           log_it "cloud: enable rp_filter on public interface: $vif"
> -         sed -i "s/net.ipv4.conf.$vif.rp_filter.*$/net.ipv4.conf.$vif.rp_filter
> = 1/" /etc/sysctl.conf
> +         sed -i "s/net.ipv4.conf.$vif.rp_filter.*$/net.ipv4.conf.$vif.rp_filter
> = 1/" /etc/sysctl.conf
>           echo "1" > /proc/sys/net/ipv4/conf/$vif/rp_filter
>        done
>    fi
> @@ -593,11 +592,11 @@ setup_common() {
>    then
>         setup_interface "2" $ETH2_IP $ETH2_MASK $GW
>    fi
> -
> +
>    echo $NAME > /etc/hostname
>    echo 'AVAHI_DAEMON_DETECT_LOCAL=0' > /etc/default/avahi-daemon
>    hostname $NAME
> -
> +
>    #Nameserver
>    sed -i -e "/^nameserver.*$/d" /etc/resolv.conf # remove previous entries
>    sed -i -e "/^nameserver.*$/d" /etc/dnsmasq-resolv.conf # remove
> previous entries
> @@ -606,7 +605,7 @@ setup_common() {
>      echo "nameserver $internalNS1" > /etc/dnsmasq-resolv.conf
>      echo "nameserver $internalNS1" > /etc/resolv.conf
>    fi
> -
> +
>    if [ -n "$internalNS2" ]
>    then
>      echo "nameserver $internalNS2" >> /etc/dnsmasq-resolv.conf
> @@ -617,7 +616,7 @@ setup_common() {
>      echo "nameserver $NS1" >> /etc/dnsmasq-resolv.conf
>      echo "nameserver $NS1" >> /etc/resolv.conf
>    fi
> -
> +
>    if [ -n "$NS2" ]
>    then
>      echo "nameserver $NS2" >> /etc/dnsmasq-resolv.conf
> @@ -652,7 +651,7 @@ setup_common() {
>      ip route add default via $GW dev $gwdev
>
>    fi
> -
> +
>    # a hacking way to activate vSwitch under VMware
>    ping -n -c 3 $GW &
>    sleep 3
> @@ -667,7 +666,7 @@ setup_common() {
>        ping -n -c 3 $MGMT_GW &
>        sleep 3
>        pkill ping
> -
> +
>    fi
>
>    local hyp=$(hypervisor)
> @@ -689,7 +688,7 @@ setup_dnsmasq() {
>
>    #get the template
>    cp /etc/dnsmasq.conf.tmpl /etc/dnsmasq.conf
> -
> +
>    if [ -n "$DOMAIN" ]
>    then
>          #send domain name to dhcp clients
> @@ -699,17 +698,17 @@ setup_dnsmasq() {
>          #answer all local domain queries
>          sed  -i -e "s/^[#]*local=.*$/local=\/$DOMAIN\//"
> /etc/dnsmasq.conf
>    fi
> -
> +
>    if [ -n  "$DNS_SEARCH_ORDER" ]
>    then
>        sed -i -e "/^[#]*dhcp-option.*=119.*$/d" /etc/dnsmasq.conf
>        echo "dhcp-option-force=119,$DNS_SEARCH_ORDER" >> /etc/dnsmasq.conf
>        # set the domain search order as a space seprated list for option 15
>        DNS_SEARCH_ORDER=$(echo $DNS_SEARCH_ORDER | sed 's/,/ /g')
> -      #send domain name to dhcp clients
> +      #send domain name to dhcp clients
>        sed -i s/[#]*dhcp-option=15.*$/dhcp-option=15,\""$DNS_SEARCH_ORDER"\"/
> /etc/dnsmasq.conf
>    fi
> -
> +
>    if [ $DHCP_RANGE ]
>    then
>      sed -i -e "s/^dhcp-range_ip4=.*$/dhcp-range=$DHCP_RANGE,static/"
> /etc/dnsmasq.conf
> @@ -880,11 +879,11 @@ setup_router() {
>
>    oldmd5=
>    [ -f "/etc/udev/rules.d/70-persistent-net.rules" ] && oldmd5=$(md5sum
> "/etc/udev/rules.d/70-persistent-net.rules" | awk '{print $1}')
> -
> +
>    if [ -n "$ETH2_IP" ]
>    then
>        setup_common eth0 eth1 eth2
> -
> +
>        if [ -n "$EXTRA_PUBNICS" ]
>        then
>          for((i = 3; i < 3 + $EXTRA_PUBNICS; i++))
> @@ -902,13 +901,13 @@ setup_router() {
>          done
>        fi
>    fi
> -
> -  # Moved to Cs Python code
> +
> +  # Moved to Cs Python code
>    #if [ -n "$ETH2_IP" -a "$RROUTER" == "1" ]
>    #then
>      #setup_redundant_router
>    #fi
> -
> +
>    log_it "Checking udev NIC assignment order changes"
>    if [ "$NIC_MACS" != "" ]
>    then
> @@ -916,7 +915,7 @@ setup_router() {
>      newmd5=$(md5sum "/tmp/udev-rules" | awk '{print $1}')
>      rm /tmp/interfaces
>      rm /tmp/udev-rules
> -
> +
>      if [ "$oldmd5" != "$newmd5" ]
>      then
>        log_it "udev NIC assignment requires reboot to take effect"
> @@ -925,7 +924,7 @@ setup_router() {
>        reboot
>      fi
>    fi
> -
> +
>    setup_aesni
>    setup_dnsmasq
>    setup_apache2 $ETH0_IP
> @@ -933,7 +932,6 @@ setup_router() {
>    sed -i  /gateway/d /etc/hosts
>    echo "$ETH0_IP $NAME" >> /etc/hosts
>
> -
>    enable_svc dnsmasq 1
>    enable_svc haproxy 1
>    enable_irqbalance 1
> @@ -957,10 +955,8 @@ setup_router() {
>
>    #setup hourly logrotate
>    mv -n /etc/cron.daily/logrotate /etc/cron.hourly 2>&1
> -
> -}
> -
>
> +}
>
>  setup_vpcrouter() {
>    log_it "Setting up VPC virtual router system vm"
> @@ -974,11 +970,11 @@ auto lo eth0
>  iface lo inet loopback
>  EOF
>    setup_interface "0" $ETH0_IP $ETH0_MASK $GW
> -
> +
>    echo $NAME > /etc/hostname
>    echo 'AVAHI_DAEMON_DETECT_LOCAL=0' > /etc/default/avahi-daemon
>    hostname $NAME
> -
> +
>    #Nameserver
>    sed -i -e "/^nameserver.*$/d" /etc/resolv.conf # remove previous entries
>    sed -i -e "/^nameserver.*$/d" /etc/dnsmasq-resolv.conf # remove
> previous entries
> @@ -987,7 +983,7 @@ EOF
>      echo "nameserver $internalNS1" > /etc/dnsmasq-resolv.conf
>      echo "nameserver $internalNS1" > /etc/resolv.conf
>    fi
> -
> +
>    if [ -n "$internalNS2" ]
>    then
>      echo "nameserver $internalNS2" >> /etc/dnsmasq-resolv.conf
> @@ -998,7 +994,7 @@ EOF
>      echo "nameserver $NS1" >> /etc/dnsmasq-resolv.conf
>      echo "nameserver $NS1" >> /etc/resolv.conf
>    fi
> -
> +
>    if [ -n "$NS2" ]
>    then
>      echo "nameserver $NS2" >> /etc/dnsmasq-resolv.conf
> @@ -1009,7 +1005,7 @@ EOF
>       if [ "$hyp" == "vmware" ] || [ "$hyp" == "hyperv" ];
>       then
>           ip route add $MGMTNET via $LOCAL_GW dev eth0
> -
> +
>            # a hacking way to activate vSwitch under VMware
>           ping -n -c 3 $LOCAL_GW &
>           sleep 3
> @@ -1065,8 +1061,6 @@ EOF
>
>  }
>
> -
> -
>  setup_dhcpsrvr() {
>    log_it "Setting up dhcp server system vm"
>    setup_common eth0 eth1
> @@ -1108,10 +1102,10 @@ setup_storage_network() {
>                 log_it "Incompleted parameters STORAGE_IP:$STORAGE_IP,
> STORAGE_NETMASK:$STORAGE_NETMASK, STORAGE_CIDR:$STORAGE_CIDR. Cannot
> setup storage network"
>                 return
>         fi
> -
> +
>         echo "" >> /etc/network/interfaces
>         echo "auto eth3" >> /etc/network/interfaces
> -
> +
>         setup_interface "3" "$STORAGE_IP" "$STORAGE_NETMASK"
>      [ -n "$MTU" ] && ifconfig eth3 mtu $MTU && echo "  mtu $MTU" >>
> /etc/network/interfaces
>         #ip route add "$STORAGE_CIDR" via "$STORAGE_IP"
> @@ -1260,7 +1254,7 @@ setup_elbvm() {
>    else
>      setup_sshd $ETH1_IP "eth1"
>    fi
> -
> +
>    enable_fwding 0
>    enable_svc haproxy 0
>    enable_irqbalance 0
> @@ -1283,7 +1277,7 @@ setup_ilbvm() {
>    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_svc haproxy 1
>    enable_irqbalance 1
> @@ -1317,11 +1311,11 @@ start() {
>    [ $? -ne 0 ] && log_it "Failed to detect hypervisor type, bailing out
> of early init" && exit 10
>    log_it "Detected that we are running inside $hyp guest"
>    get_boot_params
> -  patch
> +  # patch - removed since this was done by cloud-early-init
>    patch_log4j
>    parse_cmd_line
>    change_password
> -  case $TYPE in
> +  case $TYPE in
>       router)
>           [ "$NAME" == "" ] && NAME=router
>           setup_router
> @@ -1400,7 +1394,7 @@ for i in $CMDLINE
>      # Two lines so values do not accidently interpretted as escapes!!
>      echo -n \"${KEY}\"': '\"${VALUE}\" >> ${CHEF_TMP_FILE}
>      COMMA=",\n\t"
> -    case $KEY in
> +    case $KEY in
>        disable_rp_filter)
>            DISABLE_RP_FILTER=$VALUE
>            ;;
> @@ -1483,13 +1477,13 @@ for i in $CMDLINE
>          DHCP_RANGE=$(echo $VALUE | tr ':' ',')
>         ;;
>        bootproto)
> -        BOOTPROTO=$VALUE
> +        BOOTPROTO=$VALUE
>         ;;
>        type)
> -        TYPE=$VALUE
> +        TYPE=$VALUE
>             ;;
>        defaultroute)
> -        DEFAULTROUTE=$VALUE
> +        DEFAULTROUTE=$VALUE
>         ;;
>        redundant_router)
>          RROUTER=$VALUE
> @@ -1556,7 +1550,7 @@ case "$1" in
>  start)
>
>         log_action_begin_msg "Executing cloud-early-config"
> -        log_it "Executing cloud-early-config"
> +  log_it "Executing cloud-early-config"
>         if start; then
>             log_action_end_msg $?
>         else
> diff --git a/systemvm/patches/debian/config/etc/init.d/cloud-early-init
> b/systemvm/patches/debian/config/etc/init.d/cloud-early-init
> new file mode 100644
> index 00000000000..ea7690d7ba3
> --- /dev/null
> +++ b/systemvm/patches/debian/config/etc/init.d/cloud-early-init
> @@ -0,0 +1,222 @@
> +#!/bin/bash
> +### BEGIN INIT INFO
> +# Provides:          cloud-early-init
> +# Required-Start:    mountkernfs $local_fs
> +# Required-Stop:     $local_fs
> +# Should-Start:
> +# Should-Stop:
> +# Default-Start:     S
> +# Default-Stop:      0 6
> +# Short-Description: configure according to cmdline
> +### 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.
> +
> +PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
> +
> +# include req for patchsystemvm
> +. /lib/lsb/init-functions
> +
> +log_it() {
> +  echo "$(date) cloud-early-init $@" >> /var/log/cloud.log
> +  log_action_msg "$@"
> +}
> +
> +hypervisor() {
> +  [ -d /proc/xen ] && mount -t xenfs none /proc/xen
> +  [ -d /proc/xen ] && echo "xen-domU" && return 0
> +
> +  local try=$([ -x /usr/sbin/virt-what ] && virt-what | tail -1)
> +  [ "$try" != "" ] && echo $try && return 0
> +
> +  vmware-checkvm &> /dev/null && echo "vmware" && return 0
> +
> +  grep -q QEMU /proc/cpuinfo  && echo "kvm" && return 0
> +  grep -q QEMU /var/log/messages && echo "kvm" && return 0
> +
> +  echo "unknown" && return 1
> +
> +}
> +
> +get_boot_params() {
> +  local EXTRA_MOUNT=/media/extra
> +  local hyp=$(hypervisor)
> +  [ $? -ne 0 ] && log_it "Failed to detect hypervisor type, bailing out
> of early init" && exit 10
> +
> +  case $hyp in
> +     xen-domU|xen-hvm)
> +          cat /proc/cmdline > /var/cache/cloud/cmdline
> +          sed -i "s/%/ /g" /var/cache/cloud/cmdline
> +          ;;
> +     kvm)
> +          VPORT=$(find /dev/virtio-ports -type l -name '*.vport'
> 2>/dev/null|head -1)
> +
> +          if [ -z "$VPORT" ]; then
> +            log_it "No suitable VirtIO port was found in
> /dev/virtio-ports" && exit 2
> +          fi
> +
> +          if [ ! -e "$VPORT" ]; then
> +            log_it "${VPORT} not loaded, perhaps guest kernel is too
> old." && exit 2
> +          fi
> +
> +             local factor=2
> +             local progress=1
> +                 for i in {1..5}
> +                 do
> +               while read line; do
> +                 if [[ $line == cmdline:* ]]; then
> +                   cmd=${line//cmdline:/}
> +                echo $cmd > /var/cache/cloud/cmdline
> +                 elif [[ $line == pubkey:* ]]; then
> +                   pubkey=${line//pubkey:/}
> +                   echo $pubkey > /var/cache/cloud/authorized_keys
> +                   echo $pubkey > /root/.ssh/authorized_keys
> +              fi
> +               done < $VPORT
> +               # In case of reboot we do not send the boot args again.
> +               # So, no need to wait for them, as the boot args are
> already set at startup
> +               if [ -s /var/cache/cloud/cmdline  ]
> +               then
> +              log_it "Found a non empty cmdline file. Will now exit the
> loop and proceed with configuration."
> +              break;
> +            fi
> +            sleep ${progress}s
> +            progress=$[ progress * factor ]
> +                 done
> +          chmod go-rwx /root/.ssh/authorized_keys
> +          ;;
> +     vmware)
> +          vmtoolsd --cmd 'machine.id.get' > /var/cache/cloud/cmdline
> +          ;;
> +     virtualpc|hyperv)
> +          # Hyper-V is recognized as virtualpc hypervisor type. Boot args
> are passed using KVP Daemon
> +          #waiting for the hv_kvp_daemon to start up
> +          #sleep  need to fix the race condition of hv_kvp_daemon and
> cloud-early-config
> +          sleep 5
> +          cp -f /var/opt/hyperv/.kvp_pool_0 /var/cache/cloud/cmdline
> +          cat /dev/null > /var/opt/hyperv/.kvp_pool_0
> +          ;;
> +     virtualbox)
> +          # Virtualbox is used to test the virtual router
> +          # get the commandline from a dmistring  (yes, hacky!)
> +          dmidecode | grep cmdline | sed 's/^.*cmdline://' >
> /var/cache/cloud/cmdline
> +          RV=$?
> +          if [ $RV -ne 0 ] ; then
> +            log_it "Failed to get cmdline from a virtualbox dmi property"
> +          fi
> +          ;;
> +  esac
> +
> +}
> +
> +patch() {
> +  local PATCH_MOUNT=/media/cdrom
> +  local patchfile=$PATCH_MOUNT/cloud-scripts.tgz
> +  local md5file=/var/cache/cloud/cloud-scripts-signature
> +  local privkey=$PATCH_MOUNT/authorized_keys
> +  local shouldpatch=false
> +  local cdrom_dev=
> +  mkdir -p $PATCH_MOUNT
> +
> +  if [ -e /dev/xvdd ]; then
> +       cdrom_dev=/dev/xvdd
> +  elif [ -e /dev/cdrom ]; then
> +       cdrom_dev=/dev/cdrom
> +  elif [ -e /dev/cdrom1 ]; then
> +       cdrom_dev=/dev/cdrom1
> +  elif [ -e /dev/cdrom2 ]; then
> +       cdrom_dev=/dev/cdrom2
> +  elif [ -e /dev/cdrom3 ]; then
> +       cdrom_dev=/dev/cdrom3
> +  fi
> +  [ -f /var/cache/cloud/authorized_keys ] && privkey=/var/cache/cloud/
> authorized_keys
> +
> +  if [ -n "$cdrom_dev" ]; then
> +    mount -o ro $cdrom_dev $PATCH_MOUNT
> +    [ -f $privkey ] && cp -f $privkey /root/.ssh/ && chmod go-rwx
> /root/.ssh/authorized_keys
> +    local oldmd5=
> +    [ -f ${md5file} ] && oldmd5=$(cat ${md5file})
> +    local newmd5=
> +    [ -f ${patchfile} ] && newmd5=$(md5sum ${patchfile} | awk '{print
> $1}')
> +
> +   if [ "$oldmd5" != "$newmd5" ] && [ -f ${patchfile} ] && [ "$newmd5"
!=
> "" ]
> +    then
> +      shouldpatch=true
> +      log_it "Patching scripts oldmd5=$oldmd5 newmd5=$newmd5"
> +      tar xzf $patchfile -C /
> +      echo ${newmd5} > ${md5file}
> +    else
> +      log_it "Scripts up to date oldmd5=$oldmd5 newmd5=$newmd5"
> +    fi
> +    log_it "Patching cloud service"
> +    hyperVisor=$(hypervisor)
> +    /opt/cloud/bin/patchsystemvm.sh $PATCH_MOUNT $hyperVisor
> +    log_it "Unmounting $PATCH_MOUNT"
> +    umount $PATCH_MOUNT
> +
> +    # Historical reboot removed due to cloud-early-init now running
> before services started
> +
> +  fi
> +
> +  if [ -f /mnt/cmdline ]; then
> +    cat /mnt/cmdline > /var/cache/cloud/cmdline
> +  fi
> +  return 0
> +}
> +
> +start() {
> +
> +  local hyp=$(hypervisor)
> +  [ $? -ne 0 ] && log_it "Failed to detect hypervisor type, bailing out
> of cloud-early-init" && exit 10
> +  log_it "Detected that we are running inside $hyp guest."
> +  get_boot_params
> +  patch
> +  if [ "$hyp" == "hyperv" ]; then
> +    # eject the systemvm.iso
> +     eject
> +  fi
> +  return 0
> +}
> +
> +case "$1" in
> +start)
> +       log_action_begin_msg "Executing cloud-early-init."
> +  log_it "Executing cloud-early-init."
> +       if start; then
> +           log_action_end_msg $?
> +       else
> +           log_action_end_msg $?
> +       fi
> +       ;;
> +
> +stop)
> +       log_action_begin_msg "Stopping cloud-early-init."
> +  log_it "Stopping cloud-early-init."
> +       log_action_end_msg 0
> +       ;;
> +
> +*)
> +       echo "Usage: /etc/init.d/cloud-early-init {start|stop}."
> +       exit 1
> +       ;;
> +esac
> +
> +# Serialize cloud-early-init and cloud-early-config
> +log_it "Calling cloud-early-config."
> +/etc/init.d/cloud-early-config start
> +
> +exit 0
> diff --git a/systemvm/patches/debian/config/etc/init.d/cloud-passwd-srvr
> b/systemvm/patches/debian/config/etc/init.d/cloud-passwd-srvr
> index 33b0ea310cb..41a1a782dbe 100755
> --- a/systemvm/patches/debian/config/etc/init.d/cloud-passwd-srvr
> +++ b/systemvm/patches/debian/config/etc/init.d/cloud-passwd-srvr
> @@ -1,11 +1,11 @@
> -#!/bin/bash
> +#!/bin/bash
>  ### BEGIN INIT INFO
>  # Provides:          cloud-passwd-srvr
> -# Required-Start:    mountkernfs $local_fs cloud-early-config
> iptables-persistent
> +# Required-Start:    mountkernfs $local_fs cloud-early-init
> iptables-persistent
>  # Required-Stop:     $local_fs
> -# Should-Start:
> -# Should-Stop:
> -# Default-Start:
> +# Should-Start:
> +# Should-Stop:
> +# Default-Start:
>  # Default-Stop:      0 6
>  # Short-Description: Web server that sends passwords to User VMs
>  ### END INIT INFO
> @@ -74,7 +74,7 @@ remove_iptables_rules()
>  }
>
>  start() {
> -  [ "$ENABLED" != 0 ]  || exit 0
> +  [ "$ENABLED" != 0 ]  || exit 0
>    pid=$(getpid)
>    [ "$pid" != "" ] && echo "Password server is already running
> (pid=$pid)" && return 0
>    add_iptables_rules
> diff --git a/systemvm/patches/debian/config/etc/init.d/postinit
> b/systemvm/patches/debian/config/etc/init.d/postinit
> index 818959fde3b..9af911fc40a 100755
> --- a/systemvm/patches/debian/config/etc/init.d/postinit
> +++ b/systemvm/patches/debian/config/etc/init.d/postinit
> @@ -1,10 +1,10 @@
>  #!/bin/bash -e
>  ### BEGIN INIT INFO
>  # Provides:          postinit
> -# Required-Start:    mountkernfs $local_fs cloud-early-config
> +# Required-Start:    mountkernfs $local_fs cloud-early-init
>  # Required-Stop:     $local_fs
> -# Should-Start:
> -# Should-Stop:
> +# Should-Start:
> +# Should-Stop:
>  # Default-Start:     2 3 4 5
>  # Default-Stop:      0 1 6
>  # Short-Description:   post-init
> @@ -19,7 +19,7 @@
>  # 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
> @@ -61,7 +61,7 @@ setup_redundant_router() {
>  }
>
>  start() {
> -  case $TYPE in
> +  case $TYPE in
>       secstorage)
>           [ "$NAME" == "" ] && NAME=secstorage
>           setup_secstorage;
> @@ -95,7 +95,7 @@ for i in $CMDLINE
>      # search for foo=bar pattern and cut out foo
>      KEY=$(echo $i | cut -d= -f1)
>      VALUE=$(echo $i | cut -d= -f2)
> -    case $KEY in
> +    case $KEY in
>        eth0ip)
>            ETH0_IP=$VALUE
>            ;;
> @@ -142,10 +142,10 @@ for i in $CMDLINE
>          DHCP_RANGE=$(echo $VALUE | tr ':' ',')
>         ;;
>        bootproto)
> -        BOOTPROTO=$VALUE
> +        BOOTPROTO=$VALUE
>         ;;
>        type)
> -        TYPE=$VALUE
> +        TYPE=$VALUE
>         ;;
>        redundant_router)
>          RROUTER=$VALUE
> diff --git a/systemvm/patches/debian/config/opt/cloud/bin/patchsystemvm.sh
> b/systemvm/patches/debian/config/opt/cloud/bin/patchsystemvm.sh
> index 9222a8c89b7..f5154fff409 100755
> --- a/systemvm/patches/debian/config/opt/cloud/bin/patchsystemvm.sh
> +++ b/systemvm/patches/debian/config/opt/cloud/bin/patchsystemvm.sh
> @@ -17,18 +17,26 @@
>  # under the License.
>
>  #set -x
> -logfile="/var/log/patchsystemvm.log"
> +logfile="/var/log/cloud.log"
> +
> +log_it() {
> +  echo "$(date) patchsystemvm.sh $@" >> $logfile
> +}
> +
>  # To use existing console proxy .zip-based package file
>  patch_console_proxy() {
>     local patchfile=$1
> +   log_it "Patching CPVM/SSVM with cloud agent jars from $patchfile"
>     rm /usr/local/cloud/systemvm -rf
>     mkdir -p /usr/local/cloud/systemvm
> -   echo "All" | unzip $patchfile -d /usr/local/cloud/systemvm >$logfile
> 2>&1
> +   log_it "Patching /usr/local/cloud/systemvm:"
> +   echo "All" | unzip $patchfile -d /usr/local/cloud/systemvm >>$logfile
> 2>&1
>     find /usr/local/cloud/systemvm/ -name \*.sh | xargs chmod 555
>     return 0
>  }
>
>  consoleproxy_svcs() {
> +   log_it "Configuring console proxy services"
>     chkconfig cloud on
>     chkconfig postinit on
>     chkconfig cloud-passwd-srvr off
> @@ -46,6 +54,7 @@ consoleproxy_svcs() {
>  }
>
>  secstorage_svcs() {
> +   log_it "Configuring SSVM services"
>     chkconfig cloud on
>     chkconfig postinit on
>     chkconfig cloud-passwd-srvr off
> @@ -63,10 +72,11 @@ secstorage_svcs() {
>  }
>
>  routing_svcs() {
> +   log_it "Configuring VR services"
>     grep "redundant_router=1" /var/cache/cloud/cmdline > /dev/null
>     RROUTER=$?
>     chkconfig cloud off
> -   chkconfig haproxy on ;
> +   chkconfig haproxy on ;
>     chkconfig ssh on
>     chkconfig nfs-common off
>     chkconfig portmap off
> @@ -74,6 +84,7 @@ routing_svcs() {
>     echo "cloud nfs-common portmap" > /var/cache/cloud/disabled_svcs
>     if [ $RROUTER -eq 0 ]
>     then
> +       log_it "Configuring redundant VR services"
>         chkconfig dnsmasq off
>         chkconfig cloud-passwd-srvr off
>         chkconfig keepalived on
> @@ -82,6 +93,7 @@ routing_svcs() {
>         echo "keepalived conntrackd postinit" >>
> /var/cache/cloud/enabled_svcs
>         echo "dnsmasq cloud-passwd-srvr" >> /var/cache/cloud/disabled_svcs
>     else
> +       log_it "Configuring non-redundant VR services"
>         chkconfig dnsmasq on
>         chkconfig cloud-passwd-srvr on
>         chkconfig keepalived off
> @@ -92,9 +104,10 @@ routing_svcs() {
>  }
>
>  dhcpsrvr_svcs() {
> +   log_it "Configuring DHCP services"
>     chkconfig cloud off
> -   chkconfig cloud-passwd-srvr on ;
> -   chkconfig haproxy off ;
> +   chkconfig cloud-passwd-srvr on ;
> +   chkconfig haproxy off ;
>     chkconfig dnsmasq on
>     chkconfig ssh on
>     chkconfig nfs-common off
> @@ -106,8 +119,9 @@ dhcpsrvr_svcs() {
>  }
>
>  elbvm_svcs() {
> +   log_it "Configuring external load balancing VM services"
>     chkconfig cloud off
> -   chkconfig haproxy on ;
> +   chkconfig haproxy on ;
>     chkconfig ssh on
>     chkconfig nfs-common off
>     chkconfig portmap off
> @@ -117,10 +131,10 @@ elbvm_svcs() {
>     echo "cloud dnsmasq cloud-passwd-srvr apache2 nfs-common portmap" >
> /var/cache/cloud/disabled_svcs
>  }
>
> -
>  ilbvm_svcs() {
> +   log_it "Configuring internal load balancing VM services"
>     chkconfig cloud off
> -   chkconfig haproxy on ;
> +   chkconfig haproxy on ;
>     chkconfig ssh on
>     chkconfig nfs-common off
>     chkconfig portmap off
> @@ -131,6 +145,7 @@ ilbvm_svcs() {
>  }
>
>  enable_pcihotplug() {
> +   log_it "Configuring PCI hot plug"
>     sed -i -e "/acpiphp/d" /etc/modules
>     sed -i -e "/pci_hotplug/d" /etc/modules
>     echo acpiphp >> /etc/modules
> @@ -138,6 +153,7 @@ enable_pcihotplug() {
>  }
>
>  enable_serial_console() {
> +   log_it "Enabling serial console"
>     sed -i -e "/^serial.*/d" /boot/grub/grub.conf
>     sed -i -e "/^terminal.*/d" /boot/grub/grub.conf
>     sed -i -e "/^default.*/a\serial --unit=0 --speed=115200 --parity=no
> --stop=1" /boot/grub/grub.conf
> @@ -147,8 +163,11 @@ enable_serial_console() {
>     sed -i -e "/6:23:respawn/a\s0:2345:respawn:/sbin/getty -L 115200
> ttyS0 vt102" /etc/inittab
>  }
>
> +log_it "Starting $0 $*"
>
>  CMDLINE=$(cat /var/cache/cloud/cmdline)
> +log_it "CMDLINE passed to system VM patch process: $CMDLINE"
> +
>  TYPE="router"
>  PATCH_MOUNT=$1
>  Hypervisor=$2
> @@ -169,10 +188,11 @@ done
>
>  if [ "$TYPE" == "consoleproxy" ] || [ "$TYPE" == "secstorage" ]  && [ -f
> ${PATCH_MOUNT}/systemvm.zip ]
>  then
> +  log_it "Patching ${TYPE}."
>    patch_console_proxy ${PATCH_MOUNT}/systemvm.zip
>    if [ $? -gt 0 ]
>    then
> -    printf "Failed to apply patch systemvm\n" >$logfile
> +    log_it "Failed to apply patch systemvm"
>      exit 5
>    fi
>  fi
> @@ -183,26 +203,29 @@ echo "" > /root/.ssh/known_hosts
>
>  if [ "$Hypervisor" == "kvm" ]
>  then
> +   log_it "Enabling PCI hotplug and serial console for KVM"
>     enable_pcihotplug
>     enable_serial_console
>  fi
>
>  if [ "$TYPE" == "router" ] || [ "$TYPE" == "vpcrouter" ]
>  then
> +  log_it "Updating ${TYPE} services"
>    routing_svcs
>    if [ $? -gt 0 ]
>    then
> -    printf "Failed to execute routing_svcs\n" >$logfile
> +    log_it "Failed to execute routing_svcs"
>      exit 6
>    fi
>  fi
>
>  if [ "$TYPE" == "dhcpsrvr" ]
>  then
> +  log_it "Updating ${TYPE} services"
>    dhcpsrvr_svcs
>    if [ $? -gt 0 ]
>    then
> -    printf "Failed to execute dhcpsrvr_svcs\n" >$logfile
> +    log_it "Failed to execute dhcpsrvr_svcs"
>      exit 6
>    fi
>  fi
> @@ -210,40 +233,44 @@ fi
>
>  if [ "$TYPE" == "consoleproxy" ]
>  then
> +  log_it "Updating ${TYPE} services"
>    consoleproxy_svcs
>    if [ $? -gt 0 ]
>    then
> -    printf "Failed to execute consoleproxy_svcs\n" >$logfile
> +    log_it "Failed to execute consoleproxy_svcs"
>      exit 7
>    fi
>  fi
>
>  if [ "$TYPE" == "secstorage" ]
>  then
> +  log_it "Updating ${TYPE} services"
>    secstorage_svcs
>    if [ $? -gt 0 ]
>    then
> -    printf "Failed to execute secstorage_svcs\n" >$logfile
> +    log_it "Failed to execute secstorage_svcs"
>      exit 8
>    fi
>  fi
>
>  if [ "$TYPE" == "elbvm" ]
>  then
> +  log_it "Updating ${TYPE} services"
>    elbvm_svcs
>    if [ $? -gt 0 ]
>    then
> -    printf "Failed to execute elbvm svcs\n" >$logfile
> +    log_it "Failed to execute elbvm svcs"
>      exit 9
>    fi
>  fi
>
>  if [ "$TYPE" == "ilbvm" ]
>  then
> +  log_it "Updating ${TYPE} services"
>    ilbvm_svcs
>    if [ $? -gt 0 ]
>    then
> -    printf "Failed to execute ilbvm svcs\n" >$logfile
> +    log_it "Failed to execute ilbvm svcs"
>      exit 9
>    fi
>  fi
> diff --git a/tools/appliance/definitions/systemvmtemplate/configure_systemvm_services.sh
> b/tools/appliance/definitions/systemvmtemplate/configure_
> systemvm_services.sh
> index 60082e380a0..477e140e16b 100644
> --- a/tools/appliance/definitions/systemvmtemplate/configure_
> systemvm_services.sh
> +++ b/tools/appliance/definitions/systemvmtemplate/configure_
> systemvm_services.sh
> @@ -36,11 +36,14 @@ function install_cloud_scripts() {
>    rsync -av ./cloud_scripts/ /
>    chmod +x /opt/cloud/bin/* \
>      /root/{clearUsageRules.sh,reconfigLB.sh,monitorServices.py} \
> -    /etc/init.d/{cloud,cloud-early-config,cloud-passwd-srvr,postinit} \
> +    /etc/init.d/{cloud,cloud-early-init,cloud-early-config,cloud-passwd-srvr,postinit}
> \
>      /etc/profile.d/cloud.sh
>
> -  chkconfig --add cloud-early-config
> -  chkconfig cloud-early-config on
> +  chkconfig --add cloud-early-init
> +  chkconfig cloud-early-init on
> +  # Testing serialized cloud-early-init and cloud-early-config
> +  # chkconfig --add cloud-early-config
> +  # chkconfig cloud-early-config on
>    chkconfig --add cloud-passwd-srvr
>    chkconfig cloud-passwd-srvr off
>    chkconfig --add cloud
>
>
>
>
> ----------------------------------------------------------------
> This is an automated message from the Apache Git Service.
> To respond to the message, please log on GitHub and use the
> URL above to go to the specific comment.
>
> For queries about this service, please contact Infrastructure at:
> users@infra.apache.org
>
>
> With regards,
> Apache Git Services
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message