# Path: networking_vsphere/drivers/manager.py
# LOG = log.getLogger(__name__)
# class VcenterManager(base_manager.DriverManager):
#     def __init__(self, netcallback):
#     def _parse_mapping(self, entry):
#     def _add_cluster(self, cluster, vds):
#     def initialize_driver(self):
#     def start(self):
#     def pause(self):
#     def stop(self):
# 
# Path: networking_vsphere/tests/base.py
# CONF = cfg.CONF
# class TestCase(base.BaseTestCase):
#     def setUp(self):
#     def setup_rpc_mocks(self):
#     def flags(self, **kw):
#     def reset_flags(self):
#     def del_attributes(self):
# 
# Path: networking_vsphere/utils/vim_session.py
# LOG = log.getLogger(__name__)
# class ConnectionHandler(object):
# class VMWareAPISession(api.VMwareAPISession):
#     def set_vc_details(cls, host_ip, host_username, host_password,
#                        api_retry_count, wsdl_url, ca_cert,
#                        https_port=443, scheme="https"):
#     def stop(cls):
#     def start(cls):
#     def create_connection(cls):
#     def get_connection(cls, create=False):
#     def try_connection(cls):
#     def __init__(self, host_ip, host_username, host_password,
#                  api_retry_count, wsdl_url, scheme="https", https_port=443,
#                  create_session=True, ca_cert=None):
#     def __del__(self):
#     def _is_vim_object(self, module):
#     def _call_method(self, module, method, *args, **kwargs):
#     def _get_vim(self):


import eventlet
import mock
import os
from networking_vsphere.drivers import dvs_driver
from networking_vsphere.drivers import manager
from networking_vsphere.drivers import vc_driver
from networking_vsphere.tests import base
from networking_vsphere.tests.unit.drivers import fake_driver
from networking_vsphere.tests.unit.utils import stubs
from networking_vsphere.utils import vim_session
        self.flags(vcenter_ip="vcenter.test.com", group='VMWARE')
        self.flags(vcenter_username="fake_user", group='VMWARE')
        self.flags(vcenter_password="fake_pass", group='VMWARE')
        self.flags(vcenter_api_retry_count="1", group='VMWARE')
        self.flags(wsdl_location="http://fake.test.com", group='VMWARE')
        self.flags(cert_check=True, group='VMWARE')
        self.flags(cert_path=ca_path, group='VMWARE')
        self.flags(cluster_dvs_mapping=fake_tuple, group='VMWARE')
        with mock.patch.object(vim_session.ConnectionHandler, "stop",
                               return_value=None), \
                mock.patch.object(eventlet, "spawn"), \
                mock.patch.object(vc_driver.VCNetworkDriver, "add_cluster",
                                  return_value=True), \
                mock.patch.object(os.path, "isfile", return_value=True):
            self.assertEqual(len(self.manager.cluster_switch_mapping), 0)
            self.manager.initialize_driver()
            self.assertIsNotNone(self.manager.driver)
            self.assertEqual(len(self.manager.cluster_switch_mapping), 1)
            self.assertEqual(self.manager.ca_path, ca_path)

    def test_initialize_driver_with_cert_check_false_and_cert_path(self):
        fake_tuple = ["dc/host/cluster1:dvs1"]
        self.flags(vcenter_ip="vcenter.test.com", group='VMWARE')
        self.flags(vcenter_username="fake_user", group='VMWARE')
        self.flags(vcenter_password="fake_pass", group='VMWARE')
        self.flags(vcenter_api_retry_count="1", group='VMWARE')
        self.flags(wsdl_location="http://fake.test.com", group='VMWARE')
        self.flags(cert_check=False, group='VMWARE')
        self.flags(cert_path="/etc/ssl/certs/certs.pem", group='VMWARE')
        self.flags(cluster_dvs_mapping=fake_tuple, group='VMWARE')

