<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 06/27/2014 05:28 AM, Aline Manera
      wrote:<br>
    </div>
    <blockquote cite="mid:53AC9070.20509@linux.vnet.ibm.com" type="cite">On
      06/18/2014 06:35 AM, <a class="moz-txt-link-abbreviated" href="mailto:lvroyce@linux.vnet.ibm.com">lvroyce@linux.vnet.ibm.com</a> wrote:
      <br>
      <blockquote type="cite">From: Royce Lv
        <a class="moz-txt-link-rfc2396E" href="mailto:lvroyce@linux.vnet.ibm.com">&lt;lvroyce@linux.vnet.ibm.com&gt;</a>
        <br>
        <br>
        Image file probe will be used in identify image file os info and
        <br>
        generate reasonable configuration for it.
        <br>
        This will be useful when import image and create a vm from it.
        <br>
      </blockquote>
      <br>
      Do you mean to use libguestfs instead of our own code -
      isoinfo.py?
      <br>
    </blockquote>
    No. <br>
    The isoinfo.py can be replaced by linux shell command, such as
    "file" or "iso" related command. <br>
    But I think it is not necessary to replace it. <br>
    Not sure the libguestfs can also support the same function of
    isoinfo.py. If it can we can replace the <br>
    isoinfo.py<br>
    <br>
    <br>
    Here, I think<br>
    <b><i>We should support create VM from an image.&nbsp; </i></b><br>
    <b>Create a VM from image is faster than ISO. </b><br>
    So when we&nbsp; create a image from image, we had better to know the OS
    distro and version.<br>
    <br>
    There are several sources of an image.&nbsp; <br>
    1.&nbsp; local image<br>
    <br>
    2. remote image.&nbsp; Same as Openstack glance.<br>
    Now all OS distro support both remote ISO and image.<br>
    <br>
    3.&nbsp; create one from a VM.<br>
    User may take several snapshots for a VM. <br>
    this way we had better to merge all snapshots to one.<br>
    <br>
    <br>
    Maybe we should support a image-template pool. <br>
    move the above type images to this pool.<br>
    <br>
    <br>
    <br>
    <br>
    <blockquote cite="mid:53AC9070.20509@linux.vnet.ibm.com" type="cite">
      <br>
      <blockquote type="cite">
        <br>
        Signed-off-by: Royce Lv <a class="moz-txt-link-rfc2396E" href="mailto:lvroyce@linux.vnet.ibm.com">&lt;lvroyce@linux.vnet.ibm.com&gt;</a>
        <br>
        ---
        <br>
        &nbsp; docs/README.md&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp; 9 ++++++---
        <br>
        &nbsp; src/kimchi/exception.py |&nbsp; 2 ++
        <br>
        &nbsp; src/kimchi/imageinfo.py | 42
        ++++++++++++++++++++++++++++++++++++++++++
        <br>
        &nbsp; 3 files changed, 50 insertions(+), 3 deletions(-)
        <br>
        &nbsp; create mode 100644 src/kimchi/imageinfo.py
        <br>
        <br>
        diff --git a/docs/README.md b/docs/README.md
        <br>
        index c658637..c341a5d 100644
        <br>
        --- a/docs/README.md
        <br>
        +++ b/docs/README.md
        <br>
        @@ -53,7 +53,8 @@ Install Dependencies
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PyPAM m2crypto python-jsonschema
        rpm-build \
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; qemu-kvm python-psutil python-ethtool
        sos \
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; python-ipaddr python-lxml nfs-utils \
        <br>
        -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iscsi-initiator-utils libxslt pyparted
        nginx
        <br>
        +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iscsi-initiator-utils libxslt pyparted
        nginx \
        <br>
        +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; python-libguestfs libguestfs-tools
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # If using RHEL6, install the following additional
        packages:
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ sudo yum install python-unittest2 python-ordereddict
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Restart libvirt to allow configuration changes to take
        effect
        <br>
        @@ -75,7 +76,8 @@ for more information on how to configure your
        system to access this repository.
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; python-pam python-m2crypto
        python-jsonschema \
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; qemu-kvm libtool python-psutil
        python-ethtool \
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sosreport python-ipaddr python-lxml
        nfs-common \
        <br>
        -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; open-iscsi lvm2 xsltproc
        python-parted nginx
        <br>
        +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; open-iscsi lvm2 xsltproc
        python-parted nginx \
        <br>
        +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; python-guestfs libguestfs-tools
        <br>
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Packages version requirement:
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; python-jsonschema &gt;= 1.3.0
        <br>
        @@ -89,7 +91,8 @@ for more information on how to configure your
        system to access this repository.
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; python-pam python-M2Crypto
        python-jsonschema \
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rpm-build kvm python-psutil
        python-ethtool \
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; python-ipaddr python-lxml nfs-client
        open-iscsi \
        <br>
        -&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; libxslt-tools python-xml
        python-parted
        <br>
        +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; libxslt-tools python-xml
        python-parted \
        <br>
        +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; python-libguestfs guestfs-tools
        <br>
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Packages version requirement:
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; python-psutil &gt;= 0.6.0
        <br>
        diff --git a/src/kimchi/exception.py b/src/kimchi/exception.py
        <br>
        index fcf60cc..a983d46 100644
        <br>
        --- a/src/kimchi/exception.py
        <br>
        +++ b/src/kimchi/exception.py
        <br>
        @@ -88,6 +88,8 @@ class InvalidOperation(KimchiException):
        <br>
        &nbsp; class IsoFormatError(KimchiException):
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pass
        <br>
        <br>
        +class ImageFormatError(KimchiException):
        <br>
        +&nbsp;&nbsp;&nbsp; pass
        <br>
        <br>
        &nbsp; class TimeoutExpired(KimchiException):
        <br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pass
        <br>
        diff --git a/src/kimchi/imageinfo.py b/src/kimchi/imageinfo.py
        <br>
        new file mode 100644
        <br>
        index 0000000..d57ecac
        <br>
        --- /dev/null
        <br>
        +++ b/src/kimchi/imageinfo.py
        <br>
        @@ -0,0 +1,42 @@
        <br>
        +#
        <br>
        +# Kimchi
        <br>
        +#
        <br>
        +# Copyright IBM Corp, 2013
        <br>
        +#
        <br>
        +# This library is free software; you can redistribute it and/or
        <br>
        +# modify it under the terms of the GNU Lesser General Public
        <br>
        +# License as published by the Free Software Foundation; either
        <br>
        +# version 2.1 of the License, or (at your option) any later
        version.
        <br>
        +#
        <br>
        +# This library is distributed in the hope that it will be
        useful,
        <br>
        +# but WITHOUT ANY WARRANTY; without even the implied warranty
        of
        <br>
        +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&nbsp; See the
        GNU
        <br>
        +# Lesser General Public License for more details.
        <br>
        +#
        <br>
        +# You should have received a copy of the GNU Lesser General
        Public
        <br>
        +# License along with this library; if not, write to the Free
        Software
        <br>
        +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
        MA&nbsp; 02110-1301 USA
        <br>
        +
        <br>
        +import sys
        <br>
        +import guestfs
        <br>
        +
        <br>
        +
        <br>
        +def probe_image(image_path):
        <br>
        +&nbsp;&nbsp;&nbsp; g = guestfs.GuestFS(python_return_dict=True)
        <br>
        +&nbsp;&nbsp;&nbsp; g.add_drive_opts(image_path, readonly=1)
        <br>
        +&nbsp;&nbsp;&nbsp; g.launch()
        <br>
        +
        <br>
        +&nbsp;&nbsp;&nbsp; roots = g.inspect_os()
        <br>
        +&nbsp;&nbsp;&nbsp; if len(roots) == 0:
        <br>
        +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; raise ImageFormatError("No os found in given image.")
        <br>
        +
        <br>
        +&nbsp;&nbsp;&nbsp; for root in roots:
        <br>
        +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; version = "%d.%d" % (g.inspect_get_major_version(root),
        <br>
        +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g.inspect_get_minor_version(root))
        <br>
        +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; distro = "%s" % (g.inspect_get_distro(root))
        <br>
        +
        <br>
        +&nbsp;&nbsp;&nbsp; return (distro, version)
        <br>
        +
        <br>
        +
        <br>
        +if __name__ == '__main__':
        <br>
        +&nbsp;&nbsp;&nbsp; print probe_image(sys.argv[1])
        <br>
      </blockquote>
      <br>
      _______________________________________________
      <br>
      Kimchi-devel mailing list
      <br>
      <a class="moz-txt-link-abbreviated" href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
      <br>
      <a class="moz-txt-link-freetext" href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a>
      <br>
      <br>
      <br>
      <br>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Thanks and best regards!

Sheldon Feng(&#20911;&#23569;&#21512;)<a class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com">&lt;shaohef@linux.vnet.ibm.com&gt;</a>
IBM Linux Technology Center</pre>
  </body>
</html>