surveil-init now works in prod

Change-Id: I996360941222af0827ff2cb62ef7daf033336a3f
This commit is contained in:
aviau 2015-05-07 16:38:42 -04:00
parent a8b4567e4e
commit 905f4af92c
2 changed files with 74 additions and 62 deletions

View File

@ -43,4 +43,5 @@ ENV SURVEIL_KEYSTONE_ADMIN_TENANT_NAME=admin
CMD cd /opt/surveil && \
./setup.sh && \
((sleep 40 && surveil-init) &) && \
surveil-api

View File

@ -35,9 +35,15 @@ def main():
# Create a basic config in mongodb
mongo = pymongo.MongoClient(config.surveil_api_config['mongodb_uri'])
if opts.demo is True:
# Drop the current shinken config
mongo.drop_database('shinken')
if mongo.surveil.init.count() == 0:
# Mark packs as uploaded
print("Uploading packs...")
mongo.surveil.init.insert({"source": "surveil-init script"})
# Load the shinken packs
subprocess.call(
[
@ -65,12 +71,17 @@ def main():
"/packs/generic-host/",
]
)
else:
print("Skipping pack upload...")
# Reload the surveil config
cli_surveil = sc.Client('http://localhost:8080/v2',
auth_url='http://localhost:8080/v2/auth',
version='2_0')
# if --demo is specified, you get more hosts.
if opts.demo is True:
# shinken's ws-arbiter
cli_surveil.config.hosts.create(
use="generic-host",
contact_groups="admins",
@ -91,6 +102,7 @@ def main():
service_description="check-ws-arbiter"
)
# Linux-keystone template
cli_surveil.config.hosts.create(
host_name='test_keystone',
use='linux-keystone',
@ -105,8 +117,6 @@ def main():
}
)
# if --demo is specified, you get more hosts.
if opts.demo is True:
# DOWN HOST (cant resolve)
cli_surveil.config.hosts.create(
host_name='srv-apache-01',
@ -183,4 +193,5 @@ def main():
service_description="iamadownservice"
)
# Reload the shinken config
cli_surveil.config.reload_config()