# Path: networking_vsphere/drivers/manager.py
# LOG = log.getLogger(__name__)
# class VcenterManager(base_manager.DriverManager):
#     def __init__(self, netcallback):
#     def _parse_mapping(self, entry):
#     def _add_cluster(self, cluster, vds):
#     def initialize_driver(self):
#     def start(self):
#     def pause(self):
#     def stop(self):
# 
# Path: networking_vsphere/tests/base.py
# CONF = cfg.CONF
# class TestCase(base.BaseTestCase):
#     def setUp(self):
#     def setup_rpc_mocks(self):
#     def flags(self, **kw):
#     def reset_flags(self):
#     def del_attributes(self):
# 
# Path: networking_vsphere/utils/vim_session.py
# LOG = log.getLogger(__name__)
# class ConnectionHandler(object):
# class VMWareAPISession(api.VMwareAPISession):
#     def set_vc_details(cls, host_ip, host_username, host_password,
#                        api_retry_count, wsdl_url, ca_cert,
#                        https_port=443, scheme="https"):
#     def stop(cls):
#     def start(cls):
#     def create_connection(cls):
#     def get_connection(cls, create=False):
#     def try_connection(cls):
#     def __init__(self, host_ip, host_username, host_password,
#                  api_retry_count, wsdl_url, scheme="https", https_port=443,
#                  create_session=True, ca_cert=None):
#     def __del__(self):
#     def _is_vim_object(self, module):
#     def _call_method(self, module, method, *args, **kwargs):
#     def _get_vim(self):


# Path: networking_vsphere/tests/unit/drivers/test_manager.py
import eventlet
import mock
import os
from networking_vsphere.drivers import dvs_driver
from networking_vsphere.drivers import manager
from networking_vsphere.drivers import vc_driver
from networking_vsphere.tests import base
from networking_vsphere.tests.unit.drivers import fake_driver
from networking_vsphere.tests.unit.utils import stubs
from networking_vsphere.utils import vim_session

        self.flags(vcenter_ip="vcenter.test.com", group='VMWARE')
        self.flags(vcenter_username="fake_user", group='VMWARE')
        self.flags(vcenter_password="fake_pass", group='VMWARE')
        self.flags(vcenter_api_retry_count="1", group='VMWARE')
        self.flags(wsdl_location="http://fake.test.com", group='VMWARE')
        self.flags(cert_check=True, group='VMWARE')
        self.flags(cert_path=ca_path, group='VMWARE')
        self.flags(cluster_dvs_mapping=fake_tuple, group='VMWARE')
        with mock.patch.object(vim_session.ConnectionHandler, "stop",
                               return_value=None), \
                mock.patch.object(eventlet, "spawn"), \
                mock.patch.object(vc_driver.VCNetworkDriver, "add_cluster",
                                  return_value=True), \
                mock.patch.object(os.path, "isfile", return_value=True):
            self.assertEqual(len(self.manager.cluster_switch_mapping), 0)
            self.manager.initialize_driver()
            self.assertIsNotNone(self.manager.driver)
            self.assertEqual(len(self.manager.cluster_switch_mapping), 1)
            self.assertEqual(self.manager.ca_path, ca_path)

    def test_initialize_driver_with_cert_check_false_and_cert_path(self):
        fake_tuple = ["dc/host/cluster1:dvs1"]
        self.flags(vcenter_ip="vcenter.test.com", group='VMWARE')
        self.flags(vcenter_username="fake_user", group='VMWARE')
        self.flags(vcenter_password="fake_pass", group='VMWARE')
        self.flags(vcenter_api_retry_count="1", group='VMWARE')
        self.flags(wsdl_location="http://fake.test.com", group='VMWARE')
        self.flags(cert_check=False, group='VMWARE')
        self.flags(cert_path="/etc/ssl/certs/certs.pem", group='VMWARE')
        self.flags(cluster_dvs_mapping=fake_tuple, group='VMWARE')

        with mock.patch.object(vim_session.ConnectionHandler, "stop",