aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/moon_utilities/moon_utilities/misc.py
diff options
context:
space:
mode:
authorWuKong <rebirthmonkey@gmail.com>2017-04-22 13:25:07 +0200
committerWuKong <rebirthmonkey@gmail.com>2017-04-22 13:25:07 +0200
commitd182202fc6001983541504ed323d68479086317e (patch)
tree11d4c10cdd3e995f519c3e0e324968fdaf175114 /moonv4/moon_utilities/moon_utilities/misc.py
parent83c1c966baf73329fab8ddcfad19ad7fe0c41c2a (diff)
add moonv4
Change-Id: I247af788d0b0fb961fbc85416486b241eb1d807c Signed-off-by: WuKong <rebirthmonkey@gmail.com>
Diffstat (limited to 'moonv4/moon_utilities/moon_utilities/misc.py')
-rw-r--r--moonv4/moon_utilities/moon_utilities/misc.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/moonv4/moon_utilities/moon_utilities/misc.py b/moonv4/moon_utilities/moon_utilities/misc.py
new file mode 100644
index 00000000..d13b4511
--- /dev/null
+++ b/moonv4/moon_utilities/moon_utilities/misc.py
@@ -0,0 +1,47 @@
+# Copyright 2015 Open Platform for NFV Project, Inc. and its contributors
+# This software is distributed under the terms and conditions of the 'Apache-2.0'
+# license which can be found in the file 'LICENSE' in this package distribution
+# or at 'http://www.apache.org/licenses/LICENSE-2.0'.
+
+
+import os
+import re
+import types
+import requests
+from oslo_log import log as logging
+from oslo_config import cfg
+import oslo_messaging
+from moon_utilities import exceptions
+from oslo_config.cfg import ConfigOpts
+
+LOG = logging.getLogger(__name__)
+CONF = cfg.CONF
+
+
+def get_uuid_from_name(name, elements, **kwargs):
+ LOG.error("get_uuid_from_name {} {} {}".format(name, elements, kwargs))
+ for element in elements:
+ if type(elements[element]) is dict and elements[element].get('name') == name:
+ if kwargs:
+ for args in kwargs:
+ if elements[element].get(args) != kwargs[args]:
+ LOG.error("get_uuid_from_name2 {} {} {}".format(args, elements[element].get(args), kwargs[args]))
+ return
+ else:
+ return element
+ else:
+ return element
+
+
+def get_name_from_uuid(uuid, elements, **kwargs):
+ for element in elements:
+ if element == uuid:
+ if kwargs:
+ for args in kwargs:
+ if elements[element].get(args) != kwargs[args]:
+ return
+ else:
+ return elements[element].get('name')
+ else:
+ return elements[element].get('name')
+