Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update keeper module #33

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 0 additions & 10 deletions spamostack/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
13 changes: 9 additions & 4 deletions spamostack/spam_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import logging
import random
import traceback
import uuid

import client_factory
from Crypto.PublicKey import RSA
Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand Down