def delete_database_in_mongo(context): """ Delete database used in mongo """ fiware_service_header = u'Fiware-Service' orion_prefix = u'orion' global cb properties_class = Properties() props_mongo = properties_class.read_properties()[ "mongo_env"] # mongo properties dict m = Mongo(host=props_mongo["MONGO_HOST"], port=props_mongo["MONGO_PORT"], user=props_mongo["MONGO_USER"], password=props_mongo["MONGO_PASS"]) headers = cb.get_headers() if fiware_service_header in headers and ( headers[fiware_service_header].find(".") < 0): __logger__.debug("Deleting database in mongo...") if fiware_service_header in headers: database_name = "%s-%s" % (orion_prefix, headers[fiware_service_header]) else: database_name = orion_prefix m.connect(database_name.lower()) m.drop_database() m.disconnect() __logger__.debug("...Database \"%s\" is deleted" % database_name.lower())
def verify_mongo_is_installed_successfully(context): """ verify contextBroker is installed successfully :param context: """ global props_mongo __logger__.debug(" >> verify if mongo is installed successfully") m = Mongo(host=props_mongo["MONGO_HOST"], port=props_mongo["MONGO_PORT"], user=props_mongo["MONGO_USER"], password=props_mongo["MONGO_PASS"], version=props_mongo["MONGO_VERSION"], verify_version=props_mongo["MONGO_VERIFY_VERSION"]) m.connect() m.eval_version() m.disconnect() __logger__.info(" >> verified that mongo is installed successfully")
def delete_database_in_mongo(context): """ Delete database used in mongo """ fiware_service_header = u'Fiware-Service' orion_prefix = u'orion' global cb properties_class = Properties() props_mongo = properties_class.read_properties()["mongo_env"] # mongo properties dict m = Mongo(host=props_mongo["MONGO_HOST"], port=props_mongo["MONGO_PORT"], user=props_mongo["MONGO_USER"], password=props_mongo["MONGO_PASS"]) headers = cb.get_headers() if fiware_service_header in headers and (headers[fiware_service_header].find(".") < 0): __logger__.debug("Deleting database in mongo...") if fiware_service_header in headers: database_name = "%s-%s" % (orion_prefix, headers[fiware_service_header]) else: database_name = orion_prefix m.connect(database_name.lower()) m.drop_database() m.disconnect() __logger__.debug("...Database \"%s\" is deleted" % database_name.lower())