remove(dep): Remove dep on plumbum

- Plumbum is not on the openstack global requirements list, and removing
  it as a requirement is a prerequisite to being accepted as an
  Openstack project
This commit is contained in:
Jay Faulkner 2014-03-05 16:29:58 -08:00
parent 8b60c1c8b4
commit 88980766cd
3 changed files with 9 additions and 12 deletions

View File

@ -1,6 +1,5 @@
Werkzeug==0.9.4
requests==2.0.0
cherrypy==3.2.4
plumbum==1.4.0
stevedore==0.13
-e git+https://github.com/racker/teeth-rest.git@e876c0fddd5ce2f5223ab16936f711b0d57e19c4#egg=teeth_rest

View File

@ -17,8 +17,8 @@ limitations under the License.
import abc
import collections
import os
import subprocess
import plumbum
import stevedore
import structlog
@ -121,14 +121,14 @@ class GenericHardwareManager(HardwareManager):
for name in iface_names
if self._is_device(name)]
def _cmd(self, command_name):
"""Mocking plumbum is frustratingly difficult. Instead, mock this."""
return plumbum.local[command_name]
def _cmd(self, command):
process = subprocess.Popen(command, stdout=subprocess.PIPE)
return process.communicate()
def _list_block_devices(self):
report = self._cmd('blockdev')('--report').strip()
report = self._cmd(['blockdev', '--report'])[0]
lines = report.split('\n')
lines = [line.split() for line in lines]
lines = [line.split() for line in lines if line is not '']
startsec_idx = lines[0].index('StartSec')
device_idx = lines[0].index('Device')
size_idx = lines[0].index('Size')

View File

@ -41,18 +41,16 @@ class TestGenericHardwareManager(unittest.TestCase):
def test_get_os_install_device(self):
self.hardware._cmd = mock.Mock()
self.hardware._cmd.return_value = blockdev = mock.Mock()
blockdev.return_value = (
self.hardware._cmd.return_value = (
'RO RA SSZ BSZ StartSec Size Device\n'
'rw 256 512 4096 0 249578283616 /dev/sda\n'
'rw 256 512 4096 2048 8587837440 /dev/sda1\n'
'rw 256 512 4096 124967424 15728640 /dev/sda2\n'
'rw 256 512 4096 0 31016853504 /dev/sdb\n'
'rw 256 512 4096 0 249578283616 /dev/sdc\n')
'rw 256 512 4096 0 249578283616 /dev/sdc\n', '')
self.assertEqual(self.hardware.get_os_install_device(), '/dev/sdb')
self.hardware._cmd.assert_called_once_with('blockdev')
blockdev.assert_called_once_with('--report')
self.hardware._cmd.assert_called_once_with(['blockdev', '--report'])
def test_list_hardwre_info(self):
self.hardware.list_network_interfaces = mock.Mock()