aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4/moon_utilities/moon_utilities/misc.py
blob: 4eadd47638a7520393d408bce85753d3f593e849 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# 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 logging
import random

LOG = logging.getLogger(__name__)


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')


def get_random_name():
    _list = (
        "windy",
        "vengeful",
        "precious",
        "vivacious",
        "quiet",
        "confused",
        "exultant",
        "impossible",
        "thick",
        "obsolete",
        "piquant",
        "fanatical",
        "tame",
        "perfect",
        "animated",
        "dark",
        "stimulating",
        "drunk",
        "depressed",
        "fumbling",
        "like",
        "undesirable",
        "spurious",
        "subsequent",
        "spiteful",
        "last",
        "stale",
        "hulking",
        "giddy",
        "minor",
        "careful",
        "possessive",
        "gullible",
        "fragile",
        "divergent",
        "ill-informed",
        "false",
        "jumpy",
        "damaged",
        "likeable",
        "volatile",
        "handsomely",
        "wet",
        "long-term",
        "pretty",
        "taboo",
        "normal",
        "magnificent",
        "nutty",
        "puzzling",
        "small",
        "kind",
        "devilish",
        "chubby",
        "paltry",
        "cultured",
        "old",
        "defective",
        "hanging",
        "innocent",
        "jagged",
        "economic",
        "good",
        "sulky",
        "real",
        "bent",
        "shut",
        "furry",
        "terrific",
        "hollow",
        "terrible",
        "mammoth",
        "pleasant",
        "scared",
        "obnoxious",
        "absorbing",
        "imported",
        "infamous",
        "grieving",
        "ill-fated",
        "mighty",
        "handy",
        "comfortable",
        "astonishing",
        "brown",
        "assorted",
        "wrong",
        "unsightly",
        "spooky",
        "delightful",
        "acid",
        "inconclusive",
        "mere",
        "careless",
        "historical",
        "flashy",
        "squealing",
        "quarrelsome",
        "empty",
        "long",
    )
    return random.choice(_list)