<commit_before>#!/usr/bin/env python
# encoding: utf-8
import argparse
from zstacklib import *
from datetime import datetime


start_time = datetime.now()
# set default value
file_root = "files/sftpbackupstorage"
pip_url = "https=//pypi.python.org/simple/"
proxy = ""
sproxy = ""
chroot_env = 'false'
zstack_repo = 'false'
current_dir = os.path.dirname(os.path.realpath(__file__))
post_url = ""
pkg_sftpbackupstorage = ""
virtualenv_version = "12.1.1"
remote_user = "root"
remote_pass = None
remote_port = None

# get parameter from shell
parser = argparse.ArgumentParser(description='Deploy kvm to host')
parser.add_argument('-i', type=str, help="""specify inventory host file
                        default=/etc/ansible/hosts""")
parser.add_argument('--private-key', type=str, help='use this file to authenticate the connection')
parser.add_argument('-e', type=str, help='set additional variables as key=value or YAML/JSON')

args = parser.parse_args()
argument_dict = eval(args.e)

# update the variable from shell arguments
locals().update(argument_dict)
virtenv_path = "%s/virtualenv/sftpbackupstorage/" % zstack_root
sftp_root = "%s/sftpbackupstorage" % zstack_root
# create log
logger_dir = "/var/log/zstack/"
create_log(logger_dir)
host_post_info = HostPostInfo()
host_post_info.host_inventory = args.i
host_post_info.host = host
host_post_info.post_url = post_url
host_post_info.private_key = args.private_key
host_post_info.remote_user = remote_user
host_post_info.remote_pass = <PASSWORD>
host_post_info.remote_port = remote_port
if remote_pass is not None:
    host_post_info.become = True

# include zstacklib.py
(distro, distro_version, distro_release) = get_remote_host_info(host_post_info)
zstacklib_args = ZstackLibArgs()
zstacklib_args.distro = distro
zstacklib_args.distro_release = distro_release
zstacklib_args.distro_version = distro_version
zstacklib_args.zstack_repo = zstack_repo
zstacklib_args.yum_server = yum_server
zstacklib_args.zstack_root = zstack_root
zstacklib_args.host_post_info = host_post_info
zstacklib_args.pip_url = pip_url
zstacklib_args.trusted_host = trusted_host
zstacklib = ZstackLib(zstacklib_args)

# name: judge this process is init install or upgrade
if file_dir_exist("path=" + sftp_root, host_post_info):
    init_install = False
else:
    init_install = True
    # name: create root directories
    command = 'mkdir -p %s %s' % (sftp_root, virtenv_path)
    run_remote_command(command, host_post_info)

if distro == "RedHat" or distro == "CentOS":
    if zstack_repo != 'false':
        # name: install sftp backup storage related packages on RedHat based OS from local
        command = 'yum --disablerepo=* --enablerepo=%s --nogpgcheck install -y openssh-clients' % zstack_repo
        run_remote_command(command, host_post_info)
    else:
        # name: install sftp backup storage related packages on RedHat based OS from online
        yum_install_package("openssh-clients", host_post_info)

elif distro == "Debian" or distro == "Ubuntu":
    apt_install_packages(["openssh-client"], host_post_info)

else:
    print "unsupported OS!"
    sys.exit(1)
<commit_msg>add qemu-img into sftpbackup storage<commit_after>#!/usr/bin/env python
# encoding: utf-8
import argparse
from zstacklib import *
from datetime import datetime


start_time = datetime.now()
# set default value
file_root = "files/sftpbackupstorage"
pip_url = "https=//pypi.python.org/simple/"
proxy = ""
sproxy = ""
chroot_env = 'false'
zstack_repo = 'false'
current_dir = os.path.dirname(os.path.realpath(__file__))
post_url = ""
pkg_sftpbackupstorage = ""
virtualenv_version = "12.1.1"
remote_user = "root"
remote_pass = None
remote_port = None

# get parameter from shell
parser = argparse.ArgumentParser(description='Deploy kvm to host')
parser.add_argument('-i', type=str, help="""specify inventory host file
                        default=/etc/ansible/hosts""")
parser.add_argument('--private-key', type=str, help='use this file to authenticate the connection')
parser.add_argument('-e', type=str, help='set additional variables as key=value or YAML/JSON')

args = parser.parse_args()
argument_dict = eval(args.e)

# update the variable from shell arguments
locals().update(argument_dict)
virtenv_path = "%s/virtualenv/sftpbackupstorage/" % zstack_root
sftp_root = "%s/sftpbackupstorage" % zstack_root
# create log
logger_dir = "/var/log/zstack/"
create_log(logger_dir)
host_post_info = HostPostInfo()
host_post_info.host_inventory = args.i
host_post_info.host = host
host_post_info.post_url = post_url
host_post_info.private_key = args.private_key
host_post_info.remote_user = remote_user
host_post_info.remote_pass = <PASSWORD>
host_post_info.remote_port = remote_port
if remote_pass is not None:
    host_post_info.become = True

# include zstacklib.py
(distro, distro_version, distro_release) = get_remote_host_info(host_post_info)
zstacklib_args = ZstackLibArgs()
zstacklib_args.distro = distro
zstacklib_args.distro_release = distro_release
zstacklib_args.distro_version = distro_version
zstacklib_args.zstack_repo = zstack_repo
zstacklib_args.yum_server = yum_server
zstacklib_args.zstack_root = zstack_root
zstacklib_args.host_post_info = host_post_info
zstacklib_args.pip_url = pip_url
zstacklib_args.trusted_host = trusted_host
zstacklib = ZstackLib(zstacklib_args)

# name: judge this process is init install or upgrade
if file_dir_exist("path=" + sftp_root, host_post_info):
    init_install = False
else:
    init_install = True
    # name: create root directories
    command = 'mkdir -p %s %s' % (sftp_root, virtenv_path)
    run_remote_command(command, host_post_info)

if distro == "RedHat" or distro == "CentOS":
    if zstack_repo != 'false':
        # name: install sftp backup storage related packages on RedHat based OS from local
        command = 'yum --disablerepo=* --enablerepo=%s --nogpgcheck install -y openssh-clients qemu-img' % zstack_repo
        run_remote_command(command, host_post_info)
    else:
        # name: install sftp backup storage related packages on RedHat based OS from online
        yum_install_package("openssh-clients", host_post_info)
        yum_install_package("qemu-img", host_post_info)

elif distro == "Debian" or distro == "Ubuntu":
    apt_install_packages(["openssh-client"], host_post_info)
    apt_install_packages(["qemu-utils"], host_post_info)

else:
    print "unsupported OS!"
    sys.exit(1)

{'fraction_non_alphanumeric': 0.10107964324831795, 'fraction_numerical': 0.0018776404318572994, 'mean_word_length': 5.205825242718447, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3098765', 'n_tokens_mistral': 2205, 'n_tokens_neox': 2145, 'n_words': 489}