api.request("vm", "create", {'hostname': name, 'plan_id': 3, 'region': 'roubaix', 'image_id': 148508, 'storage': 70}) # image Centos-controller def create_centos_controller(name): api.request("vm", "create", {'hostname': name, 'plan_id': 4, 'region': 'roubaix', 'image_id': 148508, 'storage': 70}) project_name = 'ansible-' user_number = input("Numero du cluster ? ") user_number= str(user_number) #create_centos_:controller(project_name + "controller-" + user_number) create_centos_remote(project_name + "remoteafip-" + user_number) #create_ubuntu_remote(project_name + "remote-ubuntu-" + user_number) #time.sleep(240) results = api.request('vm', 'list') f = open(r"/home/hme/inventory_ansible_ville_" + user_number, "w+") hfile = open(r"/home/hme/user_list_ansible_ville_" + user_number, "w+") val = results.get("vms") user_dic = {} print len(val) for i in range(0, len(val)): flag = 0 for key, value in val[i].items(): if key == 'name': #search= "-" + user_number if "remoteafip-" not in value: break print('name=', value) user = value
#list_of_color= ['silver','green','black','blue','pink','yellow','purple','cyan','brown','magenta','amber','carmine'] #list_of_color= ['silver','green','black','blue','pink'] #list_of_color= ['yellow','purple','cyan','brown','magenta'] list_of_color = ['amber', 'carmine'] #list_of_color= ['green','black','blue'] for x in list_of_color: cluster_name = 'k8s-' + x create_master_cluster(cluster_name + "-master") for j in range(1, 3): vm_name = cluster_name + "-node-" + str(j) api.request( "vm", "create", { 'hostname': vm_name, 'plan_id': 4, 'region': 'roubaix', 'image_id': 148540, 'storage': 70 }) # sleep while lunanode setting up public ip addresses for each VMs time.sleep(240) results = api.request('vm', 'list') f = open(r"/home/hme/inventory-" + cluster_name, "w+") hfile = open(r"/home/hme/user_list-" + cluster_name, "w+") val = results.get("vms") user_dic = {} for i in range(0, len(val)): flag = 0 for key, value in val[i].items(): if key == 'name': if cluster_name not in value:
'hostname': name, 'plan_id': 3, 'region': 'roubaix', 'image_id': 148508, 'storage': 70 }) project_name = 'training-' user_number = input("Numero de la vm villeurbanne ? ") user_number = str(user_number) #create_centos_:controller(project_name + "controller-" + user_number) create_centos_remote(project_name + "jenkins-pic-" + user_number) #create_ubuntu_remote(project_name + "remote-ubuntu-" + user_number) time.sleep(240) results = api.request('vm', 'list') f = open(r"/home/hme/inventory_jenkins_villeurbanne_" + user_number, "w+") hfile = open(r"/home/hme/user_jenkins_villeurbanne_" + user_number, "w+") val = results.get('vms') all_key = ['vm_id', 'name', 'primaryip'] #print(val) user = '******' user_dic = {} for z in range(0, len(val)): if "jenkins-pic" in val[z].get(all_key[1]): #print(val[z].get(all_key[0])) name = val[z].get(all_key[1]) ip = val[z].get(all_key[2]) results = api.request('vm', 'info', {'vm_id': val[z].get(all_key[0])}) #print(results) thepass = results.get('info')
#list_of_color= ['silver','green','black','blue','pink'] #list_of_color= ['yellow','purple','cyan','brown','magenta'] #list_of_color= ['amber','carmine'] #list_of_color=['black'] #list_of_color= ['green','black','blue'] for x in list_of_color: cluster_name = 'k8s-' + x create_master_cluster(cluster_name + "-master") for j in range(1, 2): vm_name = cluster_name + "-node-" + str(j) api.request( "vm", "create", # {'hostname': vm_name, 'plan_id': 4, 'region': 'roubaix', 'image_id': 148540, 'storage': 70}) { 'hostname': vm_name, 'plan_id': 88, 'region': 'toronto', 'image_id': 240279, 'storage': 35 }) # sleep while lunanode setting up public ip addresses for each VMs time.sleep(180) results = api.request('vm', 'list') f = open(r"/home/hme/inventory-" + cluster_name, "w+") hfile = open(r"/home/hme/user_list-" + cluster_name, "w+") val = results.get("vms") all_key = ['vm_id', 'name', 'primaryip'] #print(val) user = '******' for z in range(0, len(val)):
from lndynamic import LNDynamic with open(r"/home/hme/commands.txt") as hpass: lines = hpass.readlines() api = LNDynamic(lines[0].rstrip('\n'), lines[1].rstrip('\n')) results = api.request('vm', 'list') print(results)
from lndynamic import LNDynamic with open(r"/home/hme/commands.txt") as hpass: lines = hpass.readlines() api = LNDynamic(lines[0].rstrip('\n'), lines[1].rstrip('\n')) name = 'user' number_of_vm=input("Nbr_of_vm ? ") for i in range(1, int(number_of_vm)+1): vm_name = name + str(i) api.request("vm", "create", {'hostname': vm_name, 'plan_id': 4, 'region': 'roubaix', 'image_id': 85048, 'storage': 70})
#! /usr/bin/env python from lndynamic import LNDynamic with open(r"/home/hme/.lunanode/commands.txt") as hpass: lines = hpass.readlines() api = LNDynamic(lines[0].rstrip('\n'), lines[1].rstrip('\n')) results = api.request('vm', 'list') print(results) results = api.request('vm', 'info', {'vm_id': '1c018f61-e116-46d2-8a64-18f6963e3be7'}) print ("-----------------------") print (results) results = api.request('image', 'list') print(results) #1c018f61-e116-46d2-8a64-18f6963e3be7
from lndynamic import LNDynamic with open(r"/home/hme/commands.txt") as hpass: lines = hpass.readlines() api = LNDynamic(lines[0].rstrip('\n'), lines[1].rstrip('\n')) results = api.request('vm', 'list') print(results) val = (results.get("vms")) #print type(val) #print (val[0]) #print type(val[0]) print len(val) for i in range(0, len(val)): for key, value in val[i].items(): if key == 'name': print('name=', value) if key == 'primaryip': print('ip=', value) if key == 'plan_id': print('plan_id=', value) #api.request("vm","create",{'hostname':'user2','plan_id' : 4 ,'region' :'roubaix', 'set_password': '******', 'image_id': 85048,'storage': 70}) #results = api.request('vm', 'info', {'vm_id': '08285781-c5b3-451c-a713-3df847ffdbc1'}) results = api.request('image', 'list') print(results)
#! /usr/bin/env python from lndynamic import LNDynamic with open(r"/home/hme/.lunanode/commands.txt") as hpass: lines = hpass.readlines() api = LNDynamic(lines[0].rstrip('\n'), lines[1].rstrip('\n')) results = api.request('vm', 'list') #print(results) val = results.get('vms') #print(val) for v in val: print("{}, {}".format(v['name'], v['region'])) #ret = api.request('vm','shelve',{'vm_id': v['vm_id']}) #print(ret) results = api.request('vm', 'info', {'vm_id': '66d1d1f1-e837-4340-b3be-a58709d940e2'}) #print(results) results = api.request('image', 'list') print(results)
from lndynamic import LNDynamic with open(r"/home/hme/commands.txt") as hpass: lines = hpass.readlines() api = LNDynamic(lines[0].rstrip('\n'), lines[1].rstrip('\n')) results = api.request('vm', 'list') print(results) val = (results.get("vms")) #print type(val) #print (val[0]) #print type(val[0]) print len(val) for i in range(0,len(val)): for key, value in val[i].items(): if key == 'name': print('name=',value) if key =='primaryip': print('ip=',value) if key == 'plan_id': print('plan_id=',value) api.request("vm","create",{'hostname':'user2','plan_id' : 89 ,'region' :'toronto', 'set_password': '******', 'image_id': 148497}) #results = api.request('vm', 'info', {'vm_id': '51ed49a3-1332-4fdb-82d5-5facae99c6d1'}) #print ("-----------------------") #print (results) #results = api.request('image', 'list') #print(results)
from lndynamic import LNDynamic api_id = 'YOUR API ID' api_key = 'YOUR API KEY' api = LNDynamic(api_id, api_key) print api.request('vm', 'list')
#! /usr/bin/env python from lndynamic import LNDynamic with open(r"/home/hme/.lunanode/commands.txt") as hpass: lines = hpass.readlines() api = LNDynamic(lines[0].rstrip('\n'), lines[1].rstrip('\n')) results = api.request('vm', 'list') print(results) results = api.request('vm', 'info', {'vm_id': 'e3e7ab5c-a944-4118-bf78-8a67b4722c48'}) print("-----------------------") print(results) results = api.request('image', 'list') print(results) #1c018f61-e116-46d2-8a64-18f6963e3be7