python

stdin, stdout, stderr = client.exec_command('cd /home/someone;mkdir aa')

 

 

def remote_modify(mblade):
    client = master_module.get_connection('remote_modify', mblade, port, username1, password1)
    client.exec_command('cd /opt/app/jboss-eap-6.0/standalone/configuration;mv standalone.xml standalone.xml.bak')
    stdin, stdout, stderr = client.exec_command('cd /opt/app/jboss-eap-6.0/standalone/configuration;cat standalone.xml.bak')
    file = ''
    find = 0
    for line in stdout:
        if '''<connector name="http-post" protocol="HTTP/1.1" scheme="http" socket-binding="http-post"''' in line and '/>' in line:
            find += 1
            continue
        if '''<socket-binding name="http-post" port=''' in line and '/>' in line:
            find += 1
            continue
        file = file + line + '\n'
    if find!=2:
        print '***********SOMETHING ERROR, Please check standalone.xml!!!'
    file_str = ''
    client.exec_command("cd /opt/app/jboss-eap-6.0/standalone/configuration;echo '" + file + "' > standalone.xml")
    client.close()

  

posted @ 2016-03-06 17:08  raindream  阅读(172)  评论(0编辑  收藏  举报