Esempio n. 1
0
 def _get_kv(self, key=None, session=None):
     session = session or sqla_api.get_session()
     query = session.query(KeyValue)
     if key is not None:
         query = query.filter_by(key=key)
     res = query.all()
     # If we want to use the result as an ORM
     if session:
         return res
     return [objects.KeyValue(r.key, r.value) for r in res]
Esempio n. 2
0
 def get(cls, key):
     """Gets a KeyValue CRO and returns a cinderlib KeyValue."""
     try:
         res = K8S.crd_api.get_namespaced_custom_object(
             cls.DOMAIN, cls.CRD_VERSION, cls.NAMESPACE, cls.plural, key)
         kv = objects.KeyValue(key, res['metadata']['annotations']['value'])
         cls._set_resource_version(kv, res)
         return ([kv])
     except k8s.client.rest.ApiException as exc:
         if exc.status == 404:
             return []
         raise