debuggers.hg

view tools/python/xen/xm/resources.py @ 16559:5255eac35270

Implement legacy XML-RPC interface for ACM commands.

This patch implements a (non Xen-API) legacy XML-RPC interface for the
ACM commands and funnels the calls into code introduced by the Xen-API
support for ACM security management. Since some of the functionality
has changed, also the xm applications have changed. In particular the
following old commands have been removed along with some tools the
have become obsolete now:

- loadpolicy (included in: setpolicy)
- makepolicy (included in: setpolicy)
- cfgbootpolicy (included in: setpolicy)

and the following commands been introduced:

- setpolicy
- getpolicy
- resetpolicy

All tools have been adapted to work in Xen-API and legacy XML-RPC
mode. Both modes support the same functionality.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Dec 05 09:44:20 2007 +0000 (2007-12-05)
parents 993655d24b55
children
line source
1 #============================================================================
2 # This library is free software; you can redistribute it and/or
3 # modify it under the terms of version 2.1 of the GNU Lesser General Public
4 # License as published by the Free Software Foundation.
5 #
6 # This library is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 # Lesser General Public License for more details.
10 #
11 # You should have received a copy of the GNU Lesser General Public
12 # License along with this library; if not, write to the Free Software
13 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 #============================================================================
15 # Copyright (C) 2006 International Business Machines Corp.
16 # Author: Bryan D. Payne <bdpayne@us.ibm.com>
17 #============================================================================
19 """List the resource label information from the global resource label file
20 """
21 import sys
22 from xen.util import xsconstants
23 from xen.xm.opts import OptionError
24 from xen.xm import main as xm_main
25 from xen.xm.main import server
27 def help():
28 return """
29 This program lists information for each resource in the
30 global resource label file."""
32 def print_resource_data(access_control):
33 """Prints out a resource dictionary to stdout
34 """
35 for resource in access_control:
36 tmp = access_control[resource]
37 if len(tmp) == 2:
38 policytype = xsconstants.ACM_POLICY_ID
39 (policy, label) = access_control[resource]
40 elif len(tmp) == 3:
41 policytype, policy, label = access_control[resource]
42 print resource
43 print " type: "+ policytype
44 print " policy: "+ policy
45 print " label: "+ label
47 def main (argv):
48 if len(argv) > 1:
49 raise OptionError("No arguments required")
51 if xm_main.serverType == xm_main.SERVER_XEN_API:
52 access_control = server.xenapi.XSPolicy.get_labeled_resources()
53 for key, value in access_control.items():
54 access_control[key] = tuple(value.split(':'))
55 else:
56 access_control = server.xend.security.get_labeled_resources()
58 print_resource_data(access_control)
60 if __name__ == '__main__':
61 try:
62 main(sys.argv)
63 except Exception, e:
64 sys.stderr.write('Error: %s\n' % str(e))
65 sys.exit(-1)