summaryrefslogtreecommitdiff
path: root/pycadf
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-10-18 19:47:23 +0000
committerGerrit Code Review <review@openstack.org>2013-10-18 19:47:23 +0000
commitb24d35599c5d4e460c12768eb76f4d97dde0e470 (patch)
treedda2e97a50bc34f5b70595faf640d012ea8b1db5 /pycadf
parent49eaaf1fb2f0c138aeab8687694efefdda113eef (diff)
parentea0b9c4753c160ffd2a7f912489493f8088af242 (diff)
downloadpycadf-b24d35599c5d4e460c12768eb76f4d97dde0e470.tar.gz
Merge "support namespace prefix in id"0.2.1
Diffstat (limited to 'pycadf')
-rw-r--r--pycadf/identifier.py20
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