direct-io.hg

changeset 14388:b39c0a79d4d5

Added the clear flag to host.dmesg, and added host.get_log. Use these to
implement xm dmesg and xm log using the Xen-API.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Wed Mar 14 23:16:59 2007 +0000 (2007-03-14)
parents 8645c726ce9c
children 30a83a0839bd
files tools/python/xen/xend/XendAPI.py tools/python/xen/xm/main.py
line diff
     1.1 --- a/tools/python/xen/xend/XendAPI.py	Wed Mar 14 23:14:19 2007 +0000
     1.2 +++ b/tools/python/xen/xend/XendAPI.py	Wed Mar 14 23:16:59 2007 +0000
     1.3 @@ -661,7 +661,8 @@ class XendAPI(object):
     1.4                      ('shutdown', None),
     1.5                      ('add_to_other_config', None),
     1.6                      ('remove_from_other_config', None),
     1.7 -                    ('dmesg', 'String')]
     1.8 +                    ('dmesg', 'String'),
     1.9 +                    ('get_log', 'String')]
    1.10      
    1.11      host_funcs = [('get_by_name_label', 'Set(host)')]
    1.12  
    1.13 @@ -737,8 +738,16 @@ class XendAPI(object):
    1.14              return xen_api_error(XEND_ERROR_HOST_RUNNING)
    1.15          return xen_api_error(XEND_ERROR_UNSUPPORTED)        
    1.16  
    1.17 -    def host_dmesg(self, session, host_ref):
    1.18 -        return xen_api_success(XendDmesg.instance().info())
    1.19 +    def host_dmesg(self, session, host_ref, clear):
    1.20 +        if clear:
    1.21 +            return xen_api_success(XendDmesg.instance().clear())
    1.22 +        else:
    1.23 +            return xen_api_success(XendDmesg.instance().info())
    1.24 +
    1.25 +    def host_get_log(self, session, host_ref):
    1.26 +        log_file = open(XendLogging.getLogFilename())
    1.27 +        log_buffer = log_file.read()
    1.28 +        return xen_api_success(log_buffer)
    1.29  
    1.30      def host_get_record(self, session, host_ref):
    1.31          node = XendNode.instance()
     2.1 --- a/tools/python/xen/xm/main.py	Wed Mar 14 23:14:19 2007 +0000
     2.2 +++ b/tools/python/xen/xm/main.py	Wed Mar 14 23:16:59 2007 +0000
     2.3 @@ -1498,17 +1498,33 @@ def xm_dmesg(args):
     2.4          err("No parameter required")
     2.5          usage('dmesg')
     2.6  
     2.7 -    if not use_clear:
     2.8 -        print server.xend.node.dmesg.info()
     2.9 +    if serverType == SERVER_XEN_API:
    2.10 +        if not use_clear:
    2.11 +            print server.xenapi.host.dmesg(
    2.12 +                server.xenapi.session.get_this_host(),0)
    2.13 +        else:
    2.14 +            server.xenapi.host.dmesg(
    2.15 +                server.xenapi.session.get_this_host(),1)
    2.16      else:
    2.17 -        server.xend.node.dmesg.clear()
    2.18 +        if not use_clear:
    2.19 +            print server.xend.node.dmesg.info()
    2.20 +        else:
    2.21 +            server.xend.node.dmesg.clear()
    2.22  
    2.23  def xm_log(args):
    2.24      arg_check(args, "log", 0)
    2.25 -    
    2.26 -    print server.xend.node.log()
    2.27 +
    2.28 +    if serverType == SERVER_XEN_API:
    2.29 +        print server.xenapi.host.get_log(
    2.30 +            server.xenapi.session.get_this_host())
    2.31 +    else:
    2.32 +        print server.xend.node.log()
    2.33  
    2.34  def xm_serve(args):
    2.35 +    if serverType == SERVER_XEN_API:
    2.36 +        print "Not supported with XenAPI"
    2.37 +        sys.exit(-1)
    2.38 +
    2.39      arg_check(args, "serve", 0)
    2.40  
    2.41      from fcntl import fcntl, F_SETFL