diff --git a/teeth_agent/hardware.py b/teeth_agent/hardware.py index b747180cd..e4dd68bab 100644 --- a/teeth_agent/hardware.py +++ b/teeth_agent/hardware.py @@ -44,6 +44,10 @@ class HardwareManager(object): def get_primary_mac_address(self): pass + @abc.abstractmethod + def get_os_install_device(self): + pass + class GenericHardwareManager(HardwareManager): def evaluate_hardware_support(cls): @@ -52,6 +56,9 @@ class GenericHardwareManager(HardwareManager): def get_primary_mac_address(self): return open('/sys/class/net/eth0/address', 'r').read().strip('\n') + def get_os_install_device(self): + return '/dev/sda' + def _compare_extensions(ext1, ext2): mgr1 = ext1.obj diff --git a/teeth_agent/standby.py b/teeth_agent/standby.py index 367b79374..21462c561 100644 --- a/teeth_agent/standby.py +++ b/teeth_agent/standby.py @@ -23,6 +23,7 @@ import requests from teeth_agent import base from teeth_agent import configdrive from teeth_agent import errors +from teeth_agent import hardware def _configdrive_location(): @@ -114,7 +115,7 @@ class PrepareImageCommand(base.AsyncCommandResult): location = _configdrive_location() metadata = self.command_params['metadata'] files = self.command_params['files'] - device = '/dev/sda' + device = hardware.get_manager().get_os_install_device() _download_image(image_info) configdrive.write_configdrive(location, metadata, files) diff --git a/teeth_agent/tests/hardware.py b/teeth_agent/tests/hardware.py index 33d547813..ca2d89bfd 100644 --- a/teeth_agent/tests/hardware.py +++ b/teeth_agent/tests/hardware.py @@ -25,7 +25,7 @@ class TestGenericHardwareManager(unittest.TestCase): self.hardware = hardware.GenericHardwareManager() @mock.patch('__builtin__.open') - def test_decom_mode(self, mocked_open): + def test_get_primary_mac_address(self, mocked_open): f = mocked_open.return_value f.read.return_value = '00:0c:29:8c:11:b1\n' @@ -34,3 +34,6 @@ class TestGenericHardwareManager(unittest.TestCase): mocked_open.assert_called_once_with('/sys/class/net/eth0/address', 'r') f.read.assert_called_once_with() + + def test_get_os_install_device(self): + self.assertEqual(self.hardware.get_os_install_device(), '/dev/sda')