コード例 #1
0
         pmsg("after attach:"+"".join(after_attach))
     else:
         break
     time.sleep(5)
  
 if new_devices == []:
     raise Exception("Fail, Volume attached but not found on guest" + str(instance) )
 attached_block_dev =  "/dev/"+new_devices[0].strip()
 pmsg("Attached to guest dev:"+attached_block_dev+"\nSplat our remote image into volume")
 
 #Get the md5 of the remote image before writing it to the volume for comparison purposes
 timeout=rfsize*time_per_gig+200
 if ( md5sum is None ):
     pmsg("MD5sum not provided, getting it now...")
     cmd="curl -s "+url+" | md5sum "  
     md5sum=instance.sys(cmd ,  timeout=timeout)[0]
     md5sum=md5sum.split(' ')[0]
     pmsg("The md5sum of the remote image: "+str(md5sum))
     
 #Download the remote image, write it directly to our volume
 cmd="curl "+url+" > "+attached_block_dev+" && echo 'GOOD' && sync"
 try:
     pmsg("Issuing cmd:"+cmd+" , timeout:"+str(timeout))
     output=instance.sys(cmd,  timeout=timeout)
     pmsg("Curl output:"+"".join(output))
     result = output[len(output)-1]
     result = result.split(' ')[0]
     pmsg("curl cmd's parsed result:"+result)
 except Exception, e:
     raise Exception("failed to curl image into block dev: "+str(e))
 #Make sure the curl command did not return error