Kaynağa Gözat

调整 vnc 获取目标宿主机 ip 方式

James Iter 7 yıl önce
ebeveyn
işleme
a7e25a5362
4 değiştirilmiş dosya ile 8 ekleme ve 670 silme
  1. 0 36
      jimv-ks.cfg
  2. 0 329
      jimvc.install.sh
  3. 8 1
      jimvc/api/guest.py
  4. 0 304
      jimvn.install.sh

+ 0 - 36
jimv-ks.cfg

@@ -1,36 +0,0 @@
-# Kickstart Configurator for CentOS 7.5 by James Iter
-install
-url --url="http://mirrors.aliyun.com/centos/7/os/x86_64/"
-text
-lang en_US.UTF-8
-keyboard us
-zerombr
-network --bootproto=dhcp --onboot=yes --noipv6 --activate
-network --hostname=jimvc.jimv.cn
-timezone --utc Asia/Shanghai
-
-bootloader --location=mbr --driveorder=vda --append=" crashkernel=auto"
-authconfig --enableshadow --passalgo=sha512
-# pswd.jimv.cn
-rootpw  --iscrypted $6$mZQrwpKCyg4kxnsI$/Xzs9vqmGi2brto00htH/dLzpZtOxUuxxvTwlDxyaKnESx6a5qpxyklyvFCR1LPWpCl8Qs4af0VhIgfBU6xT5/
-clearpart --all --initlabel --drives=vda
-
-# ignoredisk --only-use=vda
-part biosboot --fstype="biosboot" --ondisk=vda --size=2
-part /boot --fstype="ext2" --ondisk=vda --size=512 --label=boot --asprimary
-part / --fstype="xfs" --ondisk=vda --grow --label=root --asprimary
-
-firstboot --disable
-selinux --disabled
-firewall --disabled
-reboot
-
-%packages
-@^minimal
-@core
-kexec-tools
-%end
-
-%post
-bash -c "$(curl -fsSL http://repo.jimv.cn/jimv.standalone-for-ipxe.stage1.install.sh)"
-%end

+ 0 - 329
jimvc.install.sh

