d63391990832fcbbe07283ce0d3fb61c0f061e22
[tests.git] / qaapi / qa / modules / plc / install.py
1
2 import os, sys
3 import traceback
4 from qa import utils
5 from qa.Test import Test
6
7 class install(Test):
8     """
9     Installs a myplc
10     """
11
12     def call(self, url=None, system_type, root_dir):
13         
14         url_path = self.config.path
15         # Determine url
16         if not url:
17             try:
18
19                 print self.config.path 
20                 url_file = open("%s/URL" % url_path)
21                 url = url_file.read().strip()
22                 url_file.close()
23             except IOError:
24                 pass 
25         if not url:
26             print "URL not specified" 
27             sys.exit(1)  
28                 
29         # Save url
30         if self.config.verbose:
31             utils.header('Saving current myplc url into %s/URL' % url_path)
32         fsave=open('%s/URL' % url_path, "w")
33         fsave.write(url+'\n')
34         fsave.close()
35         
36         # Instal myplc from url          
37         if self.config.verbose:
38             utils.header('Installing myplc from url %s' % url)
39
40         # build command
41         full_command = ""
42         install_command = " rpm -Uvh %(url)s "
43         if system_type in ['vserv', 'vserver']:
44             full_command += " vserver %(root_dir)s exec "
45         elif system_type in ['chroot']:
46             pass
47         else:
48             raise Exception, "Invalid system type %(system_type)s" % locals() 
49
50         full_command += install_command % locals()
51         (stdout, stderr) = utils.popen(full_command)
52         if self.config.verbose:
53             utils.header("\n".join(stdout))
54         
55         return 1