diff options
author | Gordon Chung <chungg@ca.ibm.com> | 2013-10-17 15:17:31 -0400 |
---|---|---|
committer | Gordon Chung <chungg@ca.ibm.com> | 2013-10-17 15:17:31 -0400 |
commit | ea0b9c4753c160ffd2a7f912489493f8088af242 (patch) | |
tree | 622bdff24811ca38da68e065ccf74305e93a133c /pycadf/identifier.py | |
parent | d280b091320ab27a7de1325f1dc895016bb1c7a1 (diff) | |
download | pycadf-ea0b9c4753c160ffd2a7f912489493f8088af242.tar.gz |
support namespace prefix in id
prefix generated ids with namespace option
Change-Id: I50776202dd5be1b9ab2cfc5e177eeb9a77d6a8f9
Diffstat (limited to 'pycadf/identifier.py')
-rw-r--r-- | pycadf/identifier.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/pycadf/identifier.py b/pycadf/identifier.py index 69354a2..22d125b 100644 --- a/pycadf/identifier.py +++ b/pycadf/identifier.py @@ -15,23 +15,25 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - import uuid -from pycadf import cadftype -from pycadf import timestamp +from oslo.config import cfg + +CONF = cfg.CONF +opts = [ + cfg.StrOpt('namespace', + default='openstack', + help='namespace prefix for generated id'), +] +CONF.register_opts(opts, group='audit') -# TODO(mrutkows): Add openstack namespace prefix (e.g. 'openstack:') to all -# cadf:Identifiers # TODO(mrutkows): make the namespace prefix configurable and have it resolve to # a full openstack namespace/domain value via some declaration (e.g. # "openstack:" == "http:\\www.openstack.org\")... def generate_uuid(): - uuid_temp = uuid.uuid5(uuid.NAMESPACE_DNS, - cadftype.CADF_VERSION_1_0_0 - + timestamp.get_utc_now()) - return str(uuid_temp) + prefix = CONF.audit.namespace + ':' if CONF.audit.namespace else '' + return prefix + str(uuid.uuid4()) # TODO(mrutkows): validate any cadf:Identifier (type) record against |