You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
917 B
Python
37 lines
917 B
Python
7 years ago
|
#!/usr/bin/env python
|
||
|
|
||
|
import os
|
||
|
import sys
|
||
|
|
||
|
import googleapiclient.discovery
|
||
|
|
||
|
|
||
|
def main():
|
||
|
project = 'mitogen-load-testing'
|
||
|
zone = 'asia-south1-c'
|
||
|
group_name = 'micro-debian9'
|
||
|
|
||
|
client = googleapiclient.discovery.build('compute', 'v1')
|
||
|
resp = client.instances().list(project=project, zone=zone).execute()
|
||
|
|
||
|
ips = []
|
||
|
for inst in resp['items']:
|
||
|
if inst['status'] == 'RUNNING' and inst['name'].startswith(group_name):
|
||
|
ips.extend(
|
||
7 years ago
|
#bytes(config['natIP'])
|
||
|
bytes(interface['networkIP'])
|
||
7 years ago
|
for interface in inst['networkInterfaces']
|
||
7 years ago
|
#for config in interface['accessConfigs']
|
||
7 years ago
|
)
|
||
|
|
||
|
print 'Addresses:', ips
|
||
|
os.execvp('ansible-playbook', [
|
||
|
'anisble-playbook',
|
||
|
'--user=dw',
|
||
|
'--inventory-file=' + ','.join(ips) + ','
|
||
|
] + sys.argv[1:])
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|