コード例 #1
0
ファイル: AntColony.py プロジェクト: Semyazz/nova-stats
    def test_algorithm(self):

        ant = AntColonyAlgorithm()

        input_data_set = namedtuple("InputData", "Hosts VirtualMachines Alert")

        def host_init(self, memory, bandwidth):
            self._mem = memory
            self._bandwidth = bandwidth
            self._cpu = 1000

        def vm_init(self, mem_declared, bandwitch, cpu_util):
            self._mem_declared = mem_declared
            self._bandwidth = bandwitch
            self._cpu_util = cpu_util
            self._cpu_num = 1
            self._cpu_speed = 1000
            self._pkts_in = 0
            self._pkts_out = 0
            self._mem = mem_declared

        Host.__init__ = host_init
        Vm.__init__ = vm_init

        maxMem = 1024.0
        maxCPU = 100.0
        maxBandwith = 10000.0

        host1 = Host(1.0, 1.0)
        host1.Hostname = "host1"
        host2 = Host(1.0, 1.0)
        host2.Hostname = "host2"

        vm1 = Vm(512.0 / maxMem, 1000.0 / maxBandwith, 30.0 / 100.0)
        vm1.InstanceName = "instance-00001"
        vm2 = Vm(512.0 / maxMem, 1000.0 / maxBandwith, 30.0 / 100.0)
        vm2.InstanceName = "instance-00002"
        vm3 = Vm(1024.0 / maxMem, 1000.0 / maxBandwith, 30.0 / 100.0)
        vm3.InstanceName = "instance-00003"
        vm4 = Vm(512.0 / maxMem, 1000.0 / maxBandwith, 30.0 / 100.0)
        vm4.InstanceName = "instance-00004"

        input_data_set.Hosts = [host1, host2]
        input_data_set.VirtualMachines = [vm1, vm2, vm3, vm4]

        ant.execute_algorithm(input_data_set)
コード例 #2
0
ファイル: manager.py プロジェクト: Semyazz/nova-stats
def MockHostList():

    h1 = Host("Host1", 50, 0, 4, 1000, 8192, 2*8192/8) # 2*1GB free
    h2 = Host("Host2", 25, 0, 4, 1000, 8192, 2*8192/8) # 2*1GB free
    h3 = Host("Host3", 0, 0, 4, 1000, 8192, 4*8192/8)  # 4*1GB free
    h4 = Host("Host4", 0, 0, 4, 1000, 8192, 4*8192/8)  # 4*1GB free

    vm1 = Vm(h1.Hostname, "vm1", 100, 1, 0, 0, 2048, 1000)
    vm1.setWeights(None)

    vm2 = Vm(h1.Hostname, "vm2", 50, 2, 0, 0, 4096, 1000)
    vm2.setWeights(None)

    vm3 = Vm(h2.Hostname, "vm3", 25, 4, 0, 0, 4096, 1000)
    vm3.setWeights(None)

    vm4 = Vm(h3.Hostname, "vm4", 0, 1, 0, 0, 4096, 1000)
    vm4.setWeights(None)

    vm5 = Vm(h4.Hostname, "vm5", 0, 1, 0, 0, 4096, 1000)
    vm5.setWeights(None)

    h1._vms = [vm1, vm2]
    h1.setVmMem()

    h2._vms = [vm3]
    h2.setVmMem()

    h3._vms = [vm4]
    h3.setVmMem()

    h4._vms = [vm5]
    h4.setVmMem()


    return [h1, h2, h3, h4]