ia64/xen-unstable

view tools/python/xen/util/xsm/dummy/dummy.py @ 18442:392b04ccaf3c

xsm: A few hacks to get XSM-disabled (aka dummy) mode working.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Sep 04 16:29:38 2008 +0100 (2008-09-04)
parents 5b133625223a
children 59aba2cbbb58
line source
1 import sys
2 from xen.util import xsconstants
3 from xen.xend.XendLogging import log
5 class XSMError(Exception):
6 def __init__(self,value):
7 self.value = value
8 def __str__(self):
9 return repr(self.value)
12 security_dir_prefix = "";
13 policy_dir_prefix = "";
14 active_policy = "";
15 NULL_SSIDREF = 0;
17 #Functions exported through XML-RPC
18 xmlrpc_exports = [
19 'set_resource_label',
20 'get_resource_label',
21 'list_labels',
22 'get_labeled_resources',
23 'set_policy',
24 'reset_policy',
25 'get_policy',
26 'activate_policy',
27 'rm_bootpolicy',
28 'get_xstype',
29 'get_domain_label',
30 'set_domain_label'
31 ]
33 def err(msg):
34 """Raise XSM-dummy exception.
35 """
36 raise XSMError(msg)
38 def on():
39 return 0
41 def ssidref2label(ssidref):
42 return 0
44 def label2ssidref(label, policy, type):
45 return 0
47 def res_security_check(resource, domain_label):
48 return 1
50 def get_res_security_details(resource):
51 return ("","","")
53 def get_res_label(resource):
54 return ("","")
56 def res_security_check_xapi(rlabel, rssidref, rpolicy, xapi_dom_label):
57 return 1
59 def parse_security_label(security_label):
60 return ""
62 def calc_dom_ssidref_from_info(info):
63 return ""
65 def set_security_label(policy, label):
66 return ""
68 def ssidref2security_label(ssidref):
69 return ""
71 def has_authorization(ssidref):
72 return True
74 def get_security_label(self, xspol=None):
75 return ""
77 def get_resource_label_xapi(resource):
78 return ""
80 def get_labeled_resources_xapi():
81 return {}
83 def set_resource_label_xapi(resource, reslabel_xapi, oldlabel_xapi):
84 err("Command not supported under XSM 'dummy' module.")
86 def format_resource_label(res):
87 return ""
89 def set_resource_label(resource, policytype, policyref, reslabel,
90 oreslabel = None):
91 err("Command not supported under XSM 'dummy' module.")
93 def get_resource_label(resource):
94 return ""
96 def list_labels(policy_name, ltype):
97 return []
99 def get_labeled_resources():
100 return {}
102 def set_policy(xs_type, xml, flags, overwrite):
103 err("Command not supported under xsm 'dummy' module.")
105 def reset_policy():
106 err("Command not supported under xsm 'dummy' module.")
108 def get_policy():
109 return "", 0
111 def activate_policy():
112 err("Command not supported under xsm 'dummy' module.")
114 def rm_bootpolicy():
115 err("Command not supported under xsm 'dummy' module.")
117 def get_xstype():
118 return 0
120 def get_domain_label(domain):
121 return ""
123 def set_domain_label():
124 err("Command not supported under xsm 'dummy' module.")
126 def dump_policy():
127 pass
129 def dump_policy_file():
130 pass
132 def get_ssid(domain):
133 err("No ssid has been assigned to any domain under xsm dummy module.")