def get_openstack_ceilometer_pkgs():
    """ Returns the list of ceilometer packages used in a
        openstack node.
    """
    pkg_juno_ubuntu = [
        "ceilometer-api",
        "ceilometer-collector",
        "ceilometer-agent-central",
        "ceilometer-agent-notification",
        "ceilometer-alarm-evaluator",
        "ceilometer-alarm-notifier",
        "ceilometer-plugin-contrail",
        "mongodb-clients",
        "python-pymongo",
    ]
    pkg_kilo_ubuntu = copy.deepcopy(pkg_juno_ubuntu)
    pkg_kilo_ubuntu.remove("ceilometer-plugin-contrail")

    pkg_redhat = ["ceilometer-plugin-contrail"]

    ceilometer_pkgs = {"ubuntu": {"juno": pkg_juno_ubuntu, "kilo": pkg_kilo_ubuntu}, "redhat": {"juno": pkg_redhat}}

    act_os_type = detect_ostype()
    openstack_sku = get_openstack_sku()
    return ceilometer_pkgs.get(act_os_type, {}).get(openstack_sku, [])
def get_openstack_ceilometer_pkgs():
    """ Returns the list of ceilometer packages used in a
        openstack node.
    """
    pkg_juno_ubuntu = ['ceilometer-api',
        'ceilometer-collector',
        'ceilometer-agent-central',
        'ceilometer-agent-notification',
        'ceilometer-alarm-evaluator',
        'ceilometer-alarm-notifier',
        'ceilometer-plugin-contrail',
        'mongodb-clients',
        'python-pymongo']
    pkg_kilo_ubuntu = copy.deepcopy(pkg_juno_ubuntu)
    pkg_kilo_ubuntu.remove('ceilometer-plugin-contrail')

    pkg_redhat = ['ceilometer-plugin-contrail']

    ceilometer_pkgs = {
        'ubuntu' : {
                    'juno' : pkg_juno_ubuntu,
                    'kilo' : pkg_kilo_ubuntu
                   },
        'redhat' : {'juno' : pkg_redhat},
    }

    act_os_type = detect_ostype()
    openstack_sku = get_openstack_sku()
    return ceilometer_pkgs.get(act_os_type, {}).get(openstack_sku, [])
def get_compute_pkgs(manage_nova_compute='yes'):
    """Returns a list of packages to be installed in the
       compute node.
    """
    ostype = detect_ostype()

    if get_orchestrator() is 'vcenter':
        pkgs = ['contrail-vmware-vrouter']
    else:
        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'
        # This order of installation matters, because in a node with
        # non recommended kernel installed, contrail-vrouter-dkms pkg
        # needs to get installed first before contrail-openstack-vrouter.
        if get_orchestrator() is 'vcenter':
            pkgs = [contrail_vrouter_pkg, 'contrail-vmware-vrouter']
        else:
            pkgs = [contrail_vrouter_pkg, 'contrail-openstack-vrouter']

    # 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', 'fedora', 'centoslinux']):
        pkgs = [
            'contrail-vrouter-common',
            'openstack-utils',
        ]
        if get_openstack_sku() in ['juno']:
            pkgs.append('contrail-nova-vif')
    elif (manage_nova_compute == 'no' and ostype in ['ubuntu']):
        pkgs = [contrail_vrouter_pkg, 'contrail-vrouter-common']
        if get_orchestrator() is 'openstack':
            pkgs.append('contrail-nova-vif')
        else:
            pkgs.append('contrail-vmware-vrouter')
    # 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 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_compute_pkgs(manage_nova_compute='yes'):
    """Returns a list of packages to be installed in the
       compute node.
    """
    ostype = detect_ostype()

    if get_orchestrator() is 'vcenter':
        pkgs = ['contrail-vmware-vrouter']
    else:
        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'
        # This order of installation matters, because in a node with
        # non recommended kernel installed, contrail-vrouter-dkms pkg
        # needs to get installed first before contrail-openstack-vrouter.
        if get_orchestrator() is 'vcenter':
            pkgs = [contrail_vrouter_pkg, 'contrail-vmware-vrouter']
        else:
            pkgs = [contrail_vrouter_pkg, 'contrail-openstack-vrouter']

    # 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', 'fedora', 'centoslinux']):
        pkgs = ['contrail-vrouter-common',
               'openstack-utils',
              ]
        if get_openstack_sku() in ['juno']:
            pkgs.append('contrail-nova-vif')
    elif (manage_nova_compute== 'no' and ostype in ['ubuntu']):
        pkgs = [contrail_vrouter_pkg,
               'contrail-vrouter-common']
	if get_orchestrator() is 'openstack':
            pkgs.append('contrail-nova-vif')
        else:
            pkgs.append('contrail-vmware-vrouter')
    # 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 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_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": {"juno": pkg_contrail_ceilometer}, "redhat": {"juno": 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_net_driver_pkgs():
    """ Returns the list of network driver packages used in
        all the nodes
    """
    pkgs = []
    ostype = detect_ostype()
    if ostype == 'ubuntu':
        pkgs = ['i40e-dkms', 'bnxt-en-dkms']

    return pkgs
