Log In | Get Help   
Home My Page Projects Code Snippets Project Openings BonFIRE VCOC Demonstration Kit
Summary Activity SCM Files Wiki
[bonfiredemokit] Annotation of /virt-cluster/vc/vc-node-init.py
[bonfiredemokit] / virt-cluster / vc / vc-node-init.py Repository:
ViewVC logotype

Annotation of /virt-cluster/vc/vc-node-init.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download) (as text)

1 : agomez 1 #!/usr/bin/python
2 :     import os
3 :     import os.path
4 :     import subprocess
5 :     import sys
6 :     import time
7 :    
8 :     from logger import log,configure
9 :     if len(sys.argv)>1:
10 :     configure(logfile = sys.argv[1], debug=True, console=False)
11 :     else:
12 :     configure(debug=True, console=True)
13 :    
14 :     try:
15 :     import bonfire
16 :     import hostsfile
17 :     import ogs
18 :     import vcutil
19 :    
20 :     allow_single_cluster = True
21 :     default_bonfire = "/etc/default/bonfire"
22 :     bonfire.read_defaults(default_bonfire)
23 :     hosts_file = "/etc/hosts"
24 :     log.info("Bonfire URI: %s" % bonfire.uri)
25 :     log.info("Credentials: %s:%s" % (bonfire.user,bonfire.password,))
26 :     log.info("Experiment: %s" % bonfire.experiment_id)
27 :    
28 :     #Basic hostsfile for main nodes
29 :     while True:
30 :     try:
31 :     log.info("Get experiment")
32 :     master_host = None
33 :     shadow_host = None
34 :     while (master_host == None) and ((not allow_single_cluster) or (shadow_host == None)) :
35 :     experiment = bonfire.get_experiment(bonfire.experiment_id)
36 :     for compute in experiment['computes']:
37 :     if compute["hostname"].startswith("master"):
38 :     master_host = (compute['ip'],compute['hostname'])
39 :     elif compute["hostname"].startswith("shadow"):
40 :     shadow_host = (compute['ip'],compute['hostname'])
41 :     main_hosts = [('127.0.0.1','localhost'),(bonfire.wan_ip,bonfire.hostname), master_host]
42 :     if shadow_host:
43 :     main_hosts.append(shadow_host)
44 :     data_host = master_host
45 :     if bonfire.hostname.startswith("client-shadow"):
46 :     data_host = shadow_host
47 :     log.debug(str(main_hosts))
48 :     break
49 :     except Exception as excpt:
50 :     log.exception(excpt)
51 :     time.sleep(20)
52 :    
53 :     hostsfile.store(hosts_file,main_hosts)
54 :    
55 :     #Try to mount shared
56 :     log.info("Try to mount NFS volume")
57 :     while True:
58 :     try:
59 :     log.debug(vcutil.execute("mount -t nfs %s:/volume /shared" % data_host[1]))
60 :     break
61 :     except Exception as excpt:
62 :     log.debug("NFS volume not available")
63 :     log.exception(excpt)
64 :     try:
65 :     log.debug(vcutil.execute("umount /shared"))
66 :     except Exception as excpt:
67 :     log.exception(excpt)
68 :     time.sleep(20)
69 :    
70 :     #Mount shared
71 :     log.debug(vcutil.execute("umount /shared"))
72 :     log.info("Sync mount NFS volume")
73 :     log.debug(vcutil.execute("mount -t nfs -o nordirplus,hard,nointr,rw %s:/volume /shared" % data_host[1]))
74 :    
75 :     while not (os.path.exists("/shared/ogs/default/common/sgeexecd") and os.path.exists("/shared/ogs/default/common/settings.sh")):
76 :     log.debug("OGS directory not available")
77 :     time.sleep(5)
78 :    
79 :     #Configure OGS installation
80 :     log.debug(vcutil.execute("""export SGE_ROOT=/shared/ogs
81 :     cd $SGE_ROOT
82 :     echo \". $SGE_ROOT/default/common/settings.sh\" >> /root/.bashrc
83 :     ln -s $SGE_ROOT/default/common/sgeexecd /etc/init.d/sgeexecd
84 :     """))
85 :    
86 :     log.debug("Checking if OGS is available")
87 :     while True:
88 :     try:
89 :     log.debug(vcutil.execute(". /shared/ogs/default/common/settings.sh; qstat"))
90 :     break
91 :     except Exception as excpt:
92 :     log.exception(excpt)
93 :     time.sleep(10)
94 :    
95 :     log.debug(vcutil.execute(". /shared/ogs/default/common/settings.sh; python -u /root/vc/vc-node-execd.py /var/log/vc-node-execd.log" , fork = True))
96 :     except Exception as excpt:
97 :     log.exception(excpt)
98 :    

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge