Beispiel #1
0
    def __init__(self, uuid, record):
        self.__uuid = uuid

        # First check this class implements all the correct methods:
        for attr_ro in self.getAttrRO() + self.getAttrRW():
            if not hasattr(self, "get_%s" % attr_ro):
                raise ImplementationError(self.getClass(), "get_%s" % attr_ro)

        for attr_rw in self.getAttrRW():
            if not hasattr(self, "set_%s" % attr_rw):
                raise ImplementationError(self.getClass(), "set_%s" % attr_rw)

        for method in self.getMethods():
            if not hasattr(self, method):
                raise ImplementationError(self.getClass(), method)

        for func in self.getFuncs():
            if not hasattr(self.__class__, func):
                raise ImplementationError(self.getClass(), func)

        # Next check that the class is being created with the correct
        # parameters
        if not isinstance(record, dict):
            raise CreateUnspecifiedAttributeError("record", self.getClass())

        for attr_inst in self.getAttrInst():
            if attr_inst not in record:
                raise CreateUnspecifiedAttributeError(attr_inst,
                                                      self.getClass())
            setattr(self, attr_inst, record[attr_inst])

        # Finally register it
        XendAPIStore.register(uuid, self.getClass(), self)
Beispiel #2
0
    def __init__(self, uuid, record):
        self.__uuid = uuid
        
        # First check this class implements all the correct methods:
        for attr_ro in self.getAttrRO() + self.getAttrRW():
            if not hasattr(self, "get_%s" % attr_ro):
                raise ImplementationError(self.getClass(),
                                          "get_%s" % attr_ro)

        for attr_rw in self.getAttrRW():
            if not hasattr(self, "set_%s" % attr_rw):
                raise ImplementationError(self.getClass(),
                                          "set_%s" % attr_rw)

        for method in self.getMethods():
            if not hasattr(self, method):
                raise ImplementationError(self.getClass(),
                                          method)

        for func in self.getFuncs():
            if not hasattr(self.__class__, func):
                raise ImplementationError(self.getClass(),
                                          func)

        # Next check that the class is being created with the correct
        # parameters
        if not isinstance(record, dict):
            raise CreateUnspecifiedAttributeError(
                    "record" , self.getClass())
        
        for attr_inst in self.getAttrInst():
            if attr_inst not in record:
                raise CreateUnspecifiedAttributeError(
                    attr_inst, self.getClass())
            setattr(self, attr_inst, record[attr_inst])

        # Finally register it
        XendAPIStore.register(uuid, self.getClass(), self)