def get_net_driver_pkgs():
    """ Returns the list of network driver packages used in
        all the nodes
    """
    pkgs = []
    ostype = detect_ostype()
    if ostype == 'ubuntu':
        pkgs = ['i40e-dkms', 'bnxt-en-dkms']

    return pkgs
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
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
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' : pkg_contrail_ceilometer,
        'redhat' : pkg_contrail_ceilometer,
    }
        
    act_os_type = detect_ostype()
    return ceilometer_plugin_pkgs.get(act_os_type, [])
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
def get_compute_pkgs(manage_nova_compute="yes"):
    """Returns a list of packages to be installed in the
       compute node.
    """
    ostype = detect_ostype()

    if get_orchestrator() is "vcenter":
        pkgs = ["contrail-vmware-vrouter"]
    else:
        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"
        # This order of installation matters, because in a node with
        # non recommended kernel installed, contrail-vrouter-dkms pkg
        # needs to get installed first before contrail-openstack-vrouter.
        if get_orchestrator() is "vcenter":
            pkgs = [contrail_vrouter_pkg, "contrail-vmware-vrouter"]
        else:
            pkgs = [contrail_vrouter_pkg, "contrail-openstack-vrouter"]

    # 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", "fedora", "centoslinux"]:
        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"]
        if get_orchestrator() is "openstack":
            pkgs.append("contrail-nova-vif")
        else:
            pkgs.append("contrail-vmware-vrouter")
    # 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_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': pkg_contrail_ceilometer,
        'redhat': pkg_contrail_ceilometer,
    }

    act_os_type = detect_ostype()
    return ceilometer_plugin_pkgs.get(act_os_type, [])
def reboot_nodes(*args):
    """reboots the given nodes"""
    for host_string in args:
        with settings(host_string=host_string):
            os_type =  detect_ostype()
            print "Rebooting (%s) to boot with new kernel version" % host_string
            try:
                if os_type.lower() in ['ubuntu']:
                    sudo('sync; reboot --force', timeout=3)
                else:
                    sudo('sleep 5; shutdown -r now', timeout=3)
            except CommandTimeout:
                pass
Exemple #15
0
def reboot_nodes(*args):
    """reboots the given nodes"""
    for host_string in args:
        with settings(host_string=host_string):
            os_type = detect_ostype()
            print "Rebooting (%s) to boot with new kernel version" % host_string
            try:
                if os_type.lower() in ['ubuntu']:
                    sudo('sync; reboot --force', timeout=3)
                else:
                    sudo('sleep 5; shutdown -r now', timeout=3)
            except CommandTimeout:
                pass
Exemple #16
0
def get_metadata_secret():
    """ Retrieves metadata secret
        1. if metadata secret is supplied in testbed, retrieve its value from testbed
        2. if not defined in testbed, depending on orchestrator, retrieve it from
           the first orchestrator node
    """

    metadata_secret = None
    orch = get_orchestrator()
    if orch.lower() == 'openstack':
        openstack_host = env.roledefs['openstack'][0]

        # Use metadata_secret provided in testbed. If not available
        # retrieve metadata secret from openstack node
        metadata_secret = getattr(testbed,
                                  'neutron_metadata_proxy_shared_secret', None)

        if not metadata_secret:
            with settings(host_string=openstack_host):
                ostype = detect_ostype()
                # For Juno, use service_metadata_proxy metadata_proxy_shared_secret
                # from neutron section in /etc/nova/nova.conf
                if ostype.lower() in ['centos', 'redhat', 'centoslinux']:
                    api_version = sudo(
                        "rpm -q --queryformat='%{VERSION}' openstack-nova-api")
                    is_juno_or_higher = LooseVersion(
                        api_version) >= LooseVersion('2014.2.2')
                elif ostype.lower() in ['ubuntu']:
                    api_version = sudo(
                        "dpkg-query -W -f='${VERSION}' nova-api")
                    is_juno_or_higher = LooseVersion(
                        api_version) >= LooseVersion('2014.2.2')
                else:
                    raise RuntimeError("Unknown ostype (%s)" % ostype)

                if is_juno_or_higher:
                    status, secret = get_value('/etc/nova/nova.conf',
                                               'neutron',
                                               'service_metadata_proxy',
                                               'metadata_proxy_shared_secret')
                else:
                    status, secret = get_value(
                        '/etc/nova/nova.conf', 'DEFAULT',
                        'service_neutron_metadata_proxy',
                        'neutron_metadata_proxy_shared_secret')
            metadata_secret = secret if status == 'True' else None
    else:
        print "WARNING get_metadata_secret: Orchestrator(%s) is not supported" % orch
    return metadata_secret
