[Libguestfs] python-guestfs rbd

Li Tianqing jazeltq at 163.com
Wed Aug 6 09:02:01 UTC 2014


At 2014-08-06 04:31:09, "Richard W.M. Jones" <rjones at redhat.com> wrote:

>On Wed, Aug 06, 2014 at 04:17:24PM +0800, Li Tianqing wrote:
>> how to use python-guestfs to access rbd device? The function i found is g.add_drive_opts, but i dono know how it receive ceph's configuration. 
>
>> I found this link
>> http://rwmj.wordpress.com/2013/03/12/accessing-ceph-rbd-sheepdog-etc-using-libguestfs/
>
>Ignore this link, it's very old and describes a hack which is no
>longer needed.  Libguestfs now properly supports accessing many remote
>drives, without needing hacks.
>
>> Is that the only way i should use to access ceph rbd? Can we use
>> python-guestfs to get the same effect?
>
>Yes, you can use python-guestfs to access rbd.
>
>You need to do something like the code below.
>
>My Ceph server is switched off at the moment and I'm about to go to a
>conference, so I didn't have time to test this, but something like
>this should work.
>

>Make sure you have a recent version of libguestfs.  At least >= 1.26.


Thanks a lot .  I will try.  


>
>----------------------------------------------------------------------
>
>import guestfs
>
>g = guestfs.GuestFS (python_return_dict=True)
>
>g.set_verbose (1)
>g.set_trace (1)
>
>g.add_drive_opts ("pool/image",
>		 format="raw",
>		 readonly=1,
>		 protocol="rbd",
>		 server=[ "192.168.0.10:1234", "192.168.0.11:1235" ],
>#		 username="rbd_user_name",
>#		 secret="base64_encoded_password",
>		 )
>
>g.launch ()
>
># etc.
>
>----------------------------------------------------------------------
>
>Rich.
>
>-- 
>Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
>Read my programming and virtualization blog: http://rwmj.wordpress.com
>virt-builder quickly builds VMs from scratch
>http://libguestfs.org/virt-builder.1.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20140806/31562f9f/attachment.htm>


More information about the Libguestfs mailing list