Use keyword argument for boolean flags
Using keyword arguments makes the intent of the code clearer, due to the fact that a name is attached to a boolean value, making the reasoning about the code easier. Change-Id: I0dd05fa521ed8bbaf1c6dbd7a3e554384642c1f4
This commit is contained in:
parent
abc52448ff
commit
3f91aabce2
@ -70,5 +70,5 @@ class ConfigDriveService(baseopenstackservice.BaseOpenStackService):
|
||||
def cleanup(self):
|
||||
if self._metadata_path:
|
||||
LOG.debug('Deleting metadata folder: \'%s\'' % self._metadata_path)
|
||||
shutil.rmtree(self._metadata_path, True)
|
||||
shutil.rmtree(self._metadata_path, ignore_errors=True)
|
||||
self._metadata_path = None
|
||||
|
@ -355,12 +355,12 @@ class WindowsUtils(base.BaseOSUtils):
|
||||
return True
|
||||
|
||||
def create_user(self, username, password, password_expires=False):
|
||||
self._create_or_change_user(username, password, True,
|
||||
password_expires)
|
||||
self._create_or_change_user(username, password, create=True,
|
||||
password_expires=password_expires)
|
||||
|
||||
def set_user_password(self, username, password, password_expires=False):
|
||||
self._create_or_change_user(username, password, False,
|
||||
password_expires)
|
||||
self._create_or_change_user(username, password, create=False,
|
||||
password_expires=password_expires)
|
||||
|
||||
def _get_user_sid_and_domain(self, username):
|
||||
sid = ctypes.create_string_buffer(1024)
|
||||
@ -479,7 +479,7 @@ class WindowsUtils(base.BaseOSUtils):
|
||||
args = [w32tm_path, '/config', '/manualpeerlist:%s' % ntp_host,
|
||||
'/syncfromflags:manual', '/update']
|
||||
|
||||
(out, err, ret_val) = self.execute_process(args, False)
|
||||
(out, err, ret_val) = self.execute_process(args, shell=False)
|
||||
if ret_val:
|
||||
raise exception.CloudbaseInitException(
|
||||
'w32tm failed to configure NTP.\nOutput: %(out)s\nError:'
|
||||
@ -513,7 +513,7 @@ class WindowsUtils(base.BaseOSUtils):
|
||||
args = [netsh_path, "interface", "ipv4", "set", "subinterface",
|
||||
str(iface_index), "mtu=%s" % mtu,
|
||||
"store=persistent"]
|
||||
(out, err, ret_val) = self.execute_process(args, False)
|
||||
(out, err, ret_val) = self.execute_process(args, shell=False)
|
||||
if ret_val:
|
||||
raise exception.CloudbaseInitException(
|
||||
'Setting MTU for interface "%(mac_address)s" with '
|
||||
@ -956,4 +956,4 @@ class WindowsUtils(base.BaseOSUtils):
|
||||
args = [powershell_path, '-ExecutionPolicy', 'RemoteSigned',
|
||||
'-NonInteractive', '-File', script_path]
|
||||
|
||||
return self.execute_process(args, False)
|
||||
return self.execute_process(args, shell=False)
|
||||
|
@ -46,7 +46,7 @@ class WindowsLicensingPlugin(base.BasePlugin):
|
||||
slmgr_path = os.path.join(slmgr_dir, "slmgr.vbs")
|
||||
|
||||
(out, err, exit_code) = osutils.execute_process(
|
||||
[cscript_path, slmgr_path] + args, False, True)
|
||||
[cscript_path, slmgr_path] + args, shell=False, decode_output=True)
|
||||
|
||||
if exit_code:
|
||||
raise exception.CloudbaseInitException(
|
||||
|
@ -1283,7 +1283,7 @@ class WindowsUtilsTest(unittest.TestCase):
|
||||
else:
|
||||
mock_get_system32_dir.assert_called_once_with()
|
||||
|
||||
mock_execute_process.assert_called_with(args, False)
|
||||
mock_execute_process.assert_called_with(args, shell=False)
|
||||
self.assertEqual(mock_execute_process.return_value, response)
|
||||
|
||||
def test_execute_powershell_script_sysnative(self):
|
||||
@ -1342,7 +1342,7 @@ class WindowsUtilsTest(unittest.TestCase):
|
||||
else:
|
||||
mock_get_system32_dir.assert_called_once_with()
|
||||
|
||||
mock_execute_process.assert_called_once_with(args, False)
|
||||
mock_execute_process.assert_called_once_with(args, shell=False)
|
||||
|
||||
def test_set_ntp_client_config_sysnative_true(self):
|
||||
self._test_set_ntp_client_config(sysnative=True, ret_val=None)
|
||||
|
@ -64,7 +64,8 @@ class WindowsLicensingPluginTests(unittest.TestCase):
|
||||
get_system32_dir_calls.append(mock.call())
|
||||
|
||||
mock_osutils.execute_process.assert_called_once_with(
|
||||
[cscript_path, slmgr_path, 'fake args'], False, True)
|
||||
[cscript_path, slmgr_path, 'fake args'],
|
||||
shell=False, decode_output=True)
|
||||
self.assertEqual(get_system32_dir_calls,
|
||||
mock_osutils.get_system32_dir.call_args_list)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user