Commits

Anonymous committed c9deca1

skipping 'current' interval validation

git-svn-id: https://pysphere.googlecode.com/svn/trunk@7493908643-0a7e-a946-f69b-c8c46af5c9d1

Comments (0)

Files changed (2)

pysphere/vi_performance_manager.py

                                 interval_id=sampling_period)
 
         statistics = []
-        if not query:
+        if not query or not hasattr(query[0], "Value"):
             return statistics
+        
         for stat in query[0].Value:
             cname, cdesc, gname, gdesc, uname, udesc = self._get_counter_info(
                                                   stat.Id.CounterId,counter_obj)
         """Given an interval ID (or None for refresh rate) verifies if
         the entity or the system supports that interval. Returns the sampling
         period if so, or raises an Exception if not supported"""
-        
         summary = self.query_perf_provider_summary(entity)
         if not interval: #must support current (real time) statistics
             if not summary.CurrentSupported:
+                
+                #Here the following exception should be raised, however,
+                #some objects as datastores can retrieve metrics even though
+                #current metrics are not supported, and refreshRate isn't set.
+                #So if thi is the case, I'll just return None.
+                #For more details see:
+                #http://communities.vmware.com/message/1623870#1623870
+                return None
                 raise UnsupportedPerfIntervalError(
                                   "Current statistics not supported for this "
                                   "entity. Try using an historical interval " 
             if begin_time:
                 request.set_element_beginTime(begin_time)
             if end_time:
-                request.set_element_endTime(end_time)
+                request.set_element_endTime(end_time)              
             if interval_id:
                 request.set_element_intervalId(interval_id)
 

pysphere/vi_task_history_collector.py

+#--
+# Copyright (c) 2012, Sebastian Tello
+# All rights reserved.
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+#   * Redistributions of source code must retain the above copyright notice,
+#     this list of conditions and the following disclaimer.
+#   * Redistributions in binary form must reproduce the above copyright notice,
+#     this list of conditions and the following disclaimer in the documentation
+#     and/or other materials provided with the distribution.
+#   * Neither the name of copyright holders nor the names of its contributors
+#     may be used to endorse or promote products derived from this software
+#     without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#--
+
 from pysphere import VIProperty, VITask, VIMor
 from pysphere.resources import VimService_services as VI
 from pysphere import VIException, VIApiException, FaultTypes