rohityadavcloud commented on code in PR #6550: URL: https://github.com/apache/cloudstack/pull/6550#discussion_r951224581
########## scripts/vm/hypervisor/kvm/nsrkvmrestore.sh: ########## @@ -0,0 +1,234 @@ +#!/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. + + +version=0.9.1 + + +OPTIND=1 + +verb=0 +logDir="/nsr/logs/cloudstack/" +clusterClient="" +networkerServer="" +hvVersion="" +libvVersion="" +apiVersion="" +logFile="" +destination="" +volume="" +ssid="" +newvolumeUuid="" +POOLPATH="" + +log () { + [[ "$verb" -eq 1 ]] && builtin echo "$@" + if [[ "$1" == "-ne" || "$1" == "-e" || "$1" == "-n" ]]; then + builtin echo -e "$(date '+%Y-%m-%d %H-%M-%S>')" "${@: 2}" >> "$logFile" + else + builtin echo "$(date '+%Y-%m-%d %H-%M-%S>')" "$@" >> "$logFile" + fi +} + +vercomp(){ + local a b IFS=. -; set -f + printf -v a %08d $1; printf -v b %08d $3 + test $a "$2" $b +} + + +usage() { + echo " + +Usage:[-v] [-h] [-l log_dir] [-s networker_server] [-c networker_cluster_client] [-S ssid] [-d networker_destination_client ] [ -a volume ] [ -p pool_local_path ] + +Options: + -h Help and usage + -v Enable log mode + -l log_dir. Specify log directory. Default is /nsr/logs/cloudstack + -s networker_server Specify the EMC Networker server we are going to use + -c networker_cluster_client Specify the EMC Networker client CLUSTER to use + -d networker_destination_client Specify the EMC Networker client that is going to be used for the restore + -a volume Specify volume to restore + -p pool_local_path Local Path to Pool + -S ssid Specify SSID +Supplements Apache Cloudstack B&R Framework EMC Networker plugin and performs the backup of the Virtual Machines +" + +} + +sanity_checks() { + log "Performing environment sanity checks..." + + log -ne "\t[1] Checking if Networker is installed\t" + if [[ $(systemctl list-unit-files | grep networker) = *networker* ]]; then + log "Success" + else + log "Failure" + log -e "\n\tNetworker Service NOT FOUND. Make sure that Networker client is properly installed" + exit 1 + fi + + log -ne "\t[2] Checking if Networker is running\t" + if [[ $(systemctl is-active networker) = *active* ]]; then + log "Success" + else + log "Failure" + log -e "\n\tNetworker Service is not running. Investigate Networker logs, startup server and try again" + exit 2 + fi + log -ne "\t[3] Checking Networker DNS Resolution\t" + if [[ $(getent hosts "$networkerServer") = *$networkerServer* ]]; then + log "Success" + else + log "Failure" + log -e "\n\tNetworker Server cannot be resolved. Backups will most probably fail. Consider adding the ip/hostname to /etc/host or fix DNS resolution" + exit 3 + fi + + log -ne "\t[4] Checking QEMU / Libvirt Versions \t" + hvVersion=$(virsh version | grep hypervisor | awk '{print $(NF)}') + libvVersion=$(virsh version | grep libvirt | awk '{print $(NF)}' | tail -n 1) + apiVersion=$(virsh version | grep API | awk '{print $(NF)}') Review Comment: same as above - general remark if this can be done via the java based code libvirt-java? Does this run on mgmt server or on kvm host? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
