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:
parent
8b60c1c8b4
commit
88980766cd
@ -1,6 +1,5 @@
|
|||||||
Werkzeug==0.9.4
|
Werkzeug==0.9.4
|
||||||
requests==2.0.0
|
requests==2.0.0
|
||||||
cherrypy==3.2.4
|
cherrypy==3.2.4
|
||||||
plumbum==1.4.0
|
|
||||||
stevedore==0.13
|
stevedore==0.13
|
||||||
-e git+https://github.com/racker/teeth-rest.git@e876c0fddd5ce2f5223ab16936f711b0d57e19c4#egg=teeth_rest
|
-e git+https://github.com/racker/teeth-rest.git@e876c0fddd5ce2f5223ab16936f711b0d57e19c4#egg=teeth_rest
|
||||||
|
@ -17,8 +17,8 @@ limitations under the License.
|
|||||||
import abc
|
import abc
|
||||||
import collections
|
import collections
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
import plumbum
|
|
||||||
import stevedore
|
import stevedore
|
||||||
import structlog
|
import structlog
|
||||||
|
|
||||||
@ -121,14 +121,14 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
for name in iface_names
|
for name in iface_names
|
||||||
if self._is_device(name)]
|
if self._is_device(name)]
|
||||||
|
|
||||||
def _cmd(self, command_name):
|
def _cmd(self, command):
|
||||||
"""Mocking plumbum is frustratingly difficult. Instead, mock this."""
|
process = subprocess.Popen(command, stdout=subprocess.PIPE)
|
||||||
return plumbum.local[command_name]
|
return process.communicate()
|
||||||
|
|
||||||
def _list_block_devices(self):
|
def _list_block_devices(self):
|
||||||
report = self._cmd('blockdev')('--report').strip()
|
report = self._cmd(['blockdev', '--report'])[0]
|
||||||
lines = report.split('\n')
|
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')
|
startsec_idx = lines[0].index('StartSec')
|
||||||
device_idx = lines[0].index('Device')
|
device_idx = lines[0].index('Device')
|
||||||
size_idx = lines[0].index('Size')
|
size_idx = lines[0].index('Size')
|
||||||
|
@ -41,18 +41,16 @@ class TestGenericHardwareManager(unittest.TestCase):
|
|||||||
|
|
||||||
def test_get_os_install_device(self):
|
def test_get_os_install_device(self):
|
||||||
self.hardware._cmd = mock.Mock()
|
self.hardware._cmd = mock.Mock()
|
||||||
self.hardware._cmd.return_value = blockdev = mock.Mock()
|
self.hardware._cmd.return_value = (
|
||||||
blockdev.return_value = (
|
|
||||||
'RO RA SSZ BSZ StartSec Size Device\n'
|
'RO RA SSZ BSZ StartSec Size Device\n'
|
||||||
'rw 256 512 4096 0 249578283616 /dev/sda\n'
|
'rw 256 512 4096 0 249578283616 /dev/sda\n'
|
||||||
'rw 256 512 4096 2048 8587837440 /dev/sda1\n'
|
'rw 256 512 4096 2048 8587837440 /dev/sda1\n'
|
||||||
'rw 256 512 4096 124967424 15728640 /dev/sda2\n'
|
'rw 256 512 4096 124967424 15728640 /dev/sda2\n'
|
||||||
'rw 256 512 4096 0 31016853504 /dev/sdb\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.assertEqual(self.hardware.get_os_install_device(), '/dev/sdb')
|
||||||
self.hardware._cmd.assert_called_once_with('blockdev')
|
self.hardware._cmd.assert_called_once_with(['blockdev', '--report'])
|
||||||
blockdev.assert_called_once_with('--report')
|
|
||||||
|
|
||||||
def test_list_hardwre_info(self):
|
def test_list_hardwre_info(self):
|
||||||
self.hardware.list_network_interfaces = mock.Mock()
|
self.hardware.list_network_interfaces = mock.Mock()
|
||||||
|
Loading…
Reference in New Issue
Block a user