def test_version_all_cells_exclude_zero_service(self, mock_scatter): mock_scatter.return_value = { 'foo': {'nova-compute': 13}, 'bar': {'nova-compute': 0}, } self.assertEqual(13, service.get_minimum_version_all_cells( self.context, ['nova-compute']))
def _should_enable_custom_max_server_rules(context, rules): if rules and int(rules.get('max_server_per_host', 1)) > 1: minver = service.get_minimum_version_all_cells(context, ['nova-compute']) if minver < 33: return False return True
def test_version_all_cells_exclude_zero_service(self, mock_scatter): mock_scatter.return_value = { 'foo': {'nova-compute': 13}, 'bar': {'nova-compute': 0}, } self.assertEqual(13, service.get_minimum_version_all_cells( self.context, ['nova-compute']))
def _should_enable_custom_max_server_rules(context, rules): if rules and int(rules.get('max_server_per_host', 1)) > 1: minver = service.get_minimum_version_all_cells( context, ['nova-compute']) if minver < 33: return False return True
def raise_if_old_compute(): # to avoid circular imports from nova import context as nova_context from nova.objects import service ctxt = nova_context.get_admin_context() if CONF.api_database.connection is not None: scope = 'system' current_service_version = service.get_minimum_version_all_cells( ctxt, ['nova-compute']) else: scope = 'cell' # We in a cell so target our query to the current cell only current_service_version = service.Service.get_minimum_version( ctxt, 'nova-compute') if current_service_version == 0: # 0 means no compute in the system, # probably a fresh install before the computes are registered return oldest_supported_service_level = service.SERVICE_VERSION_ALIASES[ service.OLDEST_SUPPORTED_SERVICE_VERSION] if current_service_version < oldest_supported_service_level: raise exception.TooOldComputeService( oldest_supported_version=service.OLDEST_SUPPORTED_SERVICE_VERSION, scope=scope, min_service_level=current_service_version, oldest_supported_service=oldest_supported_service_level)
def supports_port_resource_request_during_move(): """Check to see if the global compute service version is high enough to support port resource request during move operation. :returns: True if the compute service version is high enough for port resource request move support, False otherwise. """ return service.get_minimum_version_all_cells( nova_context.get_admin_context(), ['nova-compute']) >= 49
def test_version_all_cells_with_timeout(self, mock_scatter): mock_scatter.return_value = { 'foo': {'nova-compute': 13}, 'bar': context.did_not_respond_sentinel, } self.assertEqual(13, service.get_minimum_version_all_cells( self.context, ['nova-compute'])) self.assertRaises(exception.CellTimeout, service.get_minimum_version_all_cells, self.context, ['nova-compute'], require_all=True)
def test_version_all_cells_with_fail(self, mock_scatter): mock_scatter.return_value = { 'foo': {'nova-compute': 13}, 'bar': exception.ServiceNotFound(service_id='fake'), } self.assertEqual(13, service.get_minimum_version_all_cells( self.context, ['nova-compute'])) self.assertRaises(exception.CellTimeout, service.get_minimum_version_all_cells, self.context, ['nova-compute'], require_all=True)
def test_version_all_cells_with_timeout(self, mock_scatter): mock_scatter.return_value = { 'foo': {'nova-compute': 13}, 'bar': context.did_not_respond_sentinel, } self.assertEqual(13, service.get_minimum_version_all_cells( self.context, ['nova-compute'])) self.assertRaises(exception.CellTimeout, service.get_minimum_version_all_cells, self.context, ['nova-compute'], require_all=True)
def test_version_all_cells_with_fail(self, mock_scatter): mock_scatter.return_value = { 'foo': {'nova-compute': 13}, 'bar': exception.ServiceNotFound(service_id='fake'), } self.assertEqual(13, service.get_minimum_version_all_cells( self.context, ['nova-compute'])) self.assertRaises(exception.CellTimeout, service.get_minimum_version_all_cells, self.context, ['nova-compute'], require_all=True)
def raise_if_old_compute(): # to avoid circular imports from nova import context as nova_context from nova.objects import service ctxt = nova_context.get_admin_context() if CONF.api_database.connection is not None: scope = 'system' try: current_service_version = service.get_minimum_version_all_cells( ctxt, ['nova-compute']) except exception.DBNotAllowed: # This most likely means we are in a nova-compute service # configured which is configured with a connection to the API # database. We should not be attempting to "get out" of our cell to # look at the minimum versions of nova-compute services in other # cells, so DBNotAllowed was raised. Leave a warning message # and fall back to only querying computes in our cell. LOG.warning( 'This service is configured for access to the API database ' 'but is not allowed to directly access the database. You ' 'should run this service without the ' '[api_database]/connection config option. The service version ' 'check will only query the local cell.') scope = 'cell' current_service_version = service.Service.get_minimum_version( ctxt, 'nova-compute') else: scope = 'cell' # We in a cell so target our query to the current cell only current_service_version = service.Service.get_minimum_version( ctxt, 'nova-compute') if current_service_version == 0: # 0 means no compute in the system, # probably a fresh install before the computes are registered return oldest_supported_service_level = service.SERVICE_VERSION_ALIASES[ service.OLDEST_SUPPORTED_SERVICE_VERSION] if current_service_version < oldest_supported_service_level: raise exception.TooOldComputeService( oldest_supported_version=service.OLDEST_SUPPORTED_SERVICE_VERSION, scope=scope, min_service_level=current_service_version, oldest_supported_service=oldest_supported_service_level)
def test_version_all_cells(self, mock_check): self._create_services(16, 16, 13, 16) self.assertEqual( 13, service.get_minimum_version_all_cells(self.context, ['nova-compute']))
def test_version_all_cells(self, mock_check): self._create_services(16, 16, 13, 16) self.assertEqual(13, service.get_minimum_version_all_cells( self.context, ['nova-compute']))