예제 #1
0
 def __add_display_order(self, disp, order):
     """Add a display order
     """
     for vol_attr in order.split(','):
         if vol_attr.startswith('~'):
             reverse = True
             vol_attr = vol_attr[1:]
         else:
             reverse = False
         if vol_attr == 'size':
             order_pred = lambda vol: vol.size
         elif vol_attr == 'time':
             order_pred = lambda vol: amazon2unixtime(vol.create_time)
         elif vol_attr == 'status':
             order_pred = lambda vol: vol.status
         else:
             raise CommandError("Unknown volume attribute: %s" % vol_attr)
         disp.add_display_order(order_pred, reverse)
예제 #2
0
 def __add_display_order(self, disp, order):
     """Add a display order
     """
     for snap_attr in order.split(','):
         if snap_attr.startswith('~'):
             reverse = True
             snap_attr = snap_attr[1:]
         else:
             reverse = False
         if snap_attr == 'size':
             order_pred = lambda snapshot: snapshot.volume_size
         elif snap_attr == 'time':
             order_pred = lambda snapshot: amazon2unixtime(
                                                     snapshot.start_time)
         elif snap_attr == 'status':
             order_pred = lambda snapshot: snapshot.status
         else:
             raise CommandError(
                     "Unknown snapshot attribute: %s" % snap_attr)
         disp.add_display_order(order_pred, reverse)