fabric-testbed / InformationModel

FABRIC Information Model library
MIT License
7 stars 1 forks source link

Adding attribute checks so pickled slivers from older versions can be… #115

Closed ibaldin closed 2 years ago

ibaldin commented 2 years ago

… safely restored

kthare10 commented 2 years ago

We also need changes in base_sliver::repr to see if the property exists for the instance.

    def __repr__(self):
        exclude_set = {"get_property", "get_stitch_node"}
        print_set = list()
        for k in dir(self):
            if k.startswith('get_') and k not in exclude_set:
                if hasattr(self, k[4:]):
                    print_set.append(k[4:])
        print_set.sort()
        print_vals = dict()
        for p in print_set:
            pval = self.get_property(p)
            if pval is not None and len(str(pval)) != 0:
                print_vals[p] = str(pval)
        return str(print_vals)
ibaldin commented 2 years ago

ooh yeah, you're right. Let me look at base sliver more closely - there could be other places. This unpickling an older version of an object is fraught with problems...