xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* No sxputils module for xm command
@ 2010-04-23 15:49 Xu, Jiajun
  2010-04-26  5:26 ` Juergen Gross
  0 siblings, 1 reply; 3+ messages in thread
From: Xu, Jiajun @ 2010-04-23 15:49 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com; +Cc: Juergen Gross, Keir Fraser

Hi,
I found with latest xen, 'xm' command returns fail with following error:

[root@vt-dp6 ~]# xm list
Traceback (most recent call last):
  File "/usr/sbin/xm", line 5, in ?
    from xen.xm import main
  File "/usr/lib/python2.4/site-packages/xen/xm/main.py", line 59, in ?
    from xen.util.sxputils import sxp2map, map2sxp as map_to_sxp
ImportError: No module named sxputils

Could anyone help on this? 
Thanks a lot.

Best Regards,
Jiajun

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: No sxputils module for xm command
  2010-04-23 15:49 No sxputils module for xm command Xu, Jiajun
@ 2010-04-26  5:26 ` Juergen Gross
  2010-04-26  5:36   ` Keir Fraser
  0 siblings, 1 reply; 3+ messages in thread
From: Juergen Gross @ 2010-04-26  5:26 UTC (permalink / raw)
  To: Xu, Jiajun; +Cc: xen-devel@lists.xensource.com, Keir Fraser

[-- Attachment #1: Type: text/plain, Size: 1077 bytes --]

On 04/23/2010 05:49 PM, Xu, Jiajun wrote:
> Hi,
> I found with latest xen, 'xm' command returns fail with following error:
>
> [root@vt-dp6 ~]# xm list
> Traceback (most recent call last):
>    File "/usr/sbin/xm", line 5, in ?
>      from xen.xm import main
>    File "/usr/lib/python2.4/site-packages/xen/xm/main.py", line 59, in ?
>      from xen.util.sxputils import sxp2map, map2sxp as map_to_sxp
> ImportError: No module named sxputils
>
> Could anyone help on this?
> Thanks a lot.

Sorry, the attched patch should correct that.
The module slipped through my cpupool patch (no hg add).
Now I've deleted all xen python modules on my test machine before doing a new
install. Seems to work now...


Juergen

-- 
Juergen Gross                 Principal Developer Operating Systems
TSP ES&S SWE OS6                       Telephone: +49 (0) 89 3222 2967
Fujitsu Technology Solutions              e-mail: juergen.gross@ts.fujitsu.com
Domagkstr. 28                           Internet: ts.fujitsu.com
D-80807 Muenchen                 Company details: ts.fujitsu.com/imprint.html

[-- Attachment #2: sxputils.patch --]
[-- Type: text/x-patch, Size: 2557 bytes --]

Signed-off-by: juergen.gross@ts.fujitsu.com

diff -r c87ec146229a tools/python/xen/util/sxputils.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/python/xen/util/sxputils.py	Mon Apr 26 07:14:28 2010 +0200
@@ -0,0 +1,64 @@
+#============================================================================
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#============================================================================
+# Copyright (c) 2009 Fujitsu Technology Solutions
+#============================================================================
+
+""" convert sxp to map / map to sxp.
+"""
+
+import types
+from xen.xend import sxp
+
+def map2sxp(map_val):
+    """ conversion of all key-value pairs of a map (recursively) to sxp.
+        @param map_val: map; if a value contains a list or dict it is also
+                    converted to sxp
+        @type map_val: dict
+        @return sxp expr
+        @rtype: list
+    """
+    sxp_vals = []
+    for (k, v) in map_val.items():
+        if isinstance(v, types.DictionaryType):
+            sxp_vals += [[k] + map2sxp(v)]
+        elif isinstance(v, types.ListType):
+            sxp_vals += [[k] + v]
+        else:
+            sxp_vals += [[k, v]]
+    return sxp_vals
+
+def sxp2map( s ):
+    """ conversion of sxp to map.
+        @param s: sxp expr
+        @type s:  list
+        @return: map
+        @rtype: dict
+    """
+    sxphash = {}
+
+    for child in sxp.children( s ):
+        if isinstance( child, types.ListType ) and len( child ) > 1:
+            if isinstance( child[1], types.ListType ) and len( child[1] ) > 1:
+                sxphash[ child[0] ] = sxp2map( child )
+            else:
+                childs = sxp.children(child)
+                if len(childs) > 1:
+                    sxphash[ child[0] ] = childs
+                else:
+                    sxphash[ child[0] ] = childs[0]
+
+    return sxphash
+
+

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: No sxputils module for xm command
  2010-04-26  5:26 ` Juergen Gross
@ 2010-04-26  5:36   ` Keir Fraser
  0 siblings, 0 replies; 3+ messages in thread
From: Keir Fraser @ 2010-04-26  5:36 UTC (permalink / raw)
  To: Juergen Gross, Xu, Jiajun; +Cc: xen-devel@lists.xensource.com

On 26/04/2010 06:26, "Juergen Gross" <juergen.gross@ts.fujitsu.com> wrote:

>> Could anyone help on this?
>> Thanks a lot.
> 
> Sorry, the attched patch should correct that.
> The module slipped through my cpupool patch (no hg add).
> Now I've deleted all xen python modules on my test machine before doing a new
> install. Seems to work now...

Thanks!

 K.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-26  5:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-23 15:49 No sxputils module for xm command Xu, Jiajun
2010-04-26  5:26 ` Juergen Gross
2010-04-26  5:36   ` Keir Fraser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).