def get_metadata_secret():
    """ Retrieves metadata secret
        1. if metadata secret is supplied in testbed, retrieve its value from testbed
        2. if not defined in testbed, depending on orchestrator, retrieve it from
           the first orchestrator node
    """

    metadata_secret = None
    orch = get_orchestrator()
    if orch.lower() == 'openstack':
        openstack_host = env.roledefs['openstack'][0]

        # Use metadata_secret provided in testbed. If not available
        # retrieve metadata secret from openstack node
        metadata_secret = getattr(testbed,
                                  'neutron_metadata_proxy_shared_secret',
                                  None)

        if not metadata_secret:
            with settings(host_string=openstack_host):
                ostype = detect_ostype()
                # For Juno, use service_metadata_proxy metadata_proxy_shared_secret
                # from neutron section in /etc/nova/nova.conf
                if ostype.lower() in ['centos', 'redhat', 'centoslinux']:
                    api_version = sudo("rpm -q --queryformat='%{VERSION}' openstack-nova-api")
                    is_juno_or_higher = LooseVersion(api_version) >= LooseVersion('2014.2.2')
                elif ostype.lower() in ['ubuntu']:
                    api_version = sudo("dpkg-query -W -f='${VERSION}' nova-api")
                    is_juno_or_higher = LooseVersion(api_version) >= LooseVersion('2014.2.2')
                else:
                    raise RuntimeError("Unknown ostype (%s)" % ostype)

                if is_juno_or_higher:
                    status, secret = get_value('/etc/nova/nova.conf',
                                               'neutron',
                                               'service_metadata_proxy',
                                               'metadata_proxy_shared_secret')
                else:
                    status, secret = get_value('/etc/nova/nova.conf',
                                               'DEFAULT',
                                               'service_neutron_metadata_proxy',
                                               'neutron_metadata_proxy_shared_secret')
            metadata_secret = secret if status == 'True' else None
    else:
        print "WARNING get_metadata_secret: Orchestrator(%s) is not supported" % orch
    return metadata_secret
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_nodes_to_upgrade_pkg(package, os_type, *args, **kwargs):
    """get the list of nodes in which th given package needs to be upgraded"""
    nodes = []
    version = kwargs.get("version", None)
    for host_string in args:
        with settings(host_string=host_string, warn_only=True):
            act_os_type = detect_ostype()
            if act_os_type == os_type:
                installed = sudo("dpkg -l | grep %s" % package)
                if not installed:
                    nodes.append(host_string)
                elif version and version != "%s-%s" % (get_release(package), get_build(package)):
                    nodes.append(host_string)
                else:
                    print "Required package %s installed. Skipping!" % package
            else:
                raise RuntimeError("Actual OS Type (%s) != Expected OS Type (%s)" "Aborting!" % (act_os_type, os_type))
    return nodes
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
Exemple #21
0
def get_nodes_to_upgrade_pkg(package, os_type, *args, **kwargs):
    """get the list of nodes in which th given package needs to be upgraded"""
    nodes = []
    version = kwargs.get('version', None)
    for host_string in args:
        with settings(host_string=host_string, warn_only=True):
            act_os_type = detect_ostype()
            if act_os_type == os_type:
                installed = run("dpkg -l | grep %s" % package)
                if not installed:
                    nodes.append(host_string)
                elif (version and version != '%s-%s' %
                      (get_release(package), get_build(package))):
                    nodes.append(host_string)
                else:
                    print 'Required package %s installed. Skipping!' % package
            else:
                raise RuntimeError(
                    'Actual OS Type (%s) != Expected OS Type (%s)'
                    'Aborting!' % (act_os_type, os_type))
    return nodes
def get_openstack_ceilometer_pkgs():
    """ Returns the list of ceilometer packages used in a
        openstack node.
    """
    pkg_ubuntu = ['ceilometer-api',
        'ceilometer-collector',
        'ceilometer-agent-central',
        'ceilometer-agent-notification',
        'ceilometer-alarm-evaluator',
        'ceilometer-alarm-notifier',
        'ceilometer-plugin-contrail',
        'mongodb-clients',
        'python-pymongo']
    pkg_redhat = ['ceilometer-plugin-contrail']

    ceilometer_pkgs = {
        'ubuntu' : pkg_ubuntu,
        'redhat' : pkg_redhat,
    }

    act_os_type = detect_ostype()
    return ceilometer_pkgs.get(act_os_type, [])
def get_openstack_ceilometer_pkgs():
    """ Returns the list of ceilometer packages used in a
        openstack node.
    """
    pkg_ubuntu = [
        'ceilometer-api', 'ceilometer-collector', 'ceilometer-agent-central',
        'ceilometer-agent-notification', 'ceilometer-plugin-contrail',
        'mongodb-clients', 'python-pymongo'
    ]
    if get_openstack_sku() in ['juno', 'kilo', 'liberty']:
        pkg_ubuntu += [
            'ceilometer-alarm-evaluator', 'ceilometer-alarm-notifier'
        ]

    pkg_redhat = ['ceilometer-plugin-contrail']

    ceilometer_pkgs = {
        'ubuntu': pkg_ubuntu,
        'redhat': pkg_redhat,
    }

    act_os_type = detect_ostype()
    return ceilometer_pkgs.get(act_os_type, [])