diff options
author | MatthewLi <matthew.lijun@huawei.com> | 2016-04-24 23:24:06 -0400 |
---|---|---|
committer | MatthewLi <matthew.lijun@huawei.com> | 2016-04-25 04:06:38 -0400 |
commit | d5e21b553c692948ec3710a5f1c1bc7dbabb6a62 (patch) | |
tree | 31ce2141cfd1d46b5625b19af19233ed8ec1fc6c | |
parent | a54df93abcc028f15da96538bc99bcfd03703f4b (diff) |
obtain rubbos instance info and write them into conf file
JIRA: BOTTLENECK-46
Change-Id: Ib519df7c3b532f7ae55847dc2f4cfd605ca0a24c
Signed-off-by: MatthewLi <matthew.lijun@huawei.com>
-rwxr-xr-x | testsuites/rubbos/rubbos.conf | 0 | ||||
-rwxr-xr-x | testsuites/rubbos/run_rubbos.py | 64 |
2 files changed, 62 insertions, 2 deletions
diff --git a/testsuites/rubbos/rubbos.conf b/testsuites/rubbos/rubbos.conf new file mode 100755 index 00000000..e69de29b --- /dev/null +++ b/testsuites/rubbos/rubbos.conf 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' |