Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Fix the quota caclulation bugs, add force_cleanup
Browse files Browse the repository at this point in the history
Change-Id: I99cc22325d69d271d6cc98479bda9b155d6ee158
  • Loading branch information
yicwang committed Jul 8, 2015
1 parent f1076b0 commit af1e5ca
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 3 deletions.
82 changes: 82 additions & 0 deletions scale/force_cleanup
@@ -0,0 +1,82 @@
#! /bin/bash
# Copyright 2015 Cisco Systems, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#

# A tool that can represent KloudBuster json results in
# a nicer form using HTML5, bootstrap.js and the Google Charts Javascript library

###############################################################################
# #
# This is a helper script which will delete all resources created by #
# KloudBuster. #
# #
# Normally, KloudBuster will clean up automatically when it is done. However, #
# sometimes errors or timeouts happen during the rescource creation stage, #
# which will cause KloudBuster out of sync with the real environment. If that #
# happens, a force cleanup may be needed. #
# #
# This script will simply grep the resource name with "KB" and delete them. #
# If running on a production network, please double and triple check all #
# resources names are *NOT( containing "KB", otherwise they will be deleted #
# when running with this script. #
# #
###############################################################################

# WARNING! WARNING! WARNING!
# IMPORTANT FOR RUNNING KLOUDBUSTER ON PRODUCTION CLOUDS
# ======================================================
#
# DOUBLE CHECK THE NAMES OF ALL RESOURCES THAT DOES NOT BELONG TO KLOUDBUSTER
# ARE *NOT* CONTAINING "KB"

for line in `nova list --all-tenants | grep KB | cut -d'|' -f2`; do
nova delete $line
done

echo -e "`neutron floatingip-list | grep -E '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'`" | while read line; do
fid=`echo $line | cut -d'|' -f2 | xargs`
portid=`echo $line | cut -d'|' -f5 | xargs`
if [ "$fid" != "" ] && [ "$portid" = "" ]; then
neutron floatingip-delete $fid &
fi
done;

for line in `neutron security-group-list | grep KB | cut -d'|' -f2`; do
neutron security-group-delete $line &
done;

for line in `nova flavor-list | grep kb | cut -d'|' -f3`; do
nova flavor-delete $line &
done;

for line in `neutron router-list | grep KB | cut -d'|' -f2`; do
neutron router-gateway-clear $line
for line2 in `neutron router-port-list $line | grep subnet | cut -d'"' -f4`; do
neutron router-interface-delete $line $line2
done
neutron router-delete $line
done

for line in `neutron net-list | grep KB | cut -d'|' -f2`; do
neutron net-delete $line
done

for line in `keystone tenant-list | grep KB | cut -d'|' -f2`; do
keystone tenant-delete $line
done

for line in `keystone user-list | grep KB | cut -d'|' -f2`; do
keystone user-delete $line
done
Empty file modified scale/kb_gen_chart.py 100755 → 100644
Empty file.
3 changes: 1 addition & 2 deletions scale/kb_runner.py
Expand Up @@ -54,11 +54,10 @@ def __init__(self, client_list, config, single_cloud=True):
self.report_chan_name = "kloudbuster_report"

def setup_redis(self, redis_server, redis_server_port=6379, timeout=120):
LOG.info("Setting up redis connection pool...")
LOG.info("Setting up the redis connections...")
connection_pool = redis.ConnectionPool(
host=redis_server, port=redis_server_port, db=0)

LOG.info("Setting up the redis connections...")
self.redis_obj = redis.StrictRedis(connection_pool=connection_pool,
socket_connect_timeout=1,
socket_timeout=1)
Expand Down
8 changes: 7 additions & 1 deletion scale/kloudbuster.py
Expand Up @@ -37,6 +37,9 @@
CONF = cfg.CONF
LOG = logging.getLogger(__name__)

class KBVMCreationException(Exception):
pass


def create_keystone_client(admin_creds):
"""
Expand Down Expand Up @@ -166,7 +169,7 @@ def create_vm(self, instance):
LOG.info("Creating Instance: " + instance.vm_name)
instance.create_server(**instance.boot_info)
if not instance.instance:
return
raise KBVMCreationException()

instance.fixed_ip = instance.instance.networks.values()[0][0]
if (instance.vm_name == "KB-PROXY") and (not instance.config['use_floatingip']):
Expand Down Expand Up @@ -389,6 +392,7 @@ def calc_neutron_quota(self):
server_quota['security_group_rule'] = server_quota['security_group'] * 100

client_quota = {}
total_vm = total_vm * self.server_cfg['number_tenants']
client_quota['network'] = 1
client_quota['subnet'] = 1
client_quota['router'] = 1
Expand Down Expand Up @@ -424,6 +428,7 @@ def calc_nova_quota(self):
server_quota['ram'] = total_vm * self.server_cfg['flavor']['ram']

client_quota = {}
total_vm = total_vm * self.server_cfg['number_tenants']
client_quota['instances'] = total_vm + 1
client_quota['cores'] = total_vm * self.client_cfg['flavor']['vcpus'] + 1
client_quota['ram'] = total_vm * self.client_cfg['flavor']['ram'] + 2048
Expand All @@ -436,6 +441,7 @@ def calc_cinder_quota(self):
server_quota['gigabytes'] = total_vm * self.server_cfg['flavor']['disk']

client_quota = {}
total_vm = total_vm * self.server_cfg['number_tenants']
client_quota['gigabytes'] = total_vm * self.client_cfg['flavor']['disk'] + 20

return [server_quota, client_quota]
Expand Down

0 comments on commit af1e5ca

Please sign in to comment.