Exemple #1
0
 def test_init_errors(self):
     with self.assertRaises(ValueError):
         vmware.VSphereConnection('test-user', 'test-password')
     with self.assertRaises(ValueError):
         vmware.VSphereConnection('test-user',
                                  'test-password',
                                  url='https://test-vcenter.host',
                                  host='test-vcenter.host')
Exemple #2
0
 def test_connect_with_invalid_username(self, connect_fn):
     conn = vmware.VSphereConnection('user', 'pass', url='http://url.com')
     connect_fn.SmartConnect.side_effect = Exception('incorrect user name')
     with self.assertRaises(common_types.InvalidCredsError) as ctx:
         conn.connect()
     self.assertEqual(ctx.exception.value,
                      "Check that your username and password are valid.")
Exemple #3
0
    def test_connect_to_unknown_host(self, connect_fn):
        conn = vmware.VSphereConnection('user', 'pass', url='http://url.com')
        connect_fn.SmartConnect.side_effect = Exception(
            'name or service not known')

        with self.assertRaises(common_types.LibcloudError) as ctx:
            conn.connect()
        self.assertEqual(
            ctx.exception.value,
            "Check that the vSphere (http://url.com:80/sdk) is accessible.")
Exemple #4
0
    def test_connection_refused(self, connect_fn):
        conn = vmware.VSphereConnection('user', 'pass', url='http://url.com')
        connect_fn.SmartConnect.side_effect = Exception('connection refused')

        with self.assertRaises(common_types.LibcloudError) as ctx:
            conn.connect()
        err_msg = \
            "Check that the host provided (http://url.com:80/sdk) is a " \
            "vSphere installation."
        self.assertEqual(ctx.exception.value, err_msg)
Exemple #5
0
    def test_connect(self, create_context_fn, connect_fn):
        connection = vmware.VSphereConnection('test-user',
                                              'test-password',
                                              url='https://test-vcenter.host')
        connection.connect()

        connect_fn.SmartConnect.assert_called_once_with(
            protocol='https',
            host='test-vcenter.host',
            port=443,
            user='******',
            pwd='test-password',
            path='/sdk',
            sslContext=create_context_fn.return_value)