Advertisement
Guest User

Untitled

a guest
Jun 10th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. *** Test ***
  2. def test__udev_settle(self, mocked_execute):
  3. hardware._udev_settle()
  4. mocked_execute.assert_called_once_with('udevadm', 'settle')
  5.  
  6. + def test__check_for_iscsi_f(self,mocked_execute):
  7. + hardware._check_for_iscsi()
  8. + mocked_execute.assert_called_with('iscsistart', '-f')
  9.  
  10.  
  11.  
  12. ***code***
  13.  
  14. def _udev_settle():
  15. """Wait for the udev event queue to settle.
  16.  
  17. Wait for the udev event queue to settle to make sure all devices
  18. are detected once the machine boots up.
  19.  
  20. """
  21. try:
  22. utils.execute('udevadm', 'settle')
  23. except processutils.ProcessExecutionError as e:
  24. LOG.warning('Something went wrong when waiting for udev '
  25. 'to settle. Error: %s', e)
  26. return
  27.  
  28.  
  29. +def _check_for_iscsi():
  30. + """iscsi detection
  31. +
  32. + iscsistart -f will print the iBFT or OF info.
  33. + In case such connection exists, we would like to issue
  34. + iscsistart -b to create a session to the target.
  35. + - if no connection is detected we simply return.
  36. + """
  37. + try:
  38. + utils.execute('iscsistart', '-f')
  39. + except (processutils.ProcessExecutionError, EnvironmentError) as e:
  40. + LOG.debug('No iscsi connection detected. Skipping iscsi.'
  41. + 'Error: %s', e)
  42. + return
  43. + try:
  44. + utils.execute('iscsistart', '-b')
  45. + except processutils.ProcessExecutionError as e:
  46. + LOG.warning('Something went wrong executing iscsistart -b'
  47. + 'Error: %s', e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement