Esempio n. 1
0
    def test_ratingbased(self):
        s1 = Server.objects.create(
            name='CN1',
            rating=15,
            role='hypervisor',
            hypervisor_driver=CmdbCloudConfig.TECH_HV_KVM,
            status=Resource.STATUS_INUSE)
        s2 = Server.objects.create(
            name='CN2',
            role='hypervisor',
            hypervisor_driver=CmdbCloudConfig.TECH_HV_KVM,
            status=Resource.STATUS_LOCKED)
        s3 = Server.objects.create(
            name='CN3',
            role='hypervisor',
            hypervisor_driver=CmdbCloudConfig.TECH_HV_KVM,
            status=Resource.STATUS_INUSE)
        s4 = Server.objects.create(
            name='CN4',
            rating=10,
            role='hypervisor',
            hypervisor_driver=CmdbCloudConfig.TECH_HV_KVM,
            status=Resource.STATUS_INUSE)
        s5 = Server.objects.create(name='Some server',
                                   status=Resource.STATUS_INUSE)
        s6 = Server.objects.create(
            name='CN6',
            role='hypervisor',
            hypervisor_driver=CmdbCloudConfig.TECH_HV_OPENVZ,
            status=Resource.STATUS_INUSE)

        hvisors = self.cloud.get_hypervisors(
            hypervisor_driver=CmdbCloudConfig.TECH_HV_KVM)
        self.assertEqual(3, len(hvisors))

        scheduler = RatingBasedScheduler()
        node = scheduler.get_best_node(hvisors)
        self.assertEqual(s1.id, node.id)
Esempio n. 2
0
    def __init__(self, cloud):
        super(ProxMoxJBONServiceBackend, self).__init__(cloud)

        self.scheduler = RatingBasedScheduler()