Function to create config-drive partition
Add function to create partition for config-drive to util/disk.py module. This is required to switch from 'cobbler' to 'image' provision method. Change-Id: Ia52195a2e25e4e459c8947eb2dfaea97195dbe7f Related-bug: 1575054
This commit is contained in:
parent
99f06d545e
commit
b5d884296c
|
@ -30,7 +30,7 @@ class ComputeUpgrade(upgrade.UpgradeHandler):
|
|||
def prepare(self):
|
||||
env = self.node.env
|
||||
if env_util.incompatible_provision_method(env):
|
||||
self.create_configdrive_partition()
|
||||
disk.create_configdrive_partition()
|
||||
disk.update_node_partition_info(self.node.id)
|
||||
if not self.live_migration:
|
||||
self.preserve_partition()
|
||||
|
@ -103,15 +103,6 @@ class ComputeUpgrade(upgrade.UpgradeHandler):
|
|||
'xargs -I% nova stop %']
|
||||
ssh.call(["sh", "-c", ' '.join(cmd)], stdout=ssh.PIPE, node=controller)
|
||||
|
||||
def create_configdrive_partition(self):
|
||||
disks = disk.get_node_disks(self.node)
|
||||
if not disks:
|
||||
raise Exception("No disks info was found "
|
||||
"for node {0}".format(self.node["id"]))
|
||||
# it was agreed that 10MB is enough for config drive partition
|
||||
size = 10
|
||||
disk.create_partition(disks[0]['name'], size, self.node)
|
||||
|
||||
def backup_iscsi_initiator_info(self):
|
||||
if not plugin.is_enabled(self.env, 'emc_vnx'):
|
||||
return
|
||||
|
|
|
@ -72,3 +72,5 @@ UPGRADE_NODE_PATCHES = [
|
|||
]
|
||||
|
||||
BOOTSTRAP_UNSUPPORTED_IMAGES = ["centos"]
|
||||
# NOTE(ogelbukh): it was agreed that 10MB is enough for config drive partition
|
||||
CONFIGDRIVE_PART_SIZE = 10
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
import os
|
||||
import pytest
|
||||
|
||||
from octane import magic_consts
|
||||
from octane.util import disk as disk_util
|
||||
|
||||
|
||||
|
@ -46,3 +47,33 @@ def test_update_partition_info(mocker, node):
|
|||
]
|
||||
disk_util.update_node_partition_info(test_node_id)
|
||||
mock_run_in_container.assert_called_once_with(container, expected_command)
|
||||
|
||||
|
||||
NODE_DISKS_ATTRIBUTE = [
|
||||
{
|
||||
'id': '1',
|
||||
'name': 'disk1',
|
||||
}, {
|
||||
'id': '2',
|
||||
'name': 'disk2',
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("disk_attrs", [
|
||||
NODE_DISKS_ATTRIBUTE,
|
||||
None,
|
||||
])
|
||||
def test_create_configdrive_partition(mocker, node, disk_attrs):
|
||||
name = 'disk1'
|
||||
node.mock_add_spec(['get_attribute'])
|
||||
node.data = {"id": "1"}
|
||||
node.get_attribute.return_value = disk_attrs
|
||||
mock_create_part = mocker.patch("octane.util.disk.create_partition")
|
||||
if disk_attrs:
|
||||
disk_util.create_configdrive_partition(node)
|
||||
mock_create_part.assert_called_once_with(
|
||||
name, magic_consts.CONFIGDRIVE_PART_SIZE, node)
|
||||
else:
|
||||
with pytest.raises(disk_util.NoDisksInfoError):
|
||||
disk_util.create_configdrive_partition(node)
|
||||
|
|
|
@ -11,10 +11,18 @@
|
|||
# under the License.
|
||||
import os.path
|
||||
|
||||
from octane import magic_consts
|
||||
from octane.util import docker
|
||||
from octane.util import ssh
|
||||
|
||||
|
||||
class NoDisksInfoError(Exception):
|
||||
message = "No disks info was found for node {0}"
|
||||
|
||||
def __init__(self, node_id):
|
||||
super(NoDisksInfoError, self).__init__(self.message.format(node_id))
|
||||
|
||||
|
||||
def get_node_disks(node):
|
||||
return node.get_attribute('disks')
|
||||
|
||||
|
@ -42,3 +50,12 @@ def update_node_partition_info(node_id):
|
|||
fname = 'update_node_partition_info.py'
|
||||
command = ['python', os.path.join('/tmp', fname), str(node_id)]
|
||||
docker.run_in_container('nailgun', command)
|
||||
|
||||
|
||||
def create_configdrive_partition(node):
|
||||
disks = get_node_disks(node)
|
||||
if not disks:
|
||||
raise NoDisksInfoError(node.data['id'])
|
||||
create_partition(disks[0]['name'],
|
||||
magic_consts.CONFIGDRIVE_PART_SIZE,
|
||||
node)
|
||||
|
|
Loading…
Reference in New Issue