Beispiel #1
0
    def add_config(self, uuid, config_data):
        device = self.get_device_by_uuid(uuid)
        if device is None:
            return False
        properties = props(Configuration)
        for arg, val in config_data.items():
            if val and val in properties:
                try:
                    setattr(device.config, arg, val)
                    self.session.commit()
                except Exception as e:
                    pass
                except IntegrityError:
                    self.session.rollback()

        return True
Beispiel #2
0
    def add_location(self, uuid, location_data=None):
        device = self.get_device_by_uuid(uuid)
        if device is None:
            return False
        location_data = location_data or {}
        location = device.location

        properties = props(Location)

        for arg, val in location_data.items():
            if val and val in properties:
                try:
                    setattr(location, arg, val)
                    self.session.commit()
                except Exception as e:
                    print(e)
                except IntegrityError:
                    self.session.rollback()

        return True