Esempio n. 1
0
 def yumRemove(self, package, dryRun):
     sh = shellRunner()
     if dryRun=='true':
         script = [ 'rpm', '-e', '--test', package ]
     else:
         script = [ 'yum', 'erase', '-y', package ]
     return sh.run(script)
Esempio n. 2
0
 def yumInstall(self, package, dryRun):
     sh = shellRunner()
     if dryRun=='true':
         script = [ 'yum', 'install', '-y', '--downloadonly', package ]
     else:
         script = [ 'yum', 'install', '-y', package ]
     return sh.run(script)
Esempio n. 3
0
 def tarballInstall(self, cluster, role, package):
     softwarePrefix = packageRunner.ambariPrefix+'/clusters/'+cluster+'-'+role+'/stack'
     sh = shellRunner()
     src = packageRunner.ambariPrefix+'/var/cache/downloads/'+package
     script = [ 'tar', 'fxz', src, '--strip-components', '1', '-C', softwarePrefix ]
     result = sh.run(script)
     if result['exit_code']!=0:
         err = 'Tarball decompress error, exit code: %d' % result['exit_code']
         raise Exception(err)
     return result
Esempio n. 4
0
    def torrentDownload(self, package):
        sh = shellRunner()
        startTime = time.time()
        script = ['transmission-daemon', '-y', '-O', '-M', '-w', packageRunner.downloadDir, '-g', packageRunner.ambariPrefix+'/var/cache/config']
        result = sh.run(script)
        for wait in [ 1, 1, 2, 2, 5 ]:
            script = ['transmission-remote', '-l']
            result = sh.run(script)
            if result['exit_code']==0:
                break
            time.sleep(wait)

        if result['exit_code']!=0:
            raise Exception('Unable to start transmission-daemon, exit_code:'+str(result['exit_code']))
        script = ['transmission-remote', '-a', package, '--torrent-done-script', '/usr/bin/ambari-torrent-callback']
        result = sh.run(script)
        if result['exit_code']!=0:
            raise Exception('Unable to issue transmission-remote command')
        trackerComplete = packageRunner.ambariPrefix+'/var/tmp/tracker'
        while True:
            if os.path.exists(trackerComplete):
                break
            script = ['transmission-remote', '-t', '1', '--reannounce']
            sh.run(script)
            time.sleep(5)
        endTime = time.time()
        duration = endTime - startTime
        os.remove(trackerComplete)
        code = 0
        script = [ 'transmission-remote', '-t', '1', '-r' ]
        result = sh.run(script)
        if result['exit_code']!=0:
            code = result['exit_code']
            logger.warn('Can not remove torrent, output: '+result['output']+' error: '+result['error'])
        script = [ 'transmission-remote', '--exit' ]
        result = sh.run(script)
        if result['exit_code']!=0:
            code = result['exit_code']
            logger.warn('Can not shutdown torrent client, output: '+result['output']+' error: '+result['error'])
        output = "%s downloaded duration: %d seconds." % (package, duration)
        while True:
            """ Make sure transmission-daemon is properly terminated """
            script = [ 'transmission-remote', '-l' ]
            result = sh.run(script)
            if result['exit_code']!=0:
                break
        return {'exit_code': code, 'output': output, 'error': ''}
Esempio n. 5
0
 def yumInfo(self, package):
     sh = shellRunner()
     script = [ 'yum', 'info', package ]
     return sh.run(script)
Esempio n. 6
0
 def rpmInstall(self, packages):
     sh = shellRunner()
     list = ' '.join([str(x) for x in packages])
     script = ['rpm', '-U', '--replacepkgs', list]
     return sh.run(script)
Esempio n. 7
0
 def tarballInfo(self, package):
     sh = shellRunner()
     script = [ 'cat', packageRunner.ambariPrefix+'/var/repos/'+package+'/info' ]
     return sh.run(script)