예제 #1
0
 def _remove_device_data_by_uuid(self, _uuid):
     if _uuid == None:
         return
     _row = PCSocketDeviceData(uuid=_uuid)
     _row.delete_redis_keys(self.redis)
     _row.async_delete(self.redis)
     return
예제 #2
0
 def _remove_device_data_by_pattern(self, _pattern):
     _keys = self.redis.keys(_pattern)
     for _i in _keys:
         _row = PCSocketDeviceData(uuid=self.redis.get(_i))
         _row.delete_redis_keys(self.redis)
         _row.async_delete(self.redis)
     return
예제 #3
0
    def map_device(self, _device_uuid):
        if _device_uuid == None:
            return
        
        _table = PCSocketDeviceData.__tablename__
        
        _key_0 = _table + ".pc_socket_uuid." + self.register["uuid"] + \
               ".device_uuid." + _device_uuid
        _key_1 = _table + ".device_uuid." + _device_uuid
        
        # the same host
        if self.redis.exists(_key_0):
            return

        # not the same host
        _host = self.redis.get(_key_1)
        # still the same, but no key????
        if _host != None and _host == self.register["uuid"]:
            logging.error("should not be here, two keys not consistent")
            return

        # remove the previous
        if _host != None and _host != self.register["uuid"]:
            _key_2 = _table + ".pc_socket_uuid." + _host + ".device_uuid." + _device_uuid
            _data = self.redis.get(_key_2)
            self._remove_device_data_by_uuid(_data)

        # create it
        _row = PCSocketDeviceData(uuid=str(uuid.uuid1()),
                                  pc_socket_uuid=self.register["uuid"],
                                  device_uuid=_device_uuid)
        _row.create_redis_keys(self.redis)
        _row.async_add(self.redis)
        return
예제 #4
0
 def _remove_device_data_by_uuid(self, _uuid):
     if _uuid == None:
         return
     _row = PCSocketDeviceData(uuid=_uuid)
     _row.delete_redis_keys(self.redis)
     _row.async_delete()
     return
예제 #5
0
 def _remove_device_data_by_pattern(self, _pattern):
     _keys = self.redis.keys(_pattern)
     for _i in _keys:
         _row = PCSocketDeviceData(uuid=self.redis.get(_i))
         _row.delete_redis_keys(self.redis)
         _row.async_delete()
     return
예제 #6
0
    def map_device(self, _device_uuid):
        if _device_uuid == None:
            return

        _table = PCSocketDeviceData.__tablename__

        _key_0 = _table + ".pc_socket_uuid." + self.register["uuid"] + \
               ".device_uuid." + _device_uuid
        _key_1 = _table + ".device_uuid." + _device_uuid

        # the same host
        if self.redis.exists(_key_0):
            return

        # not the same host
        _host = self.redis.get(_key_1)
        # still the same, but no key????
        if _host != None and _host == self.register["uuid"]:
            logging.error("should not be here, two keys not consistent")
            return

        # remove the previous
        if _host != None and _host != self.register["uuid"]:
            _key_2 = _table + ".pc_socket_uuid." + _host + ".device_uuid." + _device_uuid
            _data = self.redis.get(_key_2)
            self._remove_device_data_by_uuid(_data)

        # create it
        _row = PCSocketDeviceData(uuid=str(uuid.uuid1()),
                                  pc_socket_uuid=self.register["uuid"],
                                  device_uuid=_device_uuid)
        _row.create_redis_keys(self.redis)
        _row.async_add()
        return