summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/env_prepare/quota_prepare.py76
-rw-r--r--utils/env_prepare/stack_prepare.py4
-rw-r--r--utils/infra_setup/runner/yardstick.py21
-rw-r--r--utils/logger.py2
4 files changed, 98 insertions, 5 deletions
diff --git a/utils/env_prepare/quota_prepare.py b/utils/env_prepare/quota_prepare.py
new file mode 100644
index 00000000..e52a3e32
--- /dev/null
+++ b/utils/env_prepare/quota_prepare.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+import os
+import commands
+import utils.logger as log
+import utils.infra_setup.heat.manager as client_manager
+
+LOG = log.Logger(__name__).getLogger()
+
+neutron_quota = {"subnet": -1,
+ "network": -1,
+ "floatingip": -1,
+ "subnetpool": -1,
+ "router": -1,
+ "port": -1}
+
+nova_quota = {"ram": -1,
+ "cores": -1,
+ "instances": -1,
+ "key_pairs": -1,
+ "fixed_ips": -1,
+ "floating_ips": -1,
+ "server_groups": -1,
+ "injected_files": -1,
+ "metadata_items": -1,
+ "security_groups": -1,
+ "security_group_rules": -1,
+ "server_group_members": -1,
+ "injected_file_content_bytes": -1,
+ "injected_file_path_bytes": -1}
+
+
+def quota_env_prepare():
+ tenant_name = os.getenv("OS_TENANT_NAME")
+ cmd = ("openstack project list | grep " +
+ tenant_name +
+ " | awk '{print $2}'")
+
+ result = commands.getstatusoutput(cmd)
+ if result[0] == 0:
+ LOG.info(result[1])
+ else:
+ LOG.error("can't get openstack project id")
+ return 1
+
+ openstack_id = result[1]
+
+ nova_client = client_manager._get_nova_client()
+ neutron_client = client_manager._get_neutron_client()
+
+ nova_q = nova_client.quotas.get(openstack_id).to_dict()
+ neutron_q = neutron_client.show_quota(openstack_id)
+ LOG.info(tenant_name + "tenant nova and neutron quota(previous) :")
+ LOG.info(nova_q)
+ LOG.info(neutron_q)
+
+ nova_client.quotas.update(openstack_id, **nova_quota)
+ neutron_client.update_quota(openstack_id,
+ {'quota': neutron_quota})
+ LOG.info("Quota has been changed!")
+
+ nova_q = nova_client.quotas.get(openstack_id).to_dict()
+ neutron_q = neutron_client.show_quota(openstack_id)
+ LOG.info(tenant_name + "tenant nova and neutron quota(now) :")
+ LOG.info(nova_q)
+ LOG.info(neutron_q)
+ return 0
diff --git a/utils/env_prepare/stack_prepare.py b/utils/env_prepare/stack_prepare.py
index 37b523d1..3c706fad 100644
--- a/utils/env_prepare/stack_prepare.py
+++ b/utils/env_prepare/stack_prepare.py
@@ -28,10 +28,10 @@ def _prepare_env_daemon():
_source_file(rc_file)
- _append_external_network(rc_file)
+ # _append_external_network(rc_file)
# update the external_network
- _source_file(rc_file)
+ # _source_file(rc_file)
def _get_remote_rc_file(rc_file, installer_ip, installer_type):
diff --git a/utils/infra_setup/runner/yardstick.py b/utils/infra_setup/runner/yardstick.py
index 104cdfae..35b89ae8 100644
--- a/utils/infra_setup/runner/yardstick.py
+++ b/utils/infra_setup/runner/yardstick.py
@@ -64,11 +64,28 @@ def Create_Incluxdb(con_dic):
test_dict = {
"action": "createInfluxDBContainer",
}
- requests.post(
+ responce = requests.post(
base_url, data=json.dumps(test_dict), headers=headers)
+ ask_data = json.loads(responce.text)
+ task_id = ask_data["result"]["task_id"]
LOG.info("waiting for creating InfluxDB")
time.sleep(30)
- LOG.info("Done, creating InflxDB Container")
+ return task_id
+
+
+def yardstick_env_prepare(con_dic):
+ base_url = ("http://%s/yardstick/env/action"
+ % (con_dic['yardstick_test_ip']))
+ test_dict = {
+ "action": "prepareYardstickEnv",
+ }
+ LOG.info("waiting for yardstick environment prepare")
+ reponse = requests.post(
+ base_url, data=json.dumps(test_dict), headers=headers)
+ ask_data = json.loads(reponse.text)
+ task_id = ask_data["result"]["task_id"]
+ LOG.info("Done, yardstick environment prepare complete!")
+ return task_id
def find_condition(con_dic):
diff --git a/utils/logger.py b/utils/logger.py
index 5ce64238..9faaea53 100644
--- a/utils/logger.py
+++ b/utils/logger.py
@@ -36,7 +36,7 @@ class Logger:
ch = logging.StreamHandler()
log_formatter = ('%(asctime)s '
- '%(name)s %(filename)s:%(lineno)d '
+ '%(filename)s:%(lineno)d '
'%(levelname)s %(message)s')
formatter = logging.Formatter(log_formatter)