diff options
author | gordon chung <gord@live.ca> | 2014-09-03 16:21:46 -0400 |
---|---|---|
committer | gordon chung <gord@live.ca> | 2014-10-02 15:10:45 +0000 |
commit | 7316dd16b8850270db27c1298dcf5a2223f2f1e1 (patch) | |
tree | e3b4f5b6f333e4889e2f4364168825f154dd961f /ceilometerclient/openstack/common/uuidutils.py | |
parent | 5aa2a69f36c1738d9cc24470e81651732f180859 (diff) | |
download | python-ceilometerclient-7316dd16b8850270db27c1298dcf5a2223f2f1e1.tar.gz |
sync oslo codeicehouse-eol1.0.12stable/icehouse
- sync code up to Change-Id: Ie6064e73abe4b0729498a0343d50e1be35684b75
- includes fix to resolve alarm-evaluator failure
- does not include openstack/common/strutils sync as it requires
test update
Co-Authored-By: Vaibhav Kale <vaibhav_kale@persistent.co.in>
Closes-Bug: #1357343
Change-Id: Ieec08520cb39c5bf2e795dfeb3e36e52c6fd2a82
Diffstat (limited to 'ceilometerclient/openstack/common/uuidutils.py')
-rw-r--r-- | ceilometerclient/openstack/common/uuidutils.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ceilometerclient/openstack/common/uuidutils.py b/ceilometerclient/openstack/common/uuidutils.py new file mode 100644 index 0000000..234b880 --- /dev/null +++ b/ceilometerclient/openstack/common/uuidutils.py @@ -0,0 +1,37 @@ +# Copyright (c) 2012 Intel Corporation. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +""" +UUID related utilities and helper functions. +""" + +import uuid + + +def generate_uuid(): + return str(uuid.uuid4()) + + +def is_uuid_like(val): + """Returns validation of a value as a UUID. + + For our purposes, a UUID is a canonical form string: + aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa + + """ + try: + return str(uuid.UUID(val)) == val + except (TypeError, ValueError, AttributeError): + return False |