Beispiel #1
0
    def init_state(self):
        """ Initialize a dict for storing the state of the data collector."""
        vir_connection = libvirt.openReadOnly(None)
        if vir_connection is None:
            message = 'Failed to open a connection to the hypervisor'
            LOG.critical(message)
            raise OSError(message)

        hostname = vir_connection.getHostname()
        host_cpu_mhz, host_ram = self.get_host_characteristics(vir_connection)
        physical_cpus = common.physical_cpu_count(vir_connection)
        host_cpu_usable_by_vms = CONF.host_cpu_usable_by_vms

        db = db_utils.init_db()
        db.update_host(hostname,
                       int(host_cpu_mhz * host_cpu_usable_by_vms),
                       physical_cpus,
                       host_ram)

        return {'previous_time': 0.,
                'previous_cpu_time': dict(),
                'previous_cpu_mhz': dict(),
                'previous_host_cpu_time_total': 0.,
                'previous_host_cpu_time_busy': 0.,
                'previous_overload': -1,
                'vir_connection': vir_connection,
                'hostname': hostname,
                'host_cpu_overload_threshold':
                    CONF.collector.host_cpu_overload_threshold * \
                    host_cpu_usable_by_vms,
                'physical_cpus': physical_cpus,
                'physical_cpu_mhz': host_cpu_mhz,
                'physical_core_mhz': host_cpu_mhz / physical_cpus,
                'db': db}
Beispiel #2
0
    def init_state(self):
        """ Initialize a dict for storing the state of the local manager.

        :param config: A config dictionary.
         :type config: dict(str: *)

        :return: A dictionary containing the initial state of the local manager.
         :rtype: dict
        """
        vir_connection = libvirt.openReadOnly(None)
        if vir_connection is None:
            message = 'Failed to open a connection to the hypervisor'
            LOG.critical(message)
            raise OSError(message)

        physical_cpu_mhz_total = int(
            common.physical_cpu_mhz_total(vir_connection) *
            CONF.host_cpu_usable_by_vms)
        return {'previous_time': 0.,
                'vir_connection': vir_connection,
                'db': db_utils.init_db(),
                'physical_cpu_mhz_total': physical_cpu_mhz_total,
                'hostname': vir_connection.getHostname(),
                'hashed_username': sha1(CONF.os_admin_user).hexdigest(),
                'hashed_password': sha1(CONF.os_admin_password).hexdigest()}
Beispiel #3
0
    def init_state(self):
        """Initialize a dict for storing the state of the local manager.

        :param config: A config dictionary.
         :type config: dict(str: *)

        :return: A dictionary, initial state of the local manager.
         :rtype: dict
        """
        vir_connection = libvirt.openReadOnly(None)
        if vir_connection is None:
            message = 'Failed to open a connection to the hypervisor'
            LOG.critical(message)
            raise OSError(message)

        physical_cpu_mhz_total = int(
            common.physical_cpu_mhz_total(vir_connection) *
            CONF.host_cpu_usable_by_vms)
        return {'previous_time': 0.,
                'vir_connection': vir_connection,
                'db': db_utils.init_db(),
                'physical_cpu_mhz_total': physical_cpu_mhz_total,
                'hostname': vir_connection.getHostname(),
                'hashed_username': sha1(CONF.os_admin_user).hexdigest(),
                'hashed_password': sha1(CONF.os_admin_password).hexdigest()}
Beispiel #4
0
    def init_state(self):
        """Initialize a dict for storing the state of the data collector."""
        vir_connection = libvirt.openReadOnly(None)
        if vir_connection is None:
            message = 'Failed to open a connection to the hypervisor'
            LOG.critical(message)
            raise OSError(message)

        hostname = vir_connection.getHostname()
        host_cpu_mhz, host_ram = self.get_host_characteristics(vir_connection)
        physical_cpus = common.physical_cpu_count(vir_connection)
        host_cpu_usable_by_vms = CONF.host_cpu_usable_by_vms

        db = db_utils.init_db()
        db.update_host(hostname,
                       int(host_cpu_mhz * host_cpu_usable_by_vms),
                       physical_cpus,
                       host_ram)

        return {'previous_time': 0.,
                'previous_cpu_time': dict(),
                'previous_cpu_mhz': dict(),
                'previous_host_cpu_time_total': 0.,
                'previous_host_cpu_time_busy': 0.,
                'previous_overload': -1,
                'vir_connection': vir_connection,
                'hostname': hostname,
                'host_cpu_overload_threshold':
                    CONF.collector.host_cpu_overload_threshold *
                    host_cpu_usable_by_vms,
                'physical_cpus': physical_cpus,
                'physical_cpu_mhz': host_cpu_mhz,
                'physical_core_mhz': host_cpu_mhz / physical_cpus,
                'db': db}
Beispiel #5
0
def init_state(config):
    """Initialize a dict for storing the state of the database cleaner.

    :param config: A config dictionary.
    :return: A dictionary containing the initial state of the database cleaner.
    """
    return {
        'db': init_db(config['sql_connection']),
        'time_delta': datetime.timedelta(
            seconds=int(config['db_cleaner_interval']))}
Beispiel #6
0
def init_state(config):
    """Initialize a dict for storing the state of the database cleaner.

    :param config: A config dictionary.
    :return: A dictionary containing the initial state of the database cleaner.
    """
    return {
        'db':
        init_db(config['sql_connection']),
        'time_delta':
        datetime.timedelta(seconds=int(config['db_cleaner_interval']))
    }
Beispiel #7
0
 def init_state(self):
     """ Initialize a dict for storing the state of the global manager.
     """
     return {'previous_time': 0,
             'db': db_utils.init_db(),
             'nova': client.Client(2,
                                   CONF.os_admin_user,
                                   CONF.os_admin_password,
                                   CONF.global_manager.os_admin_tenant_name,
                                   CONF.global_manager.os_auth_url,
                                   service_type="compute"),
             'hashed_username': sha1(CONF.os_admin_user).hexdigest(),
             'hashed_password': sha1(CONF.os_admin_password).hexdigest(),
             'compute_hosts': CONF.global_manager.compute_hosts,
             'host_macs': {}}
Beispiel #8
0
 def init_state(self):
     """Initialize a dict for storing the state of the global manager.
     """
     return {
         'previous_time':
         0,
         'db':
         db_utils.init_db(),
         'nova':
         client.Client(2,
                       CONF.os_admin_user,
                       CONF.os_admin_password,
                       CONF.global_manager.os_admin_tenant_name,
                       CONF.global_manager.os_auth_url,
                       service_type="compute"),
         'hashed_username':
         sha1(CONF.os_admin_user).hexdigest(),
         'hashed_password':
         sha1(CONF.os_admin_password).hexdigest(),
         'compute_hosts':
         CONF.global_manager.compute_hosts,
         'host_macs': {}
     }