Exemple #1
0
    def _start_collectd(self, connection, bin_path):
        LOG.debug("Starting collectd to collect NFVi stats")
        collectd_path = os.path.join(bin_path, "collectd", "sbin", "collectd")
        config_file_path = os.path.join(bin_path, "collectd", "etc")
        self._prepare_collectd_conf(config_file_path)

        connection.execute('sudo pkill -x -9 collectd')
        cmd = "which %s > /dev/null 2>&1" % collectd_path
        exit_status, _, stderr = connection.execute(cmd)
        if exit_status != 0:
            raise ResourceCommandError(command=cmd, stderr=stderr)

        if "ovs_stats" in self.plugins:
            self._setup_ovs_stats(connection)

        LOG.debug("Starting collectd to collect NFVi stats")
        LOG.debug("Start collectd service..... %s second timeout",
                  self.timeout)
        # intel_pmu plug requires large numbers of files open, so try to set
        # ulimit -n to a large value

        cmd = "sudo bash -c 'ulimit -n 1000000 ; %s'" % collectd_path
        exit_status, _, stderr = connection.execute(cmd, timeout=self.timeout)
        if exit_status != 0:
            raise ResourceCommandError(command=cmd, stderr=stderr)

        LOG.debug("Done")
Exemple #2
0
    def _start_rabbitmq(self, connection):
        if self._reset_mq_flag:
            self._reset_rabbitmq(connection)
        else:
            if not self._check_rabbitmq_user(connection):
                self._set_rabbitmq_admin_user(connection)

        # check stdout for "sudo rabbitmqctl status" command
        cmd = "sudo rabbitmqctl status"
        _, stdout, stderr = connection.execute(cmd)
        if not re.search("RabbitMQ", stdout):
            LOG.error("rabbitmqctl status don't have RabbitMQ in running apps")
            raise ResourceCommandError(command=cmd, stderr=stderr)
Exemple #3
0
    def _set_rabbitmq_admin_user(self, connection):
        LOG.debug("add admin user to amqp")
        cmd_list = [
            "sudo rabbitmqctl add_user admin admin",
            "sudo rabbitmqctl authenticate_user admin admin",
            "sudo rabbitmqctl set_permissions -p / admin '.*' '.*' '.*'"
        ]

        for cmd in cmd_list:
            exit_status, stdout, stderr = connection.execute(cmd)
            if exit_status != 0:
                raise ResourceCommandError(command=cmd,
                                           stdout=stdout,
                                           stderr=stderr)
Exemple #4
0
    def _reset_rabbitmq(self, connection):
        # Reset amqp queue
        LOG.debug("reset and setup amqp to collect data from collectd")
        # ensure collectd.conf.d exists to avoid error/warning
        cmd_list = [
            "sudo mkdir -p /etc/collectd/collectd.conf.d",
            "sudo service rabbitmq-server restart",
            "sudo rabbitmqctl stop_app", "sudo rabbitmqctl reset",
            "sudo rabbitmqctl start_app",
            "sudo rabbitmqctl add_user admin admin",
            "sudo rabbitmqctl authenticate_user admin admin",
            "sudo rabbitmqctl set_permissions -p / admin '.*' '.*' '.*'"
        ]

        for cmd in cmd_list:
            exit_status, _, stderr = connection.execute(cmd)
            if exit_status != 0:
                raise ResourceCommandError(command=cmd, stderr=stderr)