libguestfs: Java bindings

New in version 1.0.5 of libguestfs, Java bindings:

public class LVCreate {                                               
    public static void main (String[] argv)                                     
    {                                                                           
        try {                                                                   
            GuestFS g = new GuestFS ();
                                                                                
            RandomAccessFile f = new RandomAccessFile ("test.img", "rw");       
            f.setLength (500 * 1024 * 1024);                                    
            f.close ();                                                         
                                                                                
            g.add_drive ("test.img");
            g.launch ();
            g.wait_ready ();
                                                                                
            g.pvcreate ("/dev/sda");
            g.vgcreate ("VG", new String[] {"/dev/sda"});
            g.lvcreate ("LV1", "VG", 200);
            g.lvcreate ("LV2", "VG", 200);
                                                                                
            String[] lvs = g.lvs ();
            assert lvs[0].equals ("/dev/VG/LV1");                               
            assert lvs[1].equals ("/dev/VG/LV2");                               
                                                                                
            g.sync ();
            g.close ();
        }                                                                       
        catch (Exception exn) {                                                 
            System.err.println (exn);                                           
            System.exit (1);                                                    
        }                                                                       
    }                                                                           
}                                                                               

Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.