Revision 5ba2cfd2 snf-cyclades-app/synnefo/db/models.py

b/snf-cyclades-app/synnefo/db/models.py
65 65
    @property
66 66
    def name(self):
67 67
        """Returns flavor name (generated)"""
68
        return u'C%dR%dD%d%s' % (self.cpu, self.ram, self.disk,
68
        return u'C%sR%sD%s%s' % (self.cpu, self.ram, self.disk,
69 69
                                 self.disk_template)
70 70

  
71
    def __str__(self):
72
        return self.__unicode__()
73

  
71 74
    def __unicode__(self):
72
        return u"<%s:%s>" % (str(self.id), self.name)
75
        return u"<%s:%s>" % (self.id, self.name)
73 76

  
74 77

  
75 78
class Backend(models.Model):
......
113 116
        verbose_name = u'Backend'
114 117
        ordering = ["clustername"]
115 118

  
119
    def __str__(self):
120
        return self.__unicode__()
121

  
116 122
    def __unicode__(self):
117 123
        return u"%s(id:%s)" % (self.clustername, self.id)
118 124

  
......
213 219
        verbose_name = u'Quota Serial'
214 220
        ordering = ["serial"]
215 221

  
222
    def __str__(self):
223
        return self.__unicode__()
224

  
216 225
    def __unicode__(self):
217 226
        return u"<serial: %s>" % self.serial
218 227

  
......
380 389
        verbose_name = u'Virtual machine instance'
381 390
        get_latest_by = 'created'
382 391

  
392
    def __str__(self):
393
        return self.__unicode__()
394

  
383 395
    def __unicode__(self):
384 396
        return u"<vm:%s@backend:%s>" % (self.id, self.backend_id)
385 397

  
......
418 430
        unique_together = (('meta_key', 'vm'),)
419 431
        verbose_name = u'Key-value pair of metadata for a VM.'
420 432

  
433
    def __str__(self):
434
        return self.__unicode__()
435

  
421 436
    def __unicode__(self):
422
        return u'%s: %s' % (self.meta_key, self.meta_value)
437
        return u'<Metadata %s: %s>' % (self.meta_key, self.meta_value)
423 438

  
424 439

  
425 440
class Network(models.Model):
......
507 522
    serial = models.ForeignKey(QuotaHolderSerial, related_name='network',
508 523
                               null=True, on_delete=models.SET_NULL)
509 524

  
525
    def __str__(self):
526
        return self.__unicode__()
527

  
510 528
    def __unicode__(self):
511
        return u"<Network: %s>" % str(self.id)
529
        return u"<Network: %s>" % self.id
512 530

  
513 531
    @property
514 532
    def backend_id(self):
......
633 651
    created = models.DateTimeField(auto_now_add=True)
634 652
    updated = models.DateTimeField(auto_now=True)
635 653

  
654
    def __str__(self):
655
        return self.__unicode__()
656

  
636 657
    def __unicode__(self):
637 658
        msg = u"<Subnet %s, Network: %s, CIDR: %s>"
638 659
        return msg % (self.id, self.network_id, self.cidr)
......
716 737
                                              mac_prefix)
717 738
            self.mac_prefix = mac_prefix
718 739

  
740
    def __str__(self):
741
        return self.__unicode__()
742

  
719 743
    def __unicode__(self):
720
        return u'<%s@%s>' % (self.network, self.backend)
744
        return u'<BackendNetwork %s@%s>' % (self.network, self.backend)
721 745

  
722 746

  
723 747
class IPAddress(models.Model):
......
741 765
                               related_name="ips", null=True,
742 766
                               on_delete=models.SET_NULL)
743 767

  
768
    def __str__(self):
769
        return self.__unicode__()
770

  
744 771
    def __unicode__(self):
745 772
        ip_type = "floating" if self.floating_ip else "static"
746 773
        return u"<IPAddress: %s, Network: %s, Subnet: %s, Type: %s>"\
......
785 812
    active = models.BooleanField("Whether IP still allocated to server",
786 813
                                 default=True)
787 814

  
815
    def __str__(self):
816
        return self.__unicode__()
817

  
788 818
    def __unicode__(self):
789 819
        return u"<Address: %s, Server: %s, Network: %s, Allocated at: %s>"\
790 820
               % (self.address, self.network_id, self.server_id,
......
826 856
                             choices=STATES)
827 857
    device_owner = models.CharField('Device owner', max_length=128, null=True)
828 858

  
859
    def __str__(self):
860
        return self.__unicode__()
861

  
829 862
    def __unicode__(self):
830 863
        return u"<%s:vm:%s network:%s>" % (self.id, self.machine_id,
831 864
                                           self.network_id)
......
892 925
class BridgePoolTable(PoolTable):
893 926
    manager = pools.BridgePool
894 927

  
928
    def __str__(self):
929
        return self.__unicode__()
930

  
895 931
    def __unicode__(self):
896 932
        return u"<BridgePool id:%s>" % self.id
897 933

  
......
899 935
class MacPrefixPoolTable(PoolTable):
900 936
    manager = pools.MacPrefixPool
901 937

  
938
    def __str__(self):
939
        return self.__unicode__()
940

  
902 941
    def __unicode__(self):
903 942
        return u"<MACPrefixPool id:%s>" % self.id
904 943

  
......
910 949
                               on_delete=models.PROTECT,
911 950
                               db_index=True, null=True)
912 951

  
952
    def __str__(self):
953
        return self.__unicode__()
954

  
913 955
    def __unicode__(self):
914 956
        return u"<IPv4AdressPool, Subnet: %s>" % self.subnet_id
915 957

  

Also available in: Unified diff