Add re-initialization of the master node
PuppetApplyHost is renamed to PuppetApplyTasks to perform full re-initialization of the master node by applying all puppet tasks. Change-Id: I52a02fd4e72c1fd6367f91f088beacc0e9715969
This commit is contained in:
parent
3ca668f9df
commit
ccbe6604ba
@ -45,7 +45,7 @@ ARCHIVATORS = [
|
|||||||
logs.LogsArchivator,
|
logs.LogsArchivator,
|
||||||
version.VersionArchivator,
|
version.VersionArchivator,
|
||||||
nailgun_plugins.NailgunPluginsArchivator,
|
nailgun_plugins.NailgunPluginsArchivator,
|
||||||
# puppet.PuppetApplyHost,
|
puppet.PuppetApplyTasks,
|
||||||
]
|
]
|
||||||
|
|
||||||
REPO_ARCHIVATORS = [
|
REPO_ARCHIVATORS = [
|
||||||
|
@ -20,11 +20,11 @@ class PuppetArchivator(base.DirsArchivator):
|
|||||||
tag = "puppet"
|
tag = "puppet"
|
||||||
|
|
||||||
|
|
||||||
class PuppetApplyHost(base.Base):
|
class PuppetApplyTasks(base.Base):
|
||||||
|
|
||||||
def backup(self):
|
def backup(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def restore(self):
|
def restore(self):
|
||||||
with auth.set_astute_password(self.context):
|
with auth.set_astute_password(self.context):
|
||||||
puppet.apply_host()
|
puppet.apply_all_tasks()
|
||||||
|
@ -24,6 +24,9 @@ NAILGUN_ARCHIVATOR_PATCHES = (
|
|||||||
)
|
)
|
||||||
BOOTSTRAP_INITRAMFS = "/var/www/nailgun/bootstrap/initramfs.img"
|
BOOTSTRAP_INITRAMFS = "/var/www/nailgun/bootstrap/initramfs.img"
|
||||||
|
|
||||||
|
PUPPET_TASKS_DIR = os.path.join(PUPPET_DIR, 'fuel/examples')
|
||||||
|
PUPPET_APPLY_TASKS_SCRIPT = os.path.join(PUPPET_TASKS_DIR, 'deploy.sh')
|
||||||
|
|
||||||
SSH_KEYS = ['/root/.ssh/id_rsa', '/root/.ssh/bootstrap.rsa']
|
SSH_KEYS = ['/root/.ssh/id_rsa', '/root/.ssh/bootstrap.rsa']
|
||||||
OS_SERVICES = ["nova", "keystone", "heat", "neutron", "cinder", "glance"]
|
OS_SERVICES = ["nova", "keystone", "heat", "neutron", "cinder", "glance"]
|
||||||
BRIDGES = ['br-ex', 'br-mgmt']
|
BRIDGES = ['br-ex', 'br-mgmt']
|
||||||
|
@ -525,14 +525,14 @@ def test_release_restore(mocker, mock_open, content, existing_releases, calls):
|
|||||||
mock_open.assert_called_once_with(magic_consts.OPENSTACK_FIXTURES)
|
mock_open.assert_called_once_with(magic_consts.OPENSTACK_FIXTURES)
|
||||||
|
|
||||||
|
|
||||||
def test_post_restore_puppet_apply_host(mocker):
|
def test_post_restore_puppet_apply_tasks(mocker):
|
||||||
context = backup_restore.NailgunCredentialsContext(
|
context = backup_restore.NailgunCredentialsContext(
|
||||||
user="admin", password="user_pswd")
|
user="admin", password="user_pswd")
|
||||||
mock_set_astute_password = mocker.patch(
|
mock_set_astute_password = mocker.patch(
|
||||||
"octane.util.auth.set_astute_password")
|
"octane.util.auth.set_astute_password")
|
||||||
mock_apply = mocker.patch("octane.util.puppet.apply_host")
|
mock_apply = mocker.patch("octane.util.puppet.apply_all_tasks")
|
||||||
|
|
||||||
archivator = puppet.PuppetApplyHost(None, context)
|
archivator = puppet.PuppetApplyTasks(None, context)
|
||||||
archivator.restore()
|
archivator.restore()
|
||||||
|
|
||||||
assert mock_apply.called
|
assert mock_apply.called
|
||||||
|
@ -34,13 +34,17 @@ def test_apply_task(mock_subprocess, name, returncode, is_error):
|
|||||||
mock_subprocess.assert_called_once_with(cmd)
|
mock_subprocess.assert_called_once_with(cmd)
|
||||||
|
|
||||||
|
|
||||||
def test_apply_host(mock_subprocess):
|
def test_apply_all_tasks(mock_subprocess):
|
||||||
puppet_util.apply_host()
|
puppet_util.apply_all_tasks()
|
||||||
assert mock_subprocess.call_count == 1
|
expected_filename = "/etc/puppet/modules/fuel/examples/deploy.sh"
|
||||||
|
mock_subprocess.assert_called_once_with([expected_filename])
|
||||||
|
|
||||||
|
|
||||||
def test_apply_host_error(mock_subprocess):
|
def test_apply_all_tasks_error(mocker, mock_subprocess):
|
||||||
|
mock_log = mocker.patch("octane.util.puppet.LOG")
|
||||||
exc = subprocess.CalledProcessError(1, 'TEST_PROCESS')
|
exc = subprocess.CalledProcessError(1, 'TEST_PROCESS')
|
||||||
mock_subprocess.side_effect = exc
|
mock_subprocess.side_effect = exc
|
||||||
with pytest.raises(type(exc)):
|
with pytest.raises(subprocess.CalledProcessError):
|
||||||
puppet_util.apply_host()
|
puppet_util.apply_all_tasks()
|
||||||
|
mock_log.error.assert_called_once_with(
|
||||||
|
"Cannot apply Puppet state on host: %s", exc)
|
||||||
|
@ -21,10 +21,8 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
def apply_task(task):
|
def apply_task(task):
|
||||||
path = os.path.join(magic_consts.PUPPET_DIR,
|
filename = '{0}.pp'.format(task)
|
||||||
'fuel',
|
path = os.path.join(magic_consts.PUPPET_TASKS_DIR, filename)
|
||||||
'examples',
|
|
||||||
'{0}.pp'.format(task))
|
|
||||||
cmd = ['puppet', 'apply', '-d', '-v', "--color", "false",
|
cmd = ['puppet', 'apply', '-d', '-v', "--color", "false",
|
||||||
'--detailed-exitcodes', path]
|
'--detailed-exitcodes', path]
|
||||||
try:
|
try:
|
||||||
@ -44,18 +42,12 @@ def apply_task(task):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
def apply_host():
|
def apply_all_tasks():
|
||||||
cmd = ['puppet', 'apply', '-d', '-v']
|
|
||||||
path = os.path.join(magic_consts.PUPPET_DIR,
|
|
||||||
'nailgun',
|
|
||||||
'examples',
|
|
||||||
'host-only.pp')
|
|
||||||
cmd.append(path)
|
|
||||||
try:
|
try:
|
||||||
subprocess.call(cmd)
|
subprocess.call([magic_consts.PUPPET_APPLY_TASKS_SCRIPT])
|
||||||
except subprocess.CalledProcessError as exc:
|
except subprocess.CalledProcessError as exc:
|
||||||
LOG.error("Cannot apply Puppet state on host: %s",
|
LOG.error("Cannot apply Puppet state on host: %s",
|
||||||
exc.message)
|
exc)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user