From d5e21b553c692948ec3710a5f1c1bc7dbabb6a62 Mon Sep 17 00:00:00 2001 From: MatthewLi Date: Sun, 24 Apr 2016 23:24:06 -0400 Subject: obtain rubbos instance info and write them into conf file JIRA: BOTTLENECK-46 Change-Id: Ib519df7c3b532f7ae55847dc2f4cfd605ca0a24c Signed-off-by: MatthewLi --- testsuites/rubbos/rubbos.conf | 0 testsuites/rubbos/run_rubbos.py | 64 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100755 testsuites/rubbos/rubbos.conf (limited to 'testsuites') diff --git a/testsuites/rubbos/rubbos.conf b/testsuites/rubbos/rubbos.conf new file mode 100755 index 00000000..e69de29b diff --git a/testsuites/rubbos/run_rubbos.py b/testsuites/rubbos/run_rubbos.py index 0a4acd94..32221f72 100755 --- a/testsuites/rubbos/run_rubbos.py +++ b/testsuites/rubbos/run_rubbos.py @@ -186,15 +186,75 @@ def rubbos_create_instances(template_file, rubbos_parameters=None, stack_name="b print "After %d seconds, the stack's status is [%s]" %(timeInProgress, stack_status) return True if stack_status == "CREATE_COMPLETE" else False +def get_instances(nova_client): + try: + instances = nova_client.servers.list(search_opts={'all_tenants': 1}) + return instances + except Exception, e: + print "Error [get_instances(nova_client)]:", e + return None + def rubbos_run(): - pass + print "========== run rubbos ===========" + + nova = _get_nova_client() + + instances = get_instances(nova) + control_servers = [] + client_servers = [] + web_servers = [] + cjdbc_controller = [] + database_servers = [] + for instance in instances: + name = getattr(instance, 'name') + private_ip = [ x['addr'] for x in getattr(instance, 'addresses').itervalues().next() if x['OS-EXT-IPS:type'] == 'fixed'] + public_ip = [ x['addr'] for x in getattr(instance, 'addresses').itervalues().next() if x['OS-EXT-IPS:type'] == 'floating'] + + if name.find("control") > 0: + control_servers.append(''.join(str(name)+':'+public_ip[0]+':'+private_ip[0])) + if name.find("client") > 0: + client_servers.append(''.join(str(name)+':'+private_ip[0])) + if name.find("tomcat") > 0: + web_servers.append(''.join(str(name)+':'+private_ip[0])) + if name.find("cjdbc") > 0: + cjdbc_controller.append(''.join(str(name)+':'+private_ip[0])) + if name.find("mysql") > 0: + database_servers.append(''.join(str(name)+':'+private_ip[0])) + + f = open('rubbos.conf', 'w') + f.write('[Controller]\n\n') + f.write('controller=') + for i in control_servers: + f.write(i+',') + f.write('\n\n') + f.write('[Hosts]\n\n') + f.write('client_servers=') + for i in client_servers: + f.write(i + ',') + f.write('\n') + f.write('web_servers=') + for i in web_servers: + f.write(i+',') + f.write('\n') + f.write('cjdbc_controller=') + for i in cjdbc_controller: + f.write(i+',') + f.write('\n') + f.write('database_servers=') + for i in database_servers: + f.write(i + ',') + f.close() + f = open('rubbos.conf','r') + line = f.readlines() + f.close() + for i in line: + print(i) def main(): global Heat_template global Bottlenecks_repo_dir global image_url Bottlenecks_repo_dir = "/home/opnfv/bottlenecks" # same in Dockerfile, docker directory - #Bottlenecks_repo_dir = "/root/wyg/bottlenecks" # Test dir in local env image_url = 'http://artifacts.opnfv.org/bottlenecks/rubbos/bottlenecks-trusty-server.img' -- cgit 1.2.3-korg