kill redis server before restart redis

remove force download local repo
enable compass check

Change-Id: I6d0682fe027f283d194e7173215618a8b75b14d4
This commit is contained in:
xiaodongwang 2014-11-01 11:22:01 -07:00
parent ec24bb4208
commit fd41871603
8 changed files with 82 additions and 18 deletions

View File

@ -67,6 +67,11 @@ def delete_clusters():
cluster_id = cluster['id']
hosts = cluster_api.list_cluster_hosts(user, cluster_id)
host_id_list = [host['id'] for host in hosts]
logging.info(
'delete cluster %s and cluster hosts %s',
cluster_id, host_id_list
)
logging.info('delete underlying host? %s', delete_underlying_host)
if flags.OPTIONS.async:
celery.send_task(
'compass.tasks.delete_cluster',

View File

@ -17,6 +17,7 @@
import logging
from compass.actions import util
from compass.db.api import cluster as cluster_api
from compass.db.api import user as user_db
from compass.deployment.deploy_manager import DeployManager
from compass.deployment.utils import constants as const
@ -40,6 +41,22 @@ def delete_cluster(
user = user_db.get_user_object(username)
for host_id in host_id_list:
cluster_api.update_cluster_host_state(
user, cluster_id, host_id, state='ERROR'
)
cluster_api.update_cluster_state(
user, cluster_id, state='ERROR'
)
cluster_api.update_cluster(
user, cluster_id, reinstall_distributed_system=True
)
for host_id in host_id_list:
cluster_api.update_cluster_host(
user, cluster_id, host_id, reinstall_os=True
)
cluster_info = util.ActionHelper.get_cluster_info(cluster_id, user)
adapter_id = cluster_info[const.ADAPTER_ID]
@ -48,9 +65,10 @@ def delete_cluster(
hosts_info = util.ActionHelper.get_hosts_info(
cluster_id, host_id_list, user)
logging.debug('adapter info: %s', adapter_info)
logging.debug('cluster info: %s', cluster_info)
logging.debug('hosts info: %s', hosts_info)
deploy_manager = DeployManager(adapter_info, cluster_info, hosts_info)
logging.debug('Created deploy manager with %s %s %s'
% (adapter_info, cluster_info, hosts_info))
deploy_manager.remove_hosts(
package_only=not delete_underlying_host,

View File

@ -549,10 +549,13 @@ def add_clusterhost_internal(
session, models.Host, False, id=machine_id
)
if host:
if host_api.is_host_editable(
session, host, cluster.creator,
reinstall_os_set=kwargs.get('reinstall_os', False),
exception_when_not_editable=False
if (
host_dict and
host_api.is_host_editable(
session, host, cluster.creator,
reinstall_os_set=kwargs.get('reinstall_os', False),
exception_when_not_editable=False
)
):
if 'name' in host_dict:
hostname = host_dict['name']
@ -719,6 +722,38 @@ def add_cluster_host(
)
@utils.wrap_to_dict(RESP_CLUSTERHOST_FIELDS)
def _update_clusterhost(session, updater, clusterhost, **kwargs):
clusterhost_dict = {}
host_dict = {}
for key, value in kwargs.items():
if key in UPDATED_HOST_FIELDS:
host_dict[key] = value
else:
clusterhost_dict[key] = value
if host_dict:
from compass.db.api import host as host_api
host = clusterhost.host
if host_api.is_host_editable(
session, host, clusterhost.cluster.creator,
reinstall_os_set=kwargs.get('reinstall_os', False),
exception_when_not_editable=False
):
if 'name' in host_dict:
hostname = host_dict['name']
host_by_name = utils.get_db_object(
session, models.Host, False, name=hostname
)
if host_by_name and host_by_name.id != host.id:
raise exception.InvalidParameter(
'host name %s exists in host %s' % (
hostname, host_by_name.id
)
)
utils.update_db_object(
session, host,
**host_dict
)
def roles_validates(roles):
cluster_roles = []
cluster = clusterhost.cluster
@ -759,7 +794,7 @@ def _update_clusterhost(session, updater, clusterhost, **kwargs):
@utils.supported_filters(
optional_support_keys=UPDATED_CLUSTERHOST_FIELDS,
optional_support_keys=(UPDATED_HOST_FIELDS + UPDATED_CLUSTERHOST_FIELDS),
ignore_support_keys=IGNORE_FIELDS
)
@database.run_in_session()
@ -775,7 +810,7 @@ def update_cluster_host(
@utils.supported_filters(
optional_support_keys=UPDATED_CLUSTERHOST_FIELDS,
optional_support_keys=(UPDATED_HOST_FIELDS + UPDATED_CLUSTERHOST_FIELDS),
ignore_support_keys=IGNORE_FIELDS
)
@database.run_in_session()

View File

@ -302,8 +302,10 @@ class CobblerInstaller(OSInstaller):
def delete_hosts(self):
hosts_id_list = self.config_manager.get_host_id_list()
logging.debug('delete hosts %s', hosts_id_list)
for host_id in hosts_id_list:
self.delete_single_host(host_id)
self._sync()
def delete_single_host(self, host_id):
"""Delete the host from cobbler server and clean up the installation
@ -311,11 +313,12 @@ class CobblerInstaller(OSInstaller):
"""
hostname = self.config_manager.get_hostname(host_id)
try:
log_dir_prefix = compass_setting.INSTALLATION_LOGDIR[self.NAME]
log_dir_prefix = compass_setting.INSTALLATION_LOGDIR[NAME]
self._clean_system(hostname)
self._clean_log(log_dir_prefix, hostname)
except Exception as ex:
logging.info("Deleting host got exception: %s", ex.message)
logging.error("Deleting host got exception: %s", ex)
logging.exception(ex)
def _get_host_tmpl_vars_dict(self, host_id, global_vars_dict, **kwargs):
"""Generate template variables dictionary.

View File

@ -549,7 +549,7 @@ class ChefInstaller(PKInstaller):
def _clean_log(self, log_dir_prefix, node_name):
log_dir = os.path.join(log_dir_prefix, node_name)
shutil.rmtree(log_dir, False)
shutil.rmtree(log_dir, True)
def get_supported_dist_systems(self):
"""get target systems from chef. All target_systems for compass will

View File

@ -87,6 +87,7 @@ sudo mkdir -p /var/lib/redis/
sudo chown -R redis:root /var/lib/redis
sudo mkdir -p /var/run/redis
sudo chown -R redis:root /var/run/redis
killall -9 redis-server
sudo service redis restart
echo "Checking if redis is running"
sudo service redis status
@ -153,8 +154,8 @@ else
echo "compass-progress-updated has already started"
fi
#compass check
#if [[ "$?" != "0" ]]; then
# echo "compass check failed"
# exit 1
#fi
compass check
if [[ "$?" != "0" ]]; then
echo "compass check failed"
exit 1
fi

View File

@ -22,7 +22,7 @@ sudo cp -rf $WEB_HOME/v2 /var/www/compass_web/
if [[ $LOCAL_REPO = "y" ]]; then
echo "setting up local repo"
mkdir -p /tmp/repo
download -f https://s3-us-west-1.amazonaws.com/compass-local-repo/local_repo.tar.gz local_repo.tar.gz unzip /tmp/repo || exit $?
download https://s3-us-west-1.amazonaws.com/compass-local-repo/local_repo.tar.gz local_repo.tar.gz unzip /tmp/repo || exit $?
mv -f /tmp/repo/local_repo/* /var/www/compass_web/v2/
if [[ "$?" != "0" ]]; then
echo "failed to setup local repo"

View File

@ -174,6 +174,7 @@ if [ "$tempest" == "true" ]; then
mkvirtualenv tempest
fi
workon tempest
rm -rf ${WORKON_HOME}/tempest/build
cd /tmp/tempest
pip install -e .
pip install sqlalchemy
@ -193,6 +194,7 @@ if ! lsvirtualenv |grep compass-core>/dev/null; then
fi
cd $COMPASSDIR
workon compass-core
rm -rf ${WORKON_HOME}/compass-core/build
echo "install compass requirements"
pip install -U -r requirements.txt
if [[ "$?" != "0" ]]; then
@ -256,7 +258,7 @@ fi
# download local repo
if [[ $LOCAL_REPO = "y" ]]; then
download -f https://s3-us-west-1.amazonaws.com/compass-local-repo/local_repo.tar.gz local_repo.tar.gz || exit $?
download https://s3-us-west-1.amazonaws.com/compass-local-repo/local_repo.tar.gz local_repo.tar.gz || exit $?
fi
# Install net-snmp