ia64/xen-unstable

view tools/python/xen/util/xsconstants.py @ 17796:1de5d17497fd

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