Example #1
0
def sched_sort(sched_a, sched_b):
    if is_node(sched_a):
        sched_a = sched_a.as_node_url()
    if is_node(sched_b):
        sched_b = sched_b.as_node_url()
    sched_a_cnt = sched_a.count('/')
    sched_b_cnt = sched_b.count('/')
    if sched_a_cnt == sched_b_cnt:
        cmp(sched_a, sched_b)
    return cmp(sched_a_cnt, sched_b_cnt)
Example #2
0
def sched_sort(sched_a, sched_b):
    if is_node(sched_a):
        sched_a = sched_a.as_node_url()
    if is_node(sched_b):
        sched_b = sched_b.as_node_url()
    sched_a_cnt = sched_a.count('/')
    sched_b_cnt = sched_b.count('/')
    if sched_a_cnt == sched_b_cnt:
        cmp(sched_a, sched_b)
    return cmp(sched_a_cnt, sched_b_cnt)
Example #3
0
 def _get_reference(self):
     if not is_node(self._reference):
         try:
             self._reference = as_internal_node(self._reference)
         except:
             self._reference = None
     return self._reference
Example #4
0
 def _get_reference(self):
     if not is_node(self._reference):
         try:
             self._reference = as_internal_node(self._reference)
         except:
             self._reference = None
     return self._reference
Example #5
0
 def __init_alarm_container(self):
     if not is_node(self.ALARM_PATH):
         msglog.log('Device Manager', msglog.types.WARN,
                    "%s does not exist, Device Unavailable alarms may"
                    " not be configured for export." % self.ALARM_PATH)
         self.__node_from_components(self.ALARMS_PATH_COMPONENTS)
     self.__alarm_container = as_node(self.ALARM_PATH)
     if not is_node(self.EXPORTER_PATH):
         msglog.log('Device Manager', msglog.types.WARN,
                    "%s does not exist, Device Unavailable alarms will"
                    " not be exported." % self.EXPORTER_PATH)
     else:
         exporters = as_node(self.EXPORTER_PATH)
         if not exporters.children_names():
             msglog.log('Device Manager', msglog.types.WARN,
                        "%s does not have any exporters configured,"
                        " Device Unavailable alarms will"
                        " not be exported." %
                        self.EXPORTER_PATH)
     return
Example #6
0
 def _is_rename(self, source, destination):
     if is_node(source):
         return source is destination
     s_elements = source.split('/')
     d_elements = destination.split('/')
     if len(s_elements) == len(d_elements) and s_elements[:-1] == d_elements[:-1]:
         try:
             self._get_schedule_node(destination)
         except:
             return True
     return False
Example #7
0
 def _is_rename(self, source, destination):
     if is_node(source):
         return source is destination
     s_elements = source.split('/')
     d_elements = destination.split('/')
     if len(s_elements) == len(
             d_elements) and s_elements[:-1] == d_elements[:-1]:
         try:
             self._get_schedule_node(destination)
         except:
             return True
     return False
Example #8
0
 def _get_schedule_node(self, schedule):
     if is_node(schedule):
         return schedule
     if not type(schedule) in types.StringTypes:
         raise EInvalidValue('schedule', schedule, 'expected node reference')
     schedule = urllib.unquote(schedule)
     if (not urllib.unquote(self.as_node_url()) in schedule) and \
         schedule.startswith('/') and len(schedule) > 1:
         # nodepath is relative.
         schedule = schedule[1:]
     if schedule == '/':
         # still relative - for schedules the ScheduleManager is the root.
         schedule = self
     return self.as_node(schedule)
Example #9
0
 def _get_schedule_node(self, schedule):
     if is_node(schedule):
         return schedule
     if not type(schedule) in types.StringTypes:
         raise EInvalidValue('schedule', schedule,
                             'expected node reference')
     schedule = urllib.unquote(schedule)
     if (not urllib.unquote(self.as_node_url()) in schedule) and \
         schedule.startswith('/') and len(schedule) > 1:
         # nodepath is relative.
         schedule = schedule[1:]
     if schedule == '/':
         # still relative - for schedules the ScheduleManager is the root.
         schedule = self
     return self.as_node(schedule)
Example #10
0
 def _is_node(cls,n):
     from mpx.lib import node
     cls._is_node = staticmethod(node.is_node)
     return node.is_node(n)