Esempio n. 1
0
def compareHost(serverip, serveraccount, serverpwd, projectname):
    import client_setting
    nova = client_setting.nova(serverip, serveraccount, serverpwd, projectname)
    maxHost = ""
    maxFreeMemory = 0
    for item in nova.hypervisors.list():
        #比較所有status 為 enabled的host的free memory,取最高的
        if item.status == "enabled":
            if item.free_ram_mb > maxFreeMemory:
                maxFreeMemory = item.free_ram_mb
                maxHost = item.hypervisor_hostname

    return maxHost
Esempio n. 2
0
# vmuuid="cf8f5293-050c-41a8-83ac-85e0beec8df6"
# cpu_num=2
# memory_mb=2048
# addGB=3
# 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()
Esempio n. 3
0
from threading import Thread

argv = sys.argv[1]
VM_UUID = sys.argv[2]
is_snapshotclone = sys.argv[3]
host_uuid =  sys.argv[4] # host id
sruuid = sys.argv[5]
serverip = sys.argv[6]
serveraccount = sys.argv[7]
serverpwd = sys.argv[8]
pool_name = sys.argv[9]
operator =sys.argv[10]
guid = sys.argv[11]
ProjectName= sys.argv[12]

nova = client_setting.nova(serverip,serveraccount,serverpwd,ProjectName)
servers = nova.servers
sl = servers.list()

def dynstart():
	vm = servers.get(VM_UUID)
	# print dir(vm)
	# print(vm.status)
	if vm.status == 'PAUSED':
	    vm.unpause()
	elif vm.status == 'SUSPENDED':
		vm.resume()
	return 1

def scan_vm():
    #servers define
Esempio n. 4
0
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

# server_name = 'nova-vol-test1'
Esempio n. 5
0
import client_setting
# import sys
import json

# python autoScan.py 140.128.101.205 admin 1j6el4nj4su3 admin 0 0

# #所需參數參數
ServerIp = '140.128.101.205'
ServerAccount = 'admin'
ServerPwd = '1j6el4nj4su3'
PoolName = 'admin'
ProjectName = PoolName

neutron = client_setting.neutron(ServerIp, ServerAccount, ServerPwd,
                                 ProjectName)
nova = client_setting.nova(ServerIp, ServerAccount, ServerPwd, ProjectName)
servers = nova.servers
rlist = neutron.list_routers()
net = neutron.list_networks()
sl = servers.list()

# servers = nova.servers

# sl = servers.list()

scan_list = []

# for item in rlist['routers']:
# 	scan_list.append({'key':item['name'],'category':'Connector'})

# id_array =[]
Esempio n. 6
0
import client_setting
import globalFunction as gf
import sys
import io
import os

argv = sys.argv[1]  #delvm
VM_UUID = sys.argv[2]
ServerIP = sys.argv[3]
ServerAccount = sys.argv[4]
ServerPwd = sys.argv[5]
PoolName = sys.argv[6]
Operator = sys.argv[7]
guid = sys.argv[8]
projectname = sys.argv[9]

nova = client_setting.nova(ServerIP, ServerAccount, ServerPwd, projectname)
flavors = nova.flavors
servers = nova.servers
hypervisors = nova.hypervisors


def DelVM(argv, VM_UUID, ServerIP, ServerAccount, ServerPwd, PoolName,
          Operator, guid):
    servers.delete(servers.get(VM_UUID))


DelVM(argv, VM_UUID, ServerIP, ServerAccount, ServerPwd, PoolName, Operator,
      guid)
print 1
Esempio n. 7
0
import demjson
import client_setting

# nova = client.Client(2,'admin','1j6el4nj4su3','admin','http://140.128.101.205:5000/v2.0')
nova=client_setting.nova()
hl = nova.hypervisors.list()
hosts_dict=[]

for item in hl:
    Host_UUID =item.id
    Host_Name = item.hypervisor_hostname
    Host_IP =item.host_ip

    j=demjson.decode(item.cpu_info)
    CPU_count=j['topology']['cores']
    CPU_GHZ = 0
    CPU_Socket = j['topology']['sockets']
    MemoryMB=item.memory_mb
    #check hosts status

    PowerOn = 0
    if(item.status=='up'):
    	PowerOn = 1
    else:
    	PowerOn = 0
    #


	#
    item_array={'Host_UUID':Host_UUID,'Host_Name':Host_Name,'Host_IP':Host_IP,'CPU_Count':CPU_count,'CPU_GHZ':CPU_GHZ,'CPU_Socket':CPU_Socket,'MemoryMB':MemoryMB,'PowerOn':PowerOn} 
    hosts_dict.append(item_array)