コード例 #1
0
class IBMTests(unittest.TestCase, TestCaseMixin):
    """
    Tests the IBM Developer Cloud driver.
    """
    def setUp(self):
        IBM.connectionCls.conn_classes = (None, IBMMockHttp)
        IBMMockHttp.type = None
        self.driver = IBM(IBM_USER, IBM_SECRET)

    def test_auth(self):
        IBMMockHttp.type = 'UNAUTHORIZED'

        try:
            self.driver.list_nodes()
        except InvalidCredsError, e:
            self.assertTrue(isinstance(e, InvalidCredsError))
            self.assertEquals(e.value, '401: Unauthorized')
        else:
コード例 #2
0
ファイル: test_ibm_sbc.py プロジェクト: Keisuke69/libcloud
class IBMTests(unittest.TestCase, TestCaseMixin):
    """
    Tests the IBM Developer Cloud driver.
    """

    def setUp(self):
        IBM.connectionCls.conn_classes = (None, IBMMockHttp)
        IBMMockHttp.type = None
        self.driver = IBM(*IBM_PARAMS)

    def test_auth(self):
        IBMMockHttp.type = 'UNAUTHORIZED'

        try:
            self.driver.list_nodes()
        except InvalidCredsError, e:
            self.assertTrue(isinstance(e, InvalidCredsError))
            self.assertEquals(e.value, '401: Unauthorized')
        else:
コード例 #3
0
 def setUp(self):
     IBM.connectionCls.conn_classes = (None, IBMMockHttp)
     IBMMockHttp.type = None
     self.driver = IBM(IBM_USER, IBM_SECRET)
コード例 #4
0
ファイル: test_ibm_sbc.py プロジェクト: Keisuke69/libcloud
 def setUp(self):
     IBM.connectionCls.conn_classes = (None, IBMMockHttp)
     IBMMockHttp.type = None
     self.driver = IBM(*IBM_PARAMS)
コード例 #5
0
 def setUp(self):
     IBM.connectionCls.conn_classes = (None, IBMMockHttp)
     IBMMockHttp.type = None
     self.driver = IBM(*IBM_PARAMS)
コード例 #6
0
ファイル: test_ibm_sbc.py プロジェクト: chicagobuss/libcloud
 def setUp(self):
     IBM.connectionCls.conn_classes = (None, IBMMockHttp)
     IBMMockHttp.type = None
     self.driver = IBM(IBM_USER, IBM_SECRET)