@@ -1,329 +0,0 @@
-#!/usr/bin/env bash
-#
-# JimV-C
-#
-# Copyright (C) 2017 JimV <james.iter.cn@gmail.com>
-#
-# Author: James Iter <james.iter.cn@gmail.com>
-#
-#   This script will help you to automation install JimV-C.
-#
-# Example:
-#   Pass arguments to the installer.
-#   curl https://raw.githubusercontent.com/jamesiter/JimV-C/dev/INSTALL.sh | bash -s -- --version dev
-#   bash -c "$(curl -fsSL https://raw.githubusercontent.com/jamesiter/JimV-C/dev/INSTALL.sh)" -- --version dev
-
-export PYPI='https://mirrors.aliyun.com/pypi/simple/'
-export SMTP_HOST=''
-export SMTP_USER=''
-export SMTP_PASSWORD=''
-export TOKEN=`echo $[$RANDOM]|md5sum|cut -c 1-32`
-
-ARGS=`getopt -o h --long rdb_root_password:,rdb_jimv_password:,redis_password:,jwt_secret:,secret_key:,version:,help -n 'INSTALL.sh' -- "$@"`
-
-eval set -- "${ARGS}"
-
-while true
-do
-    case "$1" in
-        --rdb_root_password)
-            export RDB_ROOT_PSWD=$2
-            shift 2
-            ;;
-        --rdb_jimv_password)
-            export RDB_JIMV_PSWD=$2
-            shift 2
-            ;;
-        --redis_password)
-            export REDIS_PSWD=$2
-            shift 2
-            ;;
-        --jwt_secret)
-            export JWT_SECRET=$2
-            shift 2
-            ;;
-        --secret_key)
-            export SECRET_KEY=$2
-            shift 2
-            ;;
-        --version)
-            export JIMV_VERSION=$2
-            export JIMVC_DOWNLOAD_URL=$(sed s@master@${JIMV_VERSION}@ <<< ${JIMVC_DOWNLOAD_URL})
-            shift 2
-            ;;
-        -h|--help)
-            echo 'INSTALL.sh [-h|--help|--rdb_root_password|--rdb_jimv_password|--redis_password|--jwt_secret|--secret_key|--version]'
-            exit 0
-            ;;
-        --)
-            shift
-            break
-            ;;
-        *)
-            echo "Internal error!"
-            exit 1
-            ;;
-    esac
-done
-
-function check_precondition() {
-    source /etc/os-release
-    case ${ID} in
-    centos|fedora|rhel)
-        if [[ ${VERSION_ID} -lt 7 ]]; then
-            echo "System version must greater than or equal to 7, We found ${VERSION_ID}."
-	        exit 1
-        fi
-        ;;
-    *)
-        echo "${ID} is unknown, Please to be installed manually."
-	    exit 1
-        ;;
-    esac
-}
-
-function ensure_hosts_layout() {
-    echo "______________________________________________________________________________"
-    /bin/cat /etc/hosts
-    echo
-    read -p "您已经布局好 /etc/hosts 了吗 [Y/N]? " answer
-
-    if [[  "x_"${answer} != "x_Y" ]] && [[ "x_"${answer} != "x_y" ]]; then
-        echo "OK, good bye!";
-        exit 0
-    fi
-}
-
-function sync_ssh_key_pair() {
-    sed -i 's@.*StrictHostKeyChecking.*@StrictHostKeyChecking no@' /etc/ssh/ssh_config
-
-    rm -f ~/.ssh/id_rsa ~/.ssh/id_rsa.pub; echo -e "\n\n\n" | ssh-keygen -N ""
-    echo >> ~/.ssh/authorized_keys
-    cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
-    chmod 0600 ~/.ssh/authorized_keys
-
-    DHOSTS=`egrep -v '^$|localhost|jimvc' /etc/hosts | awk '{ print $1; }'`
-
-    for dhost in ${DHOSTS}
-    do
-        scp -r ~/.ssh ${dhost}:~/
-        # 关闭 SSH 服务器端 Key 校验
-        ssh ${dhost} "sed -i 's@.*StrictHostKeyChecking.*@StrictHostKeyChecking no@' /etc/ssh/ssh_config"
-    done
-}
-
-function sync_hosts_file() {
-    DHOSTS=`egrep -v '^$|localhost|jimvc' /etc/hosts | awk '{ print $1; }'`
-
-    for dhost in ${DHOSTS}
-    do
-        scp /etc/hosts ${dhost}:/etc/hosts
-    done
-}
-
-function prepare() {
-
-    if [[ ! ${JIMV_VERSION} ]] || [[ ${#JIMV_VERSION} -eq 0 ]]; then
-        export JIMV_VERSION='master'
-    fi
-
-    yum install epel-release -y
-}
-
-function clear_up_environment() {
-    systemctl stop firewalld
-    systemctl disable firewalld
-    systemctl stop NetworkManager
-    systemctl disable NetworkManager
-
-    sed -i 's@SELINUX=enforcing@SELINUX=disabled@g' /etc/sysconfig/selinux
-    sed -i 's@SELINUX=enforcing@SELINUX=disabled@g' /etc/selinux/config
-    setenforce 0
-}
-
-function install_JimVC() {
-    cat > /etc/yum.repos.d/JimV.repo << EOF
-[JimV]
-name=JimV - \$basearch
-baseurl=http://repo.jimv.cn/centos/7/os/\$basearch
-        http://repo.jimv.io/centos/7/os/\$basearch
-        http://repo.iit.im/centos/7/os/\$basearch
-failovermethod=priority
-enabled=1
-gpgcheck=0
-gpgkey=https://repo.jimv.cn/RPM-GPG-KEY-JIMV-114EA591
-EOF
-    yum install jimv-controller -y
-}
-
-function generate_passwords() {
-    export GENERATE_PASSWORD_SCRIPT='/usr/bin/gen_pswd.sh'
-
-    if [[ ! ${RDB_ROOT_PSWD} ]] || [[ ${#RDB_ROOT_PSWD} -eq 0 ]]; then
-        export RDB_ROOT_PSWD=`${GENERATE_PASSWORD_SCRIPT}`
-    fi
-
-    if [[ ! ${RDB_JIMV_PSWD} ]] || [[ ${#RDB_JIMV_PSWD} -eq 0 ]]; then
-        export RDB_JIMV_PSWD=`${GENERATE_PASSWORD_SCRIPT}`
-    fi
-
-    if [[ ! ${REDIS_PSWD} ]] || [[ ${#REDIS_PSWD} -eq 0 ]]; then
-        export REDIS_PSWD=`${GENERATE_PASSWORD_SCRIPT} 128`
-    fi
-
-    if [[ ! ${JWT_SECRET} ]] || [[ ${#JWT_SECRET} -eq 0 ]]; then
-        export JWT_SECRET=`${GENERATE_PASSWORD_SCRIPT} 128`
-    fi
-
-    if [[ ! ${SECRET_KEY} ]] || [[ ${#SECRET_KEY} -eq 0 ]]; then
-        export SECRET_KEY=`${GENERATE_PASSWORD_SCRIPT} 128`
-    fi
-}
-
-function create_web_user() {
-    useradd -M www
-}
-
-function install_MariaDB() {
-    # 安装 MariaDB
-    yum install mariadb mariadb-server -y
-
-    # 配置 MariaDB
-    mkdir -p /etc/systemd/system/mariadb.service.d
-    echo '[Service]' > /etc/systemd/system/mariadb.service.d/limits.conf
-    echo 'LimitNOFILE=65535' >> /etc/systemd/system/mariadb.service.d/limits.conf
-    systemctl --system daemon-reload
-
-    sed -i '/\[mysqld\]/a\bind-address = 127.0.0.1' /etc/my.cnf
-    sed -i '/\[mysqld\]/a\log-bin' /etc/my.cnf
-    sed -i '/\[mysqld\]/a\expire_logs_days = 1' /etc/my.cnf
-    sed -i '/\[mysqld\]/a\innodb_file_per_table' /etc/my.cnf
-    sed -i '/\[mysqld\]/a\max_connections = 10000' /etc/my.cnf
-
-    # 启动并使其随机启动
-    systemctl enable mariadb.service
-    systemctl start mariadb.service
-
-# 初始化 MariaDB
-mysql_secure_installation << EOF
-
-Y
-${RDB_ROOT_PSWD}
-${RDB_ROOT_PSWD}
-Y
-Y
-Y
-Y
-EOF
-
-    # 测试是否部署成功
-    mysql -u root -p${RDB_ROOT_PSWD} -e 'show databases'
-}
-
-function install_Redis() {
-    # 安装 Redis
-    yum install redis -y
-
-    # 配置 Redis
-    echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
-    sysctl -p
-    sed -i 's@^daemonize no@daemonize yes@g' /etc/redis.conf
-    sed -i 's@^bind 127.0.0.1@bind 0.0.0.0@g' /etc/redis.conf
-    echo "requirepass ${REDIS_PSWD}" >> /etc/redis.conf
-
-    # 启动并使其随机启动
-    systemctl enable redis.service
-    systemctl start redis.service
-}
-
-function install_Nginx() {
-    # 安装 Nginx
-    yum install nginx -y
-
-    # 配置 Nginx
-    mkdir -p /etc/jimv/keys
-    chown -R www.www /var/lib/nginx
-    sed -i 's@user nginx.*$@user www;@' /etc/nginx/nginx.conf
-    sed -i '/^.*server {/,$d' /etc/nginx/nginx.conf
-    cat /usr/share/jimv/controller/misc/nginx_jimv.conf >> /etc/nginx/nginx.conf
-
-    # 启动并使其随机启动
-    systemctl enable nginx.service
-    systemctl start nginx.service
-}
-
-function initialization_db() {
-    # 建立 JimV 数据库专属用户
-    mysql -u root -p${RDB_ROOT_PSWD} -e "grant all on jimv.* to jimv@localhost identified by \"${RDB_JIMV_PSWD}\"; flush privileges"
-
-    # 初始化数据库
-    mysql -u jimv -p${RDB_JIMV_PSWD} < /usr/share/jimv/controller/misc/init.sql
-
-    # 确认是否初始化成功
-    mysql -u jimv -p${RDB_JIMV_PSWD} -e 'show databases'
-}
-
-function generate_token() {
-    redis-cli -a ${REDIS_PSWD} --raw ZADD Z:Token $(($(date +%s) + 86400)) ${TOKEN}
-}
-
-function generate_config_file() {
-    sed -i "s/\"db_password\".*$/\"db_password\": \"${RDB_JIMV_PSWD}\",/" /etc/jimvc.conf
-    sed -i "s/\"redis_password\".*$/\"redis_password\": \"${REDIS_PSWD}\",/" /etc/jimvc.conf
-    sed -i "s/\"jwt_secret\".*$/\"jwt_secret\": \"${JWT_SECRET}\",/" /etc/jimvc.conf
-    sed -i "s/\"SECRET_KEY\".*$/\"SECRET_KEY\": \"${SECRET_KEY}\",/" /etc/jimvc.conf
-    sed -i "s/\"smtp_host\".*$/\"smtp_host\": \"${SMTP_HOST}\",/" /etc/jimvc.conf
-    sed -i "s/\"smtp_user\".*$/\"smtp_user\": \"${SMTP_USER}\",/" /etc/jimvc.conf
-    sed -i "s/\"smtp_password\".*$/\"smtp_password\": \"${SMTP_PASSWORD}\",/" /etc/jimvc.conf
-}
-
-function start_JimVC() {
-    systemctl start jimvc.service
-    systemctl enable jimvc.service
-}
-
-function display_summary_information() {
-    echo
-    echo "=== 信息汇总"
-    echo "MariaDB root 密码: [${RDB_ROOT_PSWD}]"
-    echo "MariaDB jimv 密码: [${RDB_JIMV_PSWD}]"
-    echo "Redis 端口: [6379]"
-    echo "Redis 密码: [${REDIS_PSWD}]"
-    echo "======================="
-    echo
-    echo "JimV-C 已经安装完成,您再需如下几步就能完成整个 JimV 的部署: "
-    echo
-    echo "--->"
-    echo "1: 通过 Web 页面 http://`hostname -I` 初始化 JimV-C。"
-    echo
-    echo "--->"
-    echo "2: 到 [计算节点] 执行如下命令,进行 JimV-N 的部署。"
-    echo "curl http://repo.jimv.cn/jimvn.install.sh | bash -s -- --host `hostname -I` --token ${TOKEN}"
-    echo
-    echo "--->"
-    echo "3: 享受 JimV 给您带来的 '简单、快速、灵活' 开创虚拟机实例的快乐。。。。。"
-    echo
-}
-
-function deploy() {
-    check_precondition
-    clear_up_environment
-    ensure_hosts_layout
-    sync_ssh_key_pair
-    sync_hosts_file
-    prepare
-    create_web_user
-    install_JimVC
-    generate_passwords
-    install_MariaDB
-    install_Redis
-    install_Nginx
-    initialization_db
-    generate_token
-    generate_config_file
-    start_JimVC
-    display_summary_information
-}
-
-deploy
-

+ 8 - 1
jimvc/api/guest.py

@@ -1741,7 +1741,14 @@ def r_vnc(uuid):
 
         port = random.randrange(50000, 60000)
 
-    payload = {'listen_port': port, 'target_host': hosts_mapping_by_node_id[guest_ret['data']['node_id']]['hostname'],
+    config = Config()
+    config.id = 1
+    config.get()
+
+    dst_ip = hosts_mapping_by_node_id[guest_ret['data']['node_id']]['interfaces'][config.vm_manage_network]['ip']
+
+    payload = {'listen_port': port,
+               'target_host': dst_ip,
                'target_port': guest_ret['data']['vnc_port']}
 
     db.r.rpush(app_config['ipc_queue'], json.dumps(payload, ensure_ascii=False))

+ 0 - 304
jimvn.install.sh

@@ -1,304 +0,0 @@
-#!/usr/bin/env bash
-#
-# JimV-N
-#
-# Copyright (C) 2017 JimV <james.iter.cn@gmail.com>
-#
-# Author: James Iter <james.iter.cn@gmail.com>
-#
-#  This script will help you automatically installed JimV-N.
-#
-
-export SHOW_WARNING_VTX=false
-
-ARGS=`getopt -o h --long host:,token:,version:,help -n 'INSTALL.sh' -- "$@"`
-
-eval set -- "${ARGS}"
-
-while true
-do
-    case "$1" in
-        --host)
-            export HOST=$2
-            shift 2
-            ;;
-        --token)
-            export TOKEN=$2
-            shift 2
-            ;;
-        --version)
-            export JIMV_VERSION=$2
-            shift 2
-            ;;
-        -h|--help)
-            echo 'INSTALL.sh [-h|--help|--version] {--host,--token}'
-            exit 0
-            ;;
-        --)
-            shift
-            break
-            ;;
-        *)
-            echo "Internal error!"
-            exit 1
-            ;;
-    esac
-done
-
-function check_precondition() {
-    source /etc/os-release
-    case ${ID} in
-    centos|fedora|rhel)
-        if [[ ${VERSION_ID} -lt 7 ]]; then
-            echo "系统版本号必须大于等于 7,检测到当前的系统版本号为 ${VERSION_ID}."
-	        exit 1
-        fi
-        ;;
-    *)
-        echo "系统发行版 ${ID} 未被支持,请手动完成安装。"
-	    exit 1
-        ;;
-    esac
-
-    if [[ `egrep -c '(vmx|svm)' /proc/cpuinfo` -eq 0 ]]; then
-        export SHOW_WARNING_VTX=true
-    fi
-
-    if [[ ! ${JIMV_VERSION} ]] || [[ ${#JIMV_VERSION} -eq 0 ]]; then
-        export JIMV_VERSION='master'
-    fi
-
-    if [[ ! ${HOST} ]] || [[ ${#HOST} -eq 0 ]]; then
-        echo "你需要指定参数 '--host'"
-        exit 1
-    fi
-
-    if [[ ! ${TOKEN} ]] || [[ ${#TOKEN} -eq 0 ]]; then
-        echo "你需要指定参数 '--token'"
-        exit 1
-    fi
-
-    yum install epel-release -y
-    yum install jq net-tools bind-utils -y
-    yum install redis -y
-
-    # 代替语句 ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'
-    SERVER_IP=`hostname -I`; export SERVER_IP=${SERVER_IP%% *}
-    export SERVER_NETMASK=`ifconfig | grep ${SERVER_IP} | grep -Eo 'netmask ?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'`
-    export GATEWAY=`route -n | grep '^0.0.0.0' | awk '{ print $2; }'`
-    export DNS1=`nslookup 127.0.0.1 | grep Server | grep -Eo '([0-9]*\.){3}[0-9]*'`
-    export NIC=`ifconfig | grep ${SERVER_IP} -B 1 | head -1 | cut -d ':' -f 1`
-    export NODE_ID=`python -c "with open('/etc/machine-id', 'r') as f: _str = f.read().strip(); import string; import hashlib; m = hashlib.md5(); m.update(_str); print int(string.atoi(m.hexdigest(), 16).__str__()[:16])"`
-
-    JOIN_RESPONSE=`curl http://${HOST}/api/misc/_join/${NODE_ID}/${TOKEN}`
-
-    export REDIS_HOST=`echo ${JOIN_RESPONSE} | jq -r '.data.redis_host'`
-    export REDIS_PORT=`echo ${JOIN_RESPONSE} | jq -r '.data.redis_port'`
-    export REDIS_PSWD=`echo ${JOIN_RESPONSE} | jq -r '.data.redis_password'`
-    export VM_NETWORK=`echo ${JOIN_RESPONSE} | jq -r '.data.vm_network'`
-    export VM_NETWORK_MANAGE=`echo ${JOIN_RESPONSE} | jq -r '.data.vm_manage_network'`
-
-    if [[ ! ${REDIS_HOST} ]] || [[ ${#REDIS_HOST} -eq 0 ]] || [[ ${REDIS_HOST} == null ]]; then
-        echo "请确认到 ${HOST} 的连通性,或 /etc/machine-id 与集群中其它节点冲突。"
-        echo "详情: ${JOIN_RESPONSE}"
-        exit 1
-    fi
-
-    if [[ ! ${REDIS_PORT} ]] || [[ ${#REDIS_PORT} -eq 0 ]] || [[ ${REDIS_HOST} == null ]]; then
-        echo "请确认到 ${HOST} 的连通性,或 /etc/machine-id 与集群中其它节点冲突。"
-        echo "详情: ${JOIN_RESPONSE}"
-        exit 1
-    fi
-
-    if [[ ! ${REDIS_PSWD} ]] || [[ ${#REDIS_PSWD} -eq 0 ]] || [[ ${REDIS_HOST} == null ]]; then
-        echo "请确认到 ${HOST} 的连通性,或 /etc/machine-id 与集群中其它节点冲突。"
-        echo "详情: ${JOIN_RESPONSE}"
-        exit 1
-    fi
-
-    if [[ ! ${VM_NETWORK} ]] || [[ ${#VM_NETWORK} -eq 0 ]] || [[ ${REDIS_HOST} == null ]]; then
-        echo "请确认到 ${HOST} 的连通性,或 /etc/machine-id 与集群中其它节点冲突。"
-        echo "详情: ${JOIN_RESPONSE}"
-        exit 1
-    fi
-
-    if [[ ! ${VM_NETWORK_MANAGE} ]] || [[ ${#VM_NETWORK_MANAGE} -eq 0 ]] || [[ ${REDIS_HOST} == null ]]; then
-        echo "请确认到 ${HOST} 的连通性,或 /etc/machine-id 与集群中其它节点冲突。"
-        echo "详情: ${JOIN_RESPONSE}"
-        exit 1
-    fi
-
-    REDIS_RESPONSE='x_'`redis-cli -h ${REDIS_HOST} -a ${REDIS_PSWD} -p ${REDIS_PORT} --raw ping`
-
-    if [[ ${REDIS_RESPONSE} != 'x_PONG' ]]; then
-        echo "Redis 连接失败,请检查参数 --host, --token 是否正确。"
-        exit 1
-    fi
-}
-
-function custom_repository_origin() {
-    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
-    mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
-    mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
-    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
-    curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
-    sed -i '/aliyuncs/d' /etc/yum.repos.d/*.repo
-    yum clean all
-    yum makecache
-}
-
-function clear_up_environment() {
-    systemctl stop firewalld
-    systemctl disable firewalld
-    systemctl stop NetworkManager
-    systemctl disable NetworkManager
-
-    sed -i 's@SELINUX=enforcing@SELINUX=disabled@g' /etc/sysconfig/selinux
-    sed -i 's@SELINUX=enforcing@SELINUX=disabled@g' /etc/selinux/config
-    setenforce 0
-}
-
-function install_libvirt_and_libguestfish() {
-    # 安装 libvirt
-    cat > /etc/yum.repos.d/JimV.repo << EOF
-[JimV]
-name=JimV - \$basearch
-baseurl=http://repo.jimv.cn/centos/7/os/\$basearch
-        http://repo.jimv.io/centos/7/os/\$basearch
-        http://repo.iit.im/centos/7/os/\$basearch
-failovermethod=priority
-enabled=1
-gpgcheck=0
-gpgkey=https://repo.jimv.cn/RPM-GPG-KEY-JIMV-114EA591
-EOF
-
-    uname -m | grep -q 'x86_64'  && echo 'centos' >/etc/yum/vars/contentdir || echo 'altarch' >/etc/yum/vars/contentdir
-    yum install centos-release-qemu-ev -y
-    yum install jimv-node -y
-    yum install librbd1-10.2.5 -y
-}
-
-function tune_linux_kernel_parameters() {
-    sed -i '/^net.ipv4.ip_local_port_range/d' /etc/sysctl.conf
-    echo 'net.ipv4.ip_local_port_range = 15900 20000' >> /etc/sysctl.conf
-    sysctl -p
-}
-
-function handle_ssh_client_config() {
-    # 关闭 SSH 服务器端 Key 校验
-    sed -i 's@.*StrictHostKeyChecking.*@StrictHostKeyChecking no@' /etc/ssh/ssh_config
-}
-
-function handle_net_bonding_bridge() {
-    # 参考地址: https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/7/html/networking_guide/
-cat > /etc/sysconfig/network-scripts/ifcfg-${VM_NETWORK} << EOF
-DEVICE=${VM_NETWORK}
-NAME=${VM_NETWORK}
-TYPE=Bridge
-BOOTPROTO=static
-ONBOOT=yes
-DELAY=0
-IPADDR=${SERVER_IP}
-NETMASK=${SERVER_NETMASK}
-GATEWAY=${GATEWAY}
-DNS1=${DNS1}
-DNS2=8.8.8.8
-IPV6INIT=no
-EOF
-
-cat > /etc/sysconfig/network-scripts/ifcfg-bond0 << EOF
-DEVICE=bond0
-NAME=bond0
-TYPE=Bond
-BRIDGE=${VM_NETWORK}
-BONDING_MASTER=yes
-ONBOOT=yes
-BOOTPROTO=none
-BONDING_OPTS="mode=balance-alb xmit_hash_policy=layer3+4"
-EOF
-
-cat > /etc/sysconfig/network-scripts/ifcfg-${NIC} << EOF
-DEVICE=${NIC}
-NAME=${NIC}
-TYPE=Ethernet
-BOOTPROTO=none
-ONBOOT=yes
-MASTER=bond0
-SLAVE=yes
-EOF
-
-    /etc/init.d/network restart
-}
-
-function create_network_bridge_in_libvirt() {
-
-cat > /etc/libvirt/qemu/networks/${VM_NETWORK}.xml << EOF
-<network>
-    <uuid>the_uuid</uuid>
-    <name>${VM_NETWORK}</name>
-    <forward mode="bridge"/>
-    <bridge name="${VM_NETWORK}"/>
-</network>
-EOF
-
-    sed -i "s@the_uuid@`uuidgen`@" /etc/libvirt/qemu/networks/${VM_NETWORK}.xml
-
-    # 去除默认的 default 网络定义
-    rm -f /etc/libvirt/qemu/networks/default.xml /etc/libvirt/qemu/networks/autostart/default.xml
-
-    # 使其随服务自动创建
-    cd /etc/libvirt/qemu/networks/autostart/
-    ln -s ../${VM_NETWORK}.xml ${VM_NETWORK}.xml
-}
-
-function start_libvirtd() {
-    systemctl stop dnsmasq
-    systemctl disable dnsmasq
-    systemctl enable libvirtd
-    systemctl start libvirtd
-}
-
-function generate_config_file() {
-    sed -i "s/\"redis_host\".*$/\"redis_host\": \"${REDIS_HOST}\",/" /etc/jimvn.conf
-    sed -i "s/\"redis_password\".*$/\"redis_password\": \"${REDIS_PSWD}\",/" /etc/jimvn.conf
-    sed -i "s/\"redis_port\".*$/\"redis_port\": \"${REDIS_PORT}\",/" /etc/jimvn.conf
-}
-
-function start_JimVN() {
-    systemctl start jimvn.service
-    systemctl enable jimvn.service
-}
-
-function display_summary_information() {
-    echo
-    echo "=== 信息汇总"
-    echo "==========="
-    echo
-
-    if [[ ${SHOW_WARNING_VTX} = true ]]; then
-        echo "警告:请检查 CPU 是否开启 VT 技术。未开启 VT 技术的计算节点,将以 QEMU 模式运行虚拟机。"
-        echo
-    fi
-
-    echo "已经通过 'systemctl enable jimvn.service' 把 JimV-N 注册为随系统启动的服务。"
-    echo "您还可以通过命令 'systemctl [start|stop|status] jimvn.service' 来管理本机的 JimV-N。"
-    echo
-}
-
-function deploy() {
-    check_precondition
-    custom_repository_origin
-    clear_up_environment
-    install_libvirt_and_libguestfish
-    tune_linux_kernel_parameters
-    handle_ssh_client_config
-    handle_net_bonding_bridge
-    create_network_bridge_in_libvirt
-    start_libvirtd
-    generate_config_file
-    start_JimVN
-    display_summary_information
-}
-
-deploy
-