Loading cloudcontrol/common/client/tags.py +17 −10 Original line number Diff line number Diff line Loading @@ -245,6 +245,8 @@ class TagDB(object): __main__=dict(), # tags for main object # others objects ) #: associate type for each sub object self._object_types = dict() for tag in tags: self.add_tag(tag) Loading Loading @@ -272,7 +274,8 @@ class TagDB(object): for sub_id, db in self.db.iteritems(): if sub_id == '__main__': continue self._parent.add_sub_object(sub_id, db.itervalues()) self._parent.add_sub_object(sub_id, db.itervalues(), self._object_types[sub_id]) # tag handling part, used by plugins def add_tags(self, tags): Loading Loading @@ -314,16 +317,18 @@ class TagDB(object): if self._parent is not None: self._parent.remove_sub_tag(sub_id, tag_name) def add_sub_object(self, sub_id, tags): def add_sub_object(self, sub_id, tags, type_): self._object_types[sub_id] = type_ if self._parent is not None: # tags will be added after self._parent.add_sub_object(sub_id, tuple()) self._parent.add_sub_object(sub_id, tuple(), type_) # add sub object tags for t in tags: self.add_sub_tag(sub_id, t) def remove_sub_object(self, sub_id): self.db.pop(sub_id) del self.db[sub_id] del self._object_types[sub_id] if self._parent is not None: self._parent.remove_sub_object(sub_id) Loading Loading @@ -388,7 +393,7 @@ class RootTagDB(TagDB): for sub_id in self.db: if sub_id == '__main__': continue self.rpc_register_sub_object(sub_id) self.rpc_register_sub_object(sub_id, self._object_types[sub_id]) # register tags on the cc-server for tag in self.db['__main__'].itervalues(): Loading @@ -402,10 +407,10 @@ class RootTagDB(TagDB): if tag.value is not None: self.rpc_register_sub_tag(tag.sub_id, tag) def rpc_register_sub_object(self, sub_id): def rpc_register_sub_object(self, sub_id, type_): # register object on the cc-server self.rpc_call(sub_id, self.rpc_object_register_cb, 'register', sub_id, 'vm') # FIXME generalization self.rpc_call(sub_id, self.rpc_object_register_cb, 'register', sub_id, type_) def rpc_unregister_sub_object(self, sub_id): self.rpc_call( Loading Loading @@ -500,8 +505,9 @@ class RootTagDB(TagDB): if tag.value is not None: self.rpc_unregister_sub_tag(sub_id, tag_name) def add_sub_object(self, sub_id, tags): self.rpc_register_sub_object(sub_id) def add_sub_object(self, sub_id, tags, type_): self.rpc_register_sub_object(sub_id, type_) self._object_types[sub_id] = type_ # add sub object tags for t in tags: self.add_sub_tag(sub_id, t) Loading @@ -514,4 +520,5 @@ class RootTagDB(TagDB): # we don't need to unregister each sub tag on the cc-server because # it will be done when we unregister the object del self.db[sub_id] del self._object_types[sub_id] self.rpc_unregister_sub_object(sub_id) Loading
cloudcontrol/common/client/tags.py +17 −10 Original line number Diff line number Diff line Loading @@ -245,6 +245,8 @@ class TagDB(object): __main__=dict(), # tags for main object # others objects ) #: associate type for each sub object self._object_types = dict() for tag in tags: self.add_tag(tag) Loading Loading @@ -272,7 +274,8 @@ class TagDB(object): for sub_id, db in self.db.iteritems(): if sub_id == '__main__': continue self._parent.add_sub_object(sub_id, db.itervalues()) self._parent.add_sub_object(sub_id, db.itervalues(), self._object_types[sub_id]) # tag handling part, used by plugins def add_tags(self, tags): Loading Loading @@ -314,16 +317,18 @@ class TagDB(object): if self._parent is not None: self._parent.remove_sub_tag(sub_id, tag_name) def add_sub_object(self, sub_id, tags): def add_sub_object(self, sub_id, tags, type_): self._object_types[sub_id] = type_ if self._parent is not None: # tags will be added after self._parent.add_sub_object(sub_id, tuple()) self._parent.add_sub_object(sub_id, tuple(), type_) # add sub object tags for t in tags: self.add_sub_tag(sub_id, t) def remove_sub_object(self, sub_id): self.db.pop(sub_id) del self.db[sub_id] del self._object_types[sub_id] if self._parent is not None: self._parent.remove_sub_object(sub_id) Loading Loading @@ -388,7 +393,7 @@ class RootTagDB(TagDB): for sub_id in self.db: if sub_id == '__main__': continue self.rpc_register_sub_object(sub_id) self.rpc_register_sub_object(sub_id, self._object_types[sub_id]) # register tags on the cc-server for tag in self.db['__main__'].itervalues(): Loading @@ -402,10 +407,10 @@ class RootTagDB(TagDB): if tag.value is not None: self.rpc_register_sub_tag(tag.sub_id, tag) def rpc_register_sub_object(self, sub_id): def rpc_register_sub_object(self, sub_id, type_): # register object on the cc-server self.rpc_call(sub_id, self.rpc_object_register_cb, 'register', sub_id, 'vm') # FIXME generalization self.rpc_call(sub_id, self.rpc_object_register_cb, 'register', sub_id, type_) def rpc_unregister_sub_object(self, sub_id): self.rpc_call( Loading Loading @@ -500,8 +505,9 @@ class RootTagDB(TagDB): if tag.value is not None: self.rpc_unregister_sub_tag(sub_id, tag_name) def add_sub_object(self, sub_id, tags): self.rpc_register_sub_object(sub_id) def add_sub_object(self, sub_id, tags, type_): self.rpc_register_sub_object(sub_id, type_) self._object_types[sub_id] = type_ # add sub object tags for t in tags: self.add_sub_tag(sub_id, t) Loading @@ -514,4 +520,5 @@ class RootTagDB(TagDB): # we don't need to unregister each sub tag on the cc-server because # it will be done when we unregister the object del self.db[sub_id] del self._object_types[sub_id] self.rpc_unregister_sub_object(sub_id)