ia64/xen-unstable

changeset 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 4eba2151d38b
children 638811f870ba
files tools/python/xen/util/acmpolicy.py tools/python/xen/util/xsconstants.py
line diff
     1.1 --- a/tools/python/xen/util/acmpolicy.py	Mon Jun 09 09:37:22 2008 +0100
     1.2 +++ b/tools/python/xen/util/acmpolicy.py	Mon Jun 09 09:37:56 2008 +0100
     1.3 @@ -1323,6 +1323,13 @@ class ACMPolicy(XSPolicy):
     1.4          if ACM_LABEL_UNLABELED in resnames:
     1.5              resnames.remove(ACM_LABEL_UNLABELED)
     1.6  
     1.7 +        # check for duplicate labels
     1.8 +        if len(vmlabels) != len(set(vmlabels)) or \
     1.9 +           len(resnames) != len(set(resnames)) or \
    1.10 +           len(stes)     != len(set(stes))     or \
    1.11 +           len(chws)     != len(set(chws)):
    1.12 +            return -xsconstants.XSERR_POLICY_HAS_DUPLICATES, "", ""
    1.13 +
    1.14          max_chw_ssids = 1 + len(vms_with_chws)
    1.15          max_chw_types = 1 + len(vms_with_chws)
    1.16          max_ste_ssids = 1 + len(vms_with_stes) + len(resnames)
     2.1 --- a/tools/python/xen/util/xsconstants.py	Mon Jun 09 09:37:22 2008 +0100
     2.2 +++ b/tools/python/xen/util/xsconstants.py	Mon Jun 09 09:37:56 2008 +0100
     2.3 @@ -59,7 +59,8 @@ XSERR_HV_OP_FAILED             = 24 + XS
     2.4  XSERR_BOOTPOLICY_INSTALL_ERROR = 25 + XSERR_BASE
     2.5  XSERR_VM_NOT_AUTHORIZED        = 26 + XSERR_BASE
     2.6  XSERR_VM_IN_CONFLICT           = 27 + XSERR_BASE
     2.7 -XSERR_LAST                     = 27 + XSERR_BASE ## KEEP LAST
     2.8 +XSERR_POLICY_HAS_DUPLICATES    = 28 + XSERR_BASE
     2.9 +XSERR_LAST                     = 28 + XSERR_BASE ## KEEP LAST
    2.10  
    2.11  XSERR_MESSAGES = [
    2.12      '',
    2.13 @@ -89,7 +90,8 @@ XSERR_MESSAGES = [
    2.14      'Operation failed in hypervisor',
    2.15      'Boot policy installation error',
    2.16      'VM is not authorized to run',
    2.17 -    'VM label conflicts with another VM'
    2.18 +    'VM label conflicts with another VM',
    2.19 +    'Duplicate labels or types in policy'
    2.20  ]
    2.21  
    2.22  def xserr2string(err):