Exemple #1
0
def discover_cinder_topology():
    """Interrogate the OpenStack API for config info about cinder

    Get each of the resource types and call a method to index
    the documents into ES.

    """
    from goldstone.cinder.utils import get_client
    from goldstone.keystone.utils import get_region

    cinderclient = get_client()
    reg = get_region()

    _update_cinder_records("services", reg, ServicesData(),
                           cinderclient.services.list())
    _update_cinder_records("volumes", reg, VolumesData(),
                           cinderclient.volumes.list())
    _update_cinder_records("backups", reg, BackupsData(),
                           cinderclient.backups.list())
    _update_cinder_records("snapshots", reg, SnapshotsData(),
                           cinderclient.volume_snapshots.list())
    _update_cinder_records("volume_types", reg, VolTypesData(),
                           cinderclient.volume_types.list())
    _update_cinder_records("encryption_types", reg, EncryptionTypesData(),
                           cinderclient.volume_encryption_types.list())
    _update_cinder_records("transfers", reg, TransfersData(),
                           cinderclient.transfers.list())
Exemple #2
0
def nova_hypervisors_stats():
    """Get stats from the nova API and add them as Goldstone metrics."""
    from goldstone.models import es_conn, daily_index

    novaclient = get_client()
    response = novaclient.hypervisors.statistics()._info
    region = get_region()
    metric_prefix = 'nova.hypervisor.'
    now = arrow.utcnow()
    conn = es_conn()
    es_index = daily_index(MetricData.INDEX_PREFIX)
    es_doc_type = MetricData._doc_type.name      # pylint: disable=W0212

    for key, value in response.items():
        doc = {
            'type': es_doc_type,
            'name': metric_prefix + key,
            'value': value,
            'metric_type': 'gauge',
            '@timestamp': now.isoformat(),
            'region': region
        }

        if key in ['disk_available_least', 'free_disk_gb', 'local_gb',
                   'local_gb_used']:
            doc['unit'] = 'GB'
        elif key in ['free_ram_mb', 'memory_mb', 'memory_mb_used']:
            doc['unit'] = 'MB'
        else:
            doc['unit'] = 'count'

        conn.create(es_index, es_doc_type, doc)
Exemple #3
0
def discover_neutron_topology():
    from goldstone.keystone.utils import get_region
    from goldstone.neutron.utils import get_client

    client = get_client()
    reg = get_region()

    _update_neutron_records("agents", reg, AgentData(), client.list_agents())
    _update_neutron_records("extensions", reg, ExtensionData(),
                            client.list_extensions())
    _update_neutron_records("floatingips", reg, FloatingIPData(),
                            client.list_floatingips())
    _update_neutron_records("networks", reg, NetworkData(),
                            client.list_networks())
    _update_neutron_records("ports", reg, PortData(), client.list_ports())
    _update_neutron_records("quotas", reg, QuotaData(), client.list_quotas())
    _update_neutron_records("routers", reg, RouterData(),
                            client.list_routers())
    _update_neutron_records("securitygroups", reg, SecurityGroupData(),
                            client.list_security_groups())
    _update_neutron_records("securitygrouprules", reg, SecurityGroupRuleData(),
                            client.list_security_group_rules())
    _update_neutron_records("subnetpools", reg, SubnetPoolData(),
                            client.list_subnetpools())
    _update_neutron_records("subnets", reg, SubnetData(),
                            client.list_subnets())
Exemple #4
0
def discover_cinder_topology():
    """Interrogate the OpenStack API for config info about cinder

    Get each of the resource types and call a method to index
    the documents into ES.

    """
    from goldstone.cinder.utils import get_client
    from goldstone.keystone.utils import get_region

    cinderclient = get_client()
    reg = get_region()

    _update_cinder_records("services", reg, ServicesData(),
                           cinderclient.services.list())
    _update_cinder_records("volumes", reg, VolumesData(),
                           cinderclient.volumes.list())
    _update_cinder_records("backups", reg, BackupsData(),
                           cinderclient.backups.list())
    _update_cinder_records("snapshots", reg, SnapshotsData(),
                           cinderclient.volume_snapshots.list())
    _update_cinder_records("volume_types", reg, VolTypesData(),
                           cinderclient.volume_types.list())
    _update_cinder_records("encryption_types", reg, EncryptionTypesData(),
                           cinderclient.volume_encryption_types.list())
    _update_cinder_records("transfers", reg, TransfersData(),
                           cinderclient.transfers.list())
Exemple #5
0
def discover_nova_topology():
    """Contacts the configured OpenStack API endpoint and gathers Nova resource
    information.  Information is written to the daily goldstone index.

    :return: None

    """
    nova_client = get_client()
    reg = get_region()

    _update_nova_records("agents", reg, AgentsData(),
                         nova_client.agents.list())
    _update_nova_records("aggregates", reg, AggregatesData(),
                         nova_client.aggregates.list())
    _update_nova_records("availability_zones", reg, AvailZonesData(),
                         nova_client.availability_zones.list())
    _update_nova_records("cloudpipes", reg, CloudpipesData(),
                         nova_client.cloudpipe.list())
    _update_nova_records("flavors", reg, FlavorsData(),
                         nova_client.flavors.list())
    _update_nova_records("floating_ip_pools", reg, FloatingIpPoolsData(),
                         nova_client.floating_ip_pools.list())
    _update_nova_records("hosts", reg, HostsData(), nova_client.hosts.list())
    _update_nova_records("hypervisors", reg, HypervisorsData(),
                         nova_client.hypervisors.list())
    _update_nova_records("networks", reg, NetworksData(),
                         nova_client.networks.list())
    _update_nova_records("secgroups", reg, SecGroupsData(),
                         nova_client.security_groups.list())
    _update_nova_records(
        "servers", reg, ServersData(),
        nova_client.servers.list(search_opts={'all_tenants': 1}))
    _update_nova_records("services", reg, ServicesData(),
                         nova_client.services.list())
