Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update configuration.py for netbox 2.7.11 REDIS config #267

Merged
merged 1 commit into from
May 14, 2020
Merged

update configuration.py for netbox 2.7.11 REDIS config #267

merged 1 commit into from
May 14, 2020

Conversation

ryanmerolle
Copy link
Contributor

update configuration.py to use REDIS config referencing tasks in place of webhooks

Related Issue: #266

New Behavior

Minor configuration.py tweak to only change the REDIS config in configuration.py

Contrast to Current Behavior

Eliminates the message of "The 'webhooks' REDIS configuration section has been renamed to 'tasks'. Please update your configuration as "

Discussion: Benefits and Drawbacks

Could add more with regards REDIS SENTINELS config, but limited this to address the just the PR.

Changes to the Wiki

None

Proposed Release Note Entry

Update configuration.py for netbox 2.7.11 REDIS config

Double Check

  • I have read the comments and followed the PR template.
  • I have explained my PR according to the information in the comments.
  • My PR targets the develop branch.

update configuration.py to use REDIS config referencing `tasks` in place of `webhooks`
@cimnine
Copy link
Collaborator

cimnine commented Apr 4, 2020

Thanks for the PR. What do you think of the idea to have them both, webhooks and tasks? This way we would maintain compatibility with the rest of the 2.7 series, but be prepared for the upcoming 2.8 series.

@ryanmerolle
Copy link
Contributor Author

I think it’s the right move. I thought about that after I pushed the PR. Are you thinking of a conditional for a deployment with a version below 2.7.11 use webhooks?

@cimnine
Copy link
Collaborator

cimnine commented Apr 4, 2020

To be honest, I thought of that:

REDIS = {
    'tasks': {
        'HOST': os.environ.get('REDIS_HOST', 'localhost'),
        'PORT': int(os.environ.get('REDIS_PORT', 6379)),
        'PASSWORD': os.environ.get('REDIS_PASSWORD', read_secret('redis_password')),
        'DATABASE': int(os.environ.get('REDIS_DATABASE', 0)),
        'DEFAULT_TIMEOUT': int(os.environ.get('REDIS_TIMEOUT', 300)),
        'SSL': os.environ.get('REDIS_SSL', 'False').lower() == 'true',
    },
    'webhooks': {
        'HOST': os.environ.get('REDIS_HOST', 'localhost'),
        'PORT': int(os.environ.get('REDIS_PORT', 6379)),
        'PASSWORD': os.environ.get('REDIS_PASSWORD', read_secret('redis_password')),
        'DATABASE': int(os.environ.get('REDIS_DATABASE', 0)),
        'DEFAULT_TIMEOUT': int(os.environ.get('REDIS_TIMEOUT', 300)),
        'SSL': os.environ.get('REDIS_SSL', 'False').lower() == 'true',
    },
    'caching': {
        'HOST': os.environ.get('REDIS_CACHE_HOST', os.environ.get('REDIS_HOST', 'localhost')),
        'PORT': int(os.environ.get('REDIS_CACHE_PORT', os.environ.get('REDIS_PORT', 6379))),
        'PASSWORD': os.environ.get('REDIS_CACHE_PASSWORD', os.environ.get('REDIS_PASSWORD', read_secret('redis_cache_password'))),
        'DATABASE': int(os.environ.get('REDIS_CACHE_DATABASE', 1)),
        'DEFAULT_TIMEOUT': int(os.environ.get('REDIS_CACHE_TIMEOUT', os.environ.get('REDIS_TIMEOUT', 300))),
        'SSL': os.environ.get('REDIS_CACHE_SSL', os.environ.get('REDIS_SSL', 'False')).lower() == 'true',
    },
}

It's a lazy solution, and I have not tested it, but I expect no problems with it.

Unless you prefer a cleaner approach, would you mind giving it a try and if that works, update your PR?

@ryanmerolle
Copy link
Contributor Author

ryanmerolle commented Apr 4, 2020 via email

@Freddyp91
Copy link

To be honest, I thought of that:

REDIS = {
    'tasks': {
        'HOST': os.environ.get('REDIS_HOST', 'localhost'),
        'PORT': int(os.environ.get('REDIS_PORT', 6379)),
        'PASSWORD': os.environ.get('REDIS_PASSWORD', read_secret('redis_password')),
        'DATABASE': int(os.environ.get('REDIS_DATABASE', 0)),
        'DEFAULT_TIMEOUT': int(os.environ.get('REDIS_TIMEOUT', 300)),
        'SSL': os.environ.get('REDIS_SSL', 'False').lower() == 'true',
    },
    'webhooks': {
        'HOST': os.environ.get('REDIS_HOST', 'localhost'),
        'PORT': int(os.environ.get('REDIS_PORT', 6379)),
        'PASSWORD': os.environ.get('REDIS_PASSWORD', read_secret('redis_password')),
        'DATABASE': int(os.environ.get('REDIS_DATABASE', 0)),
        'DEFAULT_TIMEOUT': int(os.environ.get('REDIS_TIMEOUT', 300)),
        'SSL': os.environ.get('REDIS_SSL', 'False').lower() == 'true',
    },
    'caching': {
        'HOST': os.environ.get('REDIS_CACHE_HOST', os.environ.get('REDIS_HOST', 'localhost')),
        'PORT': int(os.environ.get('REDIS_CACHE_PORT', os.environ.get('REDIS_PORT', 6379))),
        'PASSWORD': os.environ.get('REDIS_CACHE_PASSWORD', os.environ.get('REDIS_PASSWORD', read_secret('redis_cache_password'))),
        'DATABASE': int(os.environ.get('REDIS_CACHE_DATABASE', 1)),
        'DEFAULT_TIMEOUT': int(os.environ.get('REDIS_CACHE_TIMEOUT', os.environ.get('REDIS_TIMEOUT', 300))),
        'SSL': os.environ.get('REDIS_CACHE_SSL', os.environ.get('REDIS_SSL', 'False')).lower() == 'true',
    },
}

It's a lazy solution, and I have not tested it, but I expect no problems with it.

Unless you prefer a cleaner approach, would you mind giving it a try and if that works, update your PR?

This worked for me thanks!
Now i need to figure out how to make this docker image use CENTOS instead of alpine.

@cimnine cimnine merged commit bfa69dc into netbox-community:develop May 14, 2020
@cimnine cimnine added this to the 0.24.0 milestone May 14, 2020
@cimnine cimnine mentioned this pull request May 14, 2020
@tobiasge tobiasge mentioned this pull request May 15, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants