コード例 #1
0
    def data(self):
        llclusto.drivers.HostState('up')
        class5 = ServerClass("Class 5", num_cpus=1, cores_per_cpu=4, ram_size=4096, disk_size=138)

        self.server0 = Class5Server("pgi0.lindenlab.com")
        self.server1 = Class5Server("pgi1.lindenlab.com")

        self.image0 = NGIImage("pgi-image0")
        self.image1 = NGIImage("pgi-image1")    
コード例 #2
0
class NGIImageTests(testbase.ClustoTestBase):
    """ 
    """
    
    def data(self):
        llclusto.drivers.HostState('up')
        class5 = ServerClass("Class 5", num_cpus=1, cores_per_cpu=4, ram_size=4096, disk_size=138)

        self.server0 = Class5Server("pgi0.lindenlab.com")
        self.server1 = Class5Server("pgi1.lindenlab.com")

        self.image0 = NGIImage("pgi-image0")
        self.image1 = NGIImage("pgi-image1")    

    def test_get_hosts_associated_with(self):
        """
        Test for get_hosts_associated_with() function.
        """

        self.assertEquals(self.image0.type, 'ngi_image')
        self.assertEquals(self.image1.type, 'ngi_image')

        self.assertEquals(self.server0.ngi_image, None)
        self.assertEquals(self.server1.ngi_image, None)
        
        self.server0.ngi_image = self.image0
        self.server1.ngi_image = self.image1
        self.assertEquals(self.server0.ngi_image, self.image0)
        self.assertEquals(self.server1.ngi_image, self.image1)

        self.assertEquals(self.image0.get_hosts_associated_with(), [self.server0])
        self.assertEquals(self.image1.get_hosts_associated_with(), [self.server1])

        self.server1.ngi_image = self.image0
        self.assertEquals(sorted(self.image0.get_hosts_associated_with()), sorted([self.server0, self.server1]))
        self.assertEquals(self.image1.get_hosts_associated_with(), [])