Move get_device_name_prefix to base functional test module

This usefull function will be used further.

Change-Id: Ieba6cd831cfe9ba2aaf6b022a2ea581cde488578
This commit is contained in:
Feodor Tersin 2015-07-09 15:14:56 +03:00
parent f340c63658
commit 9889be09a7
2 changed files with 14 additions and 9 deletions

View File

@ -150,6 +150,18 @@ def safe_setup(f):
return decorator
def get_device_name_prefix(device_name):
"""Return device name without device number.
/dev/sda1 -> /dev/sd
/dev/vda -> /dev/vd
"""
dev_num_pos = 0
while '0' <= device_name[dev_num_pos - 1] <= '9':
dev_num_pos -= 1
return device_name[:dev_num_pos - 1]
class TesterStateHolder(object):
ec2_client = None

View File

@ -25,13 +25,6 @@ CONF = config.CONF
LOG = log.getLogger(__name__)
def _get_device_name_prefix(device_name):
dev_num_pos = 0
while '0' <= device_name[dev_num_pos - 1] <= '9':
dev_num_pos -= 1
return device_name[:dev_num_pos - 1]
class EC2_EBSInstanceTuneBDM(base.EC2TestCase):
"""Test change root device attributes at instance launch."""
@classmethod
@ -120,7 +113,7 @@ class EC2_EBSInstanceTuneBDM(base.EC2TestCase):
def test_launch_ebs_instance_with_creating_blank_volume(self):
"""Launch instance with creating blank volume."""
device_name_prefix = _get_device_name_prefix(self.root_device_name)
device_name_prefix = base.get_device_name_prefix(self.root_device_name)
device_name = device_name_prefix + 'd'
instance_id = self.run_instance(ImageId=self.image_id,
@ -175,7 +168,7 @@ class EC2_EBSInstanceAttaching(base.EC2TestCase):
image = data['Images'][0]
root_device_name = image['RootDeviceName']
device_name_prefix = _get_device_name_prefix(root_device_name)
device_name_prefix = base.get_device_name_prefix(root_device_name)
cls.full_device_name_prefix = device_name_prefix
cls.short_device_name_prefix = device_name_prefix[len("/dev/"):]