retrieve OS install dev from the HardwareManager
This commit is contained in:
parent
5ea4484a2c
commit
ecdcb77595
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user