def upload_file(remote_location, local_location, sudo=False):
    """
    Fabric task to upload a file to a VM.
    """
    cuisine.file_upload(remote_location,
                        local_location, sudo=sudo)
    cuisine.file_ensure(remote_location)
def service_ctl(service='listenerdaemon', command='start', use_sudo=False):
    cuisine.file_ensure(('/etc/init.d/%s' % service))
    cmd = str('/etc/init.d/%s %s' % (service, command))
    if use_sudo:
        cuisine.sudo(cmd, shell=False)
    else:
        cuisine.run(cmd, shell=False)
def run_remote_background_process(p_fab_api,
                                  p_command_to_run,
                                  p_out_file,
                                  p_err_file,
                                  p_log_fun,
                                  p_shell=True,
                                  p_pty=False):
    p_log_fun('FUN_ENTER', 'gf_fabric_utils.run_remote_background_process()')
    p_log_fun('INFO', 'p_command_to_run:%s' % (p_command_to_run))

    cuisine.dir_ensure(os.path.dirname(p_out_file), recursive=True)
    cuisine.file_ensure(p_out_file)

    cuisine.dir_ensure(os.path.dirname(p_err_file), recursive=True)
    cuisine.file_ensure(p_err_file)

    #nohup is a POSIX command to ignore the HUP (hangup) signal,
    #enabling the command to keep running after the user who
    #issues the command has logged out. The HUP (hangup) signal is
    #by convention the way a terminal warns depending processes of logout.

    #streams stdout/stderr to the out_file/err_file

    command_str = 'nohup %s >%s 2>%s </dev/null &' % (
        p_command_to_run, p_out_file, p_err_file or '&1')
    out = p_fab_api.run(command_str, p_shell, p_pty)
    return out
def run_python_program(program=None, sudo=False):
    """
    Fabric task to run a Python program on a VM.
    """
    cuisine.file_ensure('/usr/bin/python')
    if sudo:
        sudo('/usr/bin/python %s' % program)
    else:
        run('/usr/bin/python %s' % program)
示例#5
0
def run_python_program(program=None, sudo=False):
    """
    Fabric task to run a Python program on a VM.
    """
    cuisine.file_ensure('/usr/bin/python')
    if sudo:
        cuisine.sudo(('/usr/bin/python %s' % program))
    else:
        cuisine.run(('/usr/bin/python %s' % program))
示例#6
0
文件: deploy.py 项目: xbee/wspushd
def create_deploy():
	'''
	Create a deploy repos on remote server
	'''
	cuisine.dir_ensure("deploy/lgw.git")
	with cd("deploy/lgw.git"):
		run("git init --bare")
		cuisine.file_ensure("hooks/post-receive")
		if not files.contains("hooks/post-receive", POST_RECEIVE):
			files.append("hooks/post-receive", POST_RECEIVE)
		run('chmod +x hooks/post-receive')
def install_files():
    '''
    Installs Python scripts and files required for Nagios autoconfiguration on
    Nagios VM.
    '''
    sudo('touch /usr/local/nagios/etc/server_list')
    sudo(str('chown %s.%s /usr/local/nagios/etc/server_list' % (ssh_user,ssh_user)))
    sudo('chmod 0644 /usr/local/nagios/etc/server_list')
    cuisine.file_ensure('/usr/local/nagios/etc/server_list')
    put('../config.ini', '/usr/local/nagios/config.ini', use_sudo=True)
    put('../vm_list_extractor/vm_list_extractor.py', '/usr/local/nagios/etc/vm_list_extractor.py', use_sudo=True)
    put('../openstack_vms_nrpe_config/openstack_vms_nrpe_config.py', '/usr/local/nagios/etc/remote.py', use_sudo=True)
    put('../openstack_vms_nrpe_config/nrpe.cfg', '/usr/local/nagios/etc/nrpe.cfg', use_sudo=True)
    put('../openstack_vms_nrpe_config/check_memory.sh', '/usr/local/nagios/libexec/check_memory.sh', use_sudo=True)
    put('../nagios_config_updater/config_generator.py', '/usr/local/nagios/etc/config_generator.py', use_sudo=True)
    put('../nagios_config_updater/config_transporter.py', '/usr/local/nagios/etc/config_transporter.py', use_sudo=True)
    put('../nagios_config_updater/nagios_config_updater.py', '/usr/local/nagios/etc/nagios_config_updater.py', use_sudo=True)
    put('../nagios_config_updater/vm_template.cfg', '/usr/local/nagios/etc/vm_template.cfg', use_sudo=True)
    put('../nagios_config_updater/nagios-template.cfg', '/usr/local/nagios/etc/nagios-template.cfg', use_sudo=True)
    put('./commands.cfg', '/usr/local/nagios/etc/objects/commands.cfg', use_sudo=True)    
    put(ssh_key_filename, ssh_remote_key_filename, use_sudo=True)
    put(ssh_public_key_filename, ssh_remote_public_key_filename, use_sudo=True)
    sudo(str('chmod 0600 %s'%(ssh_remote_key_filename)))
def run_python_program(program=None, param='0', sudo=False):
    cuisine.file_ensure('/usr/bin/python')
    if sudo:
        cuisine.sudo(('/usr/bin/python %s -n %s' % (program, param)))
    else:
        cuisine.run(('/usr/bin/python %s -n %s' % (program, param)))
def run_python_program(program=None, sudo=False):
    cuisine.file_ensure('/usr/bin/python')
    if sudo:
        cuisine.sudo(('/usr/bin/python %s' % program))
    else:
        cuisine.run(('/usr/bin/python %s' % program))
def upload_file(remote_location, local_location, sudo=False):
    cuisine.file_upload(remote_location, local_location, sudo=sudo)
    cuisine.file_ensure(remote_location)
示例#11
0
def upload_file(remote_location, local_location, sudo=False):
    """
    Fabric task to upload a file to a VM.
    """
    cuisine.file_upload(remote_location, local_location, sudo=sudo)
    cuisine.file_ensure(remote_location)
示例#12
0
文件: setup.py 项目: icclab/n_o_conf
def upload_file(remote_location, local_location, sudo=False):
    cuisine.file_upload(remote_location, local_location, sudo=sudo)
    cuisine.file_ensure(remote_location)
示例#13
0
文件: setup.py 项目: icclab/n_o_conf
def a2enmod(module=None, sudo=True):
    cuisine.file_ensure('/usr/sbin/a2enmod')
    if sudo:
        cuisine.sudo(('/usr/sbin/a2enmod %s' % module))
    else:
        cuisine.run(('/usr/sbin/a2enmod %s' % module))
def run_python_program(program=None, use_sudo=False):
    cuisine.file_ensure('/usr/bin/python')
    if use_sudo:
        cuisine.sudo(('/usr/bin/python %s' % program))
    else:
        cuisine.run(('/usr/bin/python %s' % program))