Пример #1
0
 def tags(self):
     # TODO(andy) Move metadata to a new DBO subclass "DBO with metadata"
     meta = db.get_metadata('instance', self.uuid)
     if not meta:
         # Gracefully handle malformed instances
         return None
     return meta.get(self.METADATA_KEY_TAGS, None)
Пример #2
0
    def delete(self, namespace, key=None, value=None):
        if not key:
            return error(400, 'no key specified')

        with db.get_lock('metadata', 'namespace', namespace):
            md = db.get_metadata('namespace', namespace)
            if md is None or key not in md:
                return error(404, 'key not found')
            del md[key]
            db.persist_metadata('namespace', namespace, md)
Пример #3
0
    def delete(self, network_uuid=None, key=None, network_from_db=None):
        if not key:
            return error(400, 'no key specified')

        with db.get_lock('metadata', 'network', network_uuid):
            md = db.get_metadata('network', network_uuid)
            if md is None or key not in md:
                return error(404, 'key not found')
            del md[key]
            db.persist_metadata('network', network_uuid, md)
Пример #4
0
    def delete(self, instance_uuid=None, key=None, instance_from_db=None):
        if not key:
            return error(400, 'no key specified')

        with db.get_lock('sf/metadata/instance/%s' % instance_uuid) as _:
            md = db.get_metadata('instance', instance_uuid)
            if md is None or key not in md:
                return error(404, 'key not found')
            del md[key]
            db.persist_metadata('instance', instance_uuid, md)
Пример #5
0
def _metadata_putpost(meta_type, owner, key, value):
    if meta_type not in ['namespace', 'instance', 'network']:
        return error(500, 'invalid meta_type %s' % meta_type)
    if not key:
        return error(400, 'no key specified')
    if not value:
        return error(400, 'no value specified')

    with db.get_lock('metadata', meta_type, owner):
        md = db.get_metadata(meta_type, owner)
        if md is None:
            md = {}
        md[key] = value
        db.persist_metadata(meta_type, owner, md)
Пример #6
0
 def get(self, namespace=None):
     md = db.get_metadata('namespace', namespace)
     if not md:
         return {}
     return md
Пример #7
0
 def affinity(self):
     # TODO(andy) Move metadata to a new DBO subclass "DBO with metadata"
     meta = db.get_metadata('instance', self.uuid)
     return meta.get(self.METADATA_KEY_AFFINITY, {})
Пример #8
0
 def get(self, network_uuid=None, network_from_db=None):
     md = db.get_metadata('network', network_uuid)
     if not md:
         return {}
     return md
Пример #9
0
 def get(self, instance_uuid=None, instance_from_db=None):
     md = db.get_metadata('instance', instance_uuid)
     if not md:
         return {}
     return md