RabbitComsumer: check 'surveil_tags' metadata
Change-Id: I32ada4d93d5815793b042d60addaff92051e8dc7
This commit is contained in:
parent
08951e9353
commit
a79eb3de1f
@ -35,6 +35,7 @@ rabbitconsumer:
|
||||
#SURVEIL_OS_USERNAME: "admin"
|
||||
#SURVEIL_OS_PASSWORD: "password"
|
||||
#SURVEIL_TENANT_NAME: "admin"
|
||||
#SURVEIL_DEFAULT_TAGS: "linux-openstackceilometer"
|
||||
command: bash -c "cd /opt/surveil && ./setup.sh && python setup.py develop && surveil-rabbitMQ-consumer"
|
||||
|
||||
alignak:
|
||||
|
@ -6,6 +6,7 @@ SURVEIL_OS_AUTH_URL=http://localhost/v2.0
|
||||
SURVEIL_OS_USERNAME=admin
|
||||
SURVEIL_OS_PASSWORD=password
|
||||
SURVEIL_OS_TENANT_NAME=admin
|
||||
SURVEIL_DEFAULT_TAGS=linux-openstackceilometer
|
||||
RABBIT_HOST=192.168.49.239
|
||||
RABBIT_PORT=5672
|
||||
QUEUE=test
|
||||
|
@ -77,6 +77,10 @@ def main():
|
||||
"SURVEIL_OS_TENANT_NAME": os.environ.get(
|
||||
'SURVEIL_OS_TENANT_NAME',
|
||||
config.get("rabbitconsumer", "SURVEIL_OS_TENANT_NAME")
|
||||
),
|
||||
"SURVEIL_DEFAULT_TAGS": os.environ.get(
|
||||
'SURVEIL_DEFAULT_TAGS',
|
||||
config.get("rabbitconsumer", "SURVEIL_DEFAULT_TAGS")
|
||||
)
|
||||
}
|
||||
|
||||
@ -142,10 +146,19 @@ def main():
|
||||
"_OS_PASSWORD": daemon_config["SURVEIL_OS_PASSWORD"],
|
||||
"_OS_INSTANCE_ID": event['payload']['instance_id']
|
||||
}
|
||||
|
||||
instance_tags = daemon_config["SURVEIL_DEFAULT_TAGS"]
|
||||
surveil_metadata_tags = event['payload']['metadata'].get(
|
||||
'surveil_tags',
|
||||
None
|
||||
)
|
||||
if surveil_metadata_tags is not None:
|
||||
instance_tags += ',' + surveil_metadata_tags
|
||||
|
||||
c.config.hosts.create(
|
||||
host_name=event['payload']['hostname'],
|
||||
address=event['payload']['hostname'],
|
||||
use='linux-openstackceilometer',
|
||||
use=instance_tags,
|
||||
custom_fields=custom_fields
|
||||
)
|
||||
elif event['event_type'] == 'compute.instance.delete.end':
|
||||
@ -159,4 +172,4 @@ def main():
|
||||
compt_thread.append(t)
|
||||
|
||||
channel.basic_consume(callback, queue=daemon_config["QUEUE"], no_ack=True)
|
||||
channel.start_consuming()
|
||||
channel.start_consuming()
|
||||
|
Loading…
x
Reference in New Issue
Block a user