diff --git a/setup.cfg b/setup.cfg index 167c9f2..524613f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,5 @@ [metadata] name = spamostack -version = 1.0.0 summary = Tool for creating requests to OpenStack with fake drivers description-file = README.rst license = Apache-2.0 diff --git a/spamostack/logger.py b/spamostack/logger.py index bf60925..6050563 100644 --- a/spamostack/logger.py +++ b/spamostack/logger.py @@ -16,16 +16,6 @@ import logging -class SpamFileHandler(logging.FileHandler): - - def __init__(self): - logging.FileHandler.__init__(self, "RM.log") - fmt = '%(asctime)s %(filename)s %(levelname)s: %(message)s' - fmt_date = '%Y-%m-%dT%T%Z' - formatter = logging.Formatter(fmt, fmt_date) - self.setFormatter(formatter) - - class SpamStreamHandler(logging.StreamHandler): def __init__(self): diff --git a/spamostack/spam_factory.py b/spamostack/spam_factory.py index 99fe9d4..cab91a5 100644 --- a/spamostack/spam_factory.py +++ b/spamostack/spam_factory.py @@ -16,6 +16,7 @@ import logging import random import traceback +import uuid import client_factory from Crypto.PublicKey import RSA @@ -1288,11 +1289,13 @@ def flavor_create(self): volume_sizes = [1, 2, 5, 10, 20, 40, 50, 100, 200, 500] try: + flavor_id = "spam-{}".format(uuid.uuid4()) log.info("Creating flavor with name {}".format(name)) created = self.native.flavors.create( name=name, ram=random.choice(ram_sizes), vcpus=random.choice(vcpus_num), - disk=random.choice(volume_sizes)) + disk=random.choice(volume_sizes), + flavorid=flavor_id) except Exception as exc: log.critical("Exception: {}".format(exc)) traceback.print_exc() @@ -1302,9 +1305,11 @@ def flavor_create(self): @uncache def flavor_delete(self): - flavors = self.keeper.get( - "nova", "flavors", "id", - lambda x: x in self.cache["nova"]["flavors"]) + flavors = self.keeper.get("nova", "flavors", None, + (lambda x: x.startswith("spam-") and + x in self.cache["nova"] + ["flavors"]), + "id") if len(flavors) > 0: flavor = random.choice(flavors)