Skip to content

Commit

Permalink
Make service-list output consistent
Browse files Browse the repository at this point in the history
When libvirt automatic disable/enable services, the disabled
reason will be 'None'. However, the column is Nullable and
make it 'None' let the service-list output inconsistent.
This patch changes the default value to NULL.

Change-Id: I958accb500b4b417d755cff8df8ef7d615b710c0
Closes-Bug: #1401480
  • Loading branch information
jichenjc committed Jan 9, 2015
1 parent 68e417f commit 66cad4c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nova/tests/unit/virt/libvirt/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7731,7 +7731,7 @@ def test_service_resume_after_broken_connection(self):
conn.init_host("wibble")
conn.get_num_instances()
self.assertTrue(not service_mock.disabled and
service_mock.disabled_reason is 'None')
service_mock.disabled_reason is None)

def test_immediate_delete(self):
def fake_lookup_by_name(instance_name):
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/unit/virt/test_virt_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ def test_set_host_enabled_when_auto_disabled(self):
return_value=service_mock):
self.connection._set_host_enabled(True)
self.assertFalse(service_mock.disabled)
self.assertEqual(service_mock.disabled_reason, 'None')
self.assertIsNone(service_mock.disabled_reason)

def test_set_host_enabled_when_manually_disabled(self):
self.mox.UnsetStubs()
Expand Down
4 changes: 1 addition & 3 deletions nova/virt/libvirt/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
# The libvirt driver will prefix any disable reason codes with this string.
DISABLE_PREFIX = 'AUTO: '
# Disable reason for the service which was enabled or disabled without reason
DISABLE_REASON_UNDEFINED = 'None'
DISABLE_REASON_UNDEFINED = None

# Guest config console string
CONSOLE = "console=tty0 console=ttyS0"
Expand Down Expand Up @@ -509,8 +509,6 @@ def _do_quality_warnings(self):
def _handle_conn_event(self, enabled, reason):
LOG.info(_LI("Connection event '%(enabled)d' reason '%(reason)s'"),
{'enabled': enabled, 'reason': reason})
if reason is None:
reason = DISABLE_REASON_UNDEFINED
self._set_host_enabled(enabled, reason)

def init_host(self, host):
Expand Down

0 comments on commit 66cad4c

Please sign in to comment.