[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [XEND] Only return valid VIF and VBD parameters via Xen API.



# HG changeset patch
# User Alastair Tse <atse@xxxxxxxxxxxxx>
# Node ID 84580e109557eee9a25c4b3a75cbcd828074b46a
# Parent  ec9259920f85181265b6a13f243de592ff3b161e
[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@xxxxxxxxxxxxx>
---
 tools/python/xen/xend/XendAPI.py        |   19 +++++++++++++++----
 tools/python/xen/xend/XendDomainInfo.py |    4 ++--
 2 files changed, 17 insertions(+), 6 deletions(-)

diff -r ec9259920f85 -r 84580e109557 tools/python/xen/xend/XendAPI.py
--- a/tools/python/xen/xend/XendAPI.py  Thu Dec 07 16:09:04 2006 +0000
+++ b/tools/python/xen/xend/XendAPI.py  Thu Dec 07 16:43:22 2006 +0000
@@ -1057,7 +1057,16 @@ class XendAPI:
         cfg = vm.get_dev_xenapi_config('vbd', vbd_ref)
         if not cfg:
             return xen_api_error(XEND_ERROR_VBD_INVALID)
-        return xen_api_success(cfg)
+
+        valid_vbd_keys = self.VBD_attr_ro + self.VBD_attr_rw + \
+                         self.Base_attr_ro + self.Base_attr_rw
+
+        return_cfg = {}
+        for k in cfg.keys():
+            if k in valid_vbd_keys:
+                return_cfg[k] = cfg[k]
+                
+        return xen_api_success(return_cfg)
 
     def VBD_media_change(self, session, vbd_ref, vdi_ref):
         return xen_api_error(XEND_ERROR_UNSUPPORTED)
@@ -1134,14 +1143,16 @@ class XendAPI:
         cfg = vm.get_dev_xenapi_config('vif', vif_ref)
         if not cfg:
             return xen_api_error(XEND_ERROR_VIF_INVALID)
+        
         valid_vif_keys = self.VIF_attr_ro + self.VIF_attr_rw + \
                          self.Base_attr_ro + self.Base_attr_rw
 
+        return_cfg = {}
         for k in cfg.keys():
-            if k not in valid_vif_keys:
-                del cfg[k]
+            if k in valid_vif_keys:
+                return_cfg[k] = cfg[k]
             
-        return xen_api_success(cfg)
+        return xen_api_success(return_cfg)
 
     # class methods
     def VIF_create(self, session, vif_struct):
diff -r ec9259920f85 -r 84580e109557 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Thu Dec 07 16:09:04 2006 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py   Thu Dec 07 16:43:22 2006 +0000
@@ -1784,9 +1784,9 @@ class XendDomainInfo:
     def get_memory_static_min(self):
         return self.info.get('memory_static_min', 0)
     def get_memory_dynamic_max(self):
+        return self.info.get('memory_dynamic_max', 0)
+    def get_memory_dynamic_min(self):
         return self.info.get('memory_dynamic_min', 0)
-    def get_memory_dynamic_min(self):
-        return self.info.get('memory_dynamic_max', 0)
     
     
     def get_vcpus_policy(self):

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.