<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 09:00 AM, Sheldon wrote:<br>
</div>
<blockquote cite="mid:53ACC21E.3040104@linux.vnet.ibm.com"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<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 moz-do-not-send="true"
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
moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:lvroyce@linux.vnet.ibm.com"><lvroyce@linux.vnet.ibm.com></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. </i></b><br>
<b>Create a VM from image is faster than ISO. </b><br>
So when we create a image from image, we had better to know the
OS distro and version.<br>
<br>
There are several sources of an image. <br>
1. local image<br>
<br>
2. remote image. Same as Openstack glance.<br>
Now all OS distro support both remote ISO and image.<br>
<br>
3. 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>
</blockquote>
for remote image should we support steaming install? <br>
<blockquote cite="mid:53ACC21E.3040104@linux.vnet.ibm.com"
type="cite"> <br>
<br>
<blockquote cite="mid:53AC9070.20509@linux.vnet.ibm.com"
type="cite"> <br>
<blockquote type="cite"> <br>
Signed-off-by: Royce Lv <a moz-do-not-send="true"
class="moz-txt-link-rfc2396E"
href="mailto:lvroyce@linux.vnet.ibm.com"><lvroyce@linux.vnet.ibm.com></a>
<br>
--- <br>
docs/README.md | 9 ++++++--- <br>
src/kimchi/exception.py | 2 ++ <br>
src/kimchi/imageinfo.py | 42
++++++++++++++++++++++++++++++++++++++++++ <br>
3 files changed, 50 insertions(+), 3 deletions(-) <br>
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>
PyPAM m2crypto python-jsonschema
rpm-build \ <br>
qemu-kvm python-psutil
python-ethtool sos \ <br>
python-ipaddr python-lxml nfs-utils
\ <br>
- iscsi-initiator-utils libxslt
pyparted nginx <br>
+ iscsi-initiator-utils libxslt
pyparted nginx \ <br>
+ python-libguestfs libguestfs-tools <br>
# If using RHEL6, install the following additional
packages: <br>
$ sudo yum install python-unittest2 python-ordereddict
<br>
# 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>
python-pam python-m2crypto
python-jsonschema \ <br>
qemu-kvm libtool python-psutil
python-ethtool \ <br>
sosreport python-ipaddr
python-lxml nfs-common \ <br>
- open-iscsi lvm2 xsltproc
python-parted nginx <br>
+ open-iscsi lvm2 xsltproc
python-parted nginx \ <br>
+ python-guestfs libguestfs-tools <br>
<br>
Packages version requirement: <br>
python-jsonschema >= 1.3.0 <br>
@@ -89,7 +91,8 @@ for more information on how to configure
your system to access this repository. <br>
python-pam python-M2Crypto
python-jsonschema \ <br>
rpm-build kvm python-psutil
python-ethtool \ <br>
python-ipaddr python-lxml
nfs-client open-iscsi \ <br>
- libxslt-tools python-xml
python-parted <br>
+ libxslt-tools python-xml
python-parted \ <br>
+ python-libguestfs guestfs-tools <br>
<br>
Packages version requirement: <br>
python-psutil >= 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>
class IsoFormatError(KimchiException): <br>
pass <br>
<br>
+class ImageFormatError(KimchiException): <br>
+ pass <br>
<br>
class TimeoutExpired(KimchiException): <br>
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. 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 02110-1301 USA <br>
+ <br>
+import sys <br>
+import guestfs <br>
+ <br>
+ <br>
+def probe_image(image_path): <br>
+ g = guestfs.GuestFS(python_return_dict=True) <br>
+ g.add_drive_opts(image_path, readonly=1) <br>
+ g.launch() <br>
+ <br>
+ roots = g.inspect_os() <br>
+ if len(roots) == 0: <br>
+ raise ImageFormatError("No os found in given image.")
<br>
+ <br>
+ for root in roots: <br>
+ version = "%d.%d" %
(g.inspect_get_major_version(root), <br>
+
g.inspect_get_minor_version(root)) <br>
+ distro = "%s" % (g.inspect_get_distro(root)) <br>
+ <br>
+ return (distro, version) <br>
+ <br>
+ <br>
+if __name__ == '__main__': <br>
+ print probe_image(sys.argv[1]) <br>
</blockquote>
<br>
_______________________________________________ <br>
Kimchi-devel mailing list <br>
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
<br>
<a moz-do-not-send="true" 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(冯少合)<a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com"><shaohef@linux.vnet.ibm.com></a>
IBM Linux Technology Center</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Kimchi-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
<a class="moz-txt-link-freetext" href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Thanks and best regards!
Sheldon Feng(冯少合)<a class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com"><shaohef@linux.vnet.ibm.com></a>
IBM Linux Technology Center</pre>
</body>
</html>