Changing the actions to enum list so it's more flexible.

This commit is contained in:
Mitsuo Takaki
2017-02-11 01:02:27 -08:00
parent 9f3e2b6eff
commit e8d4b88c79
4 changed files with 50 additions and 28 deletions

View File

@@ -7,10 +7,11 @@ import re
import time
import requests
import status as st
from yaml import dump
from yaml import load
import status as st
# This is the mandatory fields that must be in the configuration file in this
# same exact structure.
configuration_mandatory_fields = {
@@ -100,6 +101,15 @@ class Configuration(object):
"""
return 'update_status' in self.data['cachet'] and self.data['cachet']['update_status']
def get_action(self):
"""Retrieves the action list from the configuration. If it's empty, returns an empty list.
:return: The list of actions, which can be an empty list.
"""
if self.data['cachet'].get('action') is None:
return []
else:
return self.data['cachet']['action']
def validate(self):
"""Validates the configuration by verifying the mandatory fields are
present and in the correct format. If the validation fails, a