Do not run slmgr.vbs on Nano Server
Licensing info and activation do not apply to Nano Server. Co-Authored-By: Cosmin Poieana <cpoieana@cloudbasesolutions.com> Change-Id: Icab01ab3e9d43be5f8be2920af803f6e294095c4 Closes-Bug: #1495306
This commit is contained in:
parent
69a18423f4
commit
1117441f32
@ -60,12 +60,16 @@ class WindowsLicensingPlugin(base.BasePlugin):
|
||||
def execute(self, service, shared_data):
|
||||
osutils = osutils_factory.get_os_utils()
|
||||
|
||||
license_info = self._run_slmgr(osutils, ['/dlv'])
|
||||
LOG.info('Microsoft Windows license info:\n%s' % license_info)
|
||||
if osutils.is_nano_server():
|
||||
LOG.info("Licensing info and activation are not available on "
|
||||
"Nano Server")
|
||||
else:
|
||||
license_info = self._run_slmgr(osutils, ['/dlv'])
|
||||
LOG.info('Microsoft Windows license info:\n%s' % license_info)
|
||||
|
||||
if CONF.activate_windows:
|
||||
LOG.info("Activating Windows")
|
||||
activation_result = self._run_slmgr(osutils, ['/ato'])
|
||||
LOG.debug("Activation result:\n%s" % activation_result)
|
||||
if CONF.activate_windows:
|
||||
LOG.info("Activating Windows")
|
||||
activation_result = self._run_slmgr(osutils, ['/ato'])
|
||||
LOG.debug("Activation result:\n%s" % activation_result)
|
||||
|
||||
return base.PLUGIN_EXECUTION_DONE, False
|
||||
|
@ -81,8 +81,9 @@ class WindowsLicensingPluginTests(unittest.TestCase):
|
||||
@mock.patch('cloudbaseinit.plugins.windows.licensing'
|
||||
'.WindowsLicensingPlugin._run_slmgr')
|
||||
def _test_execute(self, mock_run_slmgr, mock_get_os_utils,
|
||||
activate_windows):
|
||||
activate_windows=None, nano=False):
|
||||
mock_osutils = mock.MagicMock()
|
||||
mock_osutils.is_nano_server.return_value = nano
|
||||
run_slmgr_calls = [mock.call(mock_osutils, ['/dlv'])]
|
||||
mock_get_os_utils.return_value = mock_osutils
|
||||
|
||||
@ -90,6 +91,8 @@ class WindowsLicensingPluginTests(unittest.TestCase):
|
||||
response = self._licensing.execute(service=None, shared_data=None)
|
||||
|
||||
mock_get_os_utils.assert_called_once_with()
|
||||
if nano:
|
||||
return # no activation available
|
||||
if activate_windows:
|
||||
run_slmgr_calls.append(mock.call(mock_osutils, ['/ato']))
|
||||
|
||||
@ -101,3 +104,6 @@ class WindowsLicensingPluginTests(unittest.TestCase):
|
||||
|
||||
def test_execute_activate_windows_false(self):
|
||||
self._test_execute(activate_windows=False)
|
||||
|
||||
def test_execute_activate_windows_nano(self):
|
||||
self._test_execute(nano=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user