Example #1
0
def _update_neutron_records(rec_type, region, database, items):
    from goldstone.utils import to_es_date
    import arrow

    body = {"@timestamp": to_es_date(arrow.utcnow().datetime),
            "region": region,
            rec_type: items.values()[0]}
    try:
        database.post(body)
    except Exception:           # pylint: disable=W0703
        logging.exception("failed to index neutron %s", rec_type)
Example #2
0
def _update_keystone_records(rec_type, region, database, items):
    from goldstone.utils import to_es_date
    import arrow

    # image list is a generator, so we need to make it not sol lazy it...
    body = {"@timestamp": to_es_date(arrow.utcnow().datetime),
            "region": region,
            rec_type: [item.to_dict() for item in items]}
    try:
        database.post(body)
    except Exception:           # pylint: disable=W0703
        logging.exception("failed to index keystone %s", rec_type)
Example #3
0
def _update_nova_records(rec_type, region, database, items):
    """Do the work for the discover_nova_topology task."""
    from goldstone.utils import to_es_date

    # image list is a generator, so we need to make it not sol lazy it...
    body = {"@timestamp": to_es_date(arrow.utcnow().datetime),
            "region": region,
            rec_type: [item.__dict__['_info'] for item in items]}
    try:
        database.post(body)
    except Exception:           # pylint: disable=W0703
        logging.exception("failed to index nova %s", rec_type)
Example #4
0
def _update_neutron_records(rec_type, region, database, items):
    from goldstone.utils import to_es_date
    import arrow

    body = {
        "@timestamp": to_es_date(arrow.utcnow().datetime),
        "region": region,
        rec_type: items.values()[0]
    }
    try:
        database.post(body)
    except Exception:  # pylint: disable=W0703
        logging.exception("failed to index neutron %s", rec_type)
Example #5
0
def _update_nova_records(rec_type, region, database, items):
    """Do the work for the discover_nova_topology task."""
    from goldstone.utils import to_es_date

    # image list is a generator, so we need to make it not sol lazy it...
    body = {
        "@timestamp": to_es_date(arrow.utcnow().datetime),
        "region": region,
        rec_type: [item.__dict__['_info'] for item in items]
    }
    try:
        database.post(body)
    except Exception:  # pylint: disable=W0703
        logging.exception("failed to index nova %s", rec_type)
Example #6
0
def _update_cinder_records(rec_type, region, database, items):
    """Post a cinder record to Elasticsearch

    Construct the JSON body and attempt to index a new document into the
    Elasticsearch database.

    """
    import arrow
    body = {"@timestamp": to_es_date(arrow.utcnow().datetime),
            "region": region,
            rec_type: [item.__dict__['_info'] for item in items]}
    try:
        database.post(body)
    except Exception:             # pylint: disable=W0703
        logger.exception("failed to index cinder %s", rec_type)
Example #7
0
def _update_cinder_records(rec_type, region, database, items):
    """Post a cinder record to Elasticsearch

    Construct the JSON body and attempt to index a new document into the
    Elasticsearch database.

    """
    import arrow
    body = {
        "@timestamp": to_es_date(arrow.utcnow().datetime),
        "region": region,
        rec_type: [item.__dict__['_info'] for item in items]
    }
    try:
        database.post(body)
    except Exception:  # pylint: disable=W0703
        logger.exception("failed to index cinder %s", rec_type)
Example #8
0
def _update_glance_image_records(client, region):
    """Do the work for the discover_glance_topology task."""
    from goldstone.utils import to_es_date
    from .models import ImagesData
    import arrow

    images_list = client.images.list()

    # Image list is a generator, so we need to make it not sol lazy it...
    body = {"@timestamp": to_es_date(arrow.utcnow().datetime),
            "region": region,
            "images": [i for i in images_list]}

    data = ImagesData()

    try:
        data.post(body)
    except Exception:          # pylint: disable=W0703
        logging.exception("failed to index glance images")
Example #9
0
def _update_glance_image_records(client, region):
    """Do the work for the discover_glance_topology task."""
    from goldstone.utils import to_es_date
    from .models import ImagesData
    import arrow

    images_list = client.images.list()

    # Image list is a generator, so we need to make it not sol lazy it...
    body = {
        "@timestamp": to_es_date(arrow.utcnow().datetime),
        "region": region,
        "images": [i for i in images_list]
    }

    data = ImagesData()

    try:
        data.post(body)
    except Exception:  # pylint: disable=W0703
        logging.exception("failed to index glance images")