Exemplo n.º 1
0
def get_kvp_for_name(name):
    try:
        kvp_db = KeyValuePair.get_by_name(name)
    except ValueError:
        kvp_db = None

    return kvp_db
Exemplo n.º 2
0
def get_kvp_for_name(name):
    try:
        kvp_db = KeyValuePair.get_by_name(name)
    except ValueError:
        kvp_db = None

    return kvp_db
Exemplo n.º 3
0
    def get_required_sensor_refs(self):
        partition_lookup_key = self._get_partition_lookup_key(self.sensor_node_name)

        kvp = KeyValuePair.get_by_name(partition_lookup_key)
        sensor_refs_str = kvp.value if kvp.value else ''
        self._supported_sensor_refs = set([
            sensor_ref.strip() for sensor_ref in sensor_refs_str.split(',')])
        return self._supported_sensor_refs
Exemplo n.º 4
0
 def __get_by_name(name):
     try:
         return KeyValuePair.get_by_name(name)
     except ValueError as e:
         LOG.debug(
             'Database lookup for name="%s" resulted in exception : %s.',
             name, e)
         return None
Exemplo n.º 5
0
    def get_required_sensor_refs(self):
        partition_lookup_key = self._get_partition_lookup_key(
            self.sensor_node_name)

        kvp = KeyValuePair.get_by_name(partition_lookup_key)
        sensor_refs_str = kvp.value if kvp.value else ''
        self._supported_sensor_refs = set(
            [sensor_ref.strip() for sensor_ref in sensor_refs_str.split(',')])
        return self._supported_sensor_refs
Exemplo n.º 6
0
    def test_kvp_crud(self):
        saved = KeyValuePairModelTest._create_save_kvp()
        retrieved = KeyValuePair.get_by_name(saved.name)
        self.assertEqual(saved.id, retrieved.id, "Same KeyValuePair was not returned.")

        # test update
        self.assertEqual(retrieved.value, "0123456789ABCDEF")
        retrieved.value = "ABCDEF0123456789"
        saved = KeyValuePair.add_or_update(retrieved)
        retrieved = KeyValuePair.get_by_name(saved.name)
        self.assertEqual(retrieved.value, "ABCDEF0123456789", "Update of key value failed")

        # cleanup
        KeyValuePairModelTest._delete([retrieved])
        try:
            retrieved = KeyValuePair.get_by_name(saved.name)
        except StackStormDBObjectNotFoundError:
            retrieved = None
        self.assertIsNone(retrieved, "managed to retrieve after failure.")
Exemplo n.º 7
0
 def _get_kv(self, key):
     kvp = None
     try:
         kvp = KeyValuePair.get_by_name(key)
     except ValueError:
         # ValueErrors are expected in case of partial lookups
         pass
     # A good default value for un-matched value is empty string since that will be used
     # for rendering templates.
     return kvp.value if kvp else ''
 def _get_kv(self, key):
     kvp = None
     try:
         kvp = KeyValuePair.get_by_name(key)
     except ValueError:
         # ValueErrors are expected in case of partial lookups
         pass
     # A good default value for un-matched value is empty string since that will be used
     # for rendering templates.
     return kvp.value if kvp else ''
Exemplo n.º 9
0
    def test_kvp_crud(self):
        saved = KeyValuePairModelTest._create_save_kvp()
        retrieved = KeyValuePair.get_by_name(saved.name)
        self.assertEqual(saved.id, retrieved.id,
                         'Same KeyValuePair was not returned.')

        # test update
        self.assertEqual(retrieved.value, '0123456789ABCDEF')
        retrieved.value = 'ABCDEF0123456789'
        saved = KeyValuePair.add_or_update(retrieved)
        retrieved = KeyValuePair.get_by_name(saved.name)
        self.assertEqual(retrieved.value, 'ABCDEF0123456789',
                         'Update of key value failed')

        # cleanup
        KeyValuePairModelTest._delete([retrieved])
        try:
            retrieved = KeyValuePair.get_by_name(saved.name)
        except StackStormDBObjectNotFoundError:
            retrieved = None
        self.assertIsNone(retrieved, 'managed to retrieve after failure.')
Exemplo n.º 10
0
    def test_kvp_crud(self):
        saved = KeyValuePairModelTest._create_save_kvp()
        retrieved = KeyValuePair.get_by_name(saved.name)
        self.assertEqual(saved.id, retrieved.id,
                         'Same KeyValuePair was not returned.')

        # test update
        self.assertEqual(retrieved.value, '0123456789ABCDEF')
        retrieved.value = 'ABCDEF0123456789'
        saved = KeyValuePair.add_or_update(retrieved)
        retrieved = KeyValuePair.get_by_name(saved.name)
        self.assertEqual(retrieved.value, 'ABCDEF0123456789',
                         'Update of key value failed')

        # cleanup
        KeyValuePairModelTest._delete([retrieved])
        try:
            retrieved = KeyValuePair.get_by_name(saved.name)
        except ValueError:
            retrieved = None
        self.assertIsNone(retrieved, 'managed to retrieve after failure.')
Exemplo n.º 11
0
 def __get_by_name(name):
     try:
         return KeyValuePair.get_by_name(name)
     except ValueError as e:
         LOG.debug('Database lookup for name="%s" resulted in exception : %s.', name, e)
         return None