コード例 #1
0
ファイル: environment.py プロジェクト: darkreapyre/fuel-main
    def revert_snapshot(self, name):
        if self.get_virtual_environment().has_snapshot(name):
            logger.info('We have snapshot with such name %s' % name)

            self.get_virtual_environment().revert(name)
            logger.info('Starting snapshot reverting ....')

            self.get_virtual_environment().resume()
            logger.info('Starting snapshot resuming ...')

            self.nodes().admin.await(self.admin_net, timeout=10 * 60)

            list = self.nodes().slaves
            for node in list:
                nailgun_node = self.fuel_web.get_nailgun_node_by_devops_node(
                    node)
                if not node.driver.node_active(node) or \
                        nailgun_node['status'] not in ['provisioned', 'ready']:
                    continue
                try:
                    self.sync_node_time(self.get_ssh_to_remote(
                        node.get_ip_address_by_network_name(self.admin_net)))
                except Exception as e:
                    logger.warn(
                        'Paramiko exception catched while'
                        ' trying to run ntpdate: %s' % e)
            return True
        return False
コード例 #2
0
ファイル: environment.py プロジェクト: Axam/fuel-main
    def revert_snapshot(self, name):
        if self.get_virtual_environment().has_snapshot(name):
            logger.info('We have snapshot with such name %s' % name)

            self.get_virtual_environment().revert(name)
            logger.info('Starting snapshot reverting ....')

            self.get_virtual_environment().resume()
            logger.info('Starting snapshot resuming ...')

            self.nodes().admin. await (self.admin_net, timeout=10 * 60)

            self.sync_time_admin_node()

            for node in self.nodes().slaves:
                if not node.driver.node_active(node):
                    continue
                try:
                    logger.info("Sync time on revert for node %s" % node.name)
                    self.sync_node_time(
                        self.get_ssh_to_remote_by_name(node.name))
                except Exception as e:
                    logger.warn('Paramiko exception catched while'
                                ' trying to run ntpdate: %s' % e)

                self.run_nailgun_agent(
                    self.get_ssh_to_remote_by_name(node.name))
            return True
        return False
コード例 #3
0
ファイル: environment.py プロジェクト: igajsin/fuel-main
    def revert_snapshot(self, name):
        if self.get_virtual_environment().has_snapshot(name):
            logger.info('We have snapshot with such name %s' % name)

            self.get_virtual_environment().revert(name)
            logger.info('Starting snapshot reverting ....')

            self.get_virtual_environment().resume()
            logger.info('Starting snapshot resuming ...')

            self.nodes().admin.await(self.admin_net, timeout=10 * 60)

            self.sync_time_admin_node()

            for node in self.nodes().slaves:
                if not node.driver.node_active(node):
                    continue
                try:
                    logger.info("Sync time on revert for node %s" % node.name)
                    self.sync_node_time(
                        self.get_ssh_to_remote_by_name(node.name))
                except Exception as e:
                    logger.warn(
                        'Paramiko exception catched while'
                        ' trying to run ntpdate: %s' % e)

                self.run_nailgun_agent(
                    self.get_ssh_to_remote_by_name(node.name))
            return True
        return False
コード例 #4
0
    def activate_plugin(self, name, version, options=None, strict=False):
        """Enable and configure a plugin for the cluster.

        :param name: name of the plugin.
        :type name: str
        :param version: version of the plugin.
        :type name: str
        :param options: configuration of the plugin (optional).
        :type options: dict
        :param strict: whether or not to fail when setting an unknown option
        (default: False).
        :type strict: boolean
        :returns: None
        """
        if options is None:
            options = {}
        msg = "Plugin {0} isn't found.".format(name)
        asserts.assert_true(
            self.fuel_web.check_plugin_exists(self.cluster_id, name),
            msg)

        logger.info("Updating settings for plugin {0} ({1}): {2}".format(
            name, version, options))
        attributes = self.nailgun_client.get_cluster_attributes(
            self.cluster_id)
        attributes = attributes['editable'][name]

        plugin_data = None
        # This key does not exist in MOS 7.0
        if 'versions' in attributes['metadata']:
            for item in attributes['metadata']['versions']:
                if item['metadata']['plugin_version'] == version:
                    plugin_data = item
                    break
            asserts.assert_is_not_none(
                plugin_data,
                "Plugin {0} ({1}) is not found".format(
                    name, version))
        else:
            plugin_data = attributes

        attributes['metadata']['enabled'] = True
        for option, value in options.items():
            path = option.split("/")
            for p in path[:-1]:
                if p in plugin_data:
                    plugin_option = plugin_data[p]
                else:
                    msg = "Plugin option {} not found".format(option)
                    if strict:
                        raise NotFound(msg)
                    logger.warn(msg)
                    plugin_option = None
                    break

            if plugin_option is not None:
                plugin_option[path[-1]] = value

        self.nailgun_client.update_cluster_attributes(self.cluster_id, {
            "editable": {name: attributes}
        })