# diskctrl = 2 # deviceidx = 0 # sruuid =0 # serverip = "140.128.101.205" # serveraccount = "admin" # serverpwd ="1j6el4nj4su3" # poolname ="" # operator ="" # guid ="" now = gf.getTime() nova = client_setting.nova(server_ip, server_account, server_pwd, project_name) # nova = client_setting.nova(serverip,serveraccount,serverpwd,projectname) neutron = client_setting.neutron(server_ip, server_account, server_pwd, project_name) cinder = client_setting.cinder(server_ip, server_account, server_pwd, project_name) volumes = nova.volumes servers = nova.servers flavors = nova.flavors networks = nova.networks hypervisors = nova.hypervisors images = nova.images ip = nova.floating_ips hl = hypervisors.list() nl = networks.list() il = images.list() sl = servers.list() fl = flavors.list() def ResourceModify():
subnet_id = sys.argv[7] keypair_id = sys.argv[8] sg_id = sys.argv[9] sruuid = sys.argv[10] host_uuid = sys.argv[11] # host id serverip = sys.argv[12] serveraccount = sys.argv[13] serverpwd = sys.argv[14] operator = sys.argv[15] guid = sys.argv[16] cinder = client_setting.cinder(serverip,serveraccount,serverpwd,pool_name) nova = client_setting.nova(serverip,serveraccount,serverpwd,pool_name) neutron = client_setting.neutron(serverip,serveraccount,serverpwd,pool_name) now = gf.getTime() flavors = nova.flavors servers = nova.servers hypervisors = nova.hypervisors if host_uuid == 'null': host_name = gf.compareHost(serverip,serveraccount,serverpwd,pool_name) else: # host_uuid = sys.argv[11] host_name = hypervisors.get(host_uuid).hypervisor_hostname
# -*- coding: utf-8 -*- import client_setting import demjson import sys import io import json import time # #所需參數參數 ServerIp = '140.128.101.205' ServerAccount = 'admin' ServerPwd = '1j6el4nj4su3' PoolName = '0' Operator = '0' Guid = 'test' ProjectName= 'admin' cinder = client_setting.cinder(ServerIp,ServerAccount,ServerPwd,ProjectName) # print dir(cinder.scheduler) volume_pool = cinder.pools.list(detailed=True) for items in volume_pool: print items._info # Share_SRUUID = 0 # Share_SRName = items._info['name'] # Share_SRTotalSize= items._info['capabilities']['total_capacity_gb'] # Share_SRFreeSize= items._info['capabilities']['free_capacity_gb'] # item_array = {"Share_SRUUID":Share_SRUUID,"Share_SRName":Share_SRName,"Share_SRTotalSize":Share_SRTotalSize,"Share_SRFreeSize":Share_SRFreeSize} # output += str(item_array)+"\n"
host_uuid = sys.argv[4] host_name = hypervisors.get(host_uuid).hypervisor_hostname # vm_uuid = "083cb621-76b8-42ba-9728-651cdc795d06" # suspend_num = 3 # host_uuid = "1" # host id # sruuid = 1 # serverip = "140.128.101.205" # serveraccount = "admin" # serverpwd = "1j6el4nj4su3" # poolname = '0' # operator ="DK" # guid = "thisav" # projectname = admin cinder = client_setting.cinder(serverip, serveraccount, serverpwd, projectname) neutron = client_setting.neutron(serverip, serveraccount, serverpwd, projectname) nova = client_setting.nova(serverip, serveraccount, serverpwd, projectname) # nova = client_setting.nova() flavors = nova.flavors servers = nova.servers hypervisors = nova.hypervisors images = nova.images vmname = servers.get(sourcevm_uuid).name Cvm = now + vmname + "_CloneVM" sl = servers.list() # snapshot tmpImage = servers.create_image(servers.get(sourcevm_uuid), sourcevm_uuid) #create vm use snapshot