Skip to content

Commit 2a79bb9

Browse files
committed
Update keeper module
- Added static method for validating uuid4 - Added simple check, that continues keeping default flavors in openstack without deleting - Remove strong constraint. Reason: https://github.com/openstack-dev/pbr/blob/e0d26741/pbr/packaging.py#L915
1 parent 0a380b4 commit 2a79bb9

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[metadata]
22
name = spamostack
3-
version = 1.0.0
43
summary = Tool for creating requests to OpenStack with fake drivers
54
description-file = README.rst
65
license = Apache-2.0

spamostack/keeper.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import logging
1717
import random
1818
import traceback
19+
import uuid
1920

2021
from spam_factory import SpamFactory
2122

@@ -119,6 +120,10 @@ def get(self, client_name, resource_name, param=None, func=None,
119120
else:
120121
probe = getattr(el, param)(*args, **kwargs)
121122

123+
if (resource_name == "flavors"
124+
and not self.validate_uuid4(probe)):
125+
continue
126+
122127
if func(probe):
123128
result.append(el)
124129
except Exception as exc:
@@ -156,6 +161,22 @@ def get(self, client_name, resource_name, param=None, func=None,
156161

157162
return result
158163

164+
@staticmethod
165+
def validate_uuid4(uuid_string):
166+
"""This method allow us validate uuid4 for keeping all standard flavors
167+
168+
@param uuid_string: UUID, with (or without) slashes
169+
@type uuid_string: `str`, or `object` with uuid representation
170+
"""
171+
uuid_string = uuid_string.replace("-", "")
172+
173+
try:
174+
val = uuid.UUID(uuid_string, version=4)
175+
except ValueError:
176+
return False
177+
178+
return val.hex == uuid_string
179+
159180
def clean(self, component_names):
160181
"""Delete all the resources for specific component
161182

spamostack/logger.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@
1616
import logging
1717

1818

19-
class SpamFileHandler(logging.FileHandler):
20-
21-
def __init__(self):
22-
logging.FileHandler.__init__(self, "RM.log")
23-
fmt = '%(asctime)s %(filename)s %(levelname)s: %(message)s'
24-
fmt_date = '%Y-%m-%dT%T%Z'
25-
formatter = logging.Formatter(fmt, fmt_date)
26-
self.setFormatter(formatter)
27-
28-
2919
class SpamStreamHandler(logging.StreamHandler):
3020

3121
def __init__(self):

0 commit comments

Comments
 (0)