Ejemplo n.º 1
0
def deploy():
    global new_dir
    #1) stop service
    from tomcat_manager import TomcatManager
    manager = TomcatManager(
        'http://' + config.get_dest_ip() + ':' +
        config.get_dest_tomcat_port() + '/manager/text',
        config.get_dest_tomcat_username(), config.get_dest_tomcat_password())
    manager.stop("/" + module)

    #2) change link
    cmds = []
    cmd_rm_current = 'rm %s' % (config.get_dest_war_path() + '/' + module +
                                '/current')
    cmds.append(cmd_rm_current)

    cmd_ln_current = 'ln -s %s %s' % (
        config.get_dest_war_path() + '/' + module + '/' + new_dir,
        config.get_dest_war_path() + '/' + module + '/current')
    cmds.append(cmd_ln_current)

    cmd = 'expect expect/ssh.exp "%s" "%s" "%s" "%s"' % (
        config.get_dest_username(), config.get_dest_password(),
        config.get_dest_ip(), '\n'.join(cmds))
    assert os.system(cmd) == 0
    #3) recover service
    manager.start("/" + module)
    print '@@@@@@@@@@@@ Deploy Successful #############'
Ejemplo n.º 2
0
def prepare():
    global new_dir
    #1) enter the directory
    cmds = []
    cmd_cd_module_path = 'cd %s' % os.path.join(config.get_dest_war_path(),
                                                module)
    cmds.append(cmd_cd_module_path)

    #2) make new directory
    import datetime
    new_dir = datetime.datetime.now().strftime('%m%d_%H%M')
    cmd_make_new_dir = 'mkdir %s' % new_dir
    cmds.append(cmd_make_new_dir)

    #3) decompress
    cmd_decompress_war = 'cd %s; %s xvf %s' % (
        new_dir, config.get_dest_java_home() + '/bin/jar',
        os.path.join(config.get_dest_scp_path(), module + '.war'))
    cmds.append(cmd_decompress_war)

    cmd_ssh = 'expect expect/ssh.exp "%s" "%s" "%s" "%s"' % (
        config.get_dest_username(), config.get_dest_password(),
        config.get_dest_ip(), '\n'.join(cmds))
    assert os.system(cmd_ssh) == 0

    merge_properties()
    print '@@@@@@@@@@@@ Prepare Successful #############'
Ejemplo n.º 3
0
def move_properties(properties):
    global new_dir
    cmds = []
    for prop in properties:
        cmds.append('mv %s %s' % (os.path.join(config.get_dest_scp_path(), prop), config.get_dest_war_path() + '/' + module + '/' + new_dir + '/WEB-INF/classes'))
    cmd_move = '\n'.join(cmds)
    cmd_ssh = 'expect expect/ssh.exp  "%s" "%s" "%s" "%s"' % (config.get_dest_username(), config.get_dest_password(), config.get_dest_ip(), cmd_move)
    assert os.system(cmd_ssh) == 0
Ejemplo n.º 4
0
def download_properties():
    cmd_scp = 'expect expect/scp_download.exp  "%s" "%s" "%s" "%s" "%s"' % (
        config.get_dest_username(), config.get_dest_ip(),
        config.get_dest_password(), config.get_local_download_path(),
        config.get_dest_war_path() + '/' + module +
        '/current/WEB-INF/classes/*.properties')
    assert os.system(cmd_scp) == 0
    print '@@@@@@@@@@@@ Download properties Successful #############'
Ejemplo n.º 5
0
def deploy():
    global new_dir
    #1) stop service
    from tomcat_manager import TomcatManager
    manager = TomcatManager('http://' + config.get_dest_ip() + ':' + config.get_dest_tomcat_port() + '/manager/text', config.get_dest_tomcat_username(), config.get_dest_tomcat_password())
    manager.stop("/" + module)
    
    #2) change link
    cmds = []
    cmd_rm_current = 'rm %s' % (config.get_dest_war_path() + '/' + module + '/current')
    cmds.append(cmd_rm_current)
    
    cmd_ln_current = 'ln -s %s %s' % (config.get_dest_war_path() + '/' + module + '/' + new_dir, config.get_dest_war_path() + '/' + module + '/current')
    cmds.append(cmd_ln_current)
    
    cmd = 'expect expect/ssh.exp "%s" "%s" "%s" "%s"' % (config.get_dest_username(), config.get_dest_password(), config.get_dest_ip(), '\n'.join(cmds))
    assert os.system(cmd) == 0
    #3) recover service
    manager.start("/" + module)
    print '@@@@@@@@@@@@ Deploy Successful #############'
Ejemplo n.º 6
0
def move_properties(properties):
    global new_dir
    cmds = []
    for prop in properties:
        cmds.append('mv %s %s' %
                    (os.path.join(config.get_dest_scp_path(),
                                  prop), config.get_dest_war_path() + '/' +
                     module + '/' + new_dir + '/WEB-INF/classes'))
    cmd_move = '\n'.join(cmds)
    cmd_ssh = 'expect expect/ssh.exp  "%s" "%s" "%s" "%s"' % (
        config.get_dest_username(), config.get_dest_password(),
        config.get_dest_ip(), cmd_move)
    assert os.system(cmd_ssh) == 0
Ejemplo n.º 7
0
def prepare():
    global new_dir
    #1) enter the directory
    cmds = []
    cmd_cd_module_path='cd %s' % os.path.join(config.get_dest_war_path(), module)
    cmds.append(cmd_cd_module_path)
    
    #2) make new directory
    import datetime
    new_dir=datetime.datetime.now().strftime('%m%d_%H%M')
    cmd_make_new_dir='mkdir %s' % new_dir
    cmds.append(cmd_make_new_dir)
    
    #3) decompress
    cmd_decompress_war='cd %s; %s xvf %s' % (new_dir, config.get_dest_java_home() + '/bin/jar', os.path.join(config.get_dest_scp_path(), module + '.war'))
    cmds.append(cmd_decompress_war)
    
    cmd_ssh='expect expect/ssh.exp "%s" "%s" "%s" "%s"' % (config.get_dest_username(), config.get_dest_password(), config.get_dest_ip(), '\n'.join(cmds))
    assert os.system(cmd_ssh) == 0
    
    merge_properties()
    print '@@@@@@@@@@@@ Prepare Successful #############'
Ejemplo n.º 8
0
def download_properties():
    cmd_scp = 'expect expect/scp_download.exp  "%s" "%s" "%s" "%s" "%s"' % (config.get_dest_username(), config.get_dest_ip(), config.get_dest_password(), config.get_local_download_path(), config.get_dest_war_path() + '/' + module + '/current/WEB-INF/classes/*.properties')
    assert os.system(cmd_scp) == 0
    print '@@@@@@@@@@@@ Download properties Successful #############'