示例#1
0
    def get_update_status(self, storagerouter):
        """
        Return available updates for framework, volumedriver, ...
        :param storagerouter: StorageRouter to get the update information from
        :type storagerouter: StorageRouter
        """
        update_info = UpdateController.get_update_information_core({})
        framework_info = update_info.pop("framework", None)
        storagedriver_info = update_info.pop("storagedriver", None)

        return_value = {
            "upgrade_ongoing": UpdateController.get_update_metadata(storagerouter_ip=storagerouter.ip)["update_ongoing"]
        }
        if framework_info is not None and framework_info["packages"]:
            return_value["framework"] = []
            for pkg_name, pkg_info in framework_info["packages"].iteritems():
                return_value["framework"].append(
                    {
                        "to": pkg_info["candidate"],
                        "name": pkg_name,
                        "gui_down": True,
                        "downtime": framework_info["downtime"],
                        "namespace": "ovs",
                        "prerequisites": framework_info["prerequisites"],
                    }
                )
        if storagedriver_info is not None and storagedriver_info["packages"]:
            return_value["storagedriver"] = []
            for pkg_name, pkg_info in storagedriver_info["packages"].iteritems():
                return_value["storagedriver"].append(
                    {
                        "to": pkg_info["candidate"],
                        "name": pkg_name,
                        "gui_down": False,
                        "downtime": storagedriver_info["downtime"],
                        "namespace": "ovs",
                        "prerequisites": storagedriver_info["prerequisites"],
                    }
                )

        for plugin_name, info in update_info.iteritems():
            if info["packages"]:
                return_value[plugin_name] = []
                for pkg_name, pkg_info in info["packages"].iteritems():
                    return_value[plugin_name].append(
                        {
                            "to": pkg_info["candidate"],
                            "name": pkg_name,
                            "gui_down": False,
                            "downtime": info["downtime"],
                            "namespace": plugin_name,
                            "prerequisites": info["prerequisites"],
                        }
                    )
        return return_value
    def post_update_alba_plugin_framework(client, components):
        """
        Execute functionality after the openvstorage-backend core packages have been updated
        For framework:
            * Restart arakoon-ovsdb on every client (if present and required)
            * Restart arakoon-config on every client (if present and required)
        For ALBA:
            * Restart ABM arakoons on every client (if present and required)
            * Restart NSM arakoons on every client (if present and required)
        :param client: Client on which to execute this post update functionality
        :type client: SSHClient
        :param components: Update components which have been executed
        :type components: list
        :return: None
        """
        if 'framework' not in components and 'alba' not in components:
            return

        update_information = AlbaUpdateController.get_update_information_alba_plugin({})
        services_to_restart = set()
        if 'alba' in components:
            services_to_restart.update(update_information.get('alba', {}).get('services_post_update', set()))
        if 'framework' in components:
            services_to_restart.update(update_information.get('framework', {}).get('services_post_update', set()))

        # Restart Arakoon (and other services)
        if services_to_restart:
            AlbaUpdateController._logger.debug('{0}: Executing hook {1}'.format(client.ip, inspect.currentframe().f_code.co_name))
            for service_name in sorted(services_to_restart):
                if not service_name.startswith('ovs-arakoon-'):
                    UpdateController.change_services_state(services=[service_name], ssh_clients=[client], action='restart')
                else:
                    cluster_name = ArakoonClusterConfig.get_cluster_name(Toolbox.remove_prefix(service_name, 'ovs-arakoon-'))
                    if cluster_name == 'config':
                        arakoon_metadata = ArakoonInstaller.get_arakoon_metadata_by_cluster_name(cluster_name='cacc', filesystem=True, ip=System.get_my_storagerouter().ip)
                    else:
                        arakoon_metadata = ArakoonInstaller.get_arakoon_metadata_by_cluster_name(cluster_name=cluster_name)
                    if arakoon_metadata['internal'] is True:
                        AlbaUpdateController._logger.debug('{0}: Restarting arakoon node {1}'.format(client.ip, cluster_name))
                        ArakoonInstaller.restart_node(cluster_name=cluster_name,
                                                      client=client)
            AlbaUpdateController._logger.debug('{0}: Executed hook {1}'.format(client.ip, inspect.currentframe().f_code.co_name))
示例#3
0
    def get_update_status(self, storagerouter):
        """
        Return available updates for framework, volumedriver, ...
        DEPRECATED API call
        :param storagerouter: StorageRouter to get the update information from
        :type storagerouter: ovs.dal.hybrids.storagerouter.StorageRouter
        :return: Asynchronous result of a CeleryTask
        :rtype: celery.result.AsyncResult
        """
        update_info = UpdateController.get_update_information_core({})
        framework_info = update_info.pop('framework', None)
        storagedriver_info = update_info.pop('storagedriver', None)

        return_value = {
            'upgrade_ongoing':
            UpdateController.get_update_metadata(
                storagerouter_ip=storagerouter.ip)['update_ongoing']
        }
        if framework_info is not None and framework_info['packages']:
            return_value['framework'] = []
            for pkg_name, pkg_info in framework_info['packages'].iteritems():
                return_value['framework'].append({
                    'to':
                    pkg_info['candidate'],
                    'name':
                    pkg_name,
                    'gui_down':
                    True,
                    'downtime':
                    framework_info['downtime'],
                    'namespace':
                    'ovs',
                    'prerequisites':
                    framework_info['prerequisites']
                })
        if storagedriver_info is not None and storagedriver_info['packages']:
            return_value['storagedriver'] = []
            for pkg_name, pkg_info in storagedriver_info['packages'].iteritems(
            ):
                return_value['storagedriver'].append({
                    'to':
                    pkg_info['candidate'],
                    'name':
                    pkg_name,
                    'gui_down':
                    False,
                    'downtime':
                    storagedriver_info['downtime'],
                    'namespace':
                    'ovs',
                    'prerequisites':
                    storagedriver_info['prerequisites']
                })

        for plugin_name, info in update_info.iteritems():
            if info['packages']:
                return_value[plugin_name] = []
                for pkg_name, pkg_info in info['packages'].iteritems():
                    return_value[plugin_name].append({
                        'to':
                        pkg_info['candidate'],
                        'name':
                        pkg_name,
                        'gui_down':
                        False,
                        'downtime':
                        info['downtime'],
                        'namespace':
                        plugin_name,
                        'prerequisites':
                        info['prerequisites']
                    })
        return return_value