コード例 #7
0
ファイル: test_ibm_sbc.py プロジェクト: mlibcloud/mlibcloud
class IBMTests(unittest.TestCase, TestCaseMixin):
    """
    Tests the IBM Developer Cloud driver.
    """
    def setUp(self):
        IBM.connectionCls.conn_classes = (None, IBMMockHttp)
        IBMMockHttp.type = None
        self.driver = IBM(*IBM_PARAMS)

    def test_auth(self):
        IBMMockHttp.type = 'UNAUTHORIZED'

        try:
            self.driver.list_nodes()
        except InvalidCredsError:
            e = sys.exc_info()[1]
            self.assertTrue(isinstance(e, InvalidCredsError))
            self.assertEquals(e.value, '401: Unauthorized')
        else:
            self.fail('test should have thrown')

    def test_list_nodes(self):
        ret = self.driver.list_nodes()
        self.assertEquals(len(ret), 3)
        self.assertEquals(ret[0].id, '26557')
        self.assertEquals(ret[0].name, 'Insight Instance')
        self.assertEquals(ret[0].public_ips, ['129.33.196.128'])
        self.assertEquals(ret[0].private_ips, [])  # Private IPs not supported
        self.assertEquals(ret[1].public_ips, [])  # Node is non-active (no IP)
        self.assertEquals(ret[1].private_ips, [])
        self.assertEquals(ret[1].id, '28193')

    def test_list_sizes(self):
        ret = self.driver.list_sizes()
        self.assertEquals(len(ret), 9)  # 9 instance configurations supported
        self.assertEquals(ret[0].id, 'BRZ32.1/2048/60*175')
        self.assertEquals(ret[1].id, 'BRZ64.2/4096/60*500*350')
        self.assertEquals(ret[2].id, 'COP32.1/2048/60')
        self.assertEquals(ret[0].name, 'Bronze 32 bit')
        self.assertEquals(ret[0].disk, None)

    def test_list_images(self):
        ret = self.driver.list_images()
        self.assertEqual(len(ret), 21)
        self.assertEqual(ret[10].name, "Rational Asset Manager 7.2.0.1")
        self.assertEqual(ret[9].id, '10002573')

    def test_list_locations(self):
        ret = self.driver.list_locations()
        self.assertEquals(len(ret), 1)
        self.assertEquals(ret[0].id, '1')
        self.assertEquals(ret[0].name, 'US North East: Poughkeepsie, NY')
        self.assertEquals(ret[0].country, 'US')

    def test_create_node(self):
        # Test creation of node
        IBMMockHttp.type = 'CREATE'
        image = NodeImage(id=11, name='Rational Insight', driver=self.driver)
        size = NodeSize('LARGE', 'LARGE', None, None, None, None, self.driver)
        location = NodeLocation('1', 'POK', 'US', driver=self.driver)
        ret = self.driver.create_node(name='RationalInsight4',
                                      image=image,
                                      size=size,
                                      location=location,
                                      publicKey='MyPublicKey',
                                      configurationData={
                                          'insight_admin_password':
                                          '******',
                                          'db2_admin_password': '******',
                                          'report_user_password': '******'
                                      })
        self.assertTrue(isinstance(ret, Node))
        self.assertEquals(ret.name, 'RationalInsight4')

        # Test creation attempt with invalid location
        IBMMockHttp.type = 'CREATE_INVALID'
        location = NodeLocation('3', 'DOESNOTEXIST', 'US', driver=self.driver)
        try:
            ret = self.driver.create_node(name='RationalInsight5',
                                          image=image,
                                          size=size,
                                          location=location,
                                          publicKey='MyPublicKey',
                                          configurationData={
                                              'insight_admin_password':
                                              '******',
                                              'db2_admin_password':
                                              '******',
                                              'report_user_password':
                                              '******'
                                          })
        except Exception:
            e = sys.exc_info()[1]
            self.assertEquals(e.args[0], 'Error 412: No DataCenter with id: 3')
        else:
            self.fail('test should have thrown')

    def test_destroy_node(self):
        # Delete existant node
        nodes = self.driver.list_nodes()  # retrieves 3 nodes
        self.assertEquals(len(nodes), 3)
        IBMMockHttp.type = 'DELETE'
        toDelete = nodes[1]
        ret = self.driver.destroy_node(toDelete)
        self.assertTrue(ret)

        # Delete non-existant node
        IBMMockHttp.type = 'DELETED'
        nodes = self.driver.list_nodes()  # retrieves 2 nodes
        self.assertEquals(len(nodes), 2)
        try:
            self.driver.destroy_node(toDelete)  # delete non-existent node
        except Exception:
            e = sys.exc_info()[1]
            self.assertEquals(e.args[0],
                              'Error 404: Invalid Instance ID 28193')
        else:
            self.fail('test should have thrown')

    def test_reboot_node(self):
        nodes = self.driver.list_nodes()
        IBMMockHttp.type = 'REBOOT'

        # Reboot active node
        self.assertEquals(len(nodes), 3)
        ret = self.driver.reboot_node(nodes[0])
        self.assertTrue(ret)

        # Reboot inactive node
        try:
            ret = self.driver.reboot_node(nodes[1])
        except Exception:
            e = sys.exc_info()[1]
            self.assertEquals(
                e.args[0], 'Error 412: Instance must be in the Active state')
        else:
            self.fail('test should have thrown')