clean cobbler and chef when refresh
Change-Id: I15d24c3e8b08956710de4c86083def4dd55cf0cf
This commit is contained in:
parent
d6ea19ad98
commit
37a334a7b7
6
bin/chef/clean_clients.sh
Executable file
6
bin/chef/clean_clients.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo "clean chef clients"
|
||||||
|
yes | knife client bulk delete '^(?!chef-).*'
|
||||||
|
if [[ "$?" != "0" ]]; then
|
||||||
|
echo "failed to clean all clients"
|
||||||
|
fi
|
13
bin/chef/clean_environments.sh
Executable file
13
bin/chef/clean_environments.sh
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo "clean chef environments"
|
||||||
|
environments=$(knife environment list)
|
||||||
|
for environment in $environments; do
|
||||||
|
if [[ "$environment" != "_default" ]]; then
|
||||||
|
yes | knife environment delete $environment
|
||||||
|
if [[ "$?" != "0" ]]; then
|
||||||
|
echo "failed to delete environment $environment"
|
||||||
|
else
|
||||||
|
echo "environment $environment is deleted"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
6
bin/chef/clean_nodes.sh
Executable file
6
bin/chef/clean_nodes.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo "clean chef nodes"
|
||||||
|
yes | knife node bulk delete '.*'
|
||||||
|
if [[ "$?" != "0" ]]; then
|
||||||
|
echo "failed to clean all nodes"
|
||||||
|
fi
|
50
bin/clean_installation_logs.py
Executable file
50
bin/clean_installation_logs.py
Executable file
@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# Copyright 2014 Huawei Technologies Co. Ltd
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
"""clean all installation logs."""
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
import site
|
||||||
|
import sys
|
||||||
|
|
||||||
|
activate_this = '$PythonHome/bin/activate_this.py'
|
||||||
|
execfile(activate_this, dict(__file__=activate_this))
|
||||||
|
site.addsitedir('$PythonHome/lib/python2.6/site-packages')
|
||||||
|
sys.path.append('$PythonHome')
|
||||||
|
os.environ['PYTHON_EGG_CACHE'] = '/tmp/.egg'
|
||||||
|
|
||||||
|
from compass.utils import flags
|
||||||
|
from compass.utils import logsetting
|
||||||
|
from compass.utils import setting_wrapper as setting
|
||||||
|
|
||||||
|
|
||||||
|
def clean_installation_logs():
|
||||||
|
installation_log_dirs = setting.INSTALLATION_LOGDIR
|
||||||
|
successful = True
|
||||||
|
for _, logdir in installation_log_dirs.items():
|
||||||
|
cmd = 'rm -rf %s/*' % logdir
|
||||||
|
status = os.system(cmd)
|
||||||
|
logging.info('run cmd %s resturns %s', cmd, status)
|
||||||
|
if status:
|
||||||
|
successful = False
|
||||||
|
return successful
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
flags.init()
|
||||||
|
logsetting.init()
|
||||||
|
clean_installation_logs()
|
9
bin/cobbler/remove_systems.sh
Executable file
9
bin/cobbler/remove_systems.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
systems=$(cobbler system list)
|
||||||
|
echo "remove systems: $systems"
|
||||||
|
for system in $systems; do
|
||||||
|
cobbler system remove --name=$system
|
||||||
|
if [[ "$?" != "0" ]]; then
|
||||||
|
echo "failed to remove system %s"
|
||||||
|
fi
|
||||||
|
done
|
@ -2,9 +2,15 @@
|
|||||||
set -e
|
set -e
|
||||||
service mysqld restart
|
service mysqld restart
|
||||||
/opt/compass/bin/manage_db.py createdb
|
/opt/compass/bin/manage_db.py createdb
|
||||||
|
echo "You may run '/opt/compass/bin/clean_nodes.sh' to clean nodes on chef server"
|
||||||
|
echo "You may run '/opt/compass/bin/clean_clients.sh' to clean clients on chef server"
|
||||||
|
echo "you may run '/opt/compass/bin/clean_environments.sh' to clean environments on chef server"
|
||||||
|
echo "you may run '/opt/compass/bin/remove_systems.sh' to clean systems on cobbler"
|
||||||
|
/opt/compass/bin/clean_installation_logs.py
|
||||||
service httpd restart
|
service httpd restart
|
||||||
service rsyslog restart
|
service rsyslog restart
|
||||||
service redis restart
|
service redis restart
|
||||||
|
sleep 10
|
||||||
redis-cli flushall
|
redis-cli flushall
|
||||||
service compass-celeryd restart
|
service compass-celeryd restart
|
||||||
service compass-progress-updated restart
|
service compass-progress-updated restart
|
||||||
|
@ -66,7 +66,6 @@ def session():
|
|||||||
.. note::
|
.. note::
|
||||||
To operate database, it should be called in database session.
|
To operate database, it should be called in database session.
|
||||||
"""
|
"""
|
||||||
import traceback
|
|
||||||
if hasattr(SESSION_HOLDER, 'session'):
|
if hasattr(SESSION_HOLDER, 'session'):
|
||||||
logging.error('we are already in session')
|
logging.error('we are already in session')
|
||||||
raise exception.DatabaseException('session already exist')
|
raise exception.DatabaseException('session already exist')
|
||||||
|
@ -16,6 +16,7 @@ sudo cp -rf $COMPASSDIR/bin/*.sh /opt/compass/bin/
|
|||||||
sudo cp -rf $COMPASSDIR/bin/compassd /usr/bin/
|
sudo cp -rf $COMPASSDIR/bin/compassd /usr/bin/
|
||||||
sudo cp -rf $COMPASSDIR/bin/compass /usr/bin/
|
sudo cp -rf $COMPASSDIR/bin/compass /usr/bin/
|
||||||
sudo cp -rf $COMPASSDIR/bin/chef/* /opt/compass/bin/
|
sudo cp -rf $COMPASSDIR/bin/chef/* /opt/compass/bin/
|
||||||
|
sudo cp -rf $COMPASSDIR/bin/cobbler/* /opt/compass/bin/
|
||||||
sudo cp -rf $WEB_HOME/public/* /var/www/compass_web/
|
sudo cp -rf $WEB_HOME/public/* /var/www/compass_web/
|
||||||
sudo cp -rf $WEB_HOME/v2 /var/www/compass_web/
|
sudo cp -rf $WEB_HOME/v2 /var/www/compass_web/
|
||||||
sudo cp -rf $COMPASSDIR/templates /etc/compass/
|
sudo cp -rf $COMPASSDIR/templates /etc/compass/
|
||||||
@ -49,15 +50,13 @@ sudo sed -i "s/\$cobbler_ip/$ipaddr/g" /etc/compass/os_installer/cobbler.conf
|
|||||||
sudo sed -i "/CHEF_INSTALLER_URL/c\CHEF_INSTALLER_URL = 'https:\/\/$ipaddr/'" /etc/compass/setting
|
sudo sed -i "/CHEF_INSTALLER_URL/c\CHEF_INSTALLER_URL = 'https:\/\/$ipaddr/'" /etc/compass/setting
|
||||||
sudo sed -i "s/\$chef_ip/$ipaddr/g" /etc/compass/package_installer/chef-icehouse.conf
|
sudo sed -i "s/\$chef_ip/$ipaddr/g" /etc/compass/package_installer/chef-icehouse.conf
|
||||||
sudo sed -i "s/\$chef_hostname/$HOSTNAME/g" /etc/compass/package_installer/chef-icehouse.conf
|
sudo sed -i "s/\$chef_hostname/$HOSTNAME/g" /etc/compass/package_installer/chef-icehouse.conf
|
||||||
sudo sed -i "s/\$compass_ip/$ipaddr/g" /etc/compass/global_config
|
|
||||||
sudo sed -i "s/\$compass_hostname/$HOSTNAME/g" /etc/compass/global_config
|
|
||||||
sudo sed -i "s/\$compass_testmode/$TESTMODE/g" /etc/compass/global_config
|
|
||||||
sudo sed -e 's|$PythonHome|'$VIRTUAL_ENV'|' -i /var/www/compass/compass.wsgi
|
sudo sed -e 's|$PythonHome|'$VIRTUAL_ENV'|' -i /var/www/compass/compass.wsgi
|
||||||
sudo sed -e 's|$PythonHome|'$VIRTUAL_ENV'|' -i /usr/bin/compass
|
sudo sed -e 's|$PythonHome|'$VIRTUAL_ENV'|' -i /usr/bin/compass
|
||||||
sudo sed -e 's|$PythonHome|'$VIRTUAL_ENV'|' -i /opt/compass/bin/poll_switch.py
|
sudo sed -e 's|$PythonHome|'$VIRTUAL_ENV'|' -i /opt/compass/bin/poll_switch.py
|
||||||
sudo sed -e 's|$PythonHome|'$VIRTUAL_ENV'|' -i /opt/compass/bin/progress_update.py
|
sudo sed -e 's|$PythonHome|'$VIRTUAL_ENV'|' -i /opt/compass/bin/progress_update.py
|
||||||
sudo sed -e 's|$PythonHome|'$VIRTUAL_ENV'|' -i /opt/compass/bin/manage_db.py
|
sudo sed -e 's|$PythonHome|'$VIRTUAL_ENV'|' -i /opt/compass/bin/manage_db.py
|
||||||
sudo sed -e 's|$PythonHome|'$VIRTUAL_ENV'|' -i /opt/compass/bin/client.py
|
sudo sed -e 's|$PythonHome|'$VIRTUAL_ENV'|' -i /opt/compass/bin/client.py
|
||||||
|
sudo sed -e 's|$PythonHome|'$VIRTUAL_ENV'|' -i /opt/compass/bin/clean_installation_logs.py
|
||||||
sudo sed -e 's|$Python|'$VIRTUAL_ENV/bin/python'|' -i /etc/init.d/compass-progress-updated
|
sudo sed -e 's|$Python|'$VIRTUAL_ENV/bin/python'|' -i /etc/init.d/compass-progress-updated
|
||||||
sudo sed -e 's|$CeleryPath|'$VIRTUAL_ENV/bin/celery'|' -i /etc/init.d/compass-celeryd
|
sudo sed -e 's|$CeleryPath|'$VIRTUAL_ENV/bin/celery'|' -i /etc/init.d/compass-celeryd
|
||||||
sudo sed -i "s/\$ipaddr/$ipaddr/g" /etc/compass/os_metadata/general.conf
|
sudo sed -i "s/\$ipaddr/$ipaddr/g" /etc/compass/os_metadata/general.conf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user