1dpm2_python(3) Python Reference
2dpm2_python(3)
3
4
5
6[1mNAME[0m
7 dpm ‐ Python interface to the DPM
8
9
10[1mSYNOPSIS[0m
11 [1mimport dpm2 as dpm[0m
12
13
14[1mDESCRIPTION[0m
15 The dpm module permits you to access the DPM client
16interface from
17 python programs. The dpm module is a swig wrapping of the
18standard C
19 interface. For detailed descriptions of each function see
20the individ‐
21 ual man page of each function.
22
23
24[1mFUNCTIONS[0m
25 [1mdpns_aborttrans ( )[0m
26
27 [1mdpns_access ( string [4m[22mpath[24m[1m, int
28[4m[22mamode[24m [1m) ‐> bool [4m[22maccess[0m
29
30 [1mdpns_accessr ( string [4m[22msfn[24m[1m, int
31[4m[22mamode[24m [1m) ‐> bool [4m[22maccess[0m
32
33 [1mdpns_addreplica ( string [4m[22mguid[24m[1m, struct
34dpns_fileid *[4m[22mfile_uniqueid[24m[1m,[0m
35 [1mstring [4m[22mserver[24m[1m, string
36[4m[22msfn[24m[1m, char [4m[22mstatus[24m[1m, char
37[4m[22mf_type[24m[1m, string [4m[22mpoolname[24m[1m,[0m
38 [1mstring [4m[22mfs[24m [1m)[0m
39
40 [1mdpns_addreplicax ( string [4m[22mguid[24m[1m, struct
41dpns_fileid *[4m[22mfile_uniqueid[24m[1m,[0m
42 [1mstring [4m[22mserver[24m[1m, string
43[4m[22msfn[24m[1m, char [4m[22mstatus[24m[1m, char
44[4m[22mf_type[24m[1m, string [4m[22mpoolname[24m[1m,[0m
45 [1mstring [4m[22mfs[24m[1m, char [4m[22mr_type[24m[1m,
46string [4m[22msetname[24m [1m)[0m
47
48 [1mdpns_chdir ( string [4m[22mpath[24m [1m)[0m
49
50 [1mdpns_chmod ( string [4m[22mpath[24m[1m, mode_t
51[4m[22mmode[24m [1m)[0m
52
53 [1mdpns_chown ( string [4m[22mpath[24m[1m, uid_t
54[4m[22mnew_uid[24m[1m, gid_t [4m[22mnew_gid[24m [1m)[0m
55
56 [1mdpns_client_setAuthorizationId ( uid_t
57[4m[22muid[24m[1m, gid_t [4m[22mgid[24m[1m, string
58[4m[22mmech[24m[1m,[0m
59 [1mstring [4m[22mid[24m [1m)[0m
60
61 [1mdpns_client_setVOMS_data ( string [4m[22mvoname[24m[1m,
62stringlist [4m[22mvomsdata[24m [1m)[0m
63
64 [1mdpns_closedir ( dpns_DIR [4m[22mdirp[24m [1m)[0m
65
66 [1mdpns_creat ( string [4m[22mpath[24m[1m, mode_t
67[4m[22mmode[24m [1m)[0m
68
69 [1mdpns_delcomment ( string [4m[22mpath[24m [1m)[0m
70
71 [1mdpns_delete ( string [4m[22mpath[24m [1m)[0m
72
73 [1mdpns_delreplica ( string [4m[22mguid[24m[1m, struct
74dpns_fileid *[4m[22mfile_uniqueid[24m[1m,[0m
75 [1mstring [4m[22msfn[24m [1m)[0m
76
77 [1mdpns_delreplicasbysfn ( ListOfString
78[4m[22msfns[24m[1m, ListOfString [4m[22mguids[24m [1m) ‐>[0m
79 [1mListOfInt [4m[22mresults[0m
80
81 [1mdpns_endsess ( )[0m
82
83 [1mdpns_endtrans ( )[0m
84
85 [1mdpns_getacl ( string [4m[22mpath[24m[1m, ) ‐> ListOf
86struct dpns_acl [4m[22macls[0m
87
88 [1mdpns_getcomment ( string [4m[22mpath[24m [1m) ‐> string
89[4m[22mcomment[0m
90
91 [1mdpns_getcwd ( ) ‐> string [4m[22mdir[0m
92
93 [1mdpns_getifcevers ( ) ‐> string [4m[22mversion[0m
94
95 [1mdpns_getlinks ( string [4m[22mpath[24m[1m, string
96[4m[22mguid[24m [1m) ‐> ListOf struct dpns_link‐[0m
97 [1minfo [4m[22mlinks[0m
98
99 [1mdpns_getreplica ( string [4m[22mpath[24m[1m, string
100[4m[22mguid[24m[1m, string [4m[22mse[24m [1m) ‐> ListOf[0m
101 [1mstruct dpns_filereplica [4m[22mreplicas[0m
102
103 [1mdpns_getreplicax ( string [4m[22mpath[24m[1m,
104string [4m[22mguid[24m[1m, string [4m[22mse[24m [1m) ‐>
105ListOf[0m
106 [1mstruct dpns_filereplicax [4m[22mreplicas[0m
107
108 [1mdpns_lchown ( string [4m[22mpath[24m[1m, uid_t
109[4m[22mnew_uid[24m[1m, gid_t [4m[22mnew_gid[24m [1m)[0m
110
111 [1mdpns_listreplicax ( string [4m[22mpoolname[24m[1m,
112string [4m[22mserver[24m[1m, string [4m[22mfs[24m[1m, int[0m
113 [4mflags[24m[1m, dpns_list * listp ) ‐> struct dpns_fil‐
114ereplica [4m[22mreplica[0m
115
116 [1mdpns_listrepset ( string [4m[22msetname[24m[1m, int
117[4m[22mflags[24m[1m, dpns_list *[4m[22mlistp[24m [1m) ‐>[0m
118 [1mstruct dpns_filereplicax [4m[22mreplica[0m
119
120 [1mdpns_lstat ( string [4m[22mpath[24m [1m) ‐> struct dp‐
121ns_filestat [4m[22mstatbuf[0m
122
123 [1mdpns_mkdir ( string [4m[22mpath[24m[1m, mode_t
124[4m[22mmode[24m [1m)[0m
125
126 [1mdpns_modreplica ( string [4m[22msfn[24m[1m, string
127[4m[22msetname[24m[1m, string [4m[22mpoolname[24m[1m, string[0m
128 [4mserver[24m [1m)[0m
129
130 [1mdpns_modreplicax ( string [4m[22msfn[24m[1m, string
131[4m[22msetname[24m[1m, string [4m[22mpoolname[24m[1m, string[0m
132 [4mserver[24m[1m, string [4m[22mfs[24m[1m, char
133[4m[22mr_type[24m [1m)[0m
134
135 [1mdpns_opendir ( string [4m[22mpath[24m [1m) ‐> dpns_DIR
136[4m[22mdir[0m
137
138 [1mdpns_opendirxg ( string [4m[22mserver[24m[1m, string
139[4m[22mpath[24m[1m, string [4m[22mguid[24m [1m) ‐> dpns_DIR[0m
140 [4mdir[0m
141
142 [1mdpns_ping ( string [4m[22mserver[24m [1m) ‐> string
143[4m[22minfo[0m
144
145 [1mdpns_readdir ( dpns_DIR [4m[22mdirp[24m [1m) ‐> struct
146dirent [4m[22mdirent[0m
147
148 [1mdpns_readdirc ( dpns_DIR [4m[22mdirp[24m [1m) ‐> struct
149dpns_direncomm [4m[22mdirent[0m
150
151 [1mdpns_readdirg ( dpns_DIR [4m[22mdirp[24m [1m) ‐> struct
152dpns_direnstatg [4m[22mdirent[0m
153
154 [1mdpns_readdirx ( dpns_DIR [4m[22mdirp[24m [1m) ‐> struct
155dpns_direnstat [4m[22mdirent[0m
156
157 [1mdpns_readdirxc ( dpns_DIR [4m[22mdirp[24m [1m) ‐>
158struct dpns_direnstatc [4m[22mdirent[0m
159
160 [1mdpns_readdirxp ( dpns_DIR [4m[22mdirp[24m[1m, string
161[4m[22mpattern[24m[1m, string [4m[22mse[24m [1m= None ) ‐>[0m
162 [1mstruct dpns_direnrep [4m[22mdirent[0m
163
164 [1mdpns_readdirxr ( dpns_DIR [4m[22mdirp[24m[1m,
165string [4m[22mse[24m [1m= None ) ‐> struct[0m
166 [1mdpns_direnrep [4m[22mdirent[0m
167
168 [1mdpns_readlink ( string [4m[22mpath[24m [1m) ‐> string
169[4m[22mlink[0m
170
171 [1mdpns_rename ( string [4m[22moldpath[24m[1m, string
172[4m[22mnewpath[24m [1m)[0m
173
174 [1mdpns_rewinddir ( dpns_DIR [4m[22mdirp[24m [1m)[0m
175
176 [1mdpns_rmdir ( string [4m[22mpath[24m [1m)[0m
177
178 [1mdpns_setacl ( string [4m[22mpath[24m[1m, ListOf struct
179dpns_acl [4m[22macls[24m [1m)[0m
180
181 [1mdpns_setatime ( string [4m[22mpath[24m[1m, struct dp‐
182ns_fileid [4m[22mfile_uniqueid[24m [1m)[0m
183
184 [1mdpns_setcomment ( string [4m[22mpath[24m[1m, string
185[4m[22mcomment[24m [1m)[0m
186
187 [1mdpns_setfsize ( string [4m[22mpath[24m[1m, struct
188dpns_fileid [4m[22mfile_uniqueid[24m[1m, long[0m
189 [4mfilesize[24m [1m)[0m
190
191 [1mdpns_setfsizec ( string [4m[22mpath[24m[1m, struct dp‐
192ns_fileid [4m[22mfile_uniqueid[24m[1m, long[0m
193 [4mfilesize[24m[1m, string [4m[22mcsumtype[24m[1m, string
194[4m[22mcsumvalue[24m [1m)[0m
195
196 [1mdpns_setptime ( string [4m[22msfn[24m[1m, long
197[4m[22mptime[24m [1m)[0m
198
199 [1mdpns_setratime ( string [4m[22msfn[24m [1m)[0m
200
201 [1mdpns_setrltime ( string [4m[22msfn[24m[1m, long
202[4m[22mltime[24m [1m)[0m
203
204 [1mdpns_setrstatus ( string [4m[22msfn[24m[1m, char
205[4m[22mstatus[24m [1m)[0m
206
207 [1mdpns_setrtype ( string [4m[22msfn[24m[1m, char
208[4m[22mtype[24m [1m)[0m
209
210 [1mdpns_startsess ( string [4m[22mserver[24m[1m, string
211[4m[22mcomment[24m [1m)[0m
212
213 [1mdpns_starttrans ( string [4m[22mserver[24m[1m, string
214[4m[22mcomment[24m [1m)[0m
215
216 [1mdpns_stat ( string [4m[22mpath[24m [1m) ‐> struct dp‐
217ns_filestat [4m[22mstatbuf[0m
218
219 [1mdpns_statg ( string [4m[22mpath[24m[1m, string
220[4m[22mguid[24m [1m) ‐> struct dpns_filestatg [4m[22mstat‐[0m
221 [4mbuf[0m
222
223 [1mdpns_statr ( string [4m[22msfn)[24m [1m) ‐> struct dp‐
224ns_filestatg [4m[22mstatbuf[0m
225
226 [1mdpns_symlink ( string [4m[22mtarget[24m[1m, string
227[4m[22mlinkname[24m [1m)[0m
228
229 [1mdpns_umask ( mode_t [4m[22mcmask[24m [1m) ‐> mode_t
230[4m[22moldmask[0m
231
232 [1mdpns_undelete ( string [4m[22mpath[24m [1m)[0m
233
234 [1mdpns_unlink ( string [4m[22mpath[24m [1m)[0m
235
236 [1mdpns_utime ( string [4m[22mpath[24m[1m, struct utimbuf
237[4m[22mtimes[24m [1m)[0m
238
239 [1mdpns_entergrpmap ( gid_t [4m[22mgid[24m[1m, string
240[4m[22mgroupname[24m [1m)[0m
241
242 [1mdpns_enterusrmap ( uid_t [4m[22muid[24m[1m, string
243[4m[22musername[24m [1m)[0m
244
245 [1mdpns_getgrpbygid ( gid_t [4m[22mgid[24m [1m) ‐> string
246[4m[22mgroup[0m
247
248 [1mdpns_getgrpbygids ( ListOfgid_t [4m[22mgids[24m [1m) ‐>
249ListOfString [4m[22mgroups[0m
250
251 [1mdpns_getgrpbynam ( string [4m[22mgroupname[24m [1m) ‐>
252gid_t [4m[22mgid[0m
253
254 [1mdpns_getgrpmap ( ) ‐> ListOf struct dpns_groupinfo
255[4m[22minfos[0m
256
257 [1mdpns_getusrbynam ( string [4m[22musername[24m [1m) ‐>
258uid_t [4m[22muid[0m
259
260 [1mdpns_getusrbyuid ( uid_t [4m[22muid[24m [1m) ‐> string
261[4m[22muser[0m
262
263 [1mdpns_getusrmap ( ) ‐> ListOf struct dpns_userinfo
264[4m[22muserinfo[0m
265
266 [1mdpns_modifygrpmap ( gid_t [4m[22mgid[24m[1m, string
267[4m[22mnewname[24m [1m)[0m
268
269 [1mdpns_modifyusrmap ( uid_t [4m[22muid[24m[1m, string
270[4m[22mnewname[24m [1m)[0m
271
272 [1mdpns_rmgrpmap ( gid_t [4m[22mgid[24m[1m, string
273[4m[22mgroupname[24m [1m)[0m
274
275 [1mdpns_rmusrmap ( uid_t [4m[22muid[24m[1m, string
276[4m[22musername[24m [1m)[0m
277
278 [1mdpm_getpoolfs ( string [4m[22mpoolname[24m [1m) ‐>
279ListOf struct dpm_fs [4m[22mdpm_fs[0m
280
281 [1mdpm_getpools ( ) ‐> ListOf struct dpm_pool
282[4m[22mdpm_pools[0m
283
284 [1mdpm_getprotocols ( ) ‐> ListOfString [4m[22mproto‐
285cols[0m
286
287 [1mdpm_getspacemd ( ListOfString [4m[22ms_tokens[24m
288[1m) ‐> ListOf struct[0m
289 [1mdpm_space_metadata [4m[22mspacemd[0m
290
291 [1mdpm_getspacetoken ( string [4m[22mu_token[24m [1m) ‐>
292ListOfString [4m[22ms_tokens[0m
293
294 [1mdpm_addfs ( string [4m[22mpoolname[24m[1m, string
295[4m[22mserver[24m[1m, string [4m[22mfs[24m[1m, int [4m[22msta‐
296tus[24m [1m)[0m
297
298 [1mdpm_addpool ( struct dpm_pool [4m[22mdpm_pool[24m
299[1m)[0m
300
301 [1mdpm_delreplica ( string [4m[22mpfn[24m [1m)[0m
302
303 [1mdpm_modifyfs ( string [4m[22mserver[24m[1m, string
304[4m[22mfs[24m[1m, int [4m[22mstatus[24m [1m)[0m
305
306 [1mdpm_modifypool ( struct dpm_pool [4m[22mdpm_pool[24m
307[1m)[0m
308
309 [1mdpm_ping ( string [4m[22mhost[24m [1m) ‐> string
310[4m[22minfo[0m
311
312 [1mdpm_releasespace ( string [4m[22ms_token[24m[1m, int
313[4m[22mforce[24m [1m)[0m
314
315 [1mdpm_reservespace ( char [4m[22ms_type[24m[1m, string
316[4m[22mu_token[24m[1m, char [4m[22mret_policy[24m[1m, char[0m
317 [4mac_latency[24m[1m, long [4m[22mreq_t_space[24m[1m,
318long [4m[22mreq_g_space[24m[1m, long [4m[22mreq_life‐
319time[24m[1m,[0m
320 [1mListOfInt [4m[22mgids[24m[1m, string [4m[22mpool‐
321name[24m [1m) ‐> char [4m[22mactual_s_type[24m[1m, long[0m
322 [4mactual_t_space[24m[1m, long [4m[22mactu‐
323al_g_space[24m[1m, long [4m[22mactual_lifetime[24m[1m,
324string[0m
325 [4ms_token[0m
326
327 [1mdpm_rmfs ( string [4m[22mserver[24m[1m, string
328[4m[22mfs[24m [1m)[0m
329
330 [1mdpm_rmpool ( string [4m[22mpoolname[24m [1m)[0m
331
332 [1mdpm_updatespace ( string [4m[22ms_token[24m[1m, long
333[4m[22mreq_t_space[24m[1m, long [4m[22mreq_g_space[24m[1m,[0m
334 [1mlong [4m[22mreq_lifetime[24m[1m, ListOfInt
335[4m[22mgids[24m [1m) ‐> long [4m[22mactual_t_space[24m[1m,
336long[0m
337 [4mactual_g_space[24m[1m, long [4m[22mactual_lifetime[0m
338
339
340[1mSTRUCTURES[0m
341 Sometimes you need to specify a structure as an input
342argument (eg.
343 [4mstruct[24m [4mdpns_acl[24m, [4mstruct[24m [4mdp‐
344ns_list[24m, [4mstruct[24m [4mdpm_pool[24m, etc.). For that
345 purpose, the module includes structure constructors,
346named exactly as
347 the structure.
348
349 Thus, to create [4mstruct[24m [4mdpns_acl[24m,
350[4mstruct[24m [4mdpns_list[24m or [4mstruct[24m [4mdp‐
351mm_pool[24m,
352 you have to do the following:
353
354 dpnsacl = dpm.dpns_acl()
355 dpnslist = dpm.dpns_list()
356 dpmpool = dpm.dpm_pool()
357
358 If you want to see how to use it in a real case, please
359have a look at
360 examples.
361
362
363[1mERRORS[0m
364 As you can see, no error code is returned. When an error
365occurs, an
366 exception is raised with a description of the error.
367
368
369[1mEXAMPLE[0m
370 #!/usr/bin/python
371
372 """
373 # Using the dpns_readdirxr method
374 """
375
376 import sys
377 import traceback
378 import dpm2 as dpm
379
380 name = "/dpm/cern.ch/home/dteam/";
381
382 try:
383 dir = dpm.dpns_opendir(name)
384
385 while 1:
386 entry = dpm.dpns_readdirxr(dir)
387 if entry == None:
388 break
389 print entry.d_name
390 for i in range(entry.nbreplicas):
391 print " ==> %s" % entry.rep[i].sfn
392
393 dpm.dpns_closedir(dir)
394 except TypeError, x:
395 print " ==> None"
396 except Exception:
397 traceback.print_exc()
398 sys.exit(1)
399
400
401[1mEXAMPLE[0m
402 #!/usr/bin/python
403
404 import sys
405 import traceback
406 import dpm2 as dpm
407
408 """
409 # Using the dpns_getreplica method
410 """
411
412 file = "/dpm/cern.ch/home/dteam/file.test"
413
414 try:
415 list = dpm.dpns_getreplica(file, "", "")
416 except Exception:
417 traceback.print_exc()
418 sys.exit(1)
419
420 for i in list:
421 print i.host
422 print i.sfn
423
424
425[1mEXAMPLE[0m
426 #!/usr/bin/python
427
428 import sys
429 import traceback
430 import dpm2 as dpm
431
432 """
433 # Using the dpns_getacl and dpns_setacl methods to add a
434user ACL
435 """
436
437 file = "/dpm/cern.ch/home/dteam/file.test"
438
439 try:
440 acls_list = dpm.dpns_getacl(file)
441 except Exception:
442 traceback.print_exc()
443 sys.exit(1)
444
445 for i in acls_list:
446 print i.a_type
447 print i.a_id
448 print i.a_perm
449
450 # When adding a first ACL for a given user, you also need
451to add the mask
452 # When adding the second user ACL, it is not necessary
453anymore
454
455 acl_user = dpm.dpns_acl()
456 acl_mask = dpm.dpns_acl()
457
458 acl_user.a_type = lfc.CNS_ACL_USER
459 acl_user.a_id = 18701 # user id
460 acl_user.a_perm = 5
461
462 acl_mask.a_type = lfc.CNS_ACL_MASK
463 acl_mask.a_id = 0 # no user id specified
464 acl_mask.a_perm = 5
465
466 acls_list.append(acl_user)
467 acls_list.append(acl_mask)
468
469 try:
470 dpm.dpns_setacl(file, acls_list)
471 except Exception:
472 traceback.print_exc()
473 sys.exit(1)
474
475
476[1mEXAMPLE[0m
477 #!/usr/bin/python
478
479 import sys
480 import traceback
481 import dpm2 as dpm
482
483 """
484 # Using the dpns_getacl and dpns_setacl methods to remove
485a user ACL
486 """
487
488 file = "/dpm/cern.ch/home/dteam/file.test"
489
490 try:
491 acls_list = dpm.dpns_getacl(file)
492 except Exception:
493 traceback.print_exc()
494 sys.exit(1)
495
496 for i in acls_list:
497 print i.a_type
498 print i.a_id
499 print i.a_perm
500
501 del acls_list[1] # delete a given user ACL from the
502list of ACLs
503
504 try:
505 dpm.dpns_setacl(file, acls_list)
506 except Exception:
507 traceback.print_exc()
508 sys.exit(1)
509
510
511[1mEXAMPLE[0m
512 #!/usr/bin/python
513
514 import sys
515 import traceback
516 import dpm2 as dpm
517
518 """
519 # Using the dpns_getusrmap method
520 """
521
522 try:
523 list = dpm.dpns_getusrmap()
524 except Exception:
525 traceback.print_exc()
526 sys.exit(1)
527
528 for i in list:
529 print i.userid + " " + i.username
530
531
532[1mEXAMPLE[0m
533 #!/usr/bin/python
534
535 import sys
536 import traceback
537 import dpm2 as dpm
538
539 """
540 # Using the dpns_getgrpmap method
541 """
542
543 try:
544 list = dpm.dpns_getgrpmap()
545 except Exception:
546 traceback.print_exc()
547 sys.exit(1)
548
549 for i in list:
550 print i.gid + " " + i.groupname
551
552
553[1mEXAMPLE[0m
554 #!/usr/bin/python
555
556 import sys
557 import traceback
558 import dpm2 as dpm
559
560 """
561 # Using the dpm_addfs method
562 """
563
564 try:
565 dpm.dpm_addfs("mypool", "mydiskserver.domain.com",
566"/mountpoint", dpm.FS_READONLY)
567 except Exception:
568 traceback.print_exc()
569 sys.exit(1)
570
571
572[1mEXAMPLE[0m
573 #!/usr/bin/python
574
575 import sys
576 import traceback
577 import dpm2 as dpm
578
579 """
580 # Using the dpm_modifyfs method
581 """
582
583 try:
584 dpm.dpm_modifyfs("mydiskserver.domain.com", "/mount‐
585point", dpm.FS_READONLY)
586 except Exception:
587 traceback.print_exc()
588 sys.exit(1)
589
590
591[1mEXAMPLE[0m
592 #!/usr/bin/python
593
594 import sys
595 import traceback
596 import dpm2 as dpm
597
598 """
599 # Using the dpm_rmfs method
600 """
601
602 try:
603 dpm.dpm_rmfs("mypool", "mydiskserver.domain.com",
604"/mountpoint")
605 except Exception:
606 traceback.print_exc()
607 sys.exit(1)
608
609
610[1mEXAMPLE[0m
611 #!/usr/bin/python
612
613 import sys
614 import traceback
615 import dpm2 as dpm
616
617 """
618 # Using the dpm_addpool method
619 """
620
621 dpmpool = dpm.dpm_pool()
622 dpmpool.poolname = "mypool"
623 dpmpool.defsize = 209715200
624 dpmpool.def_lifetime = 604800
625 dpmpool.defpintime = 604800
626 dpmpool.max_lifetime = 604800
627 dpmpool.max_pintime = 604800
628 dpmpool.nbgids = 1
629 dpmpool.gids = [0]
630 dpmpool.ret_policy = ’R’
631 dpmpool.s_type = ’D’
632
633 try:
634 dpm.dpm_addpool(dpmpool)
635 except Exception:
636 traceback.print_exc()
637 sys.exit(1)
638
639
640[1mEXAMPLE[0m
641 #!/usr/bin/python
642
643 import sys
644 import traceback
645 import dpm2 as dpm
646
647 """
648 # Using the dpm_modifypool method
649 """
650
651 dpmpool = dpm.dpm_pool()
652 dpmpool.poolname = "mypool"
653 dpmpool.defsize = 209715200
654 dpmpool.def_lifetime = 604800
655 dpmpool.defpintime = 604800
656 dpmpool.max_lifetime = 604800
657 dpmpool.max_pintime = 604800
658 dpmpool.nbgids = 1
659 dpmpool.gids = [0]
660 dpmpool.ret_policy = ’R’
661 dpmpool.s_type = ’D’
662
663 try:
664 dpm.dpm_modifypool(dpmpool)
665 except Exception:
666 traceback.print_exc()
667 sys.exit(1)
668
669
670[1mEXAMPLE[0m
671 #!/usr/bin/python
672
673 import sys
674 import traceback
675 import dpm2 as dpm
676
677 """
678 # Using the dpm_rmpool method
679 """
680
681 try:
682 dpm.dpm_rmpool("mypool")
683 except Exception:
684 traceback.print_exc()
685 sys.exit(1)
686
687
688[1mEXAMPLE[0m
689 #!/usr/bin/python
690
691 import sys
692 import traceback
693 import dpm2 as dpm
694
695 """
696 # Using the dpm_getpoolfs method
697 """
698
699 try:
700 list = dpm.dpm_getpoolfs("mypool")
701 except Exception:
702 traceback.print_exc()
703 sys.exit(1)
704
705 print len(list)
706 for i in list:
707 print "POOL " + i.poolname + " SERVER " + i.server + "
708FS " + i.fs + " CAPACITY " + i.capacity + " FREE " +
709i.free
710
711
712[1mEXAMPLE[0m
713 #!/usr/bin/python
714
715 import sys
716 import traceback
717 import dpm2 as dpm
718
719 """
720 # Using the dpm_getpools method
721 """
722
723 try:
724 list = dpm.dpm_getpools()
725 except Exception:
726 traceback.print_exc()
727 sys.exit(1)
728
729 print len(list)
730 for i in list:
731 print "POOL " + i.poolname + " CAPACITY " + i.capacity
732+ " FREE " + i.free
733
734
735[1mEXAMPLE[0m
736 #!/usr/bin/python
737
738 import sys
739 import traceback
740 import dpm2 as dpm
741
742 """
743 # Using the dpm_getprotocols method
744 """
745
746 try:
747 list = dpm.dpm_getprotocols()
748 except Exception:
749 traceback.print_exc()
750 sys.exit(1)
751
752 print len(list)
753 for i in list:
754 print i
755
756
757[1mEXAMPLE[0m
758 #!/usr/bin/python
759
760 import sys
761 import traceback
762 import dpm2 as dpm
763
764 """
765 # Using the dpm_getspacemd method
766 """
767
768 try:
769 list = dpm.dpm_getspacemd(["myspacetoken"])
770 except Exception:
771 traceback.print_exc()
772 sys.exit(1)
773
774 print len(list)
775 for i in list:
776 print "TYPE " + i.s_type + " SPACETOKEN " i.s_token + "
777USERTOKEN " + i.u_token + " TOTAL " + i.t_space + "
778GUARANTUEED " + i.g_space + " UNUSED " + i.u_space +
779" POOL " + i.poolname
780
781
782[1mEXAMPLE[0m
783 #!/usr/bin/python
784
785 import sys
786 import traceback
787 import dpm2 as dpm
788
789 """
790 # Using the dpm_getspacetoken method
791 """
792
793 try:
794 list = dpm.dpm_getspacetoken("myspacetokendesc")
795 except Exception:
796 traceback.print_exc()
797 sys.exit(1)
798
799 print len(list)
800 for i in list:
801 print i
802
803
804[1mEXAMPLE[0m
805 #!/usr/bin/python
806
807 import sys
808 import traceback
809 import dpm2 as dpm
810
811 """
812 # Using the dpm_reservespace method
813 """
814
815 try:
816 actual_s_type,actual_t_space,actual_g_space,actu‐
817al_lifetime,s_token = dpm.dpm_reservespace(’D’,
818"myspacetokendesc", ’R’, ’O’, 209715200,
819209715200, 2592000, 0, "mypoolname")
820 except Exception:
821 traceback.print_exc()
822 sys.exit(1)
823
824 print "TYPE " + actual_s_type + " TOTAL " + actual_t_space
825+ " GUARANTEED " + actual_g_space + " LIFETIME " + ac‐
826tual_lifetime + " TOKEN " + s_token
827
828
829[1mEXAMPLE[0m
830 #!/usr/bin/python
831
832 import sys
833 import traceback
834 import dpm2 as dpm
835
836 """
837 # Using the dpm_updatespace method
838 """
839
840 try:
841 actual_t_space,actual_g_space,actual_lifetime =
842dpm.dpm_updatespace("myspacetoken", 209715200, 209715200,
8432592000)
844 except Exception:
845 traceback.print_exc()
846 sys.exit(1)
847
848 print " TOTAL " + actual_t_space + " GUARANTEED " + actu‐
849al_g_space + " LIFETIME " + actual_lifetime
850
851
852[1mEXAMPLE[0m
853 #!/usr/bin/python
854
855 import sys
856 import traceback
857 import dpm2 as dpm
858
859 """
860 # Using the dpm_releasespace method
861 """
862
863 try:
864 dpm.dpm_releasespace("myspacetoken", 0)
865 except Exception:
866 traceback.print_exc()
867 sys.exit(1)
868
869
870[1mEXAMPLE[0m
871 #!/usr/bin/python
872
873 import sys
874 import traceback
875 import dpm2 as dpm
876
877 """
878 # Using the dpm_ping method
879 """
880
881 try:
882 info = dpm.dpm_ping("mydpmserver.domain.com")
883 except Exception:
884 traceback.print_exc()
885 sys.exit(1)
886
887 print info
888
889
890[1mSEE ALSO[0m
891 [1mDPM C interface man pages[0m
892
893
894
895DPM $Date$
896dpm2_python(3)
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924