Move partition info transformation to extension
remove from octane `update_node_partition_info.py` and replace it with extension api call Depends-On: I422bb368916f3a319e286edcc6103a2834097a87 Change-Id: Ifdd6bcd22304db9cd3092f2b6562296741faa7fd
This commit is contained in:
parent
0de568c5aa
commit
3c2bb12df3
|
@ -26,7 +26,6 @@ LOG = logging.getLogger(__name__)
|
|||
class ComputeInstall(install.InstallHandler):
|
||||
def prepare(self):
|
||||
self.create_configdrive_partition()
|
||||
disk.update_node_partition_info(self.node.id)
|
||||
self.preserve_partition()
|
||||
|
||||
def postdeploy(self):
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import sys
|
||||
|
||||
from nailgun.db import db
|
||||
from nailgun.extensions.volume_manager.models.node_volumes import NodeVolumes
|
||||
|
||||
|
||||
node_id = int(sys.argv[1])
|
||||
nv = db().query(NodeVolumes).filter(NodeVolumes.node_id == node_id).first()
|
||||
|
||||
if not nv:
|
||||
raise Exception("No volumes info was found for node {0}".format(node_id))
|
||||
|
||||
volumes = nv.volumes
|
||||
|
||||
try:
|
||||
os_vg = next(
|
||||
disk for disk in volumes if 'id' in disk and disk['id'] == 'os')
|
||||
except StopIteration:
|
||||
sys.exit(0)
|
||||
volumes = [disk for disk in volumes if 'id' not in disk or disk['id'] != 'os']
|
||||
|
||||
for disk in volumes:
|
||||
disk_volumes = disk['volumes']
|
||||
disk['volumes'] = []
|
||||
for v in disk_volumes:
|
||||
if v['type'] == 'pv' and v['vg'] == 'os' and v['size'] > 0:
|
||||
for vv in os_vg['volumes']:
|
||||
partition = {'name': vv['name'],
|
||||
'size': vv['size'],
|
||||
'type': 'partition',
|
||||
'mount': vv['mount'],
|
||||
'file_system': vv['file_system']}
|
||||
disk['volumes'].append(partition)
|
||||
else:
|
||||
if v['type'] == 'lvm_meta_pool' or v['type'] == 'boot':
|
||||
v['size'] = 0
|
||||
disk['volumes'].append(v)
|
||||
|
||||
db().query(NodeVolumes).filter(NodeVolumes.node_id == node_id).update(
|
||||
{"volumes": volumes})
|
||||
db.commit()
|
|
@ -247,8 +247,6 @@ def test_move_nodes(mocker, mock_subprocess, provision, compat):
|
|||
|
||||
mock_create_configdrive = mocker.patch(
|
||||
"octane.util.disk.create_configdrive_partition")
|
||||
mock_update_node_partinfo = mocker.patch(
|
||||
"octane.util.disk.update_node_partition_info")
|
||||
mock_wait_for = mocker.patch(
|
||||
"octane.util.env.wait_for_nodes")
|
||||
mock_get_provision_method = mocker.patch(
|
||||
|
@ -258,12 +256,9 @@ def test_move_nodes(mocker, mock_subprocess, provision, compat):
|
|||
if provision:
|
||||
assert mock_create_configdrive.call_args_list == \
|
||||
[mock.call(node) for node in nodes]
|
||||
assert mock_update_node_partinfo.call_args_list == \
|
||||
[mock.call(node.data["id"]) for node in nodes]
|
||||
mock_wait_for.assert_called_once_with(nodes, 'provisioned')
|
||||
else:
|
||||
assert mock_create_configdrive.call_args_list == []
|
||||
assert mock_update_node_partinfo.call_args_list == []
|
||||
assert mock_wait_for.call_args_list == []
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import pytest
|
||||
|
||||
from octane import magic_consts
|
||||
|
@ -35,19 +34,6 @@ def test_create_partition(mocker, mock_ssh_call, mock_ssh_call_output, node,
|
|||
'custom', 'ext4', str(last_part + 1), str(end_part)], node=node)
|
||||
|
||||
|
||||
def test_update_partition_info(mocker, node):
|
||||
test_node_id = 1
|
||||
fname = 'update_node_partition_info.py'
|
||||
mock_call = mocker.patch("octane.util.subprocess.call")
|
||||
expected_command = [
|
||||
'python',
|
||||
os.path.join(magic_consts.PATCHES_DIR, fname),
|
||||
str(test_node_id),
|
||||
]
|
||||
disk_util.update_node_partition_info(test_node_id)
|
||||
mock_call.assert_called_once_with(expected_command)
|
||||
|
||||
|
||||
NODE_DISKS_ATTRIBUTE = [
|
||||
{
|
||||
'id': '1',
|
||||
|
|
|
@ -9,11 +9,9 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import os.path
|
||||
|
||||
from octane import magic_consts
|
||||
from octane.util import ssh
|
||||
from octane.util import subprocess
|
||||
|
||||
|
||||
class NoDisksInfoError(Exception):
|
||||
|
@ -46,13 +44,6 @@ def create_partition(disk_name, size, node):
|
|||
node=node)
|
||||
|
||||
|
||||
def update_node_partition_info(node_id):
|
||||
fname = 'update_node_partition_info.py'
|
||||
command = ['python',
|
||||
os.path.join(magic_consts.PATCHES_DIR, fname), str(node_id)]
|
||||
subprocess.call(command)
|
||||
|
||||
|
||||
def create_configdrive_partition(node):
|
||||
disks = get_node_disks(node)
|
||||
if not disks:
|
||||
|
|
|
@ -181,7 +181,6 @@ def move_nodes(env, nodes, provision=True, roles=None):
|
|||
cmd_move_node = cmd + [str(node_id), str(env_id)]
|
||||
if provision and incompatible_provision_method(env):
|
||||
disk.create_configdrive_partition(node)
|
||||
disk.update_node_partition_info(node.data["id"])
|
||||
fuel2_env_call(cmd_move_node)
|
||||
if provision:
|
||||
LOG.info("Nodes provision started. Please wait...")
|
||||
|
|
Loading…
Reference in New Issue