Skip to content

Commit

Permalink
Merge "Uninstalling contrail-vrouter-dkms/generic package, Using the …
Browse files Browse the repository at this point in the history
…same method for Identifying the list of package to uninstall."
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Apr 22, 2015
2 parents 07bdfd3 + c942323 commit debbfac
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 127 deletions.
113 changes: 14 additions & 99 deletions fabfile/tasks/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from fabfile.utils.fabos import *
from fabfile.utils.cluster import is_lbaas_enabled, get_orchestrator,\
reboot_nodes
from fabfile.utils.install import get_compute_ceilometer_pkgs,\
get_compute_pkgs, get_ceilometer_plugin_pkgs,\
get_openstack_ceilometer_pkgs
from fabfile.utils.host import get_from_testbed_dict,\
get_openstack_internal_vip, get_hypervisor, get_env_passwords
from fabfile.tasks.helpers import reboot_node
Expand Down Expand Up @@ -280,14 +283,11 @@ def install_ceilometer_compute_node(*args):
with settings(host_string=host_string):
if not is_ceilometer_compute_install_supported():
continue
pkg_ubuntu = ['ceilometer-agent-compute']
pkg_redhat = ['openstack-ceilometer-compute']
act_os_type = detect_ostype()
if act_os_type == 'ubuntu':
apt_install(pkg_ubuntu)
elif act_os_type in ['redhat']:
yum_install(pkg_redhat)
pkgs = get_compute_ceilometer_pkgs()
if pkgs:
pkg_install(pkgs)
else:
act_os_type = detect_ostype()
raise RuntimeError('Unspported OS type (%s)' % (act_os_type))

@task
Expand All @@ -308,18 +308,10 @@ def install_contrail_ceilometer_plugin_node(*args):
with settings(host_string=host_string):
if not is_ceilometer_install_supported():
continue
pkg_contrail_ceilometer = ['ceilometer-plugin-contrail']
pkg_contrail_ceilometer = get_ceilometer_plugin_pkgs()
act_os_type = detect_ostype()
openstack_sku = get_openstack_sku()
if openstack_sku == 'icehouse':
if not act_os_type in ['ubuntu', 'redhat']:
raise RuntimeError('Unsupported OpenStack distribution '
'(%s) on OS type (%s)' % (openstack_sku, act_os_type))
elif openstack_sku == 'juno':
if not act_os_type in ['ubuntu']:
raise RuntimeError('Unsupported OpenStack distribution '
'(%s) on OS type (%s)' % (openstack_sku, act_os_type))
else:
if not pkg_contrail_ceilometer:
raise RuntimeError('Unsupported OpenStack distribution (%s) '
'on (%s)' % (openstack_sku, act_os_type))

Expand Down Expand Up @@ -362,54 +354,12 @@ def install_ceilometer_node(*args):
with settings(host_string=host_string):
if not is_ceilometer_install_supported():
continue
pkg_havana_ubuntu = ['mongodb', 'ceilometer-api',
'ceilometer-collector',
'ceilometer-agent-central',
'python-ceilometerclient']
pkg_icehouse_ubuntu = ['mongodb', 'ceilometer-api',
'ceilometer-collector',
'ceilometer-agent-central',
'ceilometer-agent-notification',
'ceilometer-alarm-evaluator',
'ceilometer-alarm-notifier',
'python-ceilometerclient',
'ceilometer-plugin-contrail']
pkg_juno_ubuntu = ['mongodb-server', 'mongodb-clients',
'python-pymongo', 'ceilometer-api',
'ceilometer-collector',
'ceilometer-agent-central',
'ceilometer-agent-notification',
'ceilometer-alarm-evaluator',
'ceilometer-alarm-notifier',
'python-ceilometerclient',
'ceilometer-plugin-contrail']
pkg_icehouse_redhat = ['ceilometer-plugin-contrail']
pkg_ceilometer = get_openstack_ceilometer_pkgs()
act_os_type = detect_ostype()
openstack_sku = get_openstack_sku()
if openstack_sku == 'havana':
if act_os_type == 'ubuntu':
pkg_ceilometer = pkg_havana_ubuntu
else:
raise RuntimeError('Unsupported OpenStack distribution '
'(%s) on OS type (%s)' % (openstack_sku, act_os_type))
elif openstack_sku == 'icehouse':
if act_os_type == 'ubuntu':
pkg_ceilometer = pkg_icehouse_ubuntu
elif act_os_type in ['redhat']:
pkg_ceilometer = pkg_icehouse_redhat
else:
raise RuntimeError('Unsupported OpenStack distribution '
'(%s) on OS type (%s)' % (openstack_sku, act_os_type))
elif openstack_sku == 'juno':
if act_os_type == 'ubuntu':
pkg_ceilometer = pkg_juno_ubuntu
else:
raise RuntimeError('Unsupported OpenStack distribution '
'(%s) on OS type (%s)' % (openstack_sku, act_os_type))
else:
if not pkg_ceilometer:
raise RuntimeError('Unsupported OpenStack distribution (%s) '
'on (%s)' % (openstack_sku, act_os_type))

