''' @author: frank ''' import sys, os, os.path import fusionstoragent from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/fusionstor-primarystorage.pid' log.configure_log('/var/log/zstack/fusionstor-primarystorage.log') logger = log.get_logger(__name__) def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from fusionstorprimarystorage import cdaemon; cdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try: iptc = iptables.from_iptables_save() iptc.add_rule('-A INPUT -p tcp -m tcp --dport 7764 -j ACCEPT')
import sys reload(sys) sys.setdefaultencoding('utf8') import shlex import hashlib import optparse import termcolor import pydoc import time import urllib3 import zstacklib.utils.log as log # comment out next line to print detail zstack cli http command to screen. log.configure_log('/var/log/zstack/zstack-cli', log_to_console=False) import apibinding.inventory as inventory import apibinding.api as api import zstacklib.utils.jsonobject as jsonobject import zstacklib.utils.filedb as filedb import zstackcli.parse_config as parse_config import zstackcli.deploy_config as deploy_config import zstackcli.read_config as read_config cld = termcolor.colored cprint = termcolor.cprint text_doc = pydoc.TextDoc() CLI_LIB_FOLDER = os.path.expanduser('~/.zstack/cli')
import sys sys.path.append("/var/lib/zstack/virtualenv/kvm/lib/python2.7/site-packages/") import json from zstacklib.utils import bash from zstacklib.utils import lvm from zstacklib.utils import log from zstacklib.utils import qemu_img log.configure_log("/var/log/zstack/convert_volume.log", log_to_console=False) logger = log.get_logger(__name__) START_TAG = "zs-start-convert" DONE_TAG = "zs-convert-done" RAW_SUFFIX = "_zs_convert_raw" QCOW2_SUFFIX = "_zs_convert_qcow2" @bash.in_bash def get_volume_format(path): info = json.loads( bash.bash_o("%s %s --output json" % (qemu_img.subcmd('info'), path))) logger.debug(info) return info["format"] def check(volume_abs_path, raw_volume_abs_path): with lvm.OperateLv(volume_abs_path, shared=False, delete_when_exception=False): if get_volume_format(volume_abs_path) == "raw":
''' @author: frank ''' import sys, os, os.path from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/kvmagent.pid' log.configure_log('/var/log/zstack/zstack-kvmagent.log') logger = log.get_logger(__name__) import kvmagent def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from kvmagent import kdaemon; kdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try: iptc = iptables.from_iptables_save()
''' @author: frank ''' import sys, os, os.path import console_proxy_agent from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/zstack-console-proxy.pid' log.configure_log('/var/log/zstack/zstack-console-proxy.log') logger = log.get_logger(__name__) def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from consoleproxy import cdaemon; cdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try: iptables.insert_single_rule_to_filter_table('-A INPUT -p tcp -m tcp --dport 7758 -j ACCEPT') cmd = sys.argv[1] py_process_name = 'from consoleproxy import cdaemon'
''' @author: frank ''' import sys, os, os.path import fusionstoragent from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/fusionstor-primarystorage.pid' log.configure_log('/var/log/zstack/fusionstor-primarystorage.log') logger = log.get_logger(__name__) def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from fusionstorprimarystorage import cdaemon; cdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try:
''' @author: Frank ''' import sys, os, os.path import virtualrouter from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables log.configure_log('/var/log/zstack/zstack-virtualrouter.log') logger = log.get_logger(__name__) def main(): usage = 'usage: python -c "from virtualrouter import virtualrouterdaemon; virtualrouterdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) pidfile = '/var/run/zstack/virtualrouter.pid' dirname = os.path.dirname(pidfile) if not os.path.exists(dirname): os.makedirs(dirname, 0755) try: iptables.insert_single_rule_to_filter_table('-A INPUT -i eth0 -p tcp -m tcp --dport 7272 -j ACCEPT') cmd = sys.argv[1] agentdaemon = virtualrouter.VirutalRouterDaemon(pidfile) if cmd == 'start': agentdaemon.start()
''' @author: frank ''' import sys, os, os.path import cephagent from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/ceph-primarystorage.pid' log.configure_log('/var/log/zstack/ceph-primarystorage.log') logger = log.get_logger(__name__) def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from cephprimarystorage import cdaemon; cdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try:
''' @author: zhou ''' import sys, os, os.path import surfsagent from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/surfs-backupstorage.pid' log.configure_log('/var/log/zstack/surfs-backupstorage.log') logger = log.get_logger(__name__) def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from surfsbackupstorage import cdaemon; cdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try:
''' @author: frank ''' import sys, os, os.path import cephagent from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/ceph-primarystorage.pid' log.configure_log('/var/log/zstack/ceph-primarystorage.log') logger = log.get_logger(__name__) def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from cephprimarystorage import cdaemon; cdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try: iptc = iptables.from_iptables_save() iptc.add_rule('-A INPUT -p tcp -m tcp --dport 7762 -j ACCEPT')
import sys sys.path.append("/var/lib/zstack/virtualenv/kvm/lib/python2.7/site-packages/") import json from zstacklib.utils import bash from zstacklib.utils import lvm from zstacklib.utils import log log.configure_log("/var/log/zstack/convert_volume.log", log_to_console=False) logger = log.get_logger(__name__) START_TAG = "zs-start-convert" DONE_TAG = "zs-convert-done" RAW_SUFFIX = "_zs_convert_raw" QCOW2_SUFFIX = "_zs_convert_qcow2" @bash.in_bash def get_volume_format(path): info = json.loads(bash.bash_o("qemu-img info %s --output json" % path)) logger.debug(info) return info["format"] def check(volume_abs_path, raw_volume_abs_path): with lvm.OperateLv(volume_abs_path, shared=False, delete_when_exception=False): if get_volume_format(volume_abs_path) == "raw": raise Exception("volume %s is raw format, no need to convert" % volume_abs_path) if lvm.has_lv_tag(volume_abs_path, START_TAG): raise Exception("there is tag %s on volume %s, there may other process processing, please check or wait" % (START_TAG, volume_abs_path)) if lvm.has_lv_tag(volume_abs_path, DONE_TAG):
''' @author: frank ''' import sys, os, os.path import sftpbackupstorage from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/sftpbackupstorageagent.pid' log.configure_log('/var/log/zstack/zstack-sftpbackupstorage.log') logger = log.get_logger(__name__) def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from sftpbackupstorage import sftpbackupstoragedaemon; sftpbackupstoragedaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try:
''' @author: Frank ''' from zstacklib.utils import log log.configure_log("/var/log/zstack/zstack-setting.log", log_to_console=False) logger = log.get_logger(__name__) from zstacklib.utils import plugin from zstacklib.utils import linux from zstacklib.utils import xmlobject from zstacklib.utils import shell import os.path import os import argparse import sys import re import datetime import textwrap class SettingPlugin(plugin.Plugin): def start(self): pass def stop(self): pass def check_system(self): pass
''' @author: frank ''' import sys, os, os.path from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/ceph-backupstorage.pid' log.configure_log('/var/log/zstack/ceph-backupstorage.log') logger = log.get_logger(__name__) import cephagent def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from cephbackupstorage import cdaemon; cdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try: cmd = sys.argv[1] py_process_name = 'from cephbackupstorage import cdaemon'
''' @author: frank ''' import sys, os, os.path import iscsiagent from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/iscsi-filesystem-agent.pid' log.configure_log('/var/log/zstack/zstack-iscsi-filesystem-agent.log') logger = log.get_logger(__name__) def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from iscsifilesystemagent import idaemon; idaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try: iptc = iptables.from_iptables_save() iptc.add_rule('-A INPUT -p tcp -m tcp --dport 7760 -j ACCEPT')
''' @author: frank ''' import sys, os, os.path from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/zstack-baremetalpxeserver.pid' log.configure_log('/var/log/zstack/zstack-baremetalpxeserver.log') logger = log.get_logger(__name__) import pxeserveragent def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from baremetalpxeserver import cdaemon; cdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try:
''' @author: frank ''' import sys, os, os.path import iscsiagent from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/iscsi-filesystem-agent.pid' log.configure_log('/var/log/zstack/zstack-iscsi-filesystem-agent.log') logger = log.get_logger(__name__) def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from iscsifilesystemagent import idaemon; idaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try:
''' @author: frank ''' import sys, os, os.path import fusionstoragent from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/fusionstor-backupstorage.pid' log.configure_log('/var/log/zstack/fusionstor-backupstorage.log') logger = log.get_logger(__name__) def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from fusionstorbackupstorage import cdaemon; cdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try: iptc = iptables.from_iptables_save() iptc.add_rule('-A INPUT -p tcp -m tcp --dport 7761 -j ACCEPT')
import readline import sys reload(sys) sys.setdefaultencoding('utf8') import shlex import hashlib import optparse import termcolor import pydoc import time import urllib3 import zstacklib.utils.log as log #comment out next line to print detail zstack cli http command to screen. log.configure_log('/var/log/zstack/zstack-cli', log_to_console=False) import apibinding.inventory as inventory import apibinding.api as api import zstacklib.utils.jsonobject as jsonobject import zstacklib.utils.filedb as filedb import zstackcli.parse_config as parse_config import zstackcli.deploy_config as deploy_config import zstackcli.read_config as read_config cld = termcolor.colored cprint = termcolor.cprint text_doc = pydoc.TextDoc()
''' @author: frank ''' import sys, os, os.path from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/app-buildsystem.pid' log.configure_log('/var/log/zstack/app-buildsystem.log') logger = log.get_logger(__name__) import appbuildsystem def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from appbuildsystem import appdaemon; appdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try:
''' @author: Frank ''' import sys, os, os.path import virtualrouter from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables log.configure_log('/var/log/zstack/zstack-virtualrouter.log') logger = log.get_logger(__name__) def main(): usage = 'usage: python -c "from virtualrouter import virtualrouterdaemon; virtualrouterdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) pidfile = '/var/run/zstack/virtualrouter.pid' dirname = os.path.dirname(pidfile) if not os.path.exists(dirname): os.makedirs(dirname, 0755) try: iptables.insert_single_rule_to_filter_table( '-A INPUT -i eth0 -p tcp -m tcp --dport 7272 -j ACCEPT') cmd = sys.argv[1] py_process_name = 'from virtualrouter import virtualrouterdaemon'
''' @author: frank ''' import sys, os, os.path from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/zstack-baremetalpxeserver.pid' log.configure_log('/var/log/zstack/zstack-baremetalpxeserver.log') logger = log.get_logger(__name__) import pxeserveragent def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from baremetalpxeserver import cdaemon; cdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try: iptc = iptables.from_iptables_save() iptc.add_rule('-A INPUT -p tcp -m tcp --dport 7770 -j ACCEPT')
''' @author: frank ''' import sys, os, os.path import console_proxy_agent from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/zstack-console-proxy.pid' log.configure_log('/var/log/zstack/zstack-console-proxy.log') logger = log.get_logger(__name__) def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from consoleproxy import cdaemon; cdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try: iptables.insert_single_rule_to_filter_table(
''' @author: frank ''' import sys, os, os.path from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/aliyunagent.pid' log.configure_log('/var/log/zstack/zstack-aliyunagent.log') logger = log.get_logger(__name__) import ecsagent def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from aliyunagent import kdaemon; kdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile)
''' @author: frank ''' import sys, os, os.path import sftpbackupstorage from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/sftpbackupstorageagent.pid' log.configure_log('/var/log/zstack/zstack-sftpbackupstorage.log') logger = log.get_logger(__name__) def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from sftpbackupstorage import sftpbackupstoragedaemon; sftpbackupstoragedaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try: iptables.insert_single_rule_to_filter_table('-A INPUT -p tcp -m tcp --dport 7171 -j ACCEPT') cmd = sys.argv[1]
import optparse import shutil import time import subprocess import copy import string import Queue import threading import traceback import signal import datetime import zstackwoodpecker.test_case as test_case test_start_time = time.time() log.configure_log('/var/log/zstack/zstack-woodpecker.log') # log shell command shell.logcmd = True # Default test folder DEFAULT_TEST_CONFIG = 'DEFAULT_TEST_CONFIG' LOCAL_WOODPECKER_FOLDER = os.path.join(os.path.expanduser('~'), '.zstackwoodpecker/integrationtest') TEST_CONFIG_FILE = 'test-config.xml' sig_flag = False USER_PATH = os.path.expanduser('~') POST_TEST_CASE_SCRIPT = '%s/.zstackwoodpecker/post_test_case_script.sh' % USER_PATH class TestError(Exception): ''' test error ''' class TestSuite(object):
''' @author: frank ''' import sys, os, os.path import cephagent from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/ceph-backupstorage.pid' log.configure_log('/var/log/zstack/ceph-backupstorage.log') logger = log.get_logger(__name__) def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from cephbackupstorage import cdaemon; cdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try: iptc = iptables.from_iptables_save() iptc.add_rule('-A INPUT -p tcp -m tcp --dport 7761 -j ACCEPT')
import time import subprocess import copy import string import Queue import threading import traceback import signal import datetime import zstackwoodpecker.test_case as test_case import zstackwoodpecker.operations.scenario_operations as scenario_operations import zstackwoodpecker.test_lib as test_lib test_start_time = time.time() log.configure_log('/var/log/zstack/zstack-woodpecker.log') # log shell command shell.logcmd = True # Default test folder DEFAULT_TEST_CONFIG = 'DEFAULT_TEST_CONFIG' LOCAL_WOODPECKER_FOLDER = os.path.join(os.path.expanduser('~'), '.zstackwoodpecker/integrationtest') TEST_CONFIG_FILE = 'test-config.xml' sig_flag = False USER_PATH = os.path.expanduser('~') POST_TEST_CASE_SCRIPT = '%s/.zstackwoodpecker/post_test_case_script.sh' % USER_PATH class TestError(Exception): ''' test error '''
''' @author: Frank ''' from zstacklib.utils import log log.configure_log("/var/log/zstack/zstack-setting.log", log_to_console=False) logger = log.get_logger(__name__) from zstacklib.utils import plugin from zstacklib.utils import linux from zstacklib.utils import xmlobject from zstacklib.utils import shell import os.path import os import argparse import sys import re import datetime import textwrap class SettingPlugin(plugin.Plugin): def start(self): pass def stop(self): pass def check_system(self):
import sys, os, os.path from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables import appliancevm log.configure_log('/var/log/zstack/zstack-appliancevm.log') logger = log.get_logger(__name__) def main(): usage = 'usage: python -c "from appliancevm import daemon; daemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) pidfile = '/var/run/zstack/appliancevm.pid' dirname = os.path.dirname(pidfile) if not os.path.exists(dirname): os.makedirs(dirname, 0755) try: iptables.insert_single_rule_to_filter_table( '-A INPUT -i eth0 -p tcp -m tcp --dport 7759 -j ACCEPT') cmd = sys.argv[1] agentdaemon = appliancevm.ApplianceVmDaemon(pidfile) if cmd == 'start': agentdaemon.start() elif cmd == 'stop': agentdaemon.stop() elif cmd == 'restart':
import sys,os,os.path from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables import appliancevm log.configure_log('/var/log/zstack/zstack-appliancevm.log') logger = log.get_logger(__name__) def main(): usage = 'usage: python -c "from appliancevm import daemon; daemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) pidfile = '/var/run/zstack/appliancevm.pid' dirname = os.path.dirname(pidfile) if not os.path.exists(dirname): os.makedirs(dirname, 0755) try: iptables.insert_single_rule_to_filter_table('-A INPUT -i eth0 -p tcp -m tcp --dport 7759 -j ACCEPT') cmd = sys.argv[1] py_process_name = 'from appliancevm import daemon' agentdaemon = appliancevm.ApplianceVmDaemon(pidfile, py_process_name) if cmd == 'start': agentdaemon.start() elif cmd == 'stop': agentdaemon.stop() elif cmd == 'restart': agentdaemon.restart()
''' @author: frank ''' import sys, os, os.path import fusionstoragent from zstacklib.utils import log from zstacklib.utils import linux import zstacklib.utils.iptables as iptables pidfile = '/var/run/zstack/fusionstor-backupstorage.pid' log.configure_log('/var/log/zstack/fusionstor-backupstorage.log') logger = log.get_logger(__name__) def prepare_pid_dir(path): pdir = os.path.dirname(path) if not os.path.isdir(pdir): os.makedirs(pdir) def main(): usage = 'usage: python -c "from fusionstorbackupstorage import cdaemon; cdaemon.main()" start|stop|restart' if len(sys.argv) != 2 or not sys.argv[1] in ['start', 'stop', 'restart']: print usage sys.exit(1) global pidfile prepare_pid_dir(pidfile) try: