コード例 #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
ファイル: app.py プロジェクト: jackadamson/shakenfist
    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
ファイル: app.py プロジェクト: jackadamson/shakenfist
    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
ファイル: app.py プロジェクト: jackadamson/shakenfist
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
ファイル: auth.py プロジェクト: mandoonandy/shakenfist
 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
ファイル: app.py プロジェクト: jackadamson/shakenfist
 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
ファイル: app.py プロジェクト: jackadamson/shakenfist
 def get(self, instance_uuid=None, instance_from_db=None):
     md = db.get_metadata('instance', instance_uuid)
     if not md:
         return {}
     return md