Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 871888 Details for
Bug 1073906
java bindings inspect_list_applications2 throws java.lang.ArrayIndexOutOfBoundsException:
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
InspectVM.java
InspectVM.java (text/plain), 3.58 KB, created by
Richard W.M. Jones
on 2014-03-07 13:08:47 UTC
(
hide
)
Description:
InspectVM.java
Filename:
MIME Type:
Creator:
Richard W.M. Jones
Created:
2014-03-07 13:08:47 UTC
Size:
3.58 KB
patch
obsolete
>// Example showing how to inspect a virtual machine disk. > >import java.util.ArrayList; >import java.util.Collections; >import java.util.Comparator; >import java.util.HashMap; >import java.util.List; >import java.util.Map; >import com.redhat.et.libguestfs.*; > >public class InspectVM >{ > static final Comparator<String> COMPARE_KEYS_LEN = > new Comparator<String>() { > public int compare (String k1, String k2) { > return k1.length() - k2.length(); > } > }; > > public static void main (String[] argv) > { > try { > if (argv.length != 1) > throw new Error ("usage: InspectVM disk.img"); > > String disk = argv[0]; > > GuestFS g = new GuestFS (); > > // Attach the disk image read-only to libguestfs. > @SuppressWarnings("serial") Map<String, Object> optargs = > new HashMap<String, Object>() { > { > //put ("format", "raw"); > put ("readonly", Boolean.TRUE); > } > }; > > g.add_drive_opts (disk, optargs); > > // Run the libguestfs back-end. > g.launch (); > > // Ask libguestfs to inspect for operating systems. > String roots[] = g.inspect_os (); > if (roots.length == 0) > throw new Error ("inspect_vm: no operating systems found"); > > for (String root : roots) { > System.out.println ("Root device: " + root); > > // Print basic information about the operating system. > System.out.println (" Product name: " + > g.inspect_get_product_name (root)); > System.out.println (" Version: " + > g.inspect_get_major_version (root) + > "." + > g.inspect_get_minor_version (root)); > System.out.println (" Type: " + > g.inspect_get_type (root)); > System.out.println (" Distro: " + > g.inspect_get_distro (root)); > > // Mount up the disks, like guestfish -i. > // > // Sort keys by length, shortest first, so that we end up > // mounting the filesystems in the correct order. > Map<String,String> mps = g.inspect_get_mountpoints (root); > List<String> mps_keys = new ArrayList<String> (mps.keySet ()); > Collections.sort (mps_keys, COMPARE_KEYS_LEN); > > for (String mp : mps_keys) { > String dev = mps.get (mp); > try { > g.mount_ro (dev, mp); > } > catch (Exception exn) { > System.err.println (exn + " (ignored)"); > } > } > > // Get list of applications. > Application2[] apps = g.inspect_list_applications2 (root); > System.out.println (" Number of apps installed = " + > apps.length); > for (Application2 app : apps) { > System.out.print (" " + app.app2_name); > System.out.print (" " + app.app2_version); > System.out.println (" " + app.app2_release); > } > > // Unmount everything. > g.umount_all (); > } > } > catch (Exception exn) { > System.err.println (exn); > System.exit (1); > } > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1073906
: 871888