Пример #1
0
 def __init__(self,line):
   self.partitions=[]
   match=self.diskre.match(line)
   self.device=match.group(1)
   self.bytes=match.group(2)
   self.diskId=""
   self.vol=volume(self.device)
Пример #2
0
def main():
   if len(sys.argv)<2: return xmlmsg("error","Usage: mount.py <device>|--all. Example: mount.py /dev/sdc")
   if sys.argv[1]=="--all": 
        out=fdisk.volumelist()
        mounted=0
        for disk in out.disks:
            vol=volume(disk.device)
            if vol.type<>"node-data": continue
            (ok, errmsg)=vol.mount()
            if ok: mounted=mounted+1
        return xmlmsg("return", str(mounted))
   else:
      vol=volume(sys.argv[1])
      if vol.type<>"node-data": return xmlmsg("error","Disk "+sys.argv[1]+" is of unknown type")
      (ok,errmsg)=vol.mount()
      if ok==False: return xmlmsg("error",str(errmsg))
      else: return xmlmsg("result",str(errmsg))
Пример #3
0
def main():
   if len(sys.argv)<2: return xmlmsg("error","Usage: prepare.py <device> [-f]. Example: prepare.py /dev/sdb")
   vol=volume(sys.argv[1])
   force=False
   if len(sys.argv)>2 and sys.argv[2]=="-f": force=True
   if vol.type<>"empty" and not force: return xmlmsg("error","Disk "+sys.argv[1]+" is not empty")
   (ok,errmsg)=vol.prepare()
   if ok==False: return xmlmsg("error",errmsg)
   else:
         (ok,errmsg2)=vol.mount()
         if ok==False: return xmlmsg("error",errmsg2)
         return xmlmsg("result",errmsg)