예제 #1
0
class VCloudTests(unittest.TestCase):

    def setUp(self):
       VCloudNodeDriver.connectionCls.host = "test"
       VCloudNodeDriver.connectionCls.conn_classes = (None, VCloudMockHttp) 
       VCloudMockHttp.type = None
       self.driver = VCloudNodeDriver('test@111111', HOSTINGCOM_SECRET)

    def test_list_images(self):
        ret = self.driver.list_images()
        self.assertEqual(ret[0].id,'https://vcloud.safesecureweb.com/vAppTemplate/1')
        self.assertEqual(ret[-1].id,'https://vcloud.safesecureweb.com/vAppTemplate/4')

    def test_list_nodes(self):
        ret = self.driver.list_nodes()
        self.assertEqual(ret[0].id, '197833')
        self.assertEqual(ret[0].state, NodeState.RUNNING)

    def test_reboot_node(self):
        node = self.driver.list_nodes()[0]
        ret = self.driver.reboot_node(node)
        self.assertTrue(ret)

    def test_destroy_node(self):
        node = self.driver.list_nodes()[0]
        ret = self.driver.destroy_node(node)
        self.assertTrue(ret)
예제 #2
0
class VCloudTests(unittest.TestCase, TestCaseMixin):

    def setUp(self):
       VCloudNodeDriver.connectionCls.host = "test"
       VCloudNodeDriver.connectionCls.conn_classes = (None, VCloudMockHttp) 
       VCloudMockHttp.type = None
       self.driver = VCloudNodeDriver('test@111111', HOSTINGCOM_SECRET)

    def test_list_images(self):
        ret = self.driver.list_images()
        self.assertEqual(ret[0].id,'https://vcloud.safesecureweb.com/vAppTemplate/1')
        self.assertEqual(ret[-1].id,'https://services.vcloudexpress.terremark.com/api/v0.8/vAppTemplate/5')

    def test_list_nodes(self):
        ret = self.driver.list_nodes()
        self.assertEqual(ret[0].id, 'https://vcloud.safesecureweb.com/vapp/197833')
        self.assertEqual(ret[0].state, NodeState.RUNNING)

    def test_list_sizes(self):
        ret = self.driver.list_sizes()
        self.assertEqual(ret[0].ram, 512)

    def test_reboot_node(self):
        node = self.driver.list_nodes()[0]
        ret = self.driver.reboot_node(node)
        self.assertTrue(ret)

    def test_destroy_node(self):
        node = self.driver.list_nodes()[0]
        ret = self.driver.destroy_node(node)
        self.assertTrue(ret)

    def test_create_node(self):
        image = self.driver.list_images()[0]
        size = self.driver.list_sizes()[0]
        node = self.driver.create_node(
            name='testerpart2', 
            image=image, 
            size=size,
            vdc='https://services.vcloudexpress.terremark.com/api/v0.8/vdc/111111',
            network='https://services.vcloudexpress.terremark.com/api/v0.8/network/518', 
            cpus=2,
        )
        self.assertEqual(node.id, 'https://services.vcloudexpress.terremark.com/api/v0.8/vapp/197833')
        self.assertEqual(node.name, 'testerpart2')

    def test_create_node_response(self):
        # should return a node object
        size = self.driver.list_sizes()[0]
        image = self.driver.list_images()[0]
        node = self.driver.create_node(
            'node-name',
            image, 
            size,
            vdc='https://services.vcloudexpress.terremark.com/api/v0.8/vdc/111111',
            network='https://services.vcloudexpress.terremark.com/api/v0.8/network/518'
            )
        self.assertTrue(isinstance(node, Node))