Exemple #6
0
def nova_hypervisors_stats():
    """Get stats from the nova API and add them as Goldstone metrics."""
    from goldstone.models import es_conn, daily_index

    novaclient = get_client()
    response = novaclient.hypervisors.statistics()._info
    region = get_region()
    metric_prefix = 'nova.hypervisor.'
    now = arrow.utcnow()
    conn = es_conn()
    es_index = daily_index(METRIC_INDEX_PREFIX)
    es_doc_type = METRIC_DOCTYPE

    for key, value in response.items():
        doc = {
            'type': es_doc_type,
            'name': metric_prefix + key,
            'value': value,
            'metric_type': 'gauge',
            '@timestamp': now.isoformat(),
            'region': region
        }

        if key in [
                'disk_available_least', 'free_disk_gb', 'local_gb',
                'local_gb_used'
        ]:
            doc['unit'] = 'GB'
        elif key in ['free_ram_mb', 'memory_mb', 'memory_mb_used']:
            doc['unit'] = 'MB'
        else:
            doc['unit'] = 'count'

        conn.create(es_index, es_doc_type, doc)
Exemple #7
0
def discover_glance_topology():
    """Update Goldstone's glance data."""

    # Get the system's sole OpenStack cloud.
    client = get_client()
    region = get_region()

    _update_glance_image_records(client, region)
Exemple #8
0
def discover_nova_topology():
    """Contacts the configured OpenStack API endpoint and gathers Nova resource
    information.  Information is written to the daily goldstone index.

    :return: None

    """
    nova_client = get_client()
    reg = get_region()

    _update_nova_records("agents",
                         reg,
                         AgentsData(),
                         nova_client.agents.list())
    _update_nova_records("aggregates",
                         reg,
                         AggregatesData(),
                         nova_client.aggregates.list())
    _update_nova_records("availability_zones",
                         reg,
                         AvailZonesData(),
                         nova_client.availability_zones.list())
    _update_nova_records("cloudpipes",
                         reg,
                         CloudpipesData(),
                         nova_client.cloudpipe.list())
    _update_nova_records("flavors",
                         reg,
                         FlavorsData(),
                         nova_client.flavors.list())
    _update_nova_records("floating_ip_pools",
                         reg,
                         FloatingIpPoolsData(),
                         nova_client.floating_ip_pools.list())
    _update_nova_records("hosts", reg, HostsData(), nova_client.hosts.list())
    _update_nova_records("hypervisors",
                         reg,
                         HypervisorsData(),
                         nova_client.hypervisors.list())
    _update_nova_records("networks",
                         reg,
                         NetworksData(),
                         nova_client.networks.list())
    _update_nova_records("secgroups",
                         reg,
                         SecGroupsData(),
                         nova_client.security_groups.list())
    _update_nova_records("servers",
                         reg,
                         ServersData(),
                         nova_client.servers.list(
                             search_opts={'all_tenants': 1}))
    _update_nova_records("services",
                         reg,
                         ServicesData(),
                         nova_client.services.list())
Exemple #9
0
def discover_neutron_topology():
    from goldstone.keystone.utils import get_region
    from goldstone.neutron.utils import get_client

    client = get_client()
    reg = get_region()

    _update_neutron_records("agents",
                            reg,
                            AgentData(),
                            client.list_agents())
    _update_neutron_records("extensions",
                            reg,
                            ExtensionData(),
                            client.list_extensions())
    _update_neutron_records("floatingips",
                            reg,
                            FloatingIPData(),
                            client.list_floatingips())
    _update_neutron_records("networks",
                            reg,
                            NetworkData(),
                            client.list_networks())
    _update_neutron_records("ports",
                            reg,
                            PortData(),
                            client.list_ports())
    _update_neutron_records("quotas",
                            reg,
                            QuotaData(),
                            client.list_quotas())
    _update_neutron_records("routers",
                            reg,
                            RouterData(),
                            client.list_routers())
    _update_neutron_records("securitygroups",
                            reg,
                            SecurityGroupData(),
                            client.list_security_groups())
    _update_neutron_records("securitygrouprules",
                            reg,
                            SecurityGroupRuleData(),
                            client.list_security_group_rules())
    _update_neutron_records("subnetpools",
                            reg,
                            SubnetPoolData(),
                            client.list_subnetpools())
    _update_neutron_records("subnets",
                            reg,
                            SubnetData(),
                            client.list_subnets())
Exemple #10
0
def discover_keystone_topology():
    from goldstone.keystone.utils import get_client, get_region

    client = get_client()
    reg = get_region()

    _update_keystone_records("endpoints",
                             reg,
                             EndpointsData(),
                             client.endpoints.list())
    _update_keystone_records("roles", reg, RolesData(), client.roles.list())
    _update_keystone_records("services",
                             reg,
                             ServicesData(),
                             client.services.list())
    _update_keystone_records("tenants",
                             reg,
                             TenantsData(),
                             client.projects.list())
    _update_keystone_records("users", reg, UsersData(), client.users.list())