Don't use mistral directory as WORK_DIR for config-download
As part of mistral removal all config-downloaded playbooks are run from tripleoclient. This changes the download location to $HOME/config-download. Documentation for default location will be changed along with all doc changes for mistral removal. Closes-Bug: #1874432 Depends-On: https://review.opendev.org/721568/ Change-Id: Ib4c9c47baabd64f008c4f61e4fa8c37a311350a3
This commit is contained in:
parent
7cef22cc68
commit
191438f743
@ -89,10 +89,11 @@ DEFAULT_VALIDATIONS_BASEDIR = '/usr/share/openstack-tripleo-validations'
|
|||||||
|
|
||||||
VALIDATIONS_LOG_BASEDIR = '/var/log/validations'
|
VALIDATIONS_LOG_BASEDIR = '/var/log/validations'
|
||||||
|
|
||||||
DEFAULT_WORK_DIR = '/var/lib/mistral'
|
DEFAULT_WORK_DIR = os.path.join(os.environ.get('HOME', '~/'),
|
||||||
|
'config-download')
|
||||||
|
|
||||||
ANSIBLE_INVENTORY = \
|
ANSIBLE_INVENTORY = os.path.join(DEFAULT_WORK_DIR,
|
||||||
'/var/lib/mistral/overcloud/tripleo-ansible-inventory.yaml'
|
'overcloud/tripleo-ansible-inventory.yaml')
|
||||||
|
|
||||||
ANSIBLE_VALIDATION_DIR = \
|
ANSIBLE_VALIDATION_DIR = \
|
||||||
'/usr/share/openstack-tripleo-validations/playbooks'
|
'/usr/share/openstack-tripleo-validations/playbooks'
|
||||||
|
@ -53,7 +53,7 @@ def export_passwords(swift, stack, excludes=True):
|
|||||||
|
|
||||||
|
|
||||||
def export_stack(heat, stack, should_filter=False,
|
def export_stack(heat, stack, should_filter=False,
|
||||||
config_download_dir='/var/lib/mistral/overcloud'):
|
config_download_dir=constants.DEFAULT_WORK_DIR):
|
||||||
|
|
||||||
# data to export
|
# data to export
|
||||||
# parameter: Parameter to be exported
|
# parameter: Parameter to be exported
|
||||||
@ -90,6 +90,7 @@ def export_stack(heat, stack, should_filter=False,
|
|||||||
if "file" in export_param:
|
if "file" in export_param:
|
||||||
# get file data
|
# get file data
|
||||||
file = os.path.join(config_download_dir,
|
file = os.path.join(config_download_dir,
|
||||||
|
stack,
|
||||||
export_param["file"])
|
export_param["file"])
|
||||||
with open(file, 'r') as ff:
|
with open(file, 'r') as ff:
|
||||||
try:
|
try:
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
#
|
#
|
||||||
|
import os
|
||||||
|
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
import mock
|
import mock
|
||||||
@ -57,7 +57,10 @@ class TestExport(TestCase):
|
|||||||
|
|
||||||
self.assertEqual(expected, data)
|
self.assertEqual(expected, data)
|
||||||
self.mock_open.assert_called_once_with(
|
self.mock_open.assert_called_once_with(
|
||||||
'/var/lib/mistral/overcloud/group_vars/overcloud.json', 'r')
|
os.path.join(
|
||||||
|
os.environ.get('HOME'),
|
||||||
|
'config-download/overcloud/group_vars/overcloud.json'),
|
||||||
|
'r')
|
||||||
|
|
||||||
@mock.patch('tripleoclient.utils.get_stack')
|
@mock.patch('tripleoclient.utils.get_stack')
|
||||||
def test_export_stack_should_filter(self, mock_get_stack):
|
def test_export_stack_should_filter(self, mock_get_stack):
|
||||||
@ -76,7 +79,10 @@ class TestExport(TestCase):
|
|||||||
|
|
||||||
self.assertEqual(expected, data)
|
self.assertEqual(expected, data)
|
||||||
self.mock_open.assert_called_once_with(
|
self.mock_open.assert_called_once_with(
|
||||||
'/var/lib/mistral/overcloud/group_vars/overcloud.json', 'r')
|
os.path.join(
|
||||||
|
os.environ.get('HOME'),
|
||||||
|
'config-download/overcloud/group_vars/overcloud.json'),
|
||||||
|
'r')
|
||||||
|
|
||||||
@mock.patch('tripleoclient.utils.get_stack')
|
@mock.patch('tripleoclient.utils.get_stack')
|
||||||
def test_export_stack_cd_dir(self, mock_get_stack):
|
def test_export_stack_cd_dir(self, mock_get_stack):
|
||||||
@ -84,7 +90,7 @@ class TestExport(TestCase):
|
|||||||
mock_get_stack.return_value = self.mock_stack
|
mock_get_stack.return_value = self.mock_stack
|
||||||
with mock.patch('six.moves.builtins.open', self.mock_open):
|
with mock.patch('six.moves.builtins.open', self.mock_open):
|
||||||
export.export_stack(heat, "overcloud",
|
export.export_stack(heat, "overcloud",
|
||||||
config_download_dir='/foo/overcloud')
|
config_download_dir='/foo')
|
||||||
self.mock_open.assert_called_once_with(
|
self.mock_open.assert_called_once_with(
|
||||||
'/foo/overcloud/group_vars/overcloud.json', 'r')
|
'/foo/overcloud/group_vars/overcloud.json', 'r')
|
||||||
|
|
||||||
|
@ -1624,7 +1624,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
|||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
playbook = '/var/lib/mistral/overcloud/deploy_steps_playbook.yaml'
|
playbook = os.path.join(os.environ.get(
|
||||||
|
'HOME'), 'config-download/overcloud/deploy_steps_playbook.yaml')
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
[mock.call(
|
[mock.call(
|
||||||
ansible_cfg=None, ansible_timeout=42,
|
ansible_cfg=None, ansible_timeout=42,
|
||||||
|
@ -233,7 +233,8 @@ class TestDeleteNode(fakes.TestDeleteNode):
|
|||||||
playbook_dir='/usr/share/ansible/tripleo-playbooks',
|
playbook_dir='/usr/share/ansible/tripleo-playbooks',
|
||||||
verbosity=mock.ANY,
|
verbosity=mock.ANY,
|
||||||
extra_vars={
|
extra_vars={
|
||||||
'access_path': '/var/lib/mistral',
|
'access_path': os.path.join(os.environ.get('HOME'),
|
||||||
|
'config-download'),
|
||||||
'execution_user': mock.ANY},
|
'execution_user': mock.ANY},
|
||||||
),
|
),
|
||||||
mock.call(
|
mock.call(
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
import os
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
@ -37,7 +38,8 @@ class TestOvercloudExport(utils.TestCommand):
|
|||||||
@mock.patch('tripleoclient.export.export_passwords')
|
@mock.patch('tripleoclient.export.export_passwords')
|
||||||
def test_export(self, mock_export_passwords,
|
def test_export(self, mock_export_passwords,
|
||||||
mock_export_stack,
|
mock_export_stack,
|
||||||
mock_safe_dump, mock_exists):
|
mock_safe_dump,
|
||||||
|
mock_exists):
|
||||||
argslist = []
|
argslist = []
|
||||||
verifylist = []
|
verifylist = []
|
||||||
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
|
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
|
||||||
@ -49,11 +51,13 @@ class TestOvercloudExport(utils.TestCommand):
|
|||||||
mock_export_passwords.assert_called_once_with(
|
mock_export_passwords.assert_called_once_with(
|
||||||
self.app.client_manager.tripleoclient.object_store,
|
self.app.client_manager.tripleoclient.object_store,
|
||||||
'overcloud', True)
|
'overcloud', True)
|
||||||
|
path = os.path.join(os.environ.get('HOME'),
|
||||||
|
'config-download/overcloud')
|
||||||
mock_export_stack.assert_called_once_with(
|
mock_export_stack.assert_called_once_with(
|
||||||
self.app.client_manager.orchestration,
|
self.app.client_manager.orchestration,
|
||||||
'overcloud',
|
'overcloud',
|
||||||
False,
|
False,
|
||||||
'/var/lib/mistral/overcloud')
|
path)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
{'parameter_defaults': {'key': 'value',
|
{'parameter_defaults': {'key': 'value',
|
||||||
'key0': 'value0'}},
|
'key0': 'value0'}},
|
||||||
@ -65,7 +69,8 @@ class TestOvercloudExport(utils.TestCommand):
|
|||||||
@mock.patch('tripleoclient.export.export_passwords')
|
@mock.patch('tripleoclient.export.export_passwords')
|
||||||
def test_export_stack_name(self, mock_export_passwords,
|
def test_export_stack_name(self, mock_export_passwords,
|
||||||
mock_export_stack,
|
mock_export_stack,
|
||||||
mock_safe_dump, mock_exists):
|
mock_safe_dump,
|
||||||
|
mock_exists):
|
||||||
argslist = ['--stack', 'foo']
|
argslist = ['--stack', 'foo']
|
||||||
verifylist = [('stack', 'foo')]
|
verifylist = [('stack', 'foo')]
|
||||||
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
|
parsed_args = self.check_parser(self.cmd, argslist, verifylist)
|
||||||
@ -75,11 +80,13 @@ class TestOvercloudExport(utils.TestCommand):
|
|||||||
mock_export_passwords.assert_called_once_with(
|
mock_export_passwords.assert_called_once_with(
|
||||||
self.app.client_manager.tripleoclient.object_store,
|
self.app.client_manager.tripleoclient.object_store,
|
||||||
'foo', True)
|
'foo', True)
|
||||||
|
path = os.path.join(os.environ.get('HOME'),
|
||||||
|
'config-download/foo')
|
||||||
mock_export_stack.assert_called_once_with(
|
mock_export_stack.assert_called_once_with(
|
||||||
self.app.client_manager.orchestration,
|
self.app.client_manager.orchestration,
|
||||||
'foo',
|
'foo',
|
||||||
False,
|
False,
|
||||||
'/var/lib/mistral/foo')
|
path)
|
||||||
|
|
||||||
@mock.patch('os.path.exists')
|
@mock.patch('os.path.exists')
|
||||||
@mock.patch('yaml.safe_dump')
|
@mock.patch('yaml.safe_dump')
|
||||||
|
@ -923,10 +923,8 @@ class DeployOvercloud(command.Command):
|
|||||||
action='store',
|
action='store',
|
||||||
default=None,
|
default=None,
|
||||||
help=_('Directory to use for saved output when using '
|
help=_('Directory to use for saved output when using '
|
||||||
'--config-download. The directory must be '
|
'--config-download. When not '
|
||||||
'writeable by the mistral user. When not '
|
'specified, $HOME/config-download will be used.')
|
||||||
'specified, the default server side value '
|
|
||||||
'will be used (/var/lib/mistral/<execution id>.')
|
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--override-ansible-cfg',
|
'--override-ansible-cfg',
|
||||||
|
@ -51,7 +51,7 @@ class ExportOvercloud(command.Command):
|
|||||||
action='store',
|
action='store',
|
||||||
help=_('Directory to search for config-download '
|
help=_('Directory to search for config-download '
|
||||||
'export data. Defaults to '
|
'export data. Defaults to '
|
||||||
'/var/lib/mistral/<stack>'))
|
'$HOME/config-download/<stack>'))
|
||||||
parser.add_argument('--no-password-excludes',
|
parser.add_argument('--no-password-excludes',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
dest='no_password_excludes',
|
dest='no_password_excludes',
|
||||||
@ -78,7 +78,8 @@ class ExportOvercloud(command.Command):
|
|||||||
"File '%s' already exists, not exporting." % output_file)
|
"File '%s' already exists, not exporting." % output_file)
|
||||||
|
|
||||||
if not parsed_args.config_download_dir:
|
if not parsed_args.config_download_dir:
|
||||||
config_download_dir = os.path.join('/var/lib/mistral',
|
config_download_dir = os.path.join(os.environ.get('HOME'),
|
||||||
|
'config-download',
|
||||||
parsed_args.stack)
|
parsed_args.stack)
|
||||||
else:
|
else:
|
||||||
config_download_dir = parsed_args.config_download_dir
|
config_download_dir = parsed_args.config_download_dir
|
||||||
|
Loading…
Reference in New Issue
Block a user