ia64/xen-unstable

view tools/python/xen/util/xsconstants.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
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) 2007 International Business Machines Corp.
16 # Author: Stefan Berger <stefanb@us.ibm.com>
17 #============================================================================
19 XS_INST_NONE = 0
20 XS_INST_BOOT = (1 << 0)
21 XS_INST_LOAD = (1 << 1)
23 XS_POLICY_ACM = (1 << 0)
24 XS_POLICY_FLASK = (1 << 1)
25 XS_POLICY_DUMMY = (1 << 2)
26 XS_POLICY_USE = 0
28 # Some internal variables used by the Xen-API
29 ACM_LABEL_VM = (1 << 0)
30 ACM_LABEL_RES = (1 << 1)
32 # Base for XS error codes for collision avoidance with other error codes
33 XSERR_BASE = 0x1000
35 # XS error codes as used by the Xen-API
36 XSERR_SUCCESS = 0
37 XSERR_GENERAL_FAILURE = 1 + XSERR_BASE
38 XSERR_BAD_XML = 2 + XSERR_BASE # XML is wrong (not according to schema)
39 XSERR_XML_PROCESSING = 3 + XSERR_BASE
40 XSERR_POLICY_INCONSISTENT = 4 + XSERR_BASE # i.e., bootstrap name not a VM label
41 XSERR_FILE_ERROR = 5 + XSERR_BASE
42 XSERR_BAD_RESOURCE_FORMAT = 6 + XSERR_BASE # badly formatted resource
43 XSERR_BAD_LABEL_FORMAT = 7 + XSERR_BASE
44 XSERR_RESOURCE_NOT_LABELED = 8 + XSERR_BASE
45 XSERR_RESOURCE_ALREADY_LABELED = 9 + XSERR_BASE
46 XSERR_WRONG_POLICY_TYPE = 10 + XSERR_BASE
47 XSERR_BOOTPOLICY_INSTALLED = 11 + XSERR_BASE
48 XSERR_NO_DEFAULT_BOOT_TITLE = 12 + XSERR_BASE
49 XSERR_POLICY_LOAD_FAILED = 13 + XSERR_BASE
50 XSERR_POLICY_LOADED = 14 + XSERR_BASE
51 XSERR_POLICY_TYPE_UNSUPPORTED = 15 + XSERR_BASE
52 XSERR_BAD_CONFLICTSET = 16 + XSERR_BASE
53 XSERR_RESOURCE_IN_USE = 17 + XSERR_BASE
54 XSERR_BAD_POLICY_NAME = 18 + XSERR_BASE
55 XSERR_VERSION_PREVENTS_UPDATE = 19 + XSERR_BASE
56 XSERR_BAD_LABEL = 20 + XSERR_BASE
57 XSERR_VM_WRONG_STATE = 21 + XSERR_BASE
58 XSERR_POLICY_NOT_LOADED = 22 + XSERR_BASE
59 XSERR_RESOURCE_ACCESS = 23 + XSERR_BASE
60 XSERR_HV_OP_FAILED = 24 + XSERR_BASE
61 XSERR_BOOTPOLICY_INSTALL_ERROR = 25 + XSERR_BASE
62 XSERR_VM_NOT_AUTHORIZED = 26 + XSERR_BASE
63 XSERR_VM_IN_CONFLICT = 27 + XSERR_BASE
64 XSERR_POLICY_HAS_DUPLICATES = 28 + XSERR_BASE
65 XSERR_LAST = 28 + XSERR_BASE ## KEEP LAST
67 XSERR_MESSAGES = [
68 '',
69 'General Failure',
70 'XML is malformed',
71 'Error while processing XML',
72 'Policy has inconsistencies',
73 'A file access error occurred',
74 'The resource format is not valid',
75 'The label format is not valid',
76 'The resource is not labeld',
77 'The resource is already labeld',
78 'The policy type is wrong',
79 'The system boot policy is installed',
80 'Could not find the default boot title',
81 'Loading of the policy failed',
82 'The policy is loaded',
83 'The policy type is unsupported',
84 'There is a bad conflict set',
85 'The resource is in use',
86 'The policy has an invalid name',
87 'The version of the policy prevents an update',
88 'The label is bad',
89 'Operation not premittend - the VM is in the wrong state',
90 'The policy is not loaded',
91 'Error accessing resource',
92 'Operation failed in hypervisor',
93 'Boot policy installation error',
94 'VM is not authorized to run',
95 'VM label conflicts with another VM',
96 'Duplicate labels or types in policy'
97 ]
99 def xserr2string(err):
100 if err == XSERR_SUCCESS:
101 return "Success"
102 if err >= XSERR_GENERAL_FAILURE and \
103 err <= XSERR_LAST:
104 return XSERR_MESSAGES[err - XSERR_BASE]
105 return "Unknown XSERR code '%s'." % (hex(err))
107 # Policy identifiers used in labels
108 ACM_POLICY_ID = 'ACM'
110 INVALID_POLICY_PREFIX = 'INV_'
112 INVALID_SSIDREF = 0xFFFFFFFFL
114 XS_INACCESSIBLE_LABEL = '__INACCESSIBLE__'