Example #1
0
def update_services():
    """
    update_services

    the update services event exists as a period task run every (x) (please see the settings) seconds

    The task event then ingests the service information within NEXUS
    """
    logger.info('Starting: {0}'.format(SERVICE_NAME))
    access_key = Config.get_config(Config.ACCESS_KEY)
    access_secret = Config.get_config(Config.ACCESS_SECRET)

    uri = settings.SERVICE_MANAGER_INTERNAL_URI
    service_manager = SimpleServiceManagerApiClient(uri, access_key,
                                                    access_secret)
    services_data = service_manager.get_my_services()

    for service_data in services_data:
        service, created = Service.objects.get_or_create(
            uuid=service_data.get('id'))
        logger.info('{0} service: {1}'.format(
            'Creating' if created else 'Updating', service_data.get('id')))

        service.uuid = service_data.get('id', service.uuid)
        service.access_key = service_data.get('access_key', service.access_key)
        service.access_secret = service_data.get('access_secret',
                                                 service.access_secret)
        service.name = service_data.get('name', service.name)

        service.save()

    logger.info('Completed: {0}'.format(SERVICE_NAME))

    return True
Example #2
0
def update_services():
    """
    update_services

    the update services event exists as a period task run every (x) (please see the settings) seconds

    The task event then ingests the service information within NEXUS
    """
    logger.info('Starting: {0}'.format(SERVICE_NAME))
    access_key = Config.get_config(Config.ACCESS_KEY)
    access_secret = Config.get_config(Config.ACCESS_SECRET)

    uri = settings.SERVICE_MANAGER_INTERNAL_URI
    service_manager = SimpleServiceManagerApiClient(uri, access_key, access_secret)
    services_data = service_manager.get_my_services()

    for service_data in services_data:
        service, created = Service.objects.get_or_create(uuid=service_data.get('id'))
        logger.info('{0} service: {1}'.format('Creating' if created else 'Updating', service_data.get('id')))

        service.uuid = service_data.get('id', service.uuid)
        service.access_key = service_data.get('access_key', service.access_key)
        service.access_secret = service_data.get('access_secret', service.access_secret)
        service.name = service_data.get('name', service.name)

        service.save()

    logger.info('Completed: {0}'.format(SERVICE_NAME))

    return True
Example #3
0
def update_clients():
    """
    update_clients

    the update clients event exists as a period task run every (x) (please see the settings) seconds

    The task event then ingests the client information within NEXUS that the service will need for its reported
    clients.
    """
    logger.info('Starting: {0}'.format(SERVICE_NAME))
    access_key = Config.get_config(Config.ACCESS_KEY)
    access_secret = Config.get_config(Config.ACCESS_SECRET)

    uri = settings.SERVICE_MANAGER_INTERNAL_URI
    service_manager = SimpleServiceManagerApiClient(uri, access_key,
                                                    access_secret)
    clients_data = service_manager.get_clients()

    for client_data in clients_data:
        try:
            client = Clients.objects.get(id=client_data.get('id'))
            logger.info('Updating client: {0}'.format(client_data.get('id')))
        except Clients.DoesNotExist:
            client = Clients()
            logger.info('Creating client: {0}'.format(client_data.get('id')))

        client.id = client_data.get('id', client.id)
        client.name = client_data.get('name', client.name)
        client.description = client_data.get('description', client.description)

        config = client_data.get('config', {})
        client.ftp_client_dir = config.get('ftp_client_dir',
                                           client.ftp_client_dir)

        client.save()

    logger.info('Completed: {0}'.format(SERVICE_NAME))

    return True
Example #4
0
def update_clients():
    """
    update_clients

    the update clients event exists as a period task run every (x) (please see the settings) seconds

    The task event then ingests the client information within NEXUS that the service will need for its reported
    clients.
    """
    logger.info('Starting: {0}'.format(SERVICE_NAME))
    access_key = Config.get_config(Config.ACCESS_KEY)
    access_secret = Config.get_config(Config.ACCESS_SECRET)

    uri = settings.SERVICE_MANAGER_INTERNAL_URI
    service_manager = SimpleServiceManagerApiClient(uri, access_key, access_secret)
    clients_data = service_manager.get_clients()

    for client_data in clients_data:
        try:
            client = Clients.objects.get(id=client_data.get('id'))
            logger.info('Updating client: {0}'.format(client_data.get('id')))
        except Clients.DoesNotExist:
            client = Clients()
            logger.info('Creating client: {0}'.format(client_data.get('id')))

        client.id = client_data.get('id', client.id)
        client.name = client_data.get('name', client.name)
        client.description = client_data.get('description', client.description)

        config = client_data.get('config', {})
        client.ftp_client_dir = config.get('ftp_client_dir', client.ftp_client_dir)

        client.save()

    logger.info('Completed: {0}'.format(SERVICE_NAME))

    return True