Beispiel #1
0
 def test_stop(self, mock_conn_stop):
     mock_conn_stop.return_value = None
     with mock.patch.object(dvs_driver.DvsNetworkDriver, "stop"
                            ) as mock_dvs_stop:
         self.manager.driver = dvs_driver.DvsNetworkDriver()
         self.manager.stop()
         self.assertTrue(mock_dvs_stop.called)
 def setUp(self):
     super(TestDvsDriver, self).setUp()
     self.cluster_dvs_mapping = {"ClusterComputeResource": "test_dvs"}
     self.fake_visdk = self.useFixture(stubs.FakeVmware())
     self.session = self.fake_visdk.session
     self.useFixture(stubs.CacheFixture())
     self.vc_driver = dvs_driver.DvsNetworkDriver()
     self.vc_driver.state = constants.DRIVER_RUNNING
     self.vc_driver.add_cluster("ClusterComputeResource", "test_dvs")
Beispiel #3
0
 def test_stop(self):
     with contextlib.nested(
             mock.patch.object(vim_session.ConnectionHandler,
                               "stop",
                               return_value=None),
             mock.patch.object(dvs_driver.DvsNetworkDriver,
                               "stop")) as (conn_stop, dvs_stop):
         self.manager.driver = dvs_driver.DvsNetworkDriver()
         self.manager.stop()
         self.assertTrue(dvs_stop.called)
Beispiel #4
0
 def initialize_driver(self):
     self.stop()
     self.driver = None
     self.vcenter_ip = cfg.CONF.VMWARE.vcenter_ip
     self.vcenter_username = cfg.CONF.VMWARE.vcenter_username
     self.vcenter_password = cfg.CONF.VMWARE.vcenter_password
     self.vcenter_api_retry_count = cfg.CONF.VMWARE.vcenter_api_retry_count
     self.wsdl_location = cfg.CONF.VMWARE.wsdl_location
     self.https_port = cfg.CONF.VMWARE.https_port
     self.ca_path = None
     self.connection_timeout = cfg.CONF.VMWARE.connection_timeout
     if cfg.CONF.VMWARE.cert_check:
         if not cfg.CONF.VMWARE.cert_path:
             LOG.error(
                 _LE("SSL certificate path is not defined to "
                     "establish secure vCenter connection. "
                     "Aborting agent!"))
             raise SystemExit(1)
         elif not os.path.isfile(cfg.CONF.VMWARE.cert_path):
             LOG.error(
                 _LE("SSL certificate does not exist at "
                     "the specified path %s. Aborting agent!"),
                 cfg.CONF.VMWARE.cert_path)
             raise SystemExit(1)
         else:
             self.ca_path = cfg.CONF.VMWARE.cert_path
     if (self.vcenter_ip and self.vcenter_username and self.vcenter_password
             and self.wsdl_location):
         vim_session.ConnectionHandler.set_vc_details(
             self.vcenter_ip, self.vcenter_username, self.vcenter_password,
             self.vcenter_api_retry_count, self.wsdl_location, self.ca_path,
             self.connection_timeout, self.https_port)
         vim_session.ConnectionHandler.start()
         if self.connection_thread:
             self.connection_thread.kill()
         self.connection_thread = eventlet.spawn(
             vim_session.ConnectionHandler.try_connection)
         try:
             self.connection_thread.wait()
         except greenlet.GreenletExit:
             LOG.warning(
                 _LW("Thread waiting on vCenter connection "
                     "exited."))
             return
     else:
         LOG.error(
             _LE("Must specify vcenter_ip, vcenter_username, "
                 "vcenter_password and wsdl_location."))
         return
     self.driver = dvs_driver.DvsNetworkDriver()
     self.driver.set_callback(self.netcallback)
     for mapping in cfg.CONF.VMWARE.cluster_dvs_mapping:
         cluster_dvs_list = self._parse_mapping(mapping)
         for cluster, vds in cluster_dvs_list:
             self._add_cluster(cluster, vds)
Beispiel #5
0
 def initialize_driver(self):
     self.stop()
     self.driver = None
     self.vcenter_ip = cfg.CONF.VMWARE.vcenter_ip
     self.vcenter_username = cfg.CONF.VMWARE.vcenter_username
     self.vcenter_password = cfg.CONF.VMWARE.vcenter_password
     self.vcenter_api_retry_count = cfg.CONF.VMWARE.vcenter_api_retry_count
     self.wsdl_location = cfg.CONF.VMWARE.wsdl_location
     self.https_port = cfg.CONF.VMWARE.https_port
     if (self.vcenter_ip and self.vcenter_username and self.vcenter_password
             and self.wsdl_location):
         vim_session.ConnectionHandler.set_vc_details(
             self.vcenter_ip, self.vcenter_username, self.vcenter_password,
             self.vcenter_api_retry_count, self.wsdl_location,
             self.https_port)
         vim_session.ConnectionHandler.start()
         if self.connection_thread:
             self.connection_thread.kill()
         self.connection_thread = eventlet.spawn(
             vim_session.ConnectionHandler.try_connection)
         try:
             self.connection_thread.wait()
         except greenlet.GreenletExit:
             LOG.warn(_("Thread waiting on vCenter connection exited."))
             return
     else:
         LOG.error(
             _("Must specify vcenter_ip, vcenter_username, "
               "vcenter_password and wsdl_location."))
         return
     self.driver = dvs_driver.DvsNetworkDriver()
     self.driver.set_callback(self.netcallback)
     for mapping in cfg.CONF.VMWARE.cluster_dvs_mapping:
         cluster_dvs_list = self._parse_mapping(mapping)
         for cluster, vds in cluster_dvs_list:
             self._add_cluster(cluster, vds)
Beispiel #6
0
 def test_pause(self):
     with mock.patch.object(dvs_driver.DvsNetworkDriver, "pause") as pause:
         self.manager.driver = dvs_driver.DvsNetworkDriver()
         self.manager.pause()
         self.assertTrue(pause.called)