Created
June 20, 2022 07:40
-
-
Save wido/93bdee19b21270a2706bc91b86d2971d to your computer and use it in GitHub Desktop.
Deploy Virtual Machines in CloudStack with python3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from cs import CloudStack | |
URL = 'https://xxx.yyyy.zzz/client/api' | |
APIKEY = 'XXXXXXXXXXXXXX' | |
SECRETKEY = 'YYYYYYYYYYYYYYYYY' | |
# NAT Network 1 | |
NETWORKID = '68c537ba-3e30-4498-9fbb-d433aae7bbda' | |
# Starter 1GB VM | |
SERVICEOFFERINGID = '06720101-2b58-48e1-adc6-676c1b7f1b97' | |
# Ubuntu 20.04 | |
TEMPLATEID = 'e5cc07ca-7b34-4fd0-8ccc-5b95a030eab1' | |
ZONEID = 'e91c3703-f236-45a5-a43a-4057191d3c48' | |
cs = CloudStack(endpoint=URL, key=APIKEY, secret=SECRETKEY) | |
print('ipv6_address,password') | |
for i in range(0, 25): | |
vm = cs.deployVirtualMachine(serviceofferingid=SERVICEOFFERINGID, templateid=TEMPLATEID, zoneid=ZONEID, networkids=NETWORKID, fetch_result=True) | |
password = vm['virtualmachine']['password'] | |
ipv6 = vm['virtualmachine']['nic'][0]['ip6address'] | |
print('{},{}'.format(ipv6,password)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment