107 |
107 |
fh.close()
|
108 |
108 |
|
109 |
109 |
def mount_bacula_support(usb_test=40):
|
110 |
|
#demonte avant de faire le montage
|
111 |
|
umount_bacula_support()
|
112 |
|
config = ConfigObj(BACULA_CONF)
|
113 |
|
DISTANT_LOGIN_MOUNT = config.get('DISTANT_LOGIN_MOUNT', '/bin/mount -t smbfs -o username={0},password={1},ip={2},uid={3},noexec,nosuid,nodev //{4}/{5} {6}')
|
114 |
|
DISTANT_MOUNT = config.get('DISTANT_MOUNT', '/bin/mount -t smbfs -o password={0},ip={1},uid={2},noexec,nosuid,nodev //{3}/{4} {5}')
|
115 |
110 |
|
|
111 |
#quitte si manual ou pas configuré
|
116 |
112 |
dic=load_bacula_support()
|
117 |
113 |
if dic['support'] == 'manual':
|
118 |
114 |
return 'Pas de montage pour la configuration manuelle'
|
... | ... | |
120 |
116 |
if dic['support'] == 'none':
|
121 |
117 |
raise Exception("ERREUR : bacula n'est pas configuré")
|
122 |
118 |
|
|
119 |
#demonte avant de faire le montage
|
|
120 |
umount_bacula_support()
|
|
121 |
config = ConfigObj(BACULA_CONF)
|
|
122 |
DISTANT_LOGIN_MOUNT = config.get('DISTANT_LOGIN_MOUNT', '/bin/mount -t smbfs -o username={0},password={1},ip={2},uid={3},noexec,nosuid,nodev //{4}/{5} {6}')
|
|
123 |
DISTANT_MOUNT = config.get('DISTANT_MOUNT', '/bin/mount -t smbfs -o password={0},ip={1},uid={2},noexec,nosuid,nodev //{3}/{4} {5}')
|
|
124 |
|
123 |
125 |
if not os.path.isdir(MOUNT_POINT):
|
124 |
126 |
os.makedirs(MOUNT_POINT)
|
125 |
127 |
#montage
|
... | ... | |
195 |
197 |
return True
|
196 |
198 |
|
197 |
199 |
def umount_bacula_support(error=False):
|
|
200 |
dic=load_bacula_support()
|
|
201 |
if dic['support'] == 'manual':
|
|
202 |
return True
|
198 |
203 |
while os.path.ismount(MOUNT_POINT):
|
199 |
204 |
cmd = ['/bin/umount', MOUNT_POINT]
|
200 |
205 |
ret, stdout, stderr = system_out(cmd)
|
... | ... | |
311 |
316 |
def test_bacula_support(force=False):
|
312 |
317 |
if not force and not bacula_active_sd():
|
313 |
318 |
raise Disabled('Bacula sd désactivé')
|
314 |
|
if os.path.ismount(MOUNT_POINT):
|
315 |
|
raise Exception('ERREUR : point de montage {0} déjà occupé'.format(MOUNT_POINT))
|
316 |
319 |
|
317 |
|
try:
|
318 |
|
mount_bacula_support(usb_test=2)
|
319 |
|
except Exception, e:
|
320 |
|
raise Exception(e)
|
|
320 |
dic=load_bacula_support()
|
|
321 |
if dic['support'] != 'manual':
|
|
322 |
if os.path.ismount(MOUNT_POINT):
|
|
323 |
raise Exception('ERREUR : point de montage {0} déjà occupé'.format(MOUNT_POINT))
|
|
324 |
|
|
325 |
try:
|
|
326 |
mount_bacula_support(usb_test=2)
|
|
327 |
except Exception, e:
|
|
328 |
raise Exception(e)
|
321 |
329 |
|
322 |
330 |
if os.path.isfile(TEST_MOUNT_FILE):
|
323 |
|
umount_bacula_support()
|
|
331 |
if dic['support'] != 'manual':
|
|
332 |
umount_bacula_support()
|
324 |
333 |
raise Exception('ERREUR : le fichier test {0} existe déjà'.format(TEST_MOUNT_FILE))
|
325 |
334 |
|
326 |
335 |
#ecriture du fichier
|
... | ... | |
332 |
341 |
if code != 0:
|
333 |
342 |
raise Exception('ERREUR : suppression impossible')
|
334 |
343 |
except Exception, e:
|
335 |
|
umount_bacula_support()
|
|
344 |
if dic['support'] != 'manual':
|
|
345 |
umount_bacula_support()
|
336 |
346 |
raise Exception(e)
|
337 |
347 |
|
338 |
348 |
#demontage
|
339 |
|
umount_bacula_support(error=True)
|
|
349 |
if dic['support'] != 'manual':
|
|
350 |
umount_bacula_support(error=True)
|
340 |
351 |
|
341 |
352 |
return "Tests de montage OK"
|
342 |
353 |
|