Skip to content

Add runbook config and storage management#11

Open
teferi wants to merge 1 commit intomasterfrom
config_storage
Open

Add runbook config and storage management#11
teferi wants to merge 1 commit intomasterfrom
config_storage

Conversation

@teferi
Copy link
Collaborator

@teferi teferi commented Dec 19, 2016

No description provided.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 0.0% when pulling d6cbcb8 on config_storage into f3303a9 on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 0.0% when pulling 1a27e76 on config_storage into f3303a9 on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 0.0% when pulling 533aa40 on config_storage into f3303a9 on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 0.0% when pulling e2520bf on config_storage into f3303a9 on master.

Configs are split in two: reader and writer for ro/wo api services
respectively. main-reader/main-writer entry point files are added.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 0.0% when pulling c513c2f on config_storage into f3303a9 on master.


def get_config(api_type=None):
"""Return cached configuration.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:param api_type: ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok =)

config = json.load(open(path))
CONF[api_type] = json.load(open(path))
logging.info("Config is '%s'" % path)
except IOError as e:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend to catch ValueError as well for cases with invalid JSON

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

jsonschema.validate(CONF[api_type], CONF_SCHEMA)
except jsonschema.ValidationError as e:
logging.error(e.message)
sys.exit(1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raise, not exit (exiting inside a non-CLI module is a potential bug)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed. This whole thing should be rewritten to oss-tools configuration I guess, but it was written well before oss-tools had config management.


@app.errorhandler(404)
def not_found(error):
logging.error(error)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

404 is not an error

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's arguable, but let's change it to debug I guess =)

ensure_index("ms_{}_{}".format("runbooks", region), api_type)


if __name__ == "__main__":

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a strange usage, this module is not a CLI endpoint.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well in a later commit I think I'm adding a function from the file to setup.cfg Although this does mean that I can do it right here =)

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.

3 participants