diff options
author | Scott Moser <smoser@ubuntu.com> | 2015-07-28 16:15:10 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2015-07-28 16:15:10 -0400 |
commit | c33b3becebfa7bf3f6e2ee67ea7bc3def6feeb8c (patch) | |
tree | 19a41d3160b3536e212342154f3c10e0f35c62ec /cloudinit/registry.py | |
parent | 55472eb02eaa5b88676a96e006f6838020f8ffe3 (diff) | |
download | vyos-cloud-init-c33b3becebfa7bf3f6e2ee67ea7bc3def6feeb8c.tar.gz vyos-cloud-init-c33b3becebfa7bf3f6e2ee67ea7bc3def6feeb8c.zip |
pull from 2.0 trunk @ a433358bbcf4e8a771b80cae34468409ed5a811d
Diffstat (limited to 'cloudinit/registry.py')
-rw-r--r-- | cloudinit/registry.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/cloudinit/registry.py b/cloudinit/registry.py new file mode 100644 index 00000000..46cf0585 --- /dev/null +++ b/cloudinit/registry.py @@ -0,0 +1,23 @@ +import copy + + +class DictRegistry(object): + """A simple registry for a mapping of objects.""" + + def __init__(self): + self._items = {} + + def register_item(self, key, item): + """Add item to the registry.""" + if key in self._items: + raise ValueError( + 'Item already registered with key {0}'.format(key)) + self._items[key] = item + + @property + def registered_items(self): + """All the items that have been registered. + + This cannot be used to modify the contents of the registry. + """ + return copy.copy(self._items) |