def is_contrail_node(node): '''Assuming that all contrail nodes are installed with package - contrail-setup, returns True if the package is installed in the node ''' package_info = '' with settings(host_string=node, warn_only=True): package_info = get_build('contrail-setup') return True if package_info else False
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
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_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): if os_type in ['ubuntu']: installed = sudo("dpkg -l | grep %s" % package) elif os_type in ['centos', 'redhat', 'centoslinux']: installed = sudo("rpm -qa | grep %s" % package) else: raise RuntimeError('Unsupported OS type!') 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 return nodes