direct-io.hg

changeset 12791:84580e109557

[XEND] Only return valid VIF and VBD parameters via Xen API.

Also fix typo for memory_dynamic_{min,max}.

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Thu Dec 07 16:43:22 2006 +0000 (2006-12-07)
parents ec9259920f85
children cf11417d7eb6
files tools/python/xen/xend/XendAPI.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendAPI.py	Thu Dec 07 16:09:04 2006 +0000
     1.2 +++ b/tools/python/xen/xend/XendAPI.py	Thu Dec 07 16:43:22 2006 +0000
     1.3 @@ -1057,7 +1057,16 @@ class XendAPI:
     1.4          cfg = vm.get_dev_xenapi_config('vbd', vbd_ref)
     1.5          if not cfg:
     1.6              return xen_api_error(XEND_ERROR_VBD_INVALID)
     1.7 -        return xen_api_success(cfg)
     1.8 +
     1.9 +        valid_vbd_keys = self.VBD_attr_ro + self.VBD_attr_rw + \
    1.10 +                         self.Base_attr_ro + self.Base_attr_rw
    1.11 +
    1.12 +        return_cfg = {}
    1.13 +        for k in cfg.keys():
    1.14 +            if k in valid_vbd_keys:
    1.15 +                return_cfg[k] = cfg[k]
    1.16 +                
    1.17 +        return xen_api_success(return_cfg)
    1.18  
    1.19      def VBD_media_change(self, session, vbd_ref, vdi_ref):
    1.20          return xen_api_error(XEND_ERROR_UNSUPPORTED)
    1.21 @@ -1134,14 +1143,16 @@ class XendAPI:
    1.22          cfg = vm.get_dev_xenapi_config('vif', vif_ref)
    1.23          if not cfg:
    1.24              return xen_api_error(XEND_ERROR_VIF_INVALID)
    1.25 +        
    1.26          valid_vif_keys = self.VIF_attr_ro + self.VIF_attr_rw + \
    1.27                           self.Base_attr_ro + self.Base_attr_rw
    1.28  
    1.29 +        return_cfg = {}
    1.30          for k in cfg.keys():
    1.31 -            if k not in valid_vif_keys:
    1.32 -                del cfg[k]
    1.33 +            if k in valid_vif_keys:
    1.34 +                return_cfg[k] = cfg[k]
    1.35              
    1.36 -        return xen_api_success(cfg)
    1.37 +        return xen_api_success(return_cfg)
    1.38  
    1.39      # class methods
    1.40      def VIF_create(self, session, vif_struct):
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Dec 07 16:09:04 2006 +0000
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Dec 07 16:43:22 2006 +0000
     2.3 @@ -1784,9 +1784,9 @@ class XendDomainInfo:
     2.4      def get_memory_static_min(self):
     2.5          return self.info.get('memory_static_min', 0)
     2.6      def get_memory_dynamic_max(self):
     2.7 -        return self.info.get('memory_dynamic_min', 0)
     2.8 +        return self.info.get('memory_dynamic_max', 0)
     2.9      def get_memory_dynamic_min(self):
    2.10 -        return self.info.get('memory_dynamic_max', 0)
    2.11 +        return self.info.get('memory_dynamic_min', 0)
    2.12      
    2.13      
    2.14      def get_vcpus_policy(self):