示例#1
0
def install_ceilometer_node(*args):
    """Installs openstack pkgs in one or list of nodes. USAGE:fab install_ceilometer_node:[email protected],[email protected]"""
    for host_string in args:
        if env.roledefs['openstack'] and \
                host_string != env.roledefs['openstack'][0]:
            continue
        with settings(host_string=host_string):
            if not is_ceilometer_install_supported():
                continue
            pkg_ceilometer = get_openstack_ceilometer_pkgs()
            act_os_type = detect_ostype()
            openstack_sku = get_openstack_sku()
            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']:
                # We need to copy the pkg from the cfgm node
                # and then install it on the openstack node
                cfgm_node = env.roledefs['cfgm'][0]
                local_tempdir = tempfile.mkdtemp()
                with lcd(local_tempdir):
                    for pkg in pkg_ceilometer:
                        with settings(host_string = cfgm_node):
                            get('/opt/contrail/contrail_install_repo/%s*.rpm' % (pkg), local_tempdir)
                output = local("ls %s/*.rpm" % (local_tempdir), capture=True)
                pkg_list = output.split('\n')
                for pkg in pkg_list:
                    install_pkg_node(pkg, host_string)
                local('rm -rf %s' % (local_tempdir))
            else:
                yum_install(pkg_ceilometer)
def uninstall_openstack_node(*args):
    """Uninstalls openstack pkgs in one or list of nodes. USAGE:fab uninstall_openstack_node:[email protected],[email protected]"""
    for host_string in args:
        with settings(host_string=host_string):
            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")
                sudo("sed -i '/.*glance.*/d' /etc/fstab")
                apt_uninstall(pkg)
            else:
                pkgs = get_pkg_list()
                yum_uninstall(pkgs)
            with cd('/etc/'):
                sudo('sudo rm -rf glance/ cinder/ openstack_dashboard/ keystone/ quantum/ nova/ haproxy/ keepalived/')
            with cd('/var/lib/'):
                sudo('sudo rm -rf nova quantum glance quantum keystone mysql haproxy')
            with cd('/var/run'):
                sudo('sudo rm -rf cinder glance quantum nova keystone')
            with cd('/var/log'):
                sudo('sudo rm -rf contrail/* nova quantum glance cinder ~/keystone-signing /tmp/keystone-signing /tmp/keystone-signing-nova')
示例#3
0
def install_ceilometer_node(*args):
    """Installs openstack pkgs in one or list of nodes. USAGE:fab install_ceilometer_node:[email protected],[email protected]"""
    for host_string in args:
        with settings(host_string=host_string):
            if not is_ceilometer_install_supported():
                continue
            pkg_ceilometer = get_openstack_ceilometer_pkgs()
            act_os_type = detect_ostype()
            openstack_sku = get_openstack_sku()
            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']:
                # We need to copy the pkg from the cfgm node
                # and then install it on the openstack node
                cfgm_node = env.roledefs['cfgm'][0]
                local_tempdir = tempfile.mkdtemp()
                with lcd(local_tempdir):
                    for pkg in pkg_ceilometer:
                        with settings(host_string = cfgm_node):
                            get('/opt/contrail/contrail_install_repo/%s*.rpm' % (pkg), local_tempdir)
                output = local("ls %s/*.rpm" % (local_tempdir), capture=True)
                pkg_list = output.split('\n')
                for pkg in pkg_list:
                    install_pkg_node(pkg, host_string)
                local('rm -rf %s' % (local_tempdir))
            else:
                yum_install(pkg_ceilometer)
示例#4
0
def uninstall_openstack_node(*args):
    """Uninstalls openstack pkgs in one or list of nodes. USAGE:fab uninstall_openstack_node:[email protected],[email protected]"""
    for host_string in args:
        with settings(host_string=host_string):
            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")
                sudo("sed -i '/.*glance.*/d' /etc/fstab")
                apt_uninstall(pkg)
            else:
                pkgs = get_pkg_list()
                yum_uninstall(pkgs)
            with cd('/etc/'):
                sudo(
                    'sudo rm -rf glance/ cinder/ openstack_dashboard/ keystone/ quantum/ nova/ haproxy/ keepalived/'
                )
            with cd('/var/lib/'):
                sudo(
                    'sudo rm -rf nova quantum glance quantum keystone mysql haproxy'
                )
            with cd('/var/run'):
                sudo('sudo rm -rf cinder glance quantum nova keystone')
            with cd('/var/log'):
                sudo(
                    'sudo rm -rf contrail/* nova quantum glance cinder ~/keystone-signing /tmp/keystone-signing /tmp/keystone-signing-nova'
                )