Store PBM wsdl in the oslo.vmware git repository

Currently, Cinder stores the PBM WSDL files in its own repository
(see commit: 10c5c93925abe3d34c4430e0ed852d8358fb2353). Now that other
projects are leveraging SPBM, we need to provide them the ability
to directly access those WSDL files without having to store them or
referencing them.

This patch (strongly inspired by the patch mentioned above) adds two
utility APIs and unit tests for it:
- get_pbm_wsdl_location()
- get_vc_version()

Change-Id: I61abc5879e71a7f5e5f46d2ec88404923e0423d8
This commit is contained in:
Arnaud Legendre
2014-06-24 19:12:06 -07:00
parent 05ef356b3d
commit dbcb5f9d1e
10 changed files with 2108 additions and 0 deletions

View File

@@ -17,6 +17,10 @@
Unit tests for PBM utility methods.
"""
import os
import urllib
import urlparse
import mock
from oslo.vmware import pbm
@@ -145,3 +149,27 @@ class PBMUtilityTest(base.TestCase):
self.assertEqual(len(hubs), len(filtered_ds))
filtered_ds_values = [ds.value for ds in filtered_ds]
self.assertEqual(set(hub_ids), set(filtered_ds_values))
def test_get_pbm_wsdl_location(self):
wsdl = pbm.get_pbm_wsdl_location(None)
self.assertIsNone(wsdl)
def expected_wsdl(version):
driver_dir = os.path.join(os.path.dirname(__file__), '..',
'oslo', 'vmware')
driver_abs_dir = os.path.abspath(driver_dir)
path = os.path.join(driver_abs_dir, 'wsdl', version,
'pbmService.wsdl')
return urlparse.urljoin('file:', urllib.pathname2url(path))
with mock.patch('os.path.exists') as path_exists:
path_exists.return_value = True
wsdl = pbm.get_pbm_wsdl_location('5')
self.assertEqual(expected_wsdl('5'), wsdl)
wsdl = pbm.get_pbm_wsdl_location('5.5')
self.assertEqual(expected_wsdl('5.5'), wsdl)
wsdl = pbm.get_pbm_wsdl_location('5.5.1')
self.assertEqual(expected_wsdl('5.5'), wsdl)
path_exists.return_value = False
wsdl = pbm.get_pbm_wsdl_location('5.5')
self.assertIsNone(wsdl)

View File

@@ -308,3 +308,14 @@ class VimUtilTest(base.TestCase):
service_content = vim.service_content
vim.client.service.RegisterExtension.assert_called_once_with(
service_content.extensionManager, mock.ANY)
def test_get_vc_version(self):
session = mock.Mock()
expected_version = '6.0.1'
session.vim.service_content.about.version = expected_version
version = vim_util.get_vc_version(session)
self.assertEqual(expected_version, version)
expected_version = '5.5'
session.vim.service_content.about.version = expected_version
version = vim_util.get_vc_version(session)
self.assertEqual(expected_version, version)