if act_os_type == 'ubuntu':
apt_install(pkg_ceilometer)
elif act_os_type in ['redhat']:
Expand Down Expand Up @@ -562,48 +512,13 @@ def install_only_vrouter_node(manage_nova_compute='yes', *args):
for host_string in args:
with settings(host_string=host_string):
ostype = detect_ostype()
pkg = ['contrail-openstack-vrouter']

# For Ubuntu, Install contrail-vrouter-generic package if one available for
# node's kernel version or install contrail-vrouter-dkms
# If dkms is already installed, continue to upgrade contrail-vrouter-dkms
if ostype in ['ubuntu']:
dkms_status = get_build('contrail-vrouter-dkms')
if dkms_status is not None:
contrail_vrouter_pkg = 'contrail-vrouter-dkms'
else:
vrouter_generic_pkg = sudo("apt-cache pkgnames contrail-vrouter-$(uname -r)")
contrail_vrouter_pkg = vrouter_generic_pkg or 'contrail-vrouter-dkms'

dpdk = getattr(env, 'dpdk', None)
if dpdk:
if env.host_string in dpdk:
contrail_vrouter_pkg = 'contrail-vrouter-dpdk-init'

pkg = [contrail_vrouter_pkg, 'contrail-openstack-vrouter']

if (manage_nova_compute == 'no' and ostype in ['centos', 'redhat']):
pkg = ['contrail-vrouter-common',
'openstack-utils',
'contrail-nova-vif',
]
elif (manage_nova_compute== 'no' and ostype in ['ubuntu']):
pkg = [contrail_vrouter_pkg,
'contrail-vrouter-common'
]
if getattr(testbed, 'haproxy', False):
pkg.append('haproxy')
if (ostype == 'ubuntu' and is_lbaas_enabled()):
pkg.append('haproxy')
pkg.append('iproute')
pkgs = get_compute_pkgs(manage_nova_compute)

if ostype == 'ubuntu':
sudo('echo "manual" >> /etc/init/supervisor-vrouter.override')
if get_hypervisor(host_string) == 'docker':
pkg.append('nova-docker')
apt_install(pkg)
apt_install(pkgs)
else:
yum_install(pkg)
yum_install(pkgs)
install_ceilometer_compute_node(host_string)

@task
Expand Down
43 changes: 15 additions & 28 deletions fabfile/tasks/uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
from fabfile.config import *
from fabfile.utils.fabos import *
from fabfile.utils.host import get_openstack_internal_vip, get_from_testbed_dict
from fabfile.utils.analytics import is_ceilometer_install_supported,\
is_ceilometer_compute_install_supported
from fabfile.utils.install import get_compute_ceilometer_pkgs,\
get_compute_pkgs, get_ceilometer_plugin_pkgs,\
get_openstack_ceilometer_pkgs

def get_pkg_list():
dont_remove_list = [
Expand Down Expand Up @@ -157,6 +162,9 @@ def uninstall_openstack_node(*args):
pkg = ['contrail-openstack']
if len(env.roledefs['openstack']) > 1 and get_openstack_internal_vip():
pkg.append('contrail-openstack-ha')
if is_ceilometer_install_supported():
pkg += get_openstack_ceilometer_pkgs()
pkg += get_ceilometer_plugin_pkgs()
if detect_ostype() == 'ubuntu':
with settings(warn_only=True):
sudo("umount /var/lib/glance/images")
Expand Down Expand Up @@ -305,35 +313,14 @@ def uninstall_only_vrouter_node(manage_nova_compute='yes', *args):
for host_string in args:
ostype = detect_ostype()
with settings(host_string=host_string):
pkg = ['contrail-openstack-vrouter']
if (manage_nova_compute == 'no' and ostype in ['centos']):
pkg = ['contrail-vrouter',
'abrt',
#'openstack-nova-compute',
'openstack-utils',
'python-thrift',
#'librabbitmq',
'contrail-nova-vif',
'contrail-setup',
'contrail-nodemgr',
'contrail-vrouter-init',
]
elif (manage_nova_compute== 'no' and ostype in ['ubuntu']):
pkg = ['contrail-nodemgr',
'contrail-setup',
'contrail-vrouter-init',
#'nova-compute',
'python-iniparse',
#'python-novaclient',
'contrail-nova-vif',
#'librabbitmq0',
'linux-crashdump',
'contrail-vrouter'
]
if getattr(testbed, 'haproxy', False):
pkg.append('haproxy')
manage_nova_compute = 'no'
if is_package_installed('contrail-openstack-vrouter'):
manage_nova_compute = 'yes'
pkgs = get_compute_pkgs(manage_nova_compute)
if ostype == 'ubuntu':
apt_uninstall(pkg)
if is_ceilometer_compute_install_supported():
pkgs.append('ceilometer-agent-compute')
apt_uninstall(pkgs)
sudo("sed -i 's/inet manual/inet dhcp/g' /etc/network/interfaces")
else:
pkgs = get_pkg_list()
Expand Down
133 changes: 133 additions & 0 deletions fabfile/utils/install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
from fabric.api import env, settings, sudo

from fabos import detect_ostype, get_release, get_build, get_openstack_sku
from fabfile.utils.host import get_hypervisor
from fabfile.utils.cluster import is_lbaas_enabled
from fabfile.config import *


def get_vrouter_kmod_pkg():
"""Return the contrail-vrouter-dkms | contrail-vrouter-generic
package to be installed in compute node depending on the kernel
version.
"""
ostype = detect_ostype()
if ostype in ['ubuntu']:
dkms_status = get_build('contrail-vrouter-dkms')
if dkms_status is not None:
contrail_vrouter_pkg = 'contrail-vrouter-dkms'
else:
# Search for matching contrail-vrouter pkg for kernel version in cache.
vrouter_generic_pkg = sudo("apt-cache pkgnames contrail-vrouter-$(uname -r)")
contrail_vrouter_pkg = vrouter_generic_pkg or 'contrail-vrouter-dkms'
else:
contrail_vrouter_pkg = None

return contrail_vrouter_pkg

def get_compute_pkgs(manage_nova_compute='yes'):
"""Returns a list of packages to be installed in the
compute node.
"""
ostype = detect_ostype()
pkgs = ['contrail-openstack-vrouter']

if ostype in ['ubuntu']:
# For Ubuntu, Install contrail-vrouter-generic package if one available for
# node's kernel version or install contrail-vrouter-dkms
# If dkms is already installed, continue to upgrade contrail-vrouter-dkms
contrail_vrouter_pkg = get_vrouter_kmod_pkg()

if env.host_string in getattr(env, 'dpdk', []):
contrail_vrouter_pkg = 'contrail-vrouter-dpdk-init'

pkgs.append(contrail_vrouter_pkg)

# Append only vrouter and contrail vrouter dependent packages
# no need to append the contrail-openstack-vrouter, which when
# installed will bring in nova-compute and its dependents.
if (manage_nova_compute == 'no' and ostype in ['centos', 'redhat']):
pkgs = ['contrail-vrouter-common',
'openstack-utils',
'contrail-nova-vif',
]
elif (manage_nova_compute== 'no' and ostype in ['ubuntu']):
pkgs = [contrail_vrouter_pkg,
'contrail-vrouter-common'
]
# Append lbaas dependent packages if haproxy is enabled..
if getattr(testbed, 'haproxy', False):
pkgs.append('haproxy')

# Append lbaas dependent packages if Lbaas is enabled..
if (ostype == 'ubuntu' and is_lbaas_enabled()):
pkgs.append('haproxy')
pkgs.append('iproute')

if ostype == 'ubuntu':
# Append nova-docker if hypervisor for this compute host is docker.
if get_hypervisor(env.host_string) == 'docker':
pkgs.append('nova-docker')

return pkgs

def get_openstack_ceilometer_pkgs():
""" Returns the list of ceilometer packages used in a
openstack node.
"""
pkg_havana_ubuntu = ['mongodb', 'ceilometer-api',
'ceilometer-collector',
'ceilometer-agent-central',
'python-ceilometerclient']
pkg_icehouse_ubuntu = pkg_havana_ubuntu + [
'ceilometer-agent-notification',
'ceilometer-alarm-evaluator',
'ceilometer-alarm-notifier',
'ceilometer-plugin-contrail']
pkg_juno_ubuntu = pkg_icehouse_ubuntu + [
'mongodb-server',
'mongodb-clients',
'python-pymongo']
pkg_juno_ubuntu.remove('mongodb')
pkg_icehouse_redhat = ['ceilometer-plugin-contrail']

ceilometer_pkgs = {
'ubuntu' : {'havana' : pkg_havana_ubuntu,
'icehouse' : pkg_icehouse_ubuntu,
'juno' : pkg_juno_ubuntu
},
'redhat' : {'icehouse' : pkg_icehouse_redhat},
}

act_os_type = detect_ostype()
openstack_sku = get_openstack_sku()
return ceilometer_pkgs.get(act_os_type, {}).get(openstack_sku, [])

def get_ceilometer_plugin_pkgs():
""" Returns the list of ceilometer plugin packages used in a
openstack node.
"""
pkg_contrail_ceilometer = ['ceilometer-plugin-contrail']
ceilometer_plugin_pkgs = {
'ubuntu' : {'icehouse' : pkg_contrail_ceilometer,
'juno' : pkg_contrail_ceilometer
},
'redhat' : {'icehouse' : pkg_contrail_ceilometer},
}

act_os_type = detect_ostype()
openstack_sku = get_openstack_sku()
return ceilometer_plugin_pkgs.get(act_os_type, {}).get(openstack_sku, [])

def get_compute_ceilometer_pkgs():
""" Returns the list of ceilometer packages used in a
compute node.
"""
pkgs = []
ostype = detect_ostype()
if ostype == 'ubuntu':
pkgs = ['ceilometer-agent-compute']
elif ostype == 'redhat':
pkgs = ['openstack-ceilometer-compute']

return pkgs

0 comments on commit debbfac

Please sign in to comment.