コード例 #1
0
    def test_vms_ram_limit(self):
        with MockTransaction:
            nova = mock('nova')
            nova.servers = mock('servers')
            flavors_to_ram = {'1': 512, '2': 1024}
            expect(manager).flavors_ram(nova). \
                and_return(flavors_to_ram).once()

            vm1 = mock('vm1')
            vm1.flavor = {'id': '1'}
            vm2 = mock('vm2')
            vm2.flavor = {'id': '2'}
            expect(nova.servers).get('vm1').and_return(vm1).once()
            expect(nova.servers).get('vm2').and_return(vm2).once()
            assert manager.vms_ram_limit(nova, ['vm1', 'vm2']) == \
                {'vm1': 512, 'vm2': 1024}
コード例 #2
0
    def test_vms_ram_limit(self):
        with MockTransaction:
            nova = mock('nova')
            nova.servers = mock('servers')
            flavors_to_ram = {'1': 512, '2': 1024}
            expect(manager).flavors_ram(nova). \
                and_return(flavors_to_ram).once()

            vm1 = mock('vm1')
            vm1.flavor = {'id': '1'}
            vm2 = mock('vm2')
            vm2.flavor = {'id': '2'}
            expect(nova.servers).get('vm1').and_return(vm1).once()
            expect(nova.servers).get('vm2').and_return(vm2).once()
            assert manager.vms_ram_limit(nova, ['vm1', 'vm2']) == \
                {'vm1': 512, 'vm2': 1024}
コード例 #3
0
hosts_to_vms = manager.vms_by_hosts(nova, hosts)
vms = [item for sublist in hosts_to_vms.values() for item in sublist]

vms_names = []
vms_status = {}
for uuid in vms:
    vm = nova.servers.get(uuid)
    vms_names.append((vm.human_id, uuid))
    vms_status[uuid] = str(vm.status)
vms_names = sorted(vms_names)

vms_cpu_usage = db.select_last_cpu_mhz_for_vms()
for vm in vms:
    if not vm in vms_cpu_usage:
        vms_cpu_usage[vm] = 0
vms_ram_usage = manager.vms_ram_limit(nova, vms)

hosts_cpu_usage_hypervisor = db.select_last_cpu_mhz_for_hosts()

hosts_cpu_usage = {}
hosts_ram_usage = {}
for host, vms in hosts_to_vms.items():
    hosts_cpu_usage[host] = hosts_cpu_usage_hypervisor[host] + \
                            sum(vms_cpu_usage[x] for x in vms)
    hosts_ram_usage[host] = manager.host_used_ram(nova, host)
        

first = True
for host in sorted(hosts_to_vms.keys()):
    if not first:
        print "-----------------------------------------------------------"
コード例 #4
0
hosts_to_vms = manager.vms_by_hosts(nova, hosts)
vms = [item for sublist in hosts_to_vms.values() for item in sublist]

vms_names = []
vms_status = {}
for uuid in vms:
    vm = nova.servers.get(uuid)
    vms_names.append((vm.human_id, uuid))
    vms_status[uuid] = str(vm.status)
vms_names = sorted(vms_names)

vms_cpu_usage = db.select_last_cpu_mhz_for_vms()
for vm in vms:
    if not vm in vms_cpu_usage:
        vms_cpu_usage[vm] = 0
vms_ram_usage = manager.vms_ram_limit(nova, vms)

hosts_cpu_usage_hypervisor = db.select_last_cpu_mhz_for_hosts()

hosts_cpu_usage = {}
hosts_ram_usage = {}
for host, vms in hosts_to_vms.items():
    hosts_cpu_usage[host] = hosts_cpu_usage_hypervisor[host] + \
                            sum(vms_cpu_usage[x] for x in vms)
    hosts_ram_usage[host] = manager.host_used_ram(nova, host)

first = True
for host in sorted(hosts_to_vms.keys()):
    if not first:
        print "-----------------------------------------------------------"
    first = False