14 print "Checking cm connection..."
16 cm.send_request(
'/ci/storage/get_list/')
18 raise Exception(
'cm_cannot_connect')
21 print "Checking images pool..."
23 print "\t...could be accessed through libvirt"
24 conn = libvirt.open(lv_address)
26 raise Exception(
'libvirt_error')
30 pool = conn.storagePoolLookupByName(
'images')
32 raise Exception(
'images_pool_not_found')
35 print "\t...has images pool"
36 vol = pool.storageVolLookupByName(
'info')
38 raise Exception(
'images_pool_has_no_info')
41 print "\t...is writable"
42 f = open(vol.path().replace(
'/info',
'/write_test'),
'w')
44 os.remove(vol.path().replace(
'/info',
'/write_test'))
46 raise Exception(
'images_pool_not_writable')
50 print "Checking cc1 user..."
53 u = pwd.getpwnam(
'cc1')
55 raise Exception(
'cc1_user_not_exists')
57 print "\t...has 331 uid"
59 raise Exception(
'cc1_user_is_not_331_uid')
61 print "\t...has 331 gid"
63 raise Exception(
'cc1_user_is_not_331_gid')
65 print "\t...could connect with him self"
66 if subprocess.call([
'ssh',
'-o',
'PasswordAuthentication=no',
'cc1@localhost',
'/bin/true']) != 0:
67 raise Exception(
'cc1_ssh_error')
72 print "Checking permissions..."
74 if (
'%o' % os.stat(
'/var/lib/cc1/.ssh/id_rsa').st_mode)[-3:] !=
'600':
75 raise Exception(
'ssh_key_wrong_permission')
77 if os.stat(
'/etc/cc1/node/config.py').st_uid != 331:
78 raise Exception(
'node_config_wrong_owner')
84 print "Checking qemu.conf file..."
86 qemu = open(
'/etc/libvirt/qemu.conf',
'r').readlines()
89 dynamic_ownership =
False
92 if 'user' in line
and 'root' in line
and not line.startswith(
'#'):
94 if 'group' in line
and 'root' in line
and not line.startswith(
'#'):
96 if 'dynamic_ownership' in line
and '0' in line
and not line.startswith(
'#'):
99 if not user
and not group
and not dynamic_ownership:
100 raise Exception(
'qemu_not_configured')
105 print "Libvirt check is not implemented"
109 print "Checking hooks..."
110 if not os.path.exists(
'/usr/sbin/cc1_node_hook'):
111 print "\t...script exists"
112 raise Exception(
'script_not_exists')
114 mode = os.stat(
'/usr/sbin/cc1_node_hook').st_mode
115 if mode & stat.S_IXUSR
and mode & stat.S_IXGRP
and mode & stat.S_IXOTH:
116 print "\t...script is executable"
118 raise Exception(
'script_not_executable')
120 if not os.path.exists(
'/etc/libvirt/hooks/qemu'):
122 raise Exception(
'hook_not_exists')
124 mode = os.stat(
'/etc/libvirt/hooks/qemu').st_mode
125 if mode & stat.S_IXUSR
and mode & stat.S_IXGRP
and mode & stat.S_IXOTH:
126 print "\t...is executable"
128 raise Exception(
'hook_not_executable')
134 print "Checking storages..."
135 conn = libvirt.open(lv_address)
137 print "\t...retreive storage list from libvirt"
139 for storage_name
in conn.listStoragePools():
140 lv_storages.append(conn.storagePoolLookupByName(storage_name))
142 print "\t...retreive storage list from cm"
143 cm_storages = cm.send_request(
'/ci/storage/get_list/')[
'data']
145 for storage
in cm_storages:
146 print "\t...if storage %s exists" % storage
147 lv_storage_names = [s.name()
for s
in lv_storages]
148 if not storage
in lv_storage_names:
149 raise Exception(
'storage_not_mounted')
151 for storage
in lv_storages:
152 print "\t...if storage %s is running" % storage.name()
153 if storage.name ==
'images':
155 elif storage.name()
in cm_storages
and storage.info()[0] != libvirt.VIR_STORAGE_POOL_RUNNING:
156 raise Exception(
'storage_not_running')
162 print "Checking public ip redirections..."
163 r = subprocess.call(
'sudo /usr/sbin/cc1_node_public_ip check', shell=
True)
165 raise Exception(
'public_ip_failed')