Beispiel #1
0
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")
Beispiel #3
0
def entities_are_not_stored_in_mongo(context):
    """
    verify that entities are not stored in mongo
    """
    global cb
    properties_class = Properties()
    props_mongo = properties_class.read_properties()[
        "mongo_env"]  # mongo properties dict
    __logger__.debug(" >> verifying entities are not stored in mongo")
    m = Mongo(host=props_mongo["MONGO_HOST"],
              port=props_mongo["MONGO_PORT"],
              user=props_mongo["MONGO_USER"],
              password=props_mongo["MONGO_PASS"])
    ngsi = NGSI()
    ngsi.verify_entities_stored_in_mongo(m, cb.get_entity_context(),
                                         cb.get_headers(), False)
    __logger__.info(" >> verified entities are not stored in mongo")
Beispiel #